I am using STAN to use a gamma-poisson regression to account for over-dispersion in a dataset, in an assignment. I have looked at the solutions to how to make the model in STAN, which is shown below:
model{
vector[N] lambda;
scale ~ cauchy( 0 , 1 );
bf ~ normal( 0 , 1 );
a ~ normal( 0 , 10 );
for ( i in 1:N ) {
lambda[i] = a + bf * fmnnty[i];
lambda[i] = exp(lambda[i]);
}
deaths ~ neg_binomial_2( lambda , scale );
}
The solution specify to use the log-link function to limit the parameter lambda to positive values. This makes sense. However, I don't understand why the STAN-code uses exp() as a link-function. Why is it that the exp() is appropriate to specify a log-link function?
The log-link is employed by exponentiating the lambda. The 'log' component means that you are modeling the log of the mean value (mu
):
log(mu) = lambda
Which you can rewrite as:
mu = exp(lambda)