[R] cross-validation
Tapio Nummi
tan at uta.fi
Sun Mar 18 13:48:18 CET 2001
Dear R-users,
I have the following problem:
The function crossval (in library bootstrap)
works well for the first degree polynomial model,
but in the case of the second degree model I got
an error message (see below). What went wrong?
> library(bootstrap)
>
> x<-c(22,23.4,24.9,28.5,29.8,31.6,34.2,36.4,37.7,39)
> y<-c(96,88,105,111,107,113,132,122,135,131)
>
> theta.fit<-function(x,y){lsfit(x,y)$coef}
> theta.predict<-function(fit,x){
+ cbind(1,x) %*% fit}
> results <- crossval(cbind(x,x^2),y,theta.fit,theta.predict)
Error in cbind(1, x) %*% fit : non-conformable arguments
Tapio Nummi
University of Tampere
Finland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010318/cc80a686/attachment.html
More information about the R-help
mailing list