Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using parmest function

    Working on an assignment question attached here
    Code:
    Code:
    collapse (mean) saidin govt nonprof beds teach, by (prov_id year treat) encode prov_id, generate(prov_id_num) // Ensure the dataset has hospital and year fixed effects tsset prov_id_num year // Declare panel data structure // Estimating the DiD model with year-specific treatment effects // Using 'i.year##i.treatment' to interact year dummies with treatment status // 2004 is the base year (omitted) *xtreg saidin i.year##i.treat, fe cluster(prov_id) xtreg saidin i.year##i.treat, fe vce(cluster prov_id) // Store the estimation results estimates store did_results //it shows an error when I run the next line parmest, saving("did_estimates.dta", replace) /// list(1.treat#2001.year 1.treat#2002.year 1.treat#2003.year 1.treat#2004.year /// 1.treat#2005.year 1.treat#2006.year 1.treat#2007.year 1.treat#2008.year /// 1.treat#2009.year 1.treat#2010.year) /// rename(estimate tr_effect ci_min tr_lo ci_max tr_hi) X // Calculate means for control and treatment groups by year preserve collapse (mean) cr_mean=saidin (mean) tr_mean=saidin, by(year treat) reshape wide cr_mean tr_mean, i(year) j(treat) rename cr_mean0 cr_mean rename tr_mean1 tr_mean save "means_by_year.dta", replace restore
    error:
    this is version 15.0 of Stata; it cannot run version 16.0 programs

    You can purchase the latest version of Stata by visiting http://www.stata.com.

    r(9);
    Did results:
    xtreg saidin i.year##i.treat, fe vce(cluster prov_id)

    note: 1.treat omitted because of collinearity

    Fixed-effects (within) regression Number of obs = 13050

    Group variable: prov_id_num Number of groups = 1305

    R-sq: within = 0.3988 Obs per group: min = 10

    between = 0.0276 avg = 10.0

    overall = 0.1839 max = 10

    F(18,1304) = 85.03

    corr(u_i, Xb) = 0.0044 Prob > F = 0.0000

    (Std. Err. adjusted for 1,305 clusters in prov_id)

    ------------------------------------------------------------------------------

    | Robust

    saidin | Coef. Std. Err. t P>|t| [95% Conf. Interval]

    -------------+----------------------------------------------------------------

    year |

    2002 | -.0496105 .0095759 -5.18 0.000 -.0683964 -.0308247

    2003 | .4009545 .0217712 18.42 0.000 .3582442 .4436649

    2004 | .9130886 .0482031 18.94 0.000 .8185245 1.007653

    2005 | 1.786406 .074284 24.05 0.000 1.640677 1.932135

    2006 | 1.971543 .0776429 25.39 0.000 1.819224 2.123861

    2007 | 2.693743 .0939984 28.66 0.000 2.509339 2.878148

    2008 | 2.885176 .0951661 30.32 0.000 2.69848 3.071871

    2009 | 3.142039 .0997124 31.51 0.000 2.946425 3.337653

    2010 | 3.241765 .0987615 32.82 0.000 3.048017 3.435514

    |

    1.treat | 0 (omitted)

    |

    year#treat |

    2002 1 | .0539812 .0950462 0.57 0.570 -.1324789 .2404414

    2003 1 | .7362102 .1655246 4.45 0.000 .4114865 1.060934

    2004 1 | 1.715832 .429485 4.00 0.000 .8732743 2.558389

    2005 1 | 2.760607 .6574471 4.20 0.000 1.470837 4.050377

    2006 1 | 2.976634 .6494365 4.58 0.000 1.702579 4.250689

    2007 1 | 3.90112 .7746336 5.04 0.000 2.381455 5.420784

    2008 1 | 4.049662 .7404265 5.47 0.000 2.597104 5.502219

    2009 1 | 4.554087 .7555774 6.03 0.000 3.071807 6.036367

    2010 1 | 4.517338 .7957025 5.68 0.000 2.956341 6.078335

    |

    _cons | .978769 .0566244 17.29 0.000 .867684 1.089854

    -------------+----------------------------------------------------------------

    sigma_u | 2.3622704

    sigma_e | 1.6712966

    rho | .66642213 (fraction of variance due to u_i)

    ------------------------------------------------------------------------------
    Dataset looks like this:

    . dataex

    ----------------------- copy starting from the next line -----------------------

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    
    clear
    
    input str7 prov_id int year byte treat float(saidin govt nonprof beds teach) long prov_id_num byte _est_did_results
    
    "11Z111" 2001 0 .53716475 1 0 35 0 1 1
    
    "11Z111" 2002 0 .1494253 1 0 35 0 1 1
    
    "11Z111" 2003 0 .1586207 1 0 35 0 1 1
    
    "11Z111" 2004 0 .13409962 1 0 35 0 1 1
    
    "11Z111" 2005 0 .13333333 1 0 35 0 1 1
    
    "11Z111" 2006 0 .11800766 1 0 35 0 1 1
    
    "11Z111" 2007 0 .1118774 1 0 35 0 1 1
    
    "11Z111" 2008 0 .9103448 1 0 35 0 1 1
    
    "11Z111" 2009 0 .8720306 1 0 35 0 1 1
    
    "11Z111" 2010 0 .8413793 1 0 35 0 1 1
    
    "11Z113" 2001 0 .194636 1 0 40 0 2 1
    
    "11Z113" 2002 0 .1494253 1 0 40 0 2 1
    
    "11Z113" 2003 0 .1586207 1 0 40 0 2 1
    
    "11Z113" 2004 0 .13409962 1 0 40 0 2 1
    
    "11Z113" 2005 0 .13333333 1 0 40 0 2 1
    
    "11Z113" 2006 0 .11800766 1 0 40 0 2 1
    
    "11Z113" 2007 0 .1118774 1 0 40 0 2 1
    
    "11Z113" 2008 0 .1072797 1 0 40 0 2 1
    
    "11Z113" 2009 0 .09655172 1 0 40 0 2 1
    
    "11Z113" 2010 0 .09501916 1 0 40 0 2 1
    
    "11Z132" 2001 0 .4743295 1 0 211 0 3 1
    
    "11Z132" 2002 0 .3961686 1 0 211 0 3 1
    
    "11Z132" 2003 0 .4176245 1 0 211 0 3 1
    
    "11Z132" 2004 0 .3900383 1 0 211 0 3 1
    
    "11Z132" 2005 0 .3823755 1 0 211 0 3 1
    
    "11Z132" 2006 0 .6030651 1 0 211 0 3 1
    
    "11Z132" 2007 0 .57701147 1 0 211 0 3 1
    
    "11Z132" 2008 0 .3072797 1 0 211 0 3 1
    
    "11Z132" 2009 0 .29042146 1 0 211 0 3 1
    
    "11Z132" 2010 0 .2881226 1 0 211 0 3 1
    
    "11Z135" 2001 0 .8168582 0 1 55 0 4 1
    
    "11Z135" 2002 0 .6942528 0 1 55 0 4 1
    
    "11Z135" 2003 0 .7019157 0 1 55 0 4 1
    
    "11Z135" 2004 0 .6559387 0 1 55 0 4 1
    
    "11Z135" 2005 0 .6360153 0 1 55 0 4 1
    
    "11Z135" 2006 0 .6030651 0 1 55 0 4 1
    
    "11Z135" 2007 0 .57701147 0 1 55 0 4 1
    
    "11Z135" 2008 0 .5678161 0 1 55 0 4 1
    
    "11Z135" 2009 0 .52796936 0 1 55 0 4 1
    
    "11Z135" 2010 0 .51187736 0 1 55 0 4 1
    
    "11Z13Z" 2001 0 .194636 1 0 34 0 5 1
    
    "11Z13Z" 2002 0 .1494253 1 0 34 0 5 1
    
    "11Z13Z" 2003 0 .6827586 1 0 34 0 5 1
    
    "11Z13Z" 2004 0 .6191571 1 0 34 0 5 1
    
    "11Z13Z" 2005 0 .6091954 1 0 34 0 5 1
    
    "11Z13Z" 2006 0 .11800766 1 0 34 0 5 1
    
    "11Z13Z" 2007 0 .4337165 1 0 34 0 5 1
    
    "11Z13Z" 2008 0 .4084291 1 0 34 0 5 1
    
    "11Z13Z" 2009 0 1.6605364 1 0 34 0 5 1
    
    "11Z13Z" 2010 0 1.57318 1 0 34 0 5 1
    
    "11Z142" 2001 0 .53716475 0 1 195 0 6 1
    
    "11Z142" 2002 0 .4475096 0 1 195 0 6 1
    
    "11Z142" 2003 0 .4429119 0 1 195 0 6 1
    
    "11Z142" 2004 0 1.1409962 0 1 195 0 6 1
    
    "11Z142" 2005 0 1.1118773 0 1 195 0 6 1
    
    "11Z142" 2006 0 2.2628353 0 1 195 0 6 1
    
    "11Z142" 2007 0 2.5042145 0 1 195 0 6 1
    
    "11Z142" 2008 0 1.1340996 0 1 195 0 6 1
    
    "11Z142" 2009 0 1.0475096 0 1 195 0 6 1
    
    "11Z142" 2010 0 .989272 0 1 195 0 6 1
    
    "11Z161" 2001 0 2.2283525 0 1 487 0 7 1
    
    "11Z161" 2002 0 2.072797 0 1 487 0 7 1
    
    "11Z161" 2003 0 3.481226 0 1 487 0 7 1
    
    "11Z161" 2004 0 4.94023 0 1 487 0 7 1
    
    "11Z161" 2005 0 6.640613 0 1 487 0 7 1
    
    "11Z161" 2006 0 6.385441 0 1 487 0 7 1
    
    "11Z161" 2007 0 7.610728 0 1 487 0 7 1
    
    "11Z161" 2008 0 8.143295 0 1 487 0 7 1
    
    "11Z161" 2009 0 9.232183 0 1 487 0 7 1
    
    "11Z161" 2010 0 10.186207 0 1 487 0 7 1
    
    "11Z163" 2001 0 .194636 0 0 174 0 8 1
    
    "11Z163" 2002 0 .6942528 0 0 174 0 8 1
    
    "11Z163" 2003 0 .7019157 0 0 174 0 8 1
    
    "11Z163" 2004 0 .4 0 0 174 0 8 1
    
    "11Z163" 2005 0 .3869732 0 0 174 0 8 1
    
    "11Z163" 2006 0 .3555556 0 0 174 0 8 1
    
    "11Z163" 2007 0 .6528736 0 0 174 0 8 1
    
    "11Z163" 2008 0 .6176245 0 0 174 0 8 1
    
    "11Z163" 2009 0 1.807663 0 0 174 0 8 1
    
    "11Z163" 2010 0 1.7609196 0 0 174 0 8 1
    
    "11Z165" 2001 0 1.3831418 0 1 336 0 9 1
    
    "11Z165" 2002 0 1.2582376 0 1 336 0 9 1
    
    "11Z165" 2003 0 1.8796935 0 1 336 0 9 1
    
    "11Z165" 2004 0 1.6720307 0 1 336 0 9 1
    
    "11Z165" 2005 0 1.5264368 0 1 336 0 9 1
    
    "11Z165" 2006 0 1.4176246 0 1 336 0 9 1
    
    "11Z165" 2007 0 2.560153 0 1 336 0 9 1
    
    "11Z165" 2008 0 3.199234 0 1 336 0 9 1
    
    "11Z165" 2009 0 3.79387 0 1 336 0 9 1
    
    "11Z165" 2010 0 3.649042 0 1 336 0 9 1
    
    "11Z177" 2001 0 .53716475 0 0 255 0 10 1
    
    "11Z177" 2002 0 .6942528 0 0 255 0 10 1
    
    "11Z177" 2003 0 1.524138 0 0 255 0 10 1
    
    "11Z177" 2004 0 2.759387 0 0 255 0 10 1
    
    "11Z177" 2005 0 4.927203 0 0 255 0 10 1
    
    "11Z177" 2006 0 4.743295 0 0 255 0 10 1
    
    "11Z177" 2007 0 4.6666665 0 0 255 0 10 1
    
    "11Z177" 2008 0 4.6191573 0 0 255 0 10 1
    
    "11Z177" 2009 0 4.548659 0 0 255 0 10 1
    
    "11Z177" 2010 0 4.5149426 0 0 255 0 10 1
    
    end
    
    label values prov_id_num prov_id_num
    
    label def prov_id_num 1 "11Z111", modify
    
    label def prov_id_num 2 "11Z113", modify
    
    label def prov_id_num 3 "11Z132", modify
    
    label def prov_id_num 4 "11Z135", modify
    
    label def prov_id_num 5 "11Z13Z", modify
    
    label def prov_id_num 6 "11Z142", modify
    
    label def prov_id_num 7 "11Z161", modify
    
    label def prov_id_num 8 "11Z163", modify
    
    label def prov_id_num 9 "11Z165", modify
    
    label def prov_id_num 10 "11Z177", modify
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 13050 observations

    Use the count() option to list more

    What am I doing wrong?
    Last edited by snigdha kashyap; 10 Apr 2025, 11:57.

  • #2
    Please note advice in our FAQ about homework or assignments.

    Comment

    Working...
    X