[R] SE for all fixed factor effect in GLMM
Marc Girondot
m@rc_grt @ending from y@hoo@fr
Sun Dec 30 05:31:31 CET 2018
Dear members,
Let do a example of simple GLMM with x and G as fixed factors and R as
random factor:
(note that question is the same with GLM or even LM):
x <- rnorm(100)
y <- rnorm(100)
G <- as.factor(sample(c("A", "B", "C", "D"), 100, replace = TRUE))
R <- as.factor(rep(1:25, 4))
library(lme4)
m <- lmer(y ~ x + G + (1 | R))
summary(m)$coefficients
I get the fixed effect fit and their SE
> summary(m)$coefficients
Estimate Std. Error t value
(Intercept) 0.07264454 0.1952380 0.3720820
x -0.02519892 0.1238621 -0.2034433
GB 0.10969225 0.3118371 0.3517614
GC -0.09771555 0.2705523 -0.3611706
GD -0.12944760 0.2740012 -0.4724344
The estimate for GA is not shown as it is fixed to 0. Normal, it is the
reference level.
But is there a way to get SE for GA of is-it non-sense question because
GA is fixed to 0 ?
______________
I propose here a solution but I don't know if it is correct. It is based
on reordering levels and averaging se for all reordering:
G <- relevel(G, "A")
m <- lmer(y ~ x + G + (1 | R))
sA <- summary(m)$coefficients
G <- relevel(G, "B")
m <- lmer(y ~ x + G + (1 | R))
sB <- summary(m)$coefficients
G <- relevel(G, "C")
m <- lmer(y ~ x + G + (1 | R))
sC <- summary(m)$coefficients
G <- relevel(G, "D")
m <- lmer(y ~ x + G + (1 | R))
sD <- summary(m)$coefficients
seA <- mean(sB["GA", "Std. Error"], sC["GA", "Std. Error"], sD["GA",
"Std. Error"])
seB <- mean(sA["GB", "Std. Error"], sC["GB", "Std. Error"], sD["GB",
"Std. Error"])
seC <- mean(sA["GC", "Std. Error"], sB["GC", "Std. Error"], sD["GC",
"Std. Error"])
seD <- mean(sA["GD", "Std. Error"], sB["GD", "Std. Error"], sC["GD",
"Std. Error"])
seA; seB; seC; seD
Thanks,
Marc
More information about the R-help
mailing list