In R I have data
and I want to make a regression analysis, finding a function that can fit the data.
So head(data)
gives
promotion new_users
39.5 100
36.1 79
0.0 18
To find the optimal regression function that fitted data I plot the residuals of the regression model to see if the residuals are systematic close the zero line. But I do not know which transformation is the best one to use. Here I tried to do linear transformation, sqrt
transformation and finally log-transformation.
lm.linear = lm(formula= data$new_users ~ data$promotion )
plot(resid(lm.linear), col="blue")
lm.sqrt = lm(formula= data$new_users ~ sqrt(data$promotion) )
plot(resid(lm.sqrt), col="blue")
lm.log = lm(formula= data$new_users ~ log(0.1+data$promotion ))
plot(resid(lm.log), col="blue")
If I simply just plot the data and the fitted regression function I can't see which regression function fittest the data best because they are very similar. Which transformation is the best one and is there another way to find out what is the best transformation ?
Thanks.
To see if I can use poission regression model I type
model=glm(data$new_users ~data$promotion, familiy="poisson", data=data)
I use goodnes of fit to see if the model fits.
with(m1, cbind(res.deviance = deviance, df = df.residual,
p = pchisq(deviance, df.residual, lower.tail=FALSE)))
I get a low p-value meaning that the model is a good fit?
Furthermore say we want to compare two poison regression models (one poission regr. model from data
and another one from another dataset say data_new
) and see if there is a significantly difference between the two, how would one do that? I assume one could use anova test to solve this.