[R] prediction in a loop with only one sample
asdf1234
farina2001 at gmx.de
Sat May 11 09:59:11 CEST 2013
Dear all,
I have a sample with 920 observations. I want to create a loop which takes
300 of these observations for the prediction and the rest to estimate the
model.
My idea was to create something like this:
cs.training.dat <- read.table...
cs.training.dat_sub1 <- subset(cs.training.dat, Income>10)
cs.training.dat_sub2 <- subset(cs.training.dat_sub1, Dept.Ratio<=1)
cs.training.dat_sub3 <- subset(cs.training.dat_sub2, Credit.Limit.Ratio<=1)
for (i in 1:500){
y.2 <- cs.training.dat_sub3$y[1+[i]:300+[i]]
y.1 <- cs.training.dat_sub3$y[-(1+[i]:300+[i])]
NTimes.60DaysLate.2 <-
(cs.training.dat_sub3$NTimes.60DaysLate[1+[i]:300+[i]])
NTimes.60DaysLate.1 <-
(cs.training.dat_sub3$NTimes.60DaysLate[-(1+[i]:300+[i])])
Credit.Limit.Ratio.2 <-
(cs.training.dat_sub3$Credit.Limit.Ratio[1+[i]:300+[i]])
Credit.Limit.Ratio.1 <-
(cs.training.dat_sub3$Credit.Limit.Ratio[-(1+[i]:300+[i])])
Dept.Ratio.2 <- (cs.training.dat_sub3$Dept.Ratio[1+[i]:300+[i]])
Dept.Ratio.1 <- (cs.training.dat_sub3$Dept.Ratio[-(1+[i]:300+[i])])
Numb.Dependents.2 <- (cs.training.dat_sub3$Numb.Dependents[1+[i]:300+[i]])
Numb.Dependents.1 <- (cs.training.dat_sub3$Numb.Dependents[-(1+[i]:300+[i]])
X.1[i] <- cbind(NTimes.60DaysLate.1, Credit.Limit.Ratio.1, Dept.Ratio.1,
Numb.Dependents.1)
X.2[i] <- cbind(NTimes.60DaysLate.2, Credit.Limit.Ratio.2, Dept.Ratio.2,
Numb.Dependents.2)
}
However, I get error massages because R cannot read 1+[i] ...
Do you have any idea how I can create 500 different pairs from my one sample
where one variabe contains 300 observation and the other the rest?
Thank you very much in advance.
--
View this message in context: http://r.789695.n4.nabble.com/prediction-in-a-loop-with-only-one-sample-tp4666819.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list