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
AR or MA or ARMA process?Hi guys, If i wrote the formula xt = 1.004 * xt-1 + ut and yt = 1.04 * yt-1 + vt are these AR or M…
Interaction and factorial interaction have different significance levelI am trying to find out the effect of the interaction terms in my model. but i keep getting conflict…
How to calculate the number of posts and different categories for a certain user before time t?Hello, I encounter a question when building models in Stata. Data example: Code: * Example genera…
instrumenting a binary endogenous regressorHello, I am trying to run a model with a binary endogenous regressor. I am still learning econometri…
Merging loan data (US) with CPS via using CBSAI'm having trouble whilst trying to merge the PPP loan data from government website with the BLS's C…
Subscribe to:
Post Comments (Atom)
0 Response to Leave One Out Cross Validation
Post a Comment