Select variables in multiple linear regression
Find an optimal submodel
RegBest(y,x, int = TRUE, wt=NULL, na.action = na.omit, method=c("r2","Cp", "adjr2"), nbest=1)
y
: A response vectorx
: A matrix of predictorsint
: Add an intercept to the modelwt
: Optional weight vectorna.action
: Handling missing valuesmethod
: Calculate R-squared, adjusted R-squared or Cp to select the model. By default a the F-test on the r-square is usednbest
: number of best models for each set of explained variables (by default 1)Returns the objects - all: gives all the nbest
best models for a given number of variables
Francois Husson francois.husson@institut-agro.fr
lm
data(milk) res = RegBest(y=milk[,6],x=milk[,-6]) res$best