[R] Offset in glm poisson using R vs Exposure in Stata
Ben Bolker
bbolker at gmail.com
Tue Nov 16 14:16:20 CET 2010
Columbine Caroline Waring <caquilegia <at> hotmail.com> writes:
> I am hoping to find someone who uses both R and program Stata for GLMs.
[snip]
> What I have is the code from Stata and am trying to reproduce the same
analysis in R - my program of choice.
>
> . glm count md ms rf sg, family(poisson)
> exposure(effort) eform
>
> I am lost at the point of finding the equivalent code for 'exposure'.
>
> Having looked at a few forums and 'googled'. I thought 'offset', used as
offset=(log(Eff)) or the
> equivalent +offset(log(Eff)) would produce the desired effect.
>
> Incidentally my code was:
glm(Count~md+ms+rf+sg+offset(Eff),family=poisson,data=DepthHabGen)
>
> (Making use of glm{stats})
>
Based on your discussion above did you mean
glm(count~md+ms+rf+sg+offset(log(Eff)),
family=poisson,data=DepthHabGen)
? is this just a typo ?
according to http://www.stata.com/help.cgi?glm
exposure(varname) include ln(varname) in model with coefficient
constrained to 1
offset(varname) include varname in model with coefficient
constrained to 1
> However, offset does not seem to be equivalent to 'exposure' in Stata. As
coefficients and log likelhood
> estimates differ.
>
> So I asked the following questions:
>
> 1. Do both programs produce the same results without
> 'exposure' i.e. glm models
>
> Yes, log likelihoods and coefficients are the same.
>
> 2. How about using the unintuitive non logged " offset=Eff" ?
>
> Coefficients and log likelihoods still differ.
You're not doing anything obviously wrong. Are you sure your
"effort" and "Eff" variables are the same, i.e. nothing got mangled
moving to R?
I don't use Stata, perhaps someone else can try. Posting a small
reproducible example would be helpful.
More information about the R-help
mailing list