
glm
and selected with function step {stats\)
.
step.adj(object, MC = 1000, scope = NULL, scale = 0, direction = c("both", "backward", "forward"), trace = 0, keep = NULL, steps = 1000, k = 2)
glm
. Note that
formula
have to write by variables name like y~var1+var2+var3
,
data
is a data.frame (see example below),
offset
is not yet implemented, avoid its use,
glm(formula, data, family=gaussian)
produce the same result of lm(formula, data), then linear model can be allways performed
step
step
step
step
step
step
step
, other arguments are not implemented yet.anova
table with an extra column reporting the corrected p-value
lm
models and gaussian glm
models it computes a F-test, form other models it uses Chisquare-test (see also anova.glm
and anova.lm
help).
glm
, anova
set.seed(17)
y=rnorm(10)
x=matrix(rnorm(50),10,5)
#define a data.frame to be used in the glm function
DATA=data.frame(y,x)
#fit the model on a toy dataset
mod=glm(y~X1+X2+X3+X4+X5,data=DATA)
#select the model using function step
mod.step=step(mod, trace=0)
#test the selected model vs the null model
anova(glm(y~1, data=DATA),mod.step,test="F")
#step.adj do the same, but it also provides multiplicity control
step.adj(mod,MC=101, trace=0)
Run the code above in your browser using DataLab