Hello,
I am trying to look for the best n given:
set obs 200
gen x = runiform(0,5)
gen U = rnormal(0,100)
gen m = exp(x) - 4*(x^2)
gen Y = m+U
and the equation in the attached image:
//note the loops below does not work for some reason but it gets the idea across
forvalues i in 1(1)20 {
gen cosx`i' = cos(x*`i')
}
forvalues i in 1(1)20 {
gen sinx`i' = sinx*(`i')
}
forvalues i in 1/20 {
gen csx`i' = (cosx`i')+(sinx`i')
}
// Y(n=1)
regress Y csx1
predict Y1
//Y(n=5)
regress Y csx1-csx5
predict Y2
//Y(n=20)
regress Y csx1-csx20
predict Y3
scatter Y1 Y2 Y3 m x, legend(order(1 "Y1" 2 "Y2" 3 "Y3" 4 "m"))
//with a scatter plot looking like the attached scatter.png:
-------------------------------------------------------------------------------------------------------------------------
How should I perform LOOCV in Stata to find the best n? I tried help in Stata but found no information on it.
(The choice of n is kind of like finding the bandwidth in kernel regression but I'm not sure how to approach it with the syntax)
Thanks,
Rayne
Related Posts with Leave One Out Cross Validation
95% confidence interval for difference in two estimatesHi, I'm reading a paper that calculated the difference in two percentages with 95%CI using Stata 14…
Error while generating transition-driven substitution matrix (trans2subs)I would like to create a transition-driven substitution matrix in Stata. I have, 1734 ids, 88 differ…
Value-weigted portfoliosCan anyone guide me how to create value-weighted portfolios in asset pricing tests? I know about equ…
Margins 'not estimable' using Fixed EffectsHi all, I am running a regression in the context online shopping with the price on the number of co…
Wishlist for statalist!I hope this is a reasonable wish - there should be an option to bookmark favorite questions and answ…
Subscribe to:
Post Comments (Atom)
0 Response to Leave One Out Cross Validation
Post a Comment