Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extracting return value from evimp in mars, earth r package

Tags:

r

Earth package in R: Hello, I am running a loop to extract 1000 data subsets from my master database and run a series of MARS-based tests which I then summarize in a df. I want to pull the evimp return values (rows=variable name, cols=# subsets, GCV, RSS) that rank input variable importance for each run. But, I cannot extract or add these values to a dataframe because it is an "evimp" class. How can I pull these values and put them into a table?

like image 871
K. Mack Avatar asked Oct 16 '25 13:10

K. Mack


1 Answers

That evimp class does make it harder to get at the data, but unclass will turn it into a matrix that you can handle.

Example:

library(earth)

data(ozone1)
earth.mod <- earth(O3 ~ ., data=ozone1, degree=2)
ev <- evimp(earth.mod, trim=FALSE)

evdf = as.data.frame(unclass(ev[,c(3,4,6)]))
evdf
         nsubsets        gcv       rss
temp           11 100.000000 100.00000
humidity        9  35.667541  38.88609
ibt             7  31.618413  33.98691
doy             7  31.618413  33.98691
ibh             6  33.432738  36.02932
dpg             6  27.452997  29.75686
vis             5  21.426773  24.09804
wind            2  10.263603  12.59467
vh              1   5.324573   7.65049
like image 92
G5W Avatar answered Oct 18 '25 07:10

G5W