简体   繁体   中英

Cross Validation using Zelig package

I am using Zelig package inside R and i want to run cross-validation.

library(Zelig)
data(med)
z.out1 <- zelig(conflict ~ major + contig + power + maxdem + mindem + years, data = mid, model = "relogit", tau = 1042/303772)

I want to run a 10-fold cross vaildation, to get the confusion matrix and to calculate more measures to validate my model. How can i do it?

Finally i figured out how to do it using Zelig. To build a model and use it to predict on new data i need to do the following:

m1<-relogit(conflict~.,trainData)
y_pred = predict(m1,testData, type="response")
y_true = testData[1]
accuracy(t(y_true),t(y_pred))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM