0
$\begingroup$

I am a beginner of Cross Validation tool, I would know what is the difference between CV and K-fold Cv. The Second one, I don't understand why my R code doesn't work:

buddy <- cvFolds(nrow(buddy), K = 5, R = 10) fit_buddy50 <- glm(default ~ ETA + Stipendio, data = buddy, family = 'binomial', alpha = 0.5)

The fit_buddy50 doesn't run and an error message comes up: Error in as.data.frame.default(data) : cannot coerce class ""cvFolds"" to a data.frame Thanks in advance

$\endgroup$

closed as off-topic by Xi'an, Silverfish, Matthew Gunn, gung - Reinstate Monica, mdewey Oct 18 '16 at 13:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Xi'an, Silverfish, Matthew Gunn
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Please add a reproducible example for people to work with. $\endgroup$ – gung - Reinstate Monica Oct 18 '16 at 12:21
  • 1
    $\begingroup$ I'm voting to close this question as off-topic because it is about how to use R without a reproducible example. $\endgroup$ – gung - Reinstate Monica Oct 18 '16 at 12:22
  • $\begingroup$ Sorry, I am new in this group and I don't know very well how it works. Anyway, I have a dataset of 10700 observations. The analysis is about credit risk scoring, so the data have to validate some analysis about young people and their probability of eligibility for personal loans. $\endgroup$ – Dalila Oct 18 '16 at 12:32
  • $\begingroup$ I follow the same example that you provided. Issues: error comes up " error in as.data.frame.default(data) : cannot coerce class 'cvfolds' to a data.frame. My data set contains 10700 numeric obs $\endgroup$ – Dalila Oct 18 '16 at 12:45
  • $\begingroup$ Your programming question might be better on R-help. $\endgroup$ – mdewey Oct 18 '16 at 13:15
0
$\begingroup$

Cross Validation is about the general technique of subsetting a data in complementary pieces, make an analysis (e.g. training a model) on selected subsets and them validate the analysis on the remaining. You can find more in this paper.

k-Fold Cross Validation is a type of Cross Validation technique where you split the data in k subsets of equal size and let one out of the analysis in each iteration, then you aggregate the results of the k iterations.

Other types are Leave-p-out Cross Validation and n-Fold Cross Validation.

About your code, you are overwriting your data with the folds, you have to run the model on the data. This answer is explaining with an example.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.