[R-sig-ME] offset() not working in nlme?
ONKELINX, Thierry
Thierry.ONKELINX at inbo.be
Fri Feb 12 15:42:23 CET 2010
Dear all,
I tried to use an offset in liner mixed model with nlme but it seems
like lme() ignores the offset. Models with or without the offset yield
exactly the same estimates. See the example below.
Is this intended behaviour or am I doing something wrong?
Best regards,
Thierry
> library(nlme)
> nSubject <- 100
> MeasurementError <- 10
> dataset <- expand.grid(Subject = seq_len(nSubject), Measurement =
seq_len(5))
> dataset$Truth <- rnorm(nSubject, mean = 100, sd = 20)[dataset$Subject]
> dataset$Precise <- round(dataset$Truth, 0)
> dataset$Unprecise <- round(rnorm(nrow(dataset), mean = dataset$Truth,
sd = MeasurementError), 0)
> dataset$Bias <- dataset$Unprecise - dataset$Precise
#With offset
> lme(Unprecise ~ offset(Precise), random = ~ 1|Subject, data =
dataset)
Linear mixed-effects model fit by REML
Data: dataset
Log-restricted-likelihood: -2014.358
Fixed: Unprecise ~ offset(Precise)
(Intercept)
97.844
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 20.10238 10.07502
Number of Observations: 500
Number of Groups: 100
#without offset
> lme(Unprecise ~ 1, random = ~ 1|Subject, data = dataset)
Linear mixed-effects model fit by REML
Data: dataset
Log-restricted-likelihood: -2014.358
Fixed: Unprecise ~ 1
(Intercept)
97.844
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 20.10238 10.07502
Number of Observations: 500
Number of Groups: 100
#calculating the offset a priori.
> lme(Bias ~ 1, random = ~ 1|Subject, data = dataset)
Linear mixed-effects model fit by REML
Data: dataset
Log-restricted-likelihood: -1868.963
Fixed: Bias ~ 1
(Intercept)
-0.066
Random effects:
Formula: ~1 | Subject
(Intercept) Residual
StdDev: 1.482101 10.07502
Number of Observations: 500
Number of Groups: 100
> sessionInfo()
R version 2.10.1 (2009-12-14)
i386-pc-mingw32
locale:
[1] LC_COLLATE=Dutch_Belgium.1252 LC_CTYPE=Dutch_Belgium.1252
[3] LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Belgium.1252
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] nlme_3.1-96
loaded via a namespace (and not attached):
[1] grid_2.10.1 lattice_0.18-3
------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in this message
and any annex are purely those of the writer and may not be regarded as stating
an official position of INBO, as long as the message is not confirmed by a duly
signed document.
More information about the R-sig-mixed-models
mailing list