Cleber N.Borges
2011-Jul-21 15:14 UTC
[R] Error: bad index in plotmo functions for MARS model (package earth)
Hello all useRs, I am tring make a simple surface plot ( 2 by 2 terms of a MARS model (with earth package) but I get the follow error message: > plotmo( mars ) Error: bad index (missing column in x?) I don't no how to workround this... :-( I thanks in advanced by some help! Thanks. Cleber ############### > > ### example code: > library( earth ) > data( gasoline, package='pls' ) > > nir <- gasoline$NIR > dim( nir ) [1] 60 401 > class( nir ) [1] "AsIs" > > oct <- gasoline$octane > > mars <- earth( oct ~ nir, nk=300, nfold=10, degree=3, trace=0 ) > > plotmo( mars ) Error: bad index (missing column in x?) > plotmo( mars, all1=T ) Error: bad index (missing column in x?) > plotmo( mars, all1=T, all2=T ) Error: bad index (missing column in x?) > > sessionInfo() R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 LC_MONETARY=Portuguese_Brazil.1252 [4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] pls_2.1-0 earth_3.2-0 plotrix_3.2-2 plotmo_1.2-6 leaps_2.9 loaded via a namespace (and not attached): [1] tools_2.13.1 >
Stephen Milborrow
2011-Jul-22 15:38 UTC
[R] Error: bad index in plotmo functions for MARS model (package earth)
On 2011-07-28 12:14:32, Cleber N.Borges wrote:> I am tring make a simple surface plot ( 2 by 2 terms of a MARS model > (with earth package) but I get the follow error message: > > > library( earth ) > > data( gasoline, package='pls' ) > > nir <- gasoline$NIR > > class( nir ) > [1] "AsIs" > > oct <- gasoline$octane > > mars <- earth( oct ~ nir, nk=300, nfold=10, degree=3, trace=0 ) > > plotmo( mars ) > Error: bad index (missing column in x?)The plotmo function is understandably confused by the fact that the class of gasoline$NIR is "AsIs". Here is a work around: g <- data.frame(octane=gasoline$octane, as.matrix(data.frame(gasoline$NIR))) colnames(g) <- sub("gasoline.NIR.", "", colnames(g)) mars <- earth(octane ~ ., data=g, degree=2) plotmo(mars, clip=F) Earth is not suited to highly collinear data like this. Note that summary(lm(octane ~ ., data=g)) gives "ALL 60 residuals are 0: no residual degrees of freedom" I will issue a new version of plotmo with better error handling for this problem. I have cc'ed this email to the maintainer of the pls package to let them know that the gasoline data has a strange class. Cleber, per the posting guide you should have sent your email directly to me, the author of the plotmo package, and not to r-help, so let's continue any further discussion off the list. Feel free to contact me if you have further questions. Regards, Steve Milborrow www.milbo.users.sonic.net
Maybe Matching Threads
- How to formulate quadratic function with interaction terms for the PLS fitting model?
- Quadratic function with interaction terms for the PLS fitting model?
- Quadratic function with interaction terms for the PLS fitting model?
- How to formulate quadratic function with interaction terms for the PLS fitting model?
- Quadratic function with interaction terms for the PLS fitting model?