[R] logLik == -Inf in gls
nhy303@abdn.ac.uk
nhy303 at abdn.ac.uk
Thu Feb 9 13:56:17 CET 2006
I am trying to fit a generalised least squares model using gls in the nlme
package.
The model seems to fit very well when I plot the fitted values against the
original values, and the model parameters have quite narrow confidence
intervals (all are significant at p<5%).
The problem is that the log likelihood is always given as -Inf. This
doesn't seem to make sense because the model seems to fit my data so well.
I have checked that the residuals are stationary using an adf test. I
can't work out whether
- the model really doesn't fit at all
- there is something in my data that stops the implementation of logLik
working correctly (the -Inf value says the calculation hasn't worked)
Possible causes are:
- There are lots of NAs in my data (model and response variables)
- There is some autocorrelation in the data that is not accounted for by
the model (most is accounted for).
But, I've tried recreating the problem using a simpler data set, and have
never found the same problem.
The command I use to fit the model is...
result2 <- gls(lci4150 ~ propCapInStomachs +
temperature +
as.factor(monthNumber) +
lagLci1 +
lagcap1 +
lagcap2,
data = monthly,
subset = subset1985,
na.action = na.approx,
weights = varFixed( ~ 1/numob4150)
)
The output I get is...
Generalized least squares fit by REML
Model: lci4150 ~ propCapInStomachs + temperature +
as.factor(monthNumber) + lagLci1 + lagcap1 + lagcap2
Data: monthly
Subset: subset1985
AIC BIC logLik
Inf Inf -Inf
Variance function:
Structure: fixed weights
Formula: ~1/numob4150
Coefficients:
Value Std.Error t-value p-value
(Intercept) -0.3282412 0.5795665 -0.566356 0.5717
propCapInStomachs 0.0093283 0.0039863 2.340107 0.0202
temperature 0.4342514 0.1526104 2.845490 0.0048
as.factor(monthNumber)2 0.3990717 0.3869991 1.031195 0.3036
as.factor(monthNumber)3 1.3788334 0.3675690 3.751223 0.0002
as.factor(monthNumber)4 1.4037195 0.3857764 3.638686 0.0003
as.factor(monthNumber)5 0.9903316 0.3436177 2.882074 0.0043
as.factor(monthNumber)6 0.3453741 0.3043698 1.134719 0.2577
as.factor(monthNumber)7 0.3948442 0.3035142 1.300909 0.1946
as.factor(monthNumber)8 0.5021812 0.3532413 1.421638 0.1565
as.factor(monthNumber)9 -0.0794319 0.3598981 -0.220707 0.8255
as.factor(monthNumber)10 0.3536805 0.3790538 0.933061 0.3518
as.factor(monthNumber)11 0.7874834 0.3557116 2.213826 0.0278
as.factor(monthNumber)12 0.1854279 0.3178320 0.583415 0.5602
lagLci1 0.5488437 0.0576144 9.526151 0.0000
lagcap1 0.0110994 0.0043669 2.541714 0.0117
lagcap2 -0.0088080 0.0041099 -2.143127 0.0332
Does anyone have any suggestions of how I can get a meaningful value for
logLik? Or some other way that I can compare models.
Thankyou,
Lillian.
--
Lillian Sandeman
PhD Student
School of Biological Sciences
University of Aberdeen
AB24 2TZ
Tel.: 01224 272648
E-mail: l.sandeman at abdn.ac.uk
More information about the R-help
mailing list