[R] possible inconsistency in nlme logLik or me

Daniel O'Shea dan.oshea at dnr.state.mn.us
Thu Jan 24 16:01:23 CET 2008


Hello,

I am comparing 2 nonlinear models one with a correlation structure.
I used the gnls command in the nlme package to fit model 1 and then the update(mod1,corr=corExp(form=~lat+lon,nugget=T) to fit the same model but with a correlation structure.  I am comparing models using AIC, but I am getting results that don't seem to match.  I get matching results for the model with no correlation structure, but non corresponding results for the model with a correlation structure.  Below are logLik for the models along with additional information.  Am I doing something wrong????? 

Information for model 1

rss=sum(resid(mod1)^2)=1318.645
var=rss/n=1.654511
n=797
number of parameters (K) = 10 (this does include the variance estimate)

if I use logLik(mod1) I get -1331.541 with 10 d.f.

if I use the formula:

(-.5*n*log(var))-(797/2*log(2*pi))-(n/2)

from Burnham and Anderson 2002 page 12,
I get the same result as above:    -1331.541


Information for model 2 with a correlation structure corr=corExp(form=~lat+lon,nugget=T)

rss=1338.92
n=797
var=rss/n=1.679950
K=12
logLik(mod2)=-1313.65 with 12 d.f.
If I use the equation from Burnham and Anderson I get:    -1337.621 different than the logLik result??


Dan



More information about the R-help mailing list