Dear Stata users,
I have an unbalanced panel data set with the following variables: id, year, nobirths, type.
I want to estimate how many hospitals (id) closed if the number of births in that year was less than 300 and the type of hospitals that closed. I do not want to consider for my estimation hospitals of type==1.
In order to do that I am using the following code:
xtset id year
tsfill, full (in order to balance the panel)
gen type2=type[_n-1]
tab nobirths type2 if nobirths[_n-1]<300&year==2014&type[_n-1]!=.&nobirths[_n-1]>0|nobirths[_n-1]<300&year==2014&type2[_n-1]!=1&nobirths[_n-1]>0, missing
However, when I obtain the table, it lists type2==1. I can see that it is because when Stata does "gen type2=type[_n-1]" is only considering the previous observation and not considering that I have panel data. Could anyone help me with a better solution?
Related Posts with Identify missing observations unbalanced panel
r(198) invalid name error messageI'm getting an r(198) error when trying to run the code below I'm new to STATA so I'm not exactly su…
regexr - Regular Expression in StataHi everyone! I am working on some regular expression problem. The data I have is something like this…
New variables using longitudinal dataMay you assist with syntax for longitudinal data. 1. Within each record "personid" I would like to …
Bivariate Dynamic Probit Model for Panel DataHello All, I would like to estimate a Bivariate Dynamic Probit model for panel data using Simulated…
Manually estimating standard error of the random effect, after the mi estimate: mixed command, with remlHello, I am using mi estimate: mixed, with reml. In Stata 16.1 Following estimation of the model, I …
Subscribe to:
Post Comments (Atom)
0 Response to Identify missing observations unbalanced panel
Post a Comment