Hi all!
I need to split my dataset into 10 folds to do cross-validation "manually" (I know about the crossfold command, but it won't work for what I need).
I need a loop that allows me to run 10 cycles. In each of them, I need to select the train set (9 parts) and the validation dataset (1 part). Then I will run my model is the trainset and use the predict command to estimate the prediction of this model on the validation dataset.
This is what I have come up with so far, which I am aware it's wrong...
sysuse auto, clear
generate prp=0
* ** variable with the fold number. I know that in R there is a command that allows me to split n observations into K groups to be used for (repeated) K-fold cross-validation (cvfolds). Any suggestion?
egen split = seq(), f(1) t(10)
forvalues i = 1/10{
reg price mpg headroom if split != `i'
predict p if split =`i'
replace prp=p
drop p
}
Thanks a lot in advance!
Related Posts with Split dataset for cross-validation
Rename variables before run "coefplot"Hi all, I have a data set that has “treatment”, “year” variables I use the below code to run a reg…
creating a new variable that meet the definitionHello, Here I have a request that is a little complicated. I will try to make is simple and logical…
testtest Code: +--------------------------+ | idom v4741 membros | |-…
Estimating Variance Components from ANOVAOne of our reviewers ask us to conduct robustness checks by using ANOVA to estimate variance compone…
Randomization schedule with uneven sample distribution.Hello, I would like to ask for help in creating a command to generate a randomization schedule for a…
Subscribe to:
Post Comments (Atom)
0 Response to Split dataset for cross-validation
Post a Comment