Description Usage Arguments Details Value Author(s) See Also Examples
The procedure takes a linear model of class lm
(including the output from a stepwise procedure given by
step
) and reduces it by iteratively deleting predictors
based on pvalues of the t-tests (see 'Details').
1 2 3 4 | reduce_model(model, ...)
## S3 method for class 'lm'
reduce_model(model, data, alpha = 0.05, intercept = TRUE)
|
model |
An object of class "lm". |
data |
A |
alpha |
The significance level at which to cut off predictors. Default is 5%. |
intercept |
Specify whether the reduction procedure has to consider an
intercept or not. Default is |
The procedure makes use of the workhorse function of lm
:
lm.fit
. This allows to explicitly specify the design matrix which enables
to split main effects from interactions. In particular, conversely to what the
function lm
currently does, it allows the inclusion of just
high order effects. For instance, it can fit just interaction terms given by
x1*x2 or x1:x2 passed with the usual R
formula notation.
reduce_model
returns an object of class "lm" with the same
components (see lm
for a complete list).
Francesco Grossetti francesco.grossetti@gmail.com.
1 2 3 4 5 6 7 8 9 10 | data_factor = mtcars
data_factor$am = as.factor( data_factor$am )
levels( data_factor$am ) = c( "no", "yes" )
complete_model = lm( hp ~ qsec + cyl + mpg + disp + drat + wt + qsec + vs +
am + gear + carb + am:qsec, data = data_factor )
summary( complete_model )
reduced_model = reduce_model( complete_model, data = data_factors )
summary( reduced_model )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.