[R] Best Subsets regression

Murray Jorgensen maj at waikato.ac.nz
Tue Feb 12 19:28:13 CET 2002


Hi,

I have found a minor problem with leaps(). In 1.3.1 under Windows 2000 I 
seem to only be able to obtain values for one statistic at a time. That is 
choosing

method=c("Cp","adjr2","r2")

just gives Cp values.

To mimic the output of Minitab's

MTB > BReg 'Fertility' 'Agriculture'-'Infant.Mortality' ;
SUBC>   NVars 1 5;
SUBC>   Best 5;
SUBC>   Constant.

I need to go

data(swiss)
leapa <-leaps(as.matrix(swiss[,-1]),swiss[,1],method="Cp", nbest=5)
leapb <-leaps(as.matrix(swiss[,-1]),swiss[,1],method="adjr2", nbest=5)
leapc <-leaps(as.matrix(swiss[,-1]),swiss[,1],method="r2", nbest=5)
best <- cbind(leapc$r2,leapb$adjr2,leapa$Cp,leapa$which)
colnames(best) <- c( "R.Sq", "Adj.R.Sq","Cp","X1","X2","X3","X4","X5")
best

which seems rather wasteful, not that it matters on a small dataset like 
"swiss".

Actually I have the same grip with SPLUS, so I suppose this feature is 
retained for compatibility?

Dr Murray Jorgensen               on leave from:
Mathematics and Statistics       Department of Statistics
University of Victoria           University of Waikato
PO BOX 3045 STN CSC              Hamilton, New Zealand
Victoria, B.C.      Email: maj at waikato.ac.nz
Canada V8W 3P4      Phone: (250) 721-7460 wk  (250) 477 2581 home

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list