I'm running Stata 15.1 on MacOS. The dataset I'm working with was generated as follows: I pooled a number of large-sample cross-sectional surveys that featured the same question for the years 2008, 2010, 2011, 2012, 2014, 2015, 2016, and 2018. My goal is to examine whether states' google search interest in related topics (for those years) influences the proportion of state respondents giving a 'disagree' response. The variables I use (including the outcome variable) here was thus created as follows:
Code:
egen var1_state_year=mean(var1), by(state year)
Code:
collapse (mean) var1_state_year var2_state_year, by(state year)
Code:
. xtmixed whstate_favors indexZ i.year state: Performing EM optimization: Performing gradient-based optimization: Iteration 0: log likelihood = -1305.9038 Iteration 1: log likelihood = -1305.9038 Computing standard errors: Mixed-effects ML regression Number of obs = 400 Group variable: state Number of groups = 50 Obs per group: min = 8 avg = 8.0 max = 8 Wald chi2(8) = 275.78 Log likelihood = -1305.9038 Prob > chi2 = 0.0000 whstate_favors Coef. Std. Err. z P>z [95% Conf. Interval] indexZ 1.336521 .620664 2.15 0.031 .1200416 2.553 year 2010 -3.011593 1.064883 -2.83 0.005 -5.098725 -.9244611 2011 -.5052854 1.064613 -0.47 0.635 -2.591888 1.581317 2012 -1.860114 1.064116 -1.75 0.080 -3.945744 .2255152 2014 -1.57528 1.111708 -1.42 0.156 -3.754188 .6036278 2015 7.134012 1.239951 5.75 0.000 4.703752 9.564272 2016 2.535333 1.522316 1.67 0.096 -.4483511 5.519016 2018 6.170662 1.577615 3.91 0.000 3.078594 9.26273 _cons 17.14003 1.323791 12.95 0.000 14.54544 19.73461 Random-effects Parameters Estimate Std. Err. [95% Conf. Interval] state: Identity sd(_cons) 7.348734 .7864944 5.958173 9.063834 sd(Residual) 5.32021 .2012029 4.94012 5.729543 LR test vs. linear model: chibar2(01) = 280.74 Prob >= chibar2 = 0.0000
If it helps, here is a sample of my data (whstate_favors=outcome variable, indexZ=state's average annual google search interest score):
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(whstate_favors indexZ) double(year state) 7.680336 -1.1429285 2008 1 24.03921 -.9920198 2008 2 13.80334 -.7394119 2008 4 8.201495 -.5032071 2008 5 20.11939 -.55897766 2008 6 18.4817 -.50976837 2008 8 22.488667 .6318882 2008 9 22.00062 -1.3594495 2008 10 48.47411 -.58522266 2008 11 14.984724 -.6737995 2008 12 11.23602 -.3982272 2008 13 28.74142 -.6180289 2008 15 10.57713 -.4047884 2008 16 17.614655 -.18826735 2008 17 16.9839 -.28340536 2008 18 13.688213 . 2008 19 14.39021 -.3851047 2008 20 11.007668 -.58850324 2008 21 13.33329 -.1981092 2008 22 21.126213 -1.1790153 2008 23 16.110003 -.6049064 2008 24 21.99363 .4941021 2008 25 12.200358 .0971468 2008 26 17.403385 -.26700228 2008 27 7.49368 -.83455 2008 28 16.29431 -.50976837 2008 29 13.251606 -1.3594495 2008 30 16.155375 -.3424566 2008 31 13.729026 -.7361313 2008 32 14.480515 -.6409932 2008 33 13.202847 -.7590957 2008 34 19.35502 -.486804 2008 35 17.36421 -.35885975 2008 36 9.305553 -.15546118 2008 37 9.009853 -.9723361 2008 38 10.74107 -.4441559 2008 39 9.809873 -.56553894 2008 40 25.01471 -.6049064 2008 41 11.75892 -.20467043 2008 42 20.31874 .5531533 2008 44 12.128377 -.1915479 2008 45 19.033066 -1.3594495 2008 46 12.045777 -.5064877 2008 47 11.860756 -.4539978 2008 48 15.495923 -.7262894 2008 49 37.404438 -.5032071 2008 50 14.6579 -.7886212 2008 51 23.78781 -.12265485 2008 53 8.866741 -.9362493 2008 54 16.52739 -.4900846 2008 55 9.820115 -.8017437 2008 56 6.425949 -1.0379485 2010 1 20.993994 -1.2413472 2010 2 15.34381 -.24075733 2010 4 4.02392 -.6049063 2010 5 19.68124 -.7525344 2010 6 16.478086 -.1915479 2010 8 17.863935 .22509107 2010 9 17.345894 -.17842548 2010 10 20.170927 -.42447215 2010 11 10.718645 -.24075726 2010 12 8.976017 -.3621403 2010 13 30.34577 -1.0445098 2010 15 11.6666 .1857236 2010 16 14.709275 .30054545 2010 17 9.224236 -.6049063 2010 18 12.499412 . 2010 19 8.198928 -.408069 2010 20 13.38905 -.2243542 2010 21 7.463886 -.6409932 2010 22 21.378126 -.5950646 2010 23 13.691906 -.4441559 2010 24 20.93805 .172601 2010 25 10.807766 .05777933 2010 26 16.0334 .24149424 2010 27 3.65953 -.9362493 2010 28 13.752706 -.6705188 2010 29 9.103647 -.850953 2010 30 5.954556 -.1160937 2010 31 9.344904 -.7361313 2010 32 13.878927 -.6442739 2010 33 16.11743 -.434314 2010 34 20.65257 -.5491358 2010 35 14.31302 -.2374767 2010 36 13.121726 -.14233859 2010 37 11.473763 -.83455 2010 38 9.93098 -.2276348 2010 39 11.126292 -.3030891 2010 40 20.6783 -.6049064 2010 41 9.692232 -.16530304 2010 42 20.0009 -.17186426 2010 44 10.009124 -1.0707548 2010 45 4.7525783 -1.1822959 2010 46 7.694825 -.6049064 2010 47 10.644823 -.2801248 2010 48 15.650936 -.3457372 2010 49 31.19452 -.8607949 2010 50 10.943864 -1.0969998 2010 51 19.273506 -.3621403 2010 53 5.90513 -1.198699 2010 54 end label values state state label def state 1 "Alabama", modify label def state 2 "Alaska", modify label def state 4 "Arizona", modify label def state 5 "Arkansas", modify label def state 6 "California", modify label def state 8 "Colorado", modify label def state 9 "Connecticut", modify label def state 10 "Delaware", modify label def state 11 "District of Columbia", modify label def state 12 "Florida", modify label def state 13 "Georgia", modify label def state 15 "Hawaii", modify label def state 16 "Idaho", modify label def state 17 "Illinois", modify label def state 18 "Indiana", modify label def state 19 "Iowa", modify label def state 20 "Kansas", modify label def state 21 "Kentucky", modify label def state 22 "Louisiana", modify label def state 23 "Maine", modify label def state 24 "Maryland", modify label def state 25 "Massachusetts", modify label def state 26 "Michigan", modify label def state 27 "Minnesota", modify label def state 28 "Mississippi", modify label def state 29 "Missouri", modify label def state 30 "Montana", modify label def state 31 "Nebraska", modify label def state 32 "Nevada", modify label def state 33 "New Hampshire", modify label def state 34 "New Jersey", modify label def state 35 "New Mexico", modify label def state 36 "New York", modify label def state 37 "North Carolina", modify label def state 38 "North Dakota", modify label def state 39 "Ohio", modify label def state 40 "Oklahoma", modify label def state 41 "Oregon", modify label def state 42 "Pennsylvania", modify label def state 44 "Rhode Island", modify label def state 45 "South Carolina", modify label def state 46 "South Dakota", modify label def state 47 "Tennessee", modify label def state 48 "Texas", modify label def state 49 "Utah", modify label def state 50 "Vermont", modify label def state 51 "Virginia", modify label def state 53 "Washington", modify label def state 54 "West Virginia", modify label def state 55 "Wisconsin", modify label def state 56 "Wyoming", modify
0 Response to xtreg, xtmixed, or reg for aggregate (state-level) repeated cross-sectional data?
Post a Comment