extract_components: extract components from list of 'lm' objects

Description Usage Arguments Value Examples

Description

extract components from list of lm objects

Usage

1
2
3
extract_components(listOfModels, response = NULL, what = c("aic", "bic",
  "llonly", "lrt", "Ftest", "sigHunt"), REML = FALSE, alpha = NULL,
  df = 1)

Arguments

listOfModels

list of lm objects

response

response vector; must be supplied if not stored in the lm object.

what

character describing the method, on the basis of which variable selection was performed

REML

logical; whether scale estimates should be calculated via REML or not. Default is FALSE since the log-likelihood is calculated with REML=FALSE by the logLik function.

alpha

significance level for selection via likelihood ratio test or significance hunting.

df

positive integer; defines the degree of freedom when using the likelihood ratio test for model selection. Defaults to 1 (testing one parameter at a time).

Value

list of components for each model. A and c: matrices and scalar of affine inequality; y: response vector; bestInd indicator for best model in listOfModels.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
set.seed(42)
y <- rnorm(10)
x <- runif(10)
mod1 <- lm(y ~ x)

x2 <- runif(10)
mod2 <- lm(y ~ x2)

# AIC comparison
AIC(mod1,mod2)

lom <- list(mod1, mod2)

# get components
comps <- extract_components(lom, response = y)
str(comps,1)
t(comps$y)%*%comps$A[[1]]%*%comps$y

davidruegamer/coinflibs documentation built on May 14, 2019, 10:33 a.m.