Hello everyone, I am new to Stata and woud like your help. I have a sample of size 249, and I would like to run a regression over the first 50 observations. The only way I know is to create a sequence variable and use "if", and it works (the blue line). I was wondering if I can use "in" instead? (the red line)
When I run the following code, I got an error message "'50-start_T+1' invalid observation number"
clear all
import excel "data/xyz.xlsx", firstrow case(lower) clear
egen t1 = seq()
tsset t1
sca n1 = 65
sca start_T = 50
gen b_cons = .
gen b_x1 = .
gen b_x2 = .
gen y_f = .
forvalues i = `=start_T'/`=_N-n1' {
//reg y x1 x2 if t1<= `i' & t1> `i'-start_T // it works
reg y x1 x2 in `i'-start_T+1/`i' // it does not work; error
predict temp in `i+n1'
replace y_f = temp in `i+n1'
drop temp
}
I would like to know how to do it because "if" does not extend to more advanced models, but I hope "in" can.
Related Posts with Run simple regression over a subsample by "in"
ebalfit: New command for entropy balancingA new command for entropy balancing is now available from SSC. Type Code: . ssc install ebalfit to…
identifying random slope by groupHi all, I have a multilevel logistic model (using melogit in Stata 15.1) written as: Code: melog…
Omitted dummy variable because of collinearityDear community I am running a panel data with fixed effects. The model I'm applying is a partial ad…
Help on storing estimates from multiple regressions run in loop for exporting them with esttabHello there, I have the following quarterly data. I intend to run a piecewise linear regression of …
Fuzzy RD PlotI am using the following code for my Fuzzy RDD analysis: Y=outcome variable R=Running variable rela…
Subscribe to:
Post Comments (Atom)
0 Response to Run simple regression over a subsample by "in"
Post a Comment