Automatically use LRT to assess the significance of the entire factor variable
R for a multivariable regression model that includes one or more factorial variables does not automatically include a likelihood ratio test (LRT) of the value of the entire factorial variable in the model. For example:
fake = data.frame( x1=rnorm(100), x2=sample(LETTERS[1:4],
size=100, replace=TRUE), y=rnorm(100) )
head(fake)
x1 x2 y
1 0.6152511 A 0.7682467
2 -0.8215727 A -0.5389245
3 -1.3287208 A -0.1797851
4 0.5837217 D 0.9509888
5 -0.2828024 C -0.9829126
6 0.3971358 B -0.4895091
m = lm(fake$y ~ fake$x1 + fake$x2)
summary(m)
If we want to test the significance of an entire variable x2
in a model, we can put in a scaled-down model m.red
and use LRT:
m.red = lm(fake$y ~ fake$x1)
anova(m, m.red, test="LRT")
But if there are many factor variables in the model, then it gets ridiculous over and over again. Should I believe there is a built-in approach?
+3
source to share
1 answer