Description Usage Arguments Examples
This is a wrapper and convenience function for several functions included in this package.
Please see calculate_selinf
for more details and how to calculate inference when
several model selection procedures are combined.
When more than one list is supplied, the best model in the first listOfModels
is used to perform inference.
1 2 |
listOfModels |
a |
... |
optionally more |
response |
response vector |
what |
|
REML |
|
df |
positive integer; defines the degree of freedom when using the likelihood ratio test for model selection.
Defaults to |
sd |
standard deviation of error used for the p-value calculation (see details) |
alpha |
value for |
gridpts, griddepth, range |
options for the calculation of confidence intervals.
See |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | library(MASS)
data("cpus")
# Fit initial model
cpus$perf <- log10(cpus$perf)
cpus$cach <- as.factor(cpus$cach)
mod <- lm(perf ~ .-name, data = cpus)
# use the stepAIC function to find the best model in a backward
# stepwise search
cpus.lm <- stepAIC(mod, trace = FALSE, direction = "backward", steps = 3)
# check model selection
cpus.lm$anova$Step
# recalculate all visited models in the first step
lom1 <- c(lapply(attr(mod$terms, "term.labels"), function(x)
update(mod, as.formula(paste0("perf ~ .-", x)))), list(mod))
# perform likelihood ratio test at level
alpha = 0.001
# check for non-significant variables
coefTable <- anova(cpus.lm)
drop <- rownames(coefTable)[alpha < coefTable[-nrow(coefTable),5]]
# drop non-significant variable
cpus.lm2 <- update(cpus.lm, as.formula(paste0(".~.-",drop)))
# compute selective inference
selinf(list(cpus.lm, cpus.lm2), lom1,
response = cpus$perf,
what = c("Ftest", "aic"),
sd = summary(cpus.lm2)$sigma)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.