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"
Seasonality line graphHi, I have a panel dataset for 308 authorities from 2014Q1 to 2018Q4. My dependent variable is HDRR …
Oaxaca threefold decomposition and selection: how to interpretDear all, I am struggling with a selection problem and I would like to know your feedback about it: …
New on SSC: mlincom - multiple linear combinations of parametersThanks to Kit Baum, a new package mlincom is now available from SSC. mlincom (multiple lincom) comp…
Help generating and analysing a repeated variable conditional on a specific baseline time-point and value.Hi Stata Forum I have an unbalanced set of panel data with individuals having a measurement at base…
outlier results interpretationDear Statalits, I hope you are well. Could you please help me on interpret the below table shows re…
Subscribe to:
Post Comments (Atom)
0 Response to Run simple regression over a subsample by "in"
Post a Comment