# Log vs square root link for Poisson data in R

I am currently working to model deaths from AIDS over time using a GLM in R. I know that there are two possible options for the link function for Poisson data, log and square root.

I know that square root would even out variability issues whereas log is need to straighten the curve. But, how can I actually test which link is better for the data?

You're confusing the effect of a data-transformation with the use of a link function in a GLM.

If you do a log-transform of the response, it will "straighten the relationship" if $E(Y|x)$ is of the form $\exp(a+bx)$. Similarly, if you take the square root of the response, it will make the variance nearly constant, if the variance is proportional to the mean (as it is with a Poisson, where it's equal to the mean).

However, in a GLM, the link function is not used to transform the data.

The GLM itself takes into account the fact that the variance of the Poisson increases with the mean; you don't need to do anything about that (as long as the Poisson assumption is suitable).

The only thing left it to account for the relationship between the predictor and the response. The link function does specify the form of the relationship between the conditional mean of the response and the predictor.

The sqrt link is mainly used for the purpose of comparing with an older analysis where a square root transform was used in order to apply least squares regression. By using the square root link you can fit a model of the same functional form but with full ML estimation of the parameters.

If you were considering using the log because of the fact that it linearized the relationship, that's definitely the link you should use. (Generally the log link is easier to interpret, as well.)

If you really wanted to entertain both link functions and choose between them you could compare the AICs; or you could compare the deviances (there are other choices of course, but both are provided in the summary output already and they do measure "fit"; whichever you look at, they should lead to the same conclusion). However, unless there's some clear indication that the log-link is inadequate or some other reason to entertain the square root link, I would simply do the log-link.

Note that if you do use the data to choose between the link functions, subsequent hypothesis tests of coefficients estimated from the same data points will (among other things) no longer have their nominal properties (standard errors will be too small, confidence intervals too narrow, p-values don't mean the same thing ...)

(By the way, those aren't the only two link-function options for a Poisson in R, since there's also the identity link ... and that's not counting what you can do if you move to a quasi-Poisson fit)

A warning: if you're modelling a variable over time, you should keep in mind that there's (a) likely to be time dependence in your counts, in a way that would invalidate the GLM assumptions of independence (e.g. your standard errors could easily be wrong); and (b) the notion of spurious regression can as readily apply to a Poisson regression as an ordinary regression (so your parameter estimates could easily be wrong/misleading as well).

I doubt that your series will be stationary, so this is potentially a serious threat to your conclusions -- but spurious regression can be a problem even with stationary series (a point that is not so widely understood; I give a reference for that in this answer which answer also illustrates the phenomenon with correlations in the non-stationary case with a simple coin-tossing example).

If you are fitting a GLiM with a Poisson distribution specified for the response, you do not have to try to stabilize the conditional variance of the response. That is automatically taken care of for you. The Poisson GLiM does not assume constant variance in the sense that a regular linear (Gaussian) regression model does.

The effect of the link function will be to change the shape of the regression line in the original data space, and thereby to change the interpretation of the coefficients. If you are worried about whether the shape / amount of curvature will be appropriate, you can always use splines. Thus, you may want to choose which link to use based on the interpretability of your coefficients. In my opinion, that will typically favor the log link.

If you only wanted to use your covariates without spline functions, and you wanted to determine which shape better fit your data, you could use cross-validation and examine the out of sample predictive error.

Although written in the context of binomial GLiMs (not Poisson), you may still be interested in reading my answer here: Difference between logit and probit models.