Dear R users:

Recently, I tried to write a program to calculate cross-validated predicted
value.
My sources are as follows. However, the R reported an error.
Could you please check the sources? Thanks.

set.seed(100)
x<-rnorm(100)
y<-sample(rep(0:1,50),replace=T)
dat<-data.frame(x,y)

library(rms)

fito<-lrm(y~x)
preo<-predict(fito)

pre<-matrix(NA,nrow=100,ncol=200)

for (i in 1:200)
{
sam<-sample(1:nrow(dat))
sam<-split(sam,1:10)
 for (j in 1:10)
{
fit<-lrm(y~x,data=dat[-sam[[j]],])
pre[sam[[j]],i]<-predict(fit,data=dat[sam[[j]],])
}
}








*Yao Zhu*
*Department of Urology
Fudan University Shanghai Cancer Center
Shanghai, China*

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to