[R-sig-eco] Cross validate model with calibrate
Philipp01
gaertner.p at gmail.com
Fri Nov 1 14:53:03 CET 2013
Hello all,
I would like to cross validate my rda() derived model with the calibrate
function (vegan package) and calculate the RMSE as value for performance
measure.
For simplicity I use the example from the predict.cca {vegan} help.
library(ade4)
library(vegan)
data(dune)
data(dune.env)
nbr <- as.numeric(rownames(dune))
library(caret)
inTrain <- createDataPartition(y=nbr, p=3/4, list=F, times=1)
train.dune <- dune[inTrain[,i],];
test.dune <- dune[-inTrain[,i],];
train.dune.env <- dune.env[inTrain[,i],];
test.dune.env <- dune.env[-inTrain[,i],];
mod <- rda(train.dune ~ A1, train.dune.env)
cal <- calibrate(mod, newdata=test.dune)
with(test.dune.env, plot(A1, cal[,"A1"] - A1, ylab="Prediction Error"))
abline(h=0)
error <- cal - test.dune.env$A1
(rmse <- sqrt(mean(error^2)))
When I apply this code snippet to my very own data I get positive and
negative "cal" values, which would be unrealistic for parameters such as
tree height (etc.). Therefore, I doubt that my approach is correct. How do
you compute the RMSE for the rda() derived model?
Regards, Philipp
--
View this message in context: http://r-sig-ecology.471788.n2.nabble.com/Cross-validate-model-with-calibrate-tp7578486.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.
More information about the R-sig-ecology
mailing list