[R] Selecting Best Regression Equation : leaps() in R and stepwise() in S+

WilDscOp wildscop at yahoo.com
Mon Apr 5 20:16:05 CEST 2004


Dear all,

	
First of all - thanks to the R-users who replied my previous mail 
"Selecting Best Regression Equation". However, seems i've got some other 
problems now -

My data in c:\leafbrn.txt file is-
--------------------------------------
i	x1	x2	x3	y
1	3.05	1.45	5.67	0.34
2	4.22	1.35	4.86	0.11
3	3.34	0.26	4.19	0.38
4	3.77	0.23	4.42	0.68
5	3.52	1.10	3.17	0.18
6	3.54	0.76	2.76	0.00
7	3.74	1.59	3.81	0.08
8	3.78	0.39	3.23	0.11
9	2.92	0.39	5.44	1.53
10	3.10	0.64	6.16	0.77
11	2.86	0.82	5.48	1.17
12	2.78	0.64	4.62	1.01
13	2.22	0.85	4.49	0.89
14	2.67	0.90	5.59	1.40
15	3.12	0.92	5.86	1.05
16	3.03	0.97	6.60	1.15
17	2.45	0.18	4.51	1.49
18	4.12	0.62	5.31	0.51
19	4.61	0.51	5.16	0.18
20	3.94	0.45	4.45	0.34
21	4.12	1.79	6.17	0.36
22	2.93	0.25	3.38	0.89
23	2.66	0.31	3.51	0.91
24	3.17	0.20	3.08	0.92
25	2.79	0.24	3.98	1.35
26	2.61	0.20	3.64	1.33
27	3.74	2.27	6.50	0.23
28	3.13	1.48	4.28	0.26
29	3.49	0.25	4.71	0.73
30	2.94	2.22	4.58	0.23
--------------------------------------

And my applied R codes are-

--------------------------------------
 > options(prompt="  R >  " )
   R >  leafbrn1<-read.table("c:\\leafbrn.txt",header=T)
   R >  leafbrn.data1<-data.frame(leafbrn1)
   R >  attach(leafbrn.data1)
   R >  x1sq<-x1^2;x2sq<-x2^2;x3sq<-x3^2;x1x2<-x1*x2;x1x3<-x1*x3;x2x3<-x2*x3;
   R >  leafbrn <- cbind(leafbrn1,x1sq,x2sq,x3sq,x1x2,x1x3,x2x3)
   R >  detach(leafbrn.data1)
   R >  leafbrn.data<-data.frame(leafbrn)
   R >  attach(leafbrn.data)
   R >  X<-cbind(x1,x2,x3,x1sq,x2sq,x3sq,x1x2,x1x3,x2x3)
   R >  Y<-y
--------------------------------------
But using package leaps {leaps downloaded from 
http://cran.r-project.org/bin/windows/contrib/1.7/leaps_2.6.zip} with the 
following command -

   R >  leaps(X,Y,int=TRUE, method=c("Cp"), names=NULL, df=NROW(x), 
nbest=choose(9,5), strictly.compatible=T)
# Since there are 9 terms and its combination is higher in 4 or 5

gives the message -

Error in leaps.exhaustive(a) : Exhaustive search will be S L O W, must 
specify really.big=T
--------------------------------------


	1. What to do ? I don't understand where to set really.big=T.

	2. Why do we need strictly.compatible=T ?

	3. Can we simultaneously use Cp, r2, adjr2 in  method?

	4. I still have problem with FORWARD / BACKWARD / STEPWISE methods. Can 
anyone please help me to solve the above problem by using these methods (I 
use R 1.7.1)?

	5. In S-plus 4, is the following command correct for the above problem? - 
it seem to give me too many calculations and i don't understand which one 
is the result!

 > options(prompt="  S+ >  " )
   S+ >  stepwise(X, Y,intercept=T, tolerance=1.e-07,method="exhaustive", 
size.max=ncol(X), nbest=choose(9,5), f.crit=4, plot=T, time=0.02)


Any response / help / comment / suggestion / idea / web-link / replies will 
be greatly appreciated.

Thanks in advance for your time.

_______________________

Mohammad Ehsanul Karim <wildscop at yahoo.com>
Institute of Statistical Research and Training
University of Dhaka, Dhaka- 1000, Bangladesh




More information about the R-help mailing list