On 1/2/19 9:35 AM, Marc Girondot wrote:
Hello members of the list,
I asked 3 days ago a question about "how to get the SE of all effects
after a glm or glmm". I post here a synthesis of the answer and a new
solution:
For example:
x <- rnorm(100)
y <- rnorm(100)
G <- as.factor(sample(c("A", "B", "C", "D"), 100, replace = TRUE)); G <-
relevel(G, "A")
m <- glm(y ~ x + G)
summary(m)$coefficients
No SE for A level in G category is calculated.
* Here is a synthesis of the answers:
1/ The first solution was proposed by Rolf Turner
<r.tur...@auckland.ac.nz>. It was to add a + 0 in the formula and then
it is possible to have the SE for the 4 levels (it works also with
objects obtained with lme4:lmer() ):
m1 <- glm(y ~ x + G +0)
summary(m1)$coefficients
However, this solution using + 0 does not works if more than one
category is included. Only the levels of the first one have all the SE
estimated.
Well, you only asked about the setting in which there was only one
categorical predictor. If there are, e.g. two (say "G" and "H") try
m2 <- glm(y ~ x + G:H + 0)
I would suggest that you learn a bit about how the formula structure
works in linear models.
cheers,
Rolf Turner
P.S. Your use of relevel() is redundant/irrelevant in this context.
R. T.
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.