Attached is a new version of my Random-Effects-Logit-via-R function. It
now returns inside the bundle most of the stuff that you need to
replicate Stata's xtlogit output. (But for the test code case you only
get the same results if you set quadpoints to at least 20 or so, the
results for the default setting are close but a little different.) My
help comment inside the function is quite detailed in that respect, and
I copy-paste it at the end of this message.
I also added specification comparison tests with respect to the pooled
logit. To that end there is a new function argument 'test', and if that
is non-zero the function will do an LR as well as a Hausman test of
pooled-vs.-RE-logit. (This is done within gretl, using R's results from
the RE spec.) The precise Hausman setup is determined by the exact
value, see the help comment; the default value means "use all
coefficients but the constant".
The LR test also seems to replicate Stata's output, although the test is
a little problematic, since the zero variance of the RE is on the edge
of the parameter space. It took me a bit of googling to learn that Stata
effectively just divides the chi2(1) p-value by 2. (It's not explained
in Stata's xtlogit.pdf help document I think.)
At some point I will make a package out of this, but right now more
testing is probably useful.
Cheers,
sven
------------
The help comment:
/*
This function needs R (apparently version >= 3.1.2),
and the "lme4" package/library must be installed inside R.
A constant term is not explicitly added by the function,
but if it exists it is moved to the top of the list!
Interpretation of 'quadpoints':
- default 1 invokes the glmer default of Laplacian,
- setting it to zero invokes our default of 32 for GHQ,
- and any other positive number is passed verbatim.
Interpretation of 'test': tests the RE spec against pooled logit;
- if non-zero does an LR test (although fishy because param boundary)
- default -1 also does Hausman test on all coefficients (jointly)
except const
- -2 Hausman test on all coeffs including the constant
- 0 suppresses the test
- any positive number: Hausman test on first n vars (excl. the const)
Contents of return bundle:
- beta (matrix): coefficients of X
- vcov (matrix): VCov-matrix of beta
- yname (string): name of the y variable
- Xnames (string): comma-separated string of X names
- LL (scalar): log likelihood
- sigma (scalar): resid. variance (as given by R's lme4 of course)
- ngroups (scalar): number of panel units/groups in sample
- quadpoints (scalar): effective number of quadrature points used
- REsd (scalar): Std.Dev. of the random effects (sigma_u)
- rho (scalar): variance portion from RE (sigma_u^2 / (sigma_u^2 /
(\pi/3))
--- The following only if test != 0:
- Hstat (scalar): Hausman test stat pooled vs. RE
- Hpv (scalar): Hausman test p-value
- lstat (scalar): LR test stat pooled vs. RE
- lpv (scalar: LR p-value (approx.)
*/