[R-sig-ME] nlme::gls potential bug
@ndrew@beet @end|ng |rom no@@@gov
Thu Jan 31 21:46:49 CET 2019
I was referred to this group. I hope someone can help out.
I have been using the nlme::gls package in R to fit a pretty
simple model (linear with AR error)
y(t) = beta*x(t) + e(t) where e(t) ~ rho*e(t-1) + Z(t)
and Z(t)~ N(0,sig^2)
I call the R routine
glsObj <- nlme::gls(y ~ x -1, data=data, correlation =
nlme::corAR1(form= ~x), method="ML")
All seems fine.
In addition, I have also coded the likelihood myself and maximized it
for beta, rho and sigma.
I get the exact same estimates of beta and rho, (as nlme::gls) but the
estimate of sigma is not the same and i can not figure out why.
The maximum likelihood estimator for sigma under this model is
sig^2 = (( 1-rho^2)u(1)^2 + sum((u(t)- rho*u(t-1))^2)/n
where the sum is t=2,...,n and
u(t) = y(t) - X(t)*beta
I have read the mixed-effects models in S and S-Plus book (nlme::gls
code is based directly on this) and this problem is specified on page
204 eq (5.5). I have also calculated sigma based on (5.7) -after the
transformation documented (5.2) -and i do not get the same value as
either the package or my implementation.
Any advice would be most welcomed. Is there a bug in the estimation of
sigma in this package?
Ecosystem Dynamics & Assessment Branch
Northeast Fisheries Science Center
NOAA Fisheries Service
166 Water Street
Woods Hole, MA 02543
More information about the R-sig-mixed-models