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
Statistical test for comparing marginal probabilities for 2 sub-groups from different regressionsI have a probably quite simple question which I do not know how to implement on Stata. The backgrou…
Svy for stratified experimental dataAlmost more of conceptual question, but I am wondering if one should use the svy prefix with specifi…
xtset and xtreg with all coefficients zeroHi everyone, I am new to using panel data on stata so I had a few questions. I am using the India …
Testing robustnessHello, I'm writing my thesis on the effect of nationality diversity on firm performance. I'm using …
statistical analysis on two-eye datasetHi everyone, I am very new to stata and I am trying to do an analysis with both eyes of one individu…
Subscribe to:
Post Comments (Atom)
0 Response to Leave One Out Cross Validation
Post a Comment