Hi!
I would like to fit log-normal fixed model with lmer. Fixed effects estimates
are returned on log scale, while variance components are returned on exp scale.
Why is this the case?
Here is my example. I fit several models to show the behaviour.
Thanks, Gregor
## --- GENERATE DATA ---
set.seed(54763278)
z <- rnorm(n=1000, mean=10, sd=1)
ai <- rep(c(1, 2), each=500)
a <- c(-2, 2)[ai]
bi <- gl(n=10, k=1, length=1000)
b <- seq(-5, 5, length.out=10)[bi]
ci <- factor(round(runif(n=1000, min=1, max=100)))
c <- rnorm(n=100)[ci]
di <- factor(round(runif(n=1000, min=1, max=50)))
d <- rnorm(n=50)[di]
z <- z + a + b + c + d
y <- exp(z)
pod <- data.frame(y, ai, bi, ci, di)
## --- FIT NORMAL MIXED MODEL ---
## z ~ Normal
tmp <- lmer(z ~ ai + bi + (1 | ci) + (1 | di), data=pod)
tmp
...
Random effects:
Groups Name Variance Std.Dev.
ci (Intercept) 1.17 1.080
di (Intercept) 0.99 0.995
Residual 1.09 1.042
number of obs: 1000, groups: ci, 100; di, 50
Fixed effects:
Estimate Std. Error t value
(Intercept) -1.3399 0.2354 -5.7
ai 4.0293 0.0706 57.1
...
## y ~ Log-Normal
tmp <- lmer(y ~ ai + bi + (1 | ci) + (1 | di), data=pod)
tmp
...
Random effects:
Groups Name Variance Std.Dev.
ci (Intercept) 1.33e+14 11531505
di (Intercept) 6.10e+13 7809115
Residual 7.35e+15 85757196
number of obs: 1000, groups: ci, 100; di, 50
Fixed effects:
Estimate Std. Error t value
(Intercept) -30997885 12065854 -2.57
ai 20613508 5480798 3.76
...
## --- FIT LOG-NORMAL MIXED MODEL ---
## y ~ Log-Normal
tmp <- lmer(y ~ ai + bi + (1 | ci) + (1 | di),
+ data=pod, family=gaussian(link="log"))
CHOLMOD warning: w"
??L_? ??<_? ??z
Error in devLaplace(PQLpars) :
Cholmod error `matrix not positive definite' at
file:../Supernodal/t_cholmod_super_numeric.c, line 613
btw, why is this happening, there is no such problem with identity
link?
## y ~ Log-Normal
tmp <- lmer(y ~ ai + bi + (1 | ci),
+ data=pod, family=gaussian(link="log"))
...
Random effects:
Groups Name Variance Std.Dev.
ci (Intercept) 4.39e+13 6622360
Residual 1.64e+14 12824146
number of obs: 1000, groups: ci, 100
Fixed effects:
Estimate Std. Error t value
(Intercept) -2.16e+00 2.83e+05 -7.6e-06
ai 4.91e+00 3.99e-01 12.33
...
Here fixed effect estimates are on log scale, while variance component
estimates are huge --> is this on exp scale?
Hi!
I would like to fit log-normal fixed model with lmer. Fixed effects estimates
are returned on log scale, while variance components are returned on exp scale.
Why is this the case?
I also tried with newest version from R-Forge (svn checkout), but I can not fit
the log-normal mixed model at all. Using the same code as in previous mail I get
tmp <- lmer(y ~ ai + bi + (1 | ci),
+ data=pod,
+ family=gaussian(link="log"))
Error in mer_finalize(ans, verbose) :
General form of glmer_linkinv not yet written
Gregor
Hi!
I would like to fit log-normal fixed model with lmer. Fixed effects estimates
are returned on log scale, while variance components are returned on exp scale.
Why is this the case?
I would just like to add that I expected to get variance estimates on link (log)
scale as it is done for poisson (log link) or binomial (logit or probit link)
families.
Regards, Gregor
The development version of the lme4 package has some of the families
(binomial or quasibinomial with logit or probit link, poisson or
quasipoisson with log link) coded in C for efficiency. The general
form will need to allow for evaluation of the family from R functions
and I haven't incorporated that yet.
On Jan 7, 2008 4:23 PM, Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si> wrote:
Gorjanc Gregor <Gregor.Gorjanc at ...> writes:
Hi!
I would like to fit log-normal fixed model with lmer. Fixed effects estimates
are returned on log scale, while variance components are returned on exp scale.
Why is this the case?
I also tried with newest version from R-Forge (svn checkout), but I can not fit
the log-normal mixed model at all. Using the same code as in previous mail I get
tmp <- lmer(y ~ ai + bi + (1 | ci),
+ data=pod,
+ family=gaussian(link="log"))
Error in mer_finalize(ans, verbose) :
General form of glmer_linkinv not yet written
Gregor
On Jan 7, 2008 4:26 PM, Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si> wrote:
Gorjanc Gregor <Gregor.Gorjanc at ...> writes:
Hi!
I would like to fit log-normal fixed model with lmer. Fixed effects estimates
are returned on log scale, while variance components are returned on exp scale.
Why is this the case?
I would just like to add that I expected to get variance estimates on link (log)
scale as it is done for poisson (log link) or binomial (logit or probit link)
families.
I'd need to look at the code more closely but I suspect that the
results you are getting are spurious.