[R] Problem with leaps (long)
F. Tusell
etptupaf at bs.ehu.es
Wed Sep 11 10:43:57 CEST 2002
I am generating a bunch of examples for my students and when I type
R BATCH demo10.R
(file demo10.R reproduced below) I get an error:
------------- Error message ------
> plot(mods$size,mods$Cp,
+ main="Cp versus talla modelos",
+ xlab=expression(p),
+ ylab=expression(C[p]))
Error in plot.window(xlim, ylim, log, asp, ...) :
need finite ylim values
In addition: Warning messages:
1: no finite arguments to min; returning Inf
2: no finite arguments to max; returning -Inf
Execution halted
----------------------------------
On looking at object "mods", I see that indeed mods$Cp is full of NaNs.
Exactly the same file worked last year. What is more strange, if I
type or paste the commands interactively, I get plausible Cp values in
mods$Cp. It is only in BATCH that the thing goes stray.
---------- File demo10.R up to the error point ---------
library(MASS)
data(UScrime)
UScrime[1:3,]
attach(UScrime)
completo <- lm(y ~ . , data=UScrime)
summary(completo)
library(leaps)
X <- as.matrix(UScrime[,-16])
y <- UScrime[,16]
mods <- leaps(x=X,y=y,method="Cp")
postscript(file="demo10.eps",
horizontal=FALSE,
width=5,height=9)
par(mfrow=c(2,1))
plot(mods$size,mods$Cp,
main="Cp versus talla modelos",
xlab=expression(p),
ylab=expression(C[p]))
--------------------------------------------------
While on the same topic, the help on line advocates the use of function
regsubsets, which is said to improve on leaps on several ways. However,
I see no way to select different criteria (Cp, R2, adjR2) in said
function.
I am using R 1.5.1 under Debian/Linux 3.0 (kernel 2.4.18, gcc -v
reports "gcc version 2.95.4 20011002", if that matters).
Many thanks for any help.
ft.
--
Fernando TUSELL e-mail:
Departamento de Econometría y Estadística etptupaf at bs.ehu.es
Facultad de CC.EE. y Empresariales Tel: (+34)94.601.3733
Avenida Lendakari Aguirre, 83 Fax: (+34)94.601.3754
E-48015 BILBAO (Spain) Secr: (+34)94.601.3740
PGP: finger etptupaf at bsdx01.bs.ehu.es http://etdx01.bs.ehu.es
----------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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