[R] cvTools for 2 models not working

varin sacha v@rin@@ch@ @ending from y@hoo@fr
Sat Apr 14 01:48:15 CEST 2018


Dear R-experts,

I am trying to do cross-validation for different models using the cvTools package.

I can't get the CV for the "FastTau" and "hbrfit". I guess I have to write my own functions at least for hbrfit. What is going wrong with FastTau ?

Here below the reproducible example. It is a simple toy example (not my real dataset) with many warnings, what is important to me are the errors.

###CROSS-VALIDATION
######################
# install.packages( "robustbase" )
# install.packages( "MASS" )
# install.packages( "quantreg" )
# install.packages( "RobPer" )
# install.packages("devtools")  # library("devtools") # install_github("kloke/hbrfit") #install.packages('http://www.stat.wmich.edu/mckean/Stat666/Pkgs/npsmReg2_0.1.1.tar.gz') 
# install.packages( "cvTools" )

library(robustbase)
library(MASS)
library(quantreg)
library(RobPer)
library(hbrfit)
library(cvTools)


X <- c(5,3,2,4,7,6,9,3,7,11,1,6,4,5,6,9,4,5,34,2,1,3,12,8,9,7,4,12,19,21)
Y <- c(25,24,23,19,17,14,13,14,25,13,17,25,14,13,19,25,16,16,20,21,25,19,12,11,9,28,21,10,2,8)
Z <- c(34,32,12,23,54,12,13,54,52,32,39,19,32,12,11,10,9,8,45,34,23,26,29,6,35,47,21,29,26,25)

  reg1 <- lm( Y ~ X+Z )
  reg <- lmrob( Y ~ X + Z)
  Huber <- rlm( Y ~ X +Z)
  Tukey <- rlm( Y ~ X+Z, psi = psi.bisquare )
  L1 <- rq( Y ~ X + Z, tau = 0.5 )
  fast <- FastTau(model.matrix(~X+Z),Y)
HBR<-hbrfit(Y ~ X +Z) 


cvFit(lmrob,formula=Y ~ X + Z, cost=rtmspe, K=5, R=100)
 
cvFit(lm,formula=Y ~ X + Z, cost=rtmspe, K=5, R=100)

cvFit(rlm,formula=Y ~ X + Z, cost=rtmspe, K=5, R=100)

cvFit(rlm,formula=Y ~ X + Z, psi = psi.bisquare, cost=rtmspe, K=5, R=100)

cvFit(rq,formula=Y ~ X + Z, tau=0.5, cost=rtmspe, K=5, R=100)

cvFit(FastTau(model.matrix(~X+Z),Y),cost=rtmspe,K=5,R=100)


cvFit(hbrfit,formula=Y ~ X + Z, cost=rtmspe, K=5, R=100)

######################



 




More information about the R-help mailing list