nsRFA (version 0.7-14)

bestlm: Subsets regression

Description

bestlm performs an exhaustive search for the best subsets of the variables in ind for predicting dip in linear regression.

Usage

bestlm (dip, ind, kmax=4, nbest=3)
 # S3 method for bestlm
print (x, ...)
 # S3 method for bestlm
summary (object, ...)

Arguments

x

object of class bestlm, output of function bestlm

object

object of class bestlm, output of function bestlm

dip

vector n x 1 of dependent variable to be predicted

ind

matrix n x K of the K independent variables (candidate predictors)

kmax

maximum size (number of regressors) to report

nbest

number of subsets of each size to report

...

other arguments

Value

bestlm returns the following values:

subselect matrix (kmax*nbest)x(ncol(ind)) with the sets of chosen linear models, ordered in function of the adjusted coefficient of determination (R2adj);

R2adj the ordered adjusted coefficient of determination;

Details

This function has been obtained using the function leaps of the R package leaps. It is based on the Alan Miller's FORTRAN routines.

Warning: the function will stop with an error if ind is not of full rank or if it has more than 31 columns.

See Also

lm, REGRDIAGNOSTICS.

Examples

Run this code
# NOT RUN {
data(hydroSIMN)

bestlm(parameters[,"Dm"], parameters[,-c(1:2)])

regr <- lm(Dm ~ Am + S2000 + NORD, parameters); regr
summary(regr)
# }

Run the code above in your browser using DataLab