Quantcast
Channel: Statalist
Viewing all 73258 articles
Browse latest View live

latent class analysis and sample size requirements

$
0
0
Dear Stata users, I have a question to ask concerning latent class analysis (LCA). I am working with a sample of 57 American cities. I am using a total of 83 city-level variables to place my 57 cities into a set of latent classes (I am considering first using exploratory factor analysis to aggregate my 83 city-level variables into 7 or so factors/indexes). My goal is to study how different latent classes of American cities are associated with the overall happiness of city residents. I am concerned that my sample size of 57 cities might be inadequate to develop a stable set of latent classes. I would very much appreciate it if anyone could offer me advice concerning whether an LCA can be done with a sample of 57. Might it be the case that I should limit the number of latent classes I develop to a certain number?

I am aware of some of the techniques (like BIC) used to establish what is the best number of latent classes to develop with LCA. I’m wondering if there is any way to get a sense of whether the outcomes of these techniques are stable and accurate.

I plan on doing LCA with Stata 15's 'gsem lca.'

I would very much appreciate your help, thank you in advance!

Yours sincerely,
Jason Settels

Fitted multiple regression line with one continuous and many dummy variables in the regressors

$
0
0
Hello everyone,

I am working with the following model -

Yi = β1 + β2 Xi + β3 Zi + β4 Pi + β5 Qi + β6 Si + εi

where Y is a binary dependent variable and among the independent variables - only X is continuous and the rest are dummies (Z, P, Q and S). I am working with Linear Probability Model, Logit and Probit model.

What I am trying to do is

a) plot the fitted values of X using its coefficients from LPM model. Here all of the dummies will be at their respective averages. Next in the same plane, I want to plot X again using its coefficient from LPM but here only one of the of the dummies will take the value of 1 (i.e. only Z) and rest will be at their averages (P, Q and S).

b) Next in a similar manner, I would like to plot the fitted values of X using its marginal effects from Logit model. Here again all of the dummies will be at their respective averages. Next in the same plane, I want to plot X using its marginal effects from Logit but similarly here, only one of the of the dummies will take the value of 1 (i.e. only Z) and rest will be at their respective averages (P, Q and S).

Can anybody please help me with the commands? I am using STATA 14.2.

Thank you very much.

How to apply the seasonal adjusted method as the Fred's?

$
0
0
Hi all, I want to apply the seasonal adjusted method on some time series from fred data. Is there any material about it?

I know there are some useful method as the link below.

http://www.abs.gov.au/websitedbs/d33...8!OpenDocument.

But how to apply the same method as that used by Fred? And how to realize it use stata?

Thanks.

Why my correlation is negative when the estimated coefficients are positive?

$
0
0
Dear Statalist Community

This should be my very last questions for statalist community. Thank you every experts who have helped me this far. I appreciate it a lot.

I am trying to explain the reason why the correlation between my dependent variable (government expenditure as a % of GDP) and independent variable (immigration) is negatively correlated, while the estimated coefficients are positive (in all cases when I include or exclude each control variables.)

1. I try to investigate by using
Code:
extremes  govex_gdp immi
and found no outliers. I wonder whether there are other ways in which I can find the reason for this?
2. I also experiment with another regression that use log on all of my variables. I would like to know whether I can interpret that in terms of one percentage change in standard deviation? eg. one standard deviation in independent variable contributes to ___% of one standard deviation increase increase in dependent variable.




Code:
. extremes  govex_gdp immi
+------------------------+
| obs: govex_~p immi |
|------------------------|
| 901. 10.20876 . |
| 586. 10.2687 . |
| 585. 10.3964 . |
| 902. 10.46668 . |
| 722. 10.53066 . |
+------------------------+

+-------------------------+
| 879. 27.4907 61872 |
| 871. 27.63227 32272 |
| 369. 27.68548 . |
| 182. 27.69099 28223 |
| 205. 27.93502 51800 |
+-------------------------+

regression without log

Code:
 xtreg  govex_gdp immi  depratio unem_perlab urbanpop_pertot pop femalepop_pertot i.year ,fe cluster (country)
Fixed-effects (within) regression Number of obs = 657
Group variable: country Number of groups = 33

R-sq: within = 0.2989 Obs per group: min = 2
between = 0.0395 avg = 19.9
overall = 0.0627 max = 29

F(32,32) = .
corr(u_i, Xb) = -0.7913 Prob > F = .

(Std. Err. adjusted for 33 clusters in country)
----------------------------------------------------------------------------------
| Robust
govex_gdp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
immi | 1.14e-06 5.01e-07 2.28 0.029 1.24e-07 2.16e-06
depratio | .0329021 .0603795 0.54 0.590 -.0900868 .1558911
unem_perlab | .1200443 .0409341 2.93 0.006 .0366643 .2034244
urbanpop_pertot | .2526613 .0645373 3.91 0.000 .1212032 .3841194
pop | 7.90e-08 1.57e-07 0.50 0.618 -2.40e-07 3.98e-07
femalepop_pertot | -.9128621 1.047256 -0.87 0.390 -3.046053 1.220329
|
year |
1982 | -.0275117 .1441005 -0.19 0.850 -.3210348 .2660114
1983 | .0287356 .3412937 0.08 0.933 -.666457 .7239282
1984 | -.672402 .4074508 -1.65 0.109 -1.502352 .1575481
1989 | -1.164444 .5968829 -1.95 0.060 -2.380255 .0513666
1990 | -.7825131 .6641094 -1.18 0.247 -2.13526 .5702335
1991 | -.3335672 .7901333 -0.42 0.676 -1.943016 1.275882
1992 | -.4937047 .800642 -0.62 0.542 -2.124559 1.13715
1993 | -.1212492 .7635012 -0.16 0.875 -1.67645 1.433952
1994 | -.8561286 .7242583 -1.18 0.246 -2.331394 .6191373
1995 | -.5426904 .8170002 -0.66 0.511 -2.206865 1.121485
1996 | -.8923355 .8015554 -1.11 0.274 -2.52505 .7403794
1997 | -1.156174 .8138863 -1.42 0.165 -2.814007 .5016577
1998 | -1.249869 .8070755 -1.55 0.131 -2.893828 .3940899
1999 | -1.177472 .8301466 -1.42 0.166 -2.868425 .5134814
2000 | -1.617467 .8595532 -1.88 0.069 -3.36832 .1333854
2001 | -1.411849 .8676217 -1.63 0.113 -3.179137 .3554382
2002 | -1.143768 .8905438 -1.28 0.208 -2.957747 .6702102
2003 | -.8068445 .9449567 -0.85 0.400 -2.731658 1.117969
2004 | -1.323295 .8930714 -1.48 0.148 -3.142422 .4958319
2005 | -1.32398 .9220267 -1.44 0.161 -3.202087 .5541268
2006 | -1.543219 .9286263 -1.66 0.106 -3.434768 .3483313
2007 | -1.860672 .9506458 -1.96 0.059 -3.797074 .0757304
2008 | -1.130692 .9602998 -1.18 0.248 -3.086759 .8253748
2009 | .1310738 .9863769 0.13 0.895 -1.87811 2.140258
2010 | -.3822114 .9845546 -0.39 0.700 -2.387684 1.623261
2011 | -1.07942 1.007688 -1.07 0.292 -3.132013 .9731725
2012 | -1.391096 1.023083 -1.36 0.183 -3.475048 .6928561
2013 | -1.530977 1.035502 -1.48 0.149 -3.640225 .5782712
|
_cons | 44.80689 54.43654 0.82 0.417 -66.0767 155.6905
-----------------+----------------------------------------------------------------
sigma_u | 4.7367037
sigma_e | 1.38224
rho | .92152662 (fraction of variance due to u_i)
----------------------------------------------------------------------------------

regression with log



Thank you
Plai

Interchanger Observations and Variable Name. Possible to Switch Observations to Varname?

$
0
0
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input str10 RegionName str16(B C) str17(D E F) str16(G H I J K L)
"City" "San Francisco" "Pittsburg" "Alameda" "San Francisco" "Fremont" "Hayward" "Antioch" "Fremont" "Hayward" "Union City" "Brentwood"
"State" "CA" "CA" "CA" "CA" "CA" "CA" "CA" "CA" "CA" "CA" "CA"
"CountyName" "San Francisco" "Contra Costa" "Alameda" "San Francisco" "Alameda" "Alameda" "Contra Costa" "Alameda" "Alameda" "Alameda" "Contra Costa"
"2010-01" "" "" "" "" "" "" "" "" "" "" ""
"2010-02" "" "" "" "" "" "" "" "" "" "" ""
"2010-03" "" "" "" "" "" "" "" "" "" "" ""
"2010-04" "" "" "" "" "" "" "" "" "" "" ""
"2010-05" "" "" "" "" "" "" "" "" "" "" ""
"2010-06" "" "" "" "" "" "" "" "" "" "" ""
"2010-07" "" "" "" "" "" "" "" "" "" "" ""
"2010-08" "" "" "" "" "" "" "" "" "" "" ""
"2010-09" "" "" "" "" "" "" "" "" "" "" ""
"2010-10" "" "" "" "" "" "" "" "" "" "" ""
"2010-11" "" "" "" "" "" "" "" "" "" "" ""
"2010-12" "" "" "" "" "" "" "" "" "" "" ""
"2011-01" "" "" "" "" "" "" "" "" "" "" ""
"2011-02" "" "" "" "" "" "" "" "" "" "" ""
"2011-03" "" "" "" "" "" "" "" "" "" "" ""
"2011-04" "" "" "" "" "" "" "" "" "" "" ""
"2011-05" "" "" "" "" "" "" "" "" "" "" ""
"2011-06" "" "" "" "" "" "" "" "" "" "" ""
"2011-07" "" "" "" "" "" "" "" "" "" "" ""
"2011-08" "" "" "" "" "" "" "" "" "" "" ""
"2011-09" "" "" "" "" "" "" "" "" "" "" ""
"2011-10" "" "" "" "" "" "" "" "" "" "" ""
"2011-11" "" "" "" "" "" "" "" "" "" "" ""
"2011-12" "" "" "" "" "" "" "" "" "" "" ""
"2012-01" "" "" "" "" "" "" "" "" "" "" ""
"2012-02" "" "" "" "" "" "" "" "" "" "" ""
"2012-03" "" "" "" "" "" "" "" "" "" "" ""
"2012-04" "" "" "" "" "" "" "" "" "" "" ""
"2012-05" "" "" "" "" "" "" "" "" "" "" ""
"2012-06" "" "" "" "" "" "" "" "" "" "" ""
"2012-07" "" "" "" "" "" "" "" "" "" "" ""
"2012-08" "" "" "" "" "" "" "" "" "" "" ""
"2012-09" "" "" "" "" "" "" "" "" "" "" ""
"2012-10" "" "" "" "" "" "" "" "" "" "" ""
"2012-11" "" "" "" "" "" "" "" "" "" "" ""
"2012-12" "" "" "" "" "" "" "" "" "" "" ""
"2013-01" "" "" "" "" "" "" "" "" "" "" ""
"2013-02" "" "" "" "" "" "" "" "" "" "" ""
"2013-03" "" "" "" "" "" "" "" "" "" "" ""
"2013-04" "" "" "" "" "" "" "" "" "" "" ""
"2013-05" "" "" "" "" "" "" "" "" "" "" ""
"2013-06" "" "" "" "" "" "" "" "" "" "" ""
"2013-07" "" "" "" "" "" "" "" "" "" "" ""
"2013-08" "" "" "" "" "371.6906292702" "" "" "" "" "" ""
"2013-09" "" "" "" "" "373.953695458593" "" "" "" "" "" ""
"2013-10" "" "" "386.804657179819" "730.366492146597" "378.995578016425" "" "" "" "" "" ""
"2013-11" "" "" "383.534074276216" "699.85" "378.872145332032" "" "" "386.597257209507" "263.189448441247" "310.735346358792" "189.298334174659"
"2013-12" "" "176.784523015344" "386.029411764706" "714.285714285714" "377.06228956229" "" "164.961496149615" "390.354454810399" "263.617196130736" "322.060353798127" "191.140278917145"
"2014-01" "" "171.554959785523" "397.631790670588" "707.674101782581" "372.614512238174" "" "155.732087227414" "391.236306729264" "271.340009537434" "331.618334892423" "190.831426392067"
"2014-02" "" "169.648365206663" "404.293533734589" "718.171296296296" "387.972356935015" "" "155.805806920079" "385.990338164251" "276.992936427851" "333.333333333333" "193.467336683417"
"2014-03" "" "174.539282250242" "378.936847466259" "729.115218115218" "387.859676783603" "" "160.48951048951" "385.759107397665" "268.853367277789" "338.898305084746" "194.083859850661"
"2014-04" "" "184.390547263682" "422.223914530671" "754.570333880679" "402.41935483871" "" "168.531468531469" "411.089513810986" "279.500880559636" "342.175170775171" "198.400210423242"
"2014-05" "" "189.420921997551" "413.393483709273" "801.0241404535479" "418.795180722892" "" "169.092772936955" "422.419179874241" "286.170212765957" "345.493827160494" "199.066689584049"
"2014-06" "" "197.202797202797" "404.24388600355" "783.871954619143" "428.703803839763" "" "167.806417674908" "416.411512553582" "288.288288288288" "348.37752668635" "200.389865374804"
"2014-07" "" "193.097781429745" "429.736486692324" "789.126853377265" "424.671385237614" "" "172.413793103448" "432.318145814913" "278.079303384603" "359.810658271937" "202.242227040808"
"2014-08" "" "196.365767878077" "408.176100628931" "843.253588516747" "422.958397534669" "" "166.945373467113" "435.344585145163" "282.347900599829" "365.378573479349" "197.359735973597"
"2014-09" "" "194.791252485089" "402.576489533011" "785.227867993714" "431.100033380242" "" "169.617863228926" "448.860497237569" "297.783933518006" "369.451697127937" "199.716048485037"
"2014-10" "" "192.81122150789" "402.220493313746" "854.80093676815" "435.940432962279" "" "168.970814132104" "445.790816326531" "295.880149812734" "364.927642322203" "203.959208158368"
"2014-11" "" "185.945273631841" "419.023821411134" "805.790960451977" "427.297008547009" "" "164.808531265148" "438.50138121547" "292.071846589863" "357.322176583025" "201.927489674162"
"2014-12" "" "186.656671664168" "406.577375810341" "837.8746594005451" "425.415663937602" "307.484915844771" "162.818327380908" "437.57292882147" "312.306709620084" "367.705662056305" "200.653158997376"
"2015-01" "" "193.535514764565" "423.558897243108" "776.595744680851" "431.912451690024" "309.980161190329" "172.79012345679" "442.225392296719" "298.181818181818" "368.889097486658" "201.346210125841"
"2015-02" "906.297513256819" "194.843827466534" "427.254171186289" "848.809888874687" "464.674789390549" "322.840847736794" "174.492385786802" "450.762829403606" "303.843807199512" "371.71506612996" "205.022060731897"
"2015-03" "959.023539668701" "194.843827466534" "446.208340503642" "863.321799307958" "484.76213592233" "331.269349845201" "178.965688712084" "458.894638598229" "313.401253918495" "372.843229763429" "212.486840718335"
"2015-04" "957.002457002457" "202.411714039621" "430.94944512947" "870.047164164811" "500" "343.381836945304" "175.636586806239" "476.472891445656" "323.897659227001" "382.424590332357" "206.877729257642"
"2015-05" "1016.94915254237" "203.729281767956" "462.365591397849" "856.470588235294" "503.46565847511" "339.7365532382" "180.684104627767" "490.181268882175" "325.885452509695" "385.740888534185" "213.810284898028"
"2015-06" "1017.998385795" "207.166388162177" "466.810333057227" "812.244897959184" "493.738334932121" "334.545454545455" "184.977081760334" "487.350104275287" "324.976787372331" "394.112005088999" "215.606788344541"
"2015-07" "1029.92311507937" "206.737400530504" "468.936384342391" "796.688660801564" "482.264218395367" "343.51106870229" "184.229918938836" "491.690382288352" "321.766848816029" "400.235849056604" "216.852207293666"
"2015-08" "1004.02252614642" "206.068329718004" "469.89247311828" "794.318181818182" "484.675577156744" "349.201596806387" "187.16577540107" "490.526315789474" "319.256756756757" "401.206636500754" "217.707736389685"
"2015-09" "998.688311688312" "205.273364485981" "470.028544243578" "828.8218267581479" "497.301587301587" "347.380410022779" "187.16577540107" "489.653943906717" "331.095725466586" "394.153791847953" "218.340611353712"
"2015-10" "1033.91254897005" "209.252286175363" "481.768087058274" "891.950565492655" "502.515371716042" "350.145350949868" "187.713310580205" "495.600991325898" "328.518744714836" "400" "217.468967777983"
"2015-11" "1031.58929976397" "209.425349087003" "480.540697105016" "915.857605177993" "508.861183386902" "359.078048780488" "186.519458332505" "492.700729927007" "329.153605015674" "405.130946018172" "220.487179487179"
"2015-12" "1061.87929717341" "208.180466038671" "472.706480304956" "915.857605177993" "509.668508287293" "362.662018746006" "184.234791500305" "496.614569536424" "322.041601323253" "405.873493975904" "220.522052205221"
"2016-01" "1046.69887278583" "211.231441165675" "472.706480304956" "915.857605177993" "486.551063066203" "369.061414989994" "185.542168674699" "487.630117163796" "319.444444444444" "403.097947214076" "214.993537268419"
"2016-02" "1061.87929717341" "221.609937758796" "472.706480304956" "934.511434511434" "495.763221153846" "373.788995112133" "188.118279569892" "509.425036390102" "329.275280898876" "411.37752703338" "223.720782791515"
"2016-03" "1080.2895495447" "222.42374278648" "490.171568627451" "939.985568693098" "507.894736842105" "386.42825607064" "193.342541436464" "530.503978779841" "343.234323432343" "414.746176720476" "222.417295424526"
"2016-04" "1034.90601193931" "224.032520325203" "486.425666516042" "960.802386875148" "513.265157919433" "386.189845474614" "193.342541436464" "535.140934519158" "342.372165112336" "422.261359633674" "224.692717996289"
"2016-05" "1048.75567269659" "222.589315525876" "486.140350877193" "942.349137931035" "521.048501417578" "385.507246376812" "196.477018964324" "537.5" "343.804233242266" "423.718220338983" "227.678571428571"
"2016-06" "1080.75040783034" "229.310344827586" "486.619997502653" "962.439732950726" "522.904871017814" "387.043189368771" "200.680272108844" "533.992861156913" "352.77945538662" "425.749545515057" "229.206963249516"
"2016-07" "1064.64123272746" "228.699551569507" "491.175072025957" "966.684578183772" "515.277108433735" "382.022471910112" "206.278095443593" "544.122448979592" "354.325913472183" "423.718220338983" "231.75355450237"
"2016-08" "1130.18867924528" "229.681978798587" "493.555568734356" "934.195064629847" "516.173434273916" "391.240310077519" "207.614523721709" "555.681653293468" "359.73597359736" "424.430641821946" "233.60462223467"
"2016-09" "1099.65237543453" "230.066445182724" "499.926470588235" "914.547304170905" "521.016920481897" "386.297376093294" "208.333333333333" "530.453257790368" "362.020275162925" "435.150310559006" "233.583076245042"
"2016-10" "1078.72823618471" "233.606557377049" "490.196078431373" "888.956494134319" "514.955141820725" "401.702370100273" "212.36689861533" "537.634408602151" "360.547645391153" "427.563942307692" "236.909202503888"
"2016-11" "1115.24163568773" "236.71160517187" "493.243853505217" "893.538675312645" "513.148343734998" "405.003470615456" "214.626865671642" "538.692026491687" "363.12984496124" "429.875608014297" "238.121296813863"
"2016-12" "1160.86235489221" "235.810810810811" "506.012065637066" "908.964237516869" "521.0173913043481" "409.429280397022" "211.86895810956" "554.112554112554" "363.12984496124" "427.062534038631" "237.137857589941"
"2017-01" "1151.05521198953" "233.59375" "526.77570549751" "910.521955260978" "520.5985014175779" "403.299398426654" "216.493594394031" "563.61316246742" "362.622036262204" "431.989366415596" "234.370855806788"
"2017-02" "1133.1775108949" "239.427860696517" "522.137486573577" "916.3720887416" "519.677002413869" "410.606200832948" "219.61252446184" "549.539170506912" "369.02530183727" "436.437902684685" "231.824610076971"
"2017-03" "1113.00688282611" "245.429977898332" "522.5840336134449" "984.001704692105" "536.950570117235" "393.143280266568" "227.272727272727" "551.283987915408" "372.334834834835" "435.391887349367" "234.220135628586"
"2017-04" "1116.95632218685" "248.607657881651" "549.215406562054" "1036.37413394919" "550.22392834293" "407.349665924276" "235.940660822657" "570.698466780239" "371.25340599455" "445.745271938207" "238.397965670693"
"2017-05" "1157.14285714286" "248.756218905473" "524.449911543565" "1034.48275862069" "555.1260977925469" "407.663316582915" "237.268396402263" "579.72027972028" "372.83017707821" "452.505966587112" "239.068549540235"
"2017-06" "1157.14285714286" "249.44099378882" "547.852495772991" "1011.24984979188" "555.1260977925469" "410.5743201256" "236.418918918919" "569.337216738352" "381.528776791873" "453.703703703704" "236.014917421417"
"2017-07" "1130.27862660216" "251.384888212653" "557.182705718271" "1014.6898146523" "556.082648113009" "386.735982750627" "236.742424242424" "591.232227488152" "390.004228281814" "465.502905266255" "237.187043493034"
"2017-08" "1092.71555538763" "251.831501831502" "549.903870498133" "1020.10644589001" "560.729716754681" "386.840202458424" "241.619585687382" "586.492890995261" "383.087765957447" "475.805041876571" "242.389515219842"
"2017-09" "1077.44107744108" "254.237288135593" "565.723270440252" "1000.9765625" "558.3850931677021" "391.509037503649" "241.619585687382" "593.791281373844" "382.671129846977" "476.417910447761" "249.508709245199"
"2017-10" "1139.59731543624" "261.343804537522" "571.739130434783" "1025.02662406816" "570.807453416149" "402.106821787414" "241.964827167981" "596.198156682028" "390.791428571429" "476.417910447761" "251.747387523745"
"2017-11" "1250.41868206168" "261.953204476094" "562.781456953642" "1050.8875739645" "578.918995130222" "398.204653622422" "238.095238095238" "629.62962962963" "404.368358913813" "482.955414012739" "252.96788842037"
"2017-12" "1233.18744339931" "265.432098765432" "565.595873163629" "1033.77425044092" "580.8080808080809" "391.791044776119" "250.446630888491" "614.285714285714" "405.672823218997" "489.038792922288" "251.817775792765"
"2018-01" "1231.63606010017" "265.939597315436" "567.6421412981" "1065.08875739645" "592.429123301946" "398.204653622422" "255.567928730512" "592.384519350812" "417.145137681292" "500.779626834864" "250.883179446006"
end



Here's the data that might help the explanation of the question. I'm looking to rename the variables B with San Francisco and C Pittsburgh - while keeping value label the same (zip code). Also of equal importance I'd need to have the City Name dropped as an observation. Or is there any way to run a time series but set TSSET to exclude observations (1/5) for instance? This way each additional column cell 1/5 that is string information regarding the City/Metropolitan within the column -- isn't instead interpreted as a (delta t) time series.

As it stands I have to drop all the observations that are words except for the single one I wan't to make the variable name.

PS: Is there a command for making the 1st observations of each column the varname directly? This workaround would at least be one solution.

Thanks for the time and any help.

random coefficient model

$
0
0
Hi statalists!
I have a question for the syntax for random coefficient model. The data is one year data.
I would like to see the returns to education by age using random coefficient model.

I have variables: ttlwages (total wages during last 30 days), edu (education level), age (age), age_squ (the square of age).

I have tried

code: mixed ttlwagesedu ||age: edu

But I could not get the result by age. How can I get the returns to education by age?
I would appreciate if you could any comments on this. Thank you in advance.

xtabond2 or xtivreg2

$
0
0
Hi guys,
i'm using STATA 13 to estimate my dyamic panel model. The aim of my thesis is to understand if globalization affects economic growth. I start from a Fixed effects model and I want to spve the endogeneity problem. Since i use a growth model, someone suggests me to use a dynamic one. I use a 5-years panel and the variables are the average over the 5 years. My dependent variable is the GDP growth rate and the regressors are different globalization indices that I used one by one, plus several macroeconomic variables used like controls, I show you an example with one of them. I add time dummies in order to take into account time effects (I add them one by one as suggested in this Forum).

GDPgrowth_5 lnFertility_5 newinvest newGen_exp newoglob are the endogenous variables
newlsc lnLife_5 are the predetermined variables

Code:
 xtabond2 GDPgrowth_5 l.GDPgrowth_5 newoglob iGDP newlsc lnLife_5 lnFertility_5 newinvest newGen_exp newInfl2 trade newdbagdp dem_5 y70 y75 y80 y85 y90 y95 y00 y05, gmm (GDPgrowth_5 lnFertility_5 newinvest newGen_exp  newoglob, lag (2 3) eq(diff)) gmm (newlsc lnLife_5, lag (1 2) eq(diff)) iv (newInfl2 dem_5 trade newdbagdp iGDP, eq(diff)) iv(y70 y75 
> y80 y85 y90 y95 y00 y05, eq(level)) twostep nolevel robust small ar(3)
Favoring space over speed. To switch, type or click on mata: mata set matafavor speed, perm.
Instruments for levels equations only ignored since noleveleq specified.
Warning: Two-step estimated covariance matrix of moments is singular.
  Using a generalized inverse to calculate optimal weighting matrix for two-step estimation.
  Difference-in-Sargan/Hansen statistics may be negative.

Dynamic panel-data estimation, two-step difference GMM
------------------------------------------------------------------------------
Group variable: id2                             Number of obs      =       224
Time variable : period                          Number of groups   =        69
Number of instruments = 56                      Obs per group: min =         0
F(20, 69)     =     18.47                                      avg =      3.25
Prob > F      =     0.000                                      max =         4
-------------------------------------------------------------------------------
              |              Corrected
  GDPgrowth_5 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
  GDPgrowth_5 |
          L1. |  -.0932418   .1432099    -0.65   0.517    -.3789377    .1924541
              |
     newoglob |   .2020836   .0897642     2.25   0.028     .0230089    .3811584
         iGDP |   -.104824   .0246037    -4.26   0.000    -.1539071   -.0557409
       newlsc |   .0821822   .0827541     0.99   0.324    -.0829077     .247272
     lnLife_5 |   .1667886   .0705606     2.36   0.021      .026024    .3075532
lnFertility_5 |   .0314123    .023665     1.33   0.189     -.015798    .0786226
    newinvest |   .2726478   .0819279     3.33   0.001     .1092061    .4360894
   newGen_exp |  -.0661485   .0816824    -0.81   0.421    -.2291005    .0968035
     newInfl2 |   .0081002   .0026686     3.04   0.003     .0027764     .013424
        trade |   .0010489    .000336     3.12   0.003     .0003785    .0017193
    newdbagdp |    .005614   .0203926     0.28   0.784    -.0350681     .046296
        dem_5 |  -.0376581   .0283473    -1.33   0.188    -.0942093    .0188931
          y70 |          0  (omitted)
          y75 |   .0095499   .0068016     1.40   0.165     -.004019    .0231188
          y80 |          0  (omitted)
          y85 |   .0015786   .0043232     0.37   0.716    -.0070458    .0102031
          y90 |    -.00236   .0079309    -0.30   0.767    -.0181817    .0134617
          y95 |   .0027976   .0132303     0.21   0.833    -.0235961    .0291912
          y00 |          0  (omitted)
          y05 |          0  (omitted)
-------------------------------------------------------------------------------
Instruments for first differences equation
  Standard
    D.(newInfl2 dem_5 trade newdbagdp iGDP)
  GMM-type (missing=0, separate instruments for each period unless collapsed)
    L(1/2).(newlsc lnLife_5)
    L(2/3).(GDPgrowth_5 lnFertility_5 newinvest newGen_exp newoglob)
------------------------------------------------------------------------------
Arellano-Bond test for AR(1) in first differences: z =  -2.08  Pr > z =  0.038
Arellano-Bond test for AR(2) in first differences: z =  -1.12  Pr > z =  0.264
Arellano-Bond test for AR(3) in first differences: z =  -0.09  Pr > z =  0.931
------------------------------------------------------------------------------
Sargan test of overid. restrictions: chi2(36)   =  78.74  Prob > chi2 =  0.000
  (Not robust, but not weakened by many instruments.)
Hansen test of overid. restrictions: chi2(36)   =  43.12  Prob > chi2 =  0.193
  (Robust, but weakened by many instruments.)

Difference-in-Hansen tests of exogeneity of instrument subsets:
  gmm(GDPgrowth_5 lnFertility_5 newinvest newGen_exp newoglob, eq(diff) lag(2 3))
    Hansen test excluding group:     chi2(1)    =   4.41  Prob > chi2 =  0.036
    Difference (null H = exogenous): chi2(35)   =  38.71  Prob > chi2 =  0.306
  gmm(newlsc lnLife_5, eq(diff) lag(1 2))
    Hansen test excluding group:     chi2(20)   =  26.00  Prob > chi2 =  0.166
    Difference (null H = exogenous): chi2(16)   =  17.12  Prob > chi2 =  0.378
  iv(newInfl2 dem_5 trade newdbagdp iGDP, eq(diff))
    Hansen test excluding group:     chi2(31)   =  35.96  Prob > chi2 =  0.247
    Difference (null H = exogenous): chi2(5)    =   7.16  Prob > chi2 =  0.209
I have the following questions:

1 - I tried to avoid the proliferation of instruments using only two lags but I obtain a warning and I don't know if it is related to this problem.
2 - I tried to change globalization indices but the GDP lagged is never significant. This may suggest that a static model using instrumental variables like xtivreg2 (but in this case I have to fins instruments) may better fit to my data to solve the endogeneity problem? Or alternatively, it might make sense to run an AB model without the dependent lagged variable to make it a static model?

I would appreciate some feedbacks (also to my AB model, I'm not 100% sure I've used the AB options well)
Thank you!

Queries on non-stationarity in an unbalanced panel dataset

$
0
0
Dear All,
I have a few queries with regard to my dataset which is unbalanced and contains data for T=54 years andN=41 countries.
My Pooled OLS and FE regressions are:

reg ln(suicide) l.WBrelativegdp l.WBrelativegdp2 year wbgdp wbunemployment hexp divorce alc, cluster(countrynum)

xtreg ln(suicide) l.WBrelativegdp l.WBrelativegdp2 year wbgdp wbunemployment hexp divorce alc, cluster(countrynum) fe

I have undertaken a fisher unit root test for panel data and have found that all variables are non stationary.

My questions are as follows:
  1. What will the effect be of non-stationary variables included? Will my coefficients be biased or is it that I am simply worried about spurious relationships?
  2. Is T=54 too small for me to worry about non-stationarity/ Has my ADF falsely found non-stationarity as a result of this small T? The reason I worry about this is because looking at the panel graphs for my main variables [ln(suicide) and l.RelativeGDP], most panels look stationary. Are my results driven by certain countries? Should I believe my ADF results?
  1. However, when I take the first differences of these variables I do agree that they become more stationary so perhaps taking the first differences is the solution to this issue?
  1. Can Fixed effects overcome the issue of non-stationarity? If so, how?

Thank you for your guidance,

Query Stata from another process

$
0
0
Is it possible to query stata from another process, preferably over a well known protocol (http, odbc, etc.); that is, pretty much using stata as a database and query it remotely.

stsplit in Mata

$
0
0
Is there a Mata version of Stata's commands -stsplit- and -stjoin-?
I need to split survival data within Mata.


repeated time values within panel

$
0
0
Hi,

I'm trying to regress with time fixed effects, so I first used the command "xtset statename year" but it went red saying, "repeated time values within panel". I have no idea how to fix this. I tried using the command duplicates which showed that there are a lot of duplicates, but I don't know how to fix this without removing any of the observations.

duplicates report statename year

Duplicates in terms of statename year

--------------------------------------
copies | observations surplus
----------+---------------------------
1 | 75 0
2 | 118 59
3 | 81 54
4 | 136 102
5 | 135 108
6 | 72 60
7 | 154 132
8 | 152 133
9 | 135 120
10 | 220 198
11 | 176 160
12 | 204 187
13 | 247 228
14 | 336 312
15 | 240 224
16 | 256 240
17 | 221 208
18 | 216 204
19 | 323 306
20 | 300 285
21 | 357 340
22 | 154 147
23 | 253 242
24 | 264 253
25 | 225 216
26 | 286 275
27 | 135 130
28 | 140 135
29 | 290 280
30 | 300 290
31 | 372 360
32 | 192 186
33 | 297 288
34 | 272 264
35 | 140 136
36 | 144 140
37 | 222 216
38 | 228 222
39 | 195 190
40 | 400 390
41 | 369 360
42 | 252 246
43 | 172 168
44 | 264 258
45 | 225 220
46 | 46 45
47 | 141 138
48 | 144 141
49 | 147 144
50 | 250 245
51 | 153 150
52 | 104 102
53 | 212 208
54 | 162 159
55 | 165 162
56 | 112 110
57 | 114 112
58 | 232 228
59 | 177 174
60 | 120 118
61 | 427 420
62 | 186 183
63 | 63 62
65 | 65 64
66 | 198 195
67 | 134 132
68 | 136 134
69 | 138 136
70 | 70 69
71 | 142 140
73 | 219 216
74 | 148 146
75 | 150 148
76 | 76 75
77 | 77 76
78 | 234 231
81 | 162 160
82 | 328 324
83 | 166 164
85 | 85 84
93 | 186 184
96 | 96 95
97 | 97 96
99 | 99 98
100 | 200 198
103 | 103 102
104 | 208 206
105 | 105 104
108 | 108 107
111 | 111 110
119 | 119 118
121 | 121 120
128 | 128 127
--------------------------------------

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double statename float year
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1968
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1970
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1972
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1974
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
101 1976
end
label values statename statename_label
label def statename_label 101 "Connecticut", modify

invalid 'replace'

$
0
0
So I am almost finished with my research between Premiership Parties and Governing Parties without Premiership, and at my final command I get an error message called "invalid 'replace' "

use MPDataset_MPDS2017b_stata14, clear
gen ptype = 0
replace ptype = 0 if party == 11320 | party == 11420 ///
| party == 11620 | party == 11810 | party == 13320 | party == 13410 ///
| party == 13420 | party == 13620 | party == 14320 | party == 14620 ///
| party == 14810 | party == 21320 | party == 21322 | party == 21421 ///
| party == 21422 | party == 21423 | party == 21425 | party == 21426 ///
| party == 21521 | party == 22320 | party == 22521 | party == 22522 ///
| party == 22722 | party == 23420 | party == 23520 | party == 33210 ///
| party == 33610 | party == 34020 | party == 34212 | party == 34313 ///
| party == 34511 | party == 35311 | party == 35313 | party == 35520 ///
| party == 41320 | party == 41521 | party == 42320 | party == 42520 ///
| party == 51320 | party == 51620 | party == 53520 | party == 53620 ///
replace ptype = 1 if party == 11110 | party == 11520 ///
| party == 13001 | party == 13230 | party == 14110 | party == 14222 ///
| party == 14223 | party == 14520 | party == 14820 | party == 14901 ///
| party == 21111 | party == 21112 | party == 21321 | party == 21522 ///
| party == 21913 | party == 21916 | party == 22330 | party == 22526 ///
| party == 22528 | party == 23113 | party == 23320 | party == 34213 ///
| party == 34710 | party == 34730 | party == 41111 | party == 41112 ///
| party == 41113 | party == 41420 | party == 42420 | party == 42710 ///
| party == 51420 | party == 51421 | party == 53110 | party == 53320 ///
label variable ptype "party type"
label define ptype 0 "Premiership Parties" 1 "Governing Non-Premiership Parties"
label values ptype ptype

here, the "replace" is 'invalid'.

However, the following command I did earlier works without any problems:

keep if date > 194000
twoway (scatter niche57 herfinN if party == 11320 | party == 11420 ///
| party == 11620 | party == 11810 | party == 13320 | party == 13410 ///
| party == 13420 | party == 13620 | party == 14320 | party == 14620 ///
| party == 14810 | party == 21320 | party == 21322 | party == 21421 ///
| party == 21422 | party == 21423 | party == 21425 | party == 21426 ///
| party == 21521 | party == 22320 | party == 22521 | party == 22522 ///
| party == 22722 | party == 23420 | party == 23520 | party == 33210 ///
| party == 33610 | party == 34020 | party == 34212 | party == 34313 ///
| party == 34511 | party == 35311 | party == 35313 | party == 35520 ///
| party == 41320 | party == 41521 | party == 42320 | party == 42520 ///
| party == 51320 | party == 51620 | party == 53520 | party == 53620, ///
msymbol(circle)) ///
(scatter niche57 herfinN if party == 11110 | party == 11520 | ///
party == 13001 | party == 13230 | party == 14110 | party == 14222 ///
| party == 14223 | party == 14520 | party == 14820 | party == 14901 ///
| party == 21111 | party == 21112 | party == 21321 | party == 21522 ///
| party == 21913 | party == 21916 | party == 22330 | party == 22526 ///
| party == 22528 | party == 23113 | party == 23320 | party == 34213 ///
| party == 34710 | party == 34730 | party == 41111 | party == 41112 ///
| party == 41113 | party == 41420 | party == 42420 | party == 42710 ///
| party == 51420 | party == 51421 | party == 53110 | party == 53320, ///
msymbol(X)), ///
title("Nicheness/Concentration") ///
subtitle("Premiership Parties vs Governing Non-Premiership Parties") ///
legend(label(1 "PP") label(2 "GNPP"))

r(2000) error in Newey-West

$
0
0
Dear all,

I have monthly data on stock market and when I tried to use Newey-West standard errors to deal with heteroskedasticity and autocorrelation, Stata says that there is no observation. Below is my -dataex- :
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int date float(csad r_mt abs_r_mt)
15341         .          .         .
15372  10.40015 -21.771555 21.771555
15400 3.6831214  1.3696393 1.3696393
15431   5.40642   6.454342  6.454342
15461  4.572629 -1.0483736 1.0483736
15492  3.924419 -12.194602 12.194602
15522 4.0851216  15.245831 15.245831
15553  4.421038   3.213805  3.213805
15584  1.545293  -.3501535  .3501535
15614 2.0632555 -4.6421685 4.6421685
15645  3.666877  -14.84067  14.84067
15675 4.5075574 -4.4080067 4.4080067
15706 1.8428906 -2.1559913 2.1559913
15737   2.49485  11.278244 11.278244
15765 2.1604996 -1.2514616 1.2514616
15796 4.3232718  -1.257523  1.257523
15826 10.606026   3.962764  3.962764
15857  5.112213   6.413789  6.413789
15887  4.484928  -4.856054  4.856054
15918  6.263611   6.968433  6.968433
15949 2.9614744   -.802722   .802722
15979  3.076989  -.8465761  .8465761
16010 10.489506   19.19976  19.19976
16040 3.4005265 -1.0016072 1.0016072
16071  8.629517  -.3082933  .3082933
16102  4.420031   7.663479  7.663479
16131   7.91593  1.8529012 1.8529012
16162  4.938119     1.0648    1.0648
16192   4.95072 -14.607905 14.607905
16223 3.8892744  3.9174936 3.9174936
16253  5.702363  -5.584903  5.584903
16284  7.320863  -5.576176  5.576176
16315  6.825109 -10.216467 10.216467
16345  3.911943  10.581155 10.581155
16376  8.563342  -8.825836  8.825836
16406 4.0248747    7.06366   7.06366
16437  6.767444  -8.656428  8.656428
16468  9.667854   5.605936  5.605936
16496 4.4664264   9.692858  9.692858
16527 12.659364   2.459548  2.459548
16557   11.2451   -4.35966   4.35966
16588  7.937766  -11.16009  11.16009
16618  5.769467  -4.593168  4.593168
16649  8.396846   2.259447  2.259447
16680  9.871736  2.2887776 2.2887776
16710  6.986581  -.5051034  .5051034
16741  7.922635 -16.813925 16.813925
16771  3.609957   2.732373  2.732373
16802  5.349097   .7332054  .7332054
16833  7.527323   23.25859  23.25859
16861  6.718209  3.0368414 3.0368414
16892  7.630779    4.88974   4.88974
16922 10.340603   5.886937  5.886937
16953  9.688768   8.262988  8.262988
16983  5.447178 -2.6733925 2.6733925
17014  6.039441  -5.767948  5.767948
17045  5.145508  2.8006885 2.8006885
17075   14.2246  10.567738 10.567738
17106  9.340332   5.390509  5.390509
17136  8.937711  10.640285 10.640285
17167  12.09225  13.240386 13.240386
17198  13.75918  4.6114182 4.6114182
17226  7.096007   7.630084  7.630084
17257  7.987866   7.694463  7.694463
17287 11.686085  16.659527 16.659527
17318 10.900064   4.312224  4.312224
17348  17.43714  2.0001624 2.0001624
17379  7.945005  13.660383 13.660383
17410  8.063833 -1.5955248 1.5955248
17440  5.245726  3.9520586 3.9520586
17471  8.522331   .4120224  .4120224
17501  5.714562  -10.72098  10.72098
17532   5.00455   .7190944  .7190944
17563  7.142439  -10.26564  10.26564
17592  6.609317 -1.1376902 1.1376902
17623   11.2239  -16.59991  16.59991
17653  8.833878   6.459142  6.459142
17684  6.001316  -4.918726  4.918726
17714  8.055031 -15.197256 15.197256
17745  8.108354  -2.220311  2.220311
17776  8.099585 -18.786123 18.786123
17806  10.02093  -19.74054  19.74054
17837  13.65648  -32.34998  32.34998
17867  8.914493   14.30076  14.30076
17898   6.74604   4.287829  4.287829
17929  5.719338   4.822899  4.822899
17957  6.543387   6.488205  6.488205
17988  5.720366  15.008144 15.008144
18018  6.967344    3.38667   3.38667
18049  7.954954   19.29539  19.29539
18079  6.887875  12.942645 12.942645
18110  6.234223  10.758305 10.758305
18141  5.344579  -17.07722  17.07722
18171 4.5722775   6.080737  6.080737
18202  5.578828   8.842843  8.842843
18232  9.408226   12.99844  12.99844
18263 4.6079955  .06648097 .06648097
18294  5.668927   -7.62164   7.62164
18322  3.139144   4.595733  4.595733
18353 4.2208114   4.677813  4.677813
end
format %tm date
Here are the problematic results:
Code:
. tsset date, monthly
        time variable:  date, 3238m6 to 3512m5, but with gaps
                delta:  1 month

. newey csad c.abs_r_mt##c.abs_r_mt, lag(1) force
no observations
r(2000);

.
Why is there 'no observations'? Below is my 'normal' regression.
Code:
.  reg csad c.abs_r_mt##c.abs_r_mt

      Source |       SS           df       MS      Number of obs   =       108
-------------+----------------------------------   F(2, 105)       =      6.12
       Model |  93.9271731         2  46.9635866   Prob > F        =    0.0031
    Residual |   805.43128       105  7.67077409   R-squared       =    0.1044
-------------+----------------------------------   Adj R-squared   =    0.0874
       Total |  899.358453       107  8.40521918   Root MSE        =    2.7696

------------------------------------------------------------------------------
        csad |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    abs_r_mt |    .043472   .1171705     0.37   0.711    -.1888554    .2757994
             |
  c.abs_r_mt#|
  c.abs_r_mt |   .0046852   .0049204     0.95   0.343    -.0050709    .0144414
             |
       _cons |   6.077043   .5529866    10.99   0.000     4.980573    7.173513
------------------------------------------------------------------------------

Persistent Multicollinearity Issue

$
0
0
I am working on a multivariate regression model that examines the relationship between an index of state consolidation as the dependent variable and a number of predictor variables. I have conducted some basic tests of the predictor variables and transformed them, etc.
However, the correlation matrix and other tests seem to show multicollinearity between some of the predictors. Theoretically, I do not see how they are related to each other. Accordingly, I tried to center and standardize the predictors. I used the commands beta and another called stdbeta. I also created some modified predictors the old-fashioned way subtracting from the mean and dividing by the standard deviation. The stdbeta command did not work and the multicollinearity persisted using the modified predictors.
I am at an impasse and work greatly appreciate some insight into this.
I have attached the do file.
Thank you,
J. David Granger
Array

Heckman selection model with Panel data

$
0
0
I am trying to perform the Heckman selection model on a Panel dataset, using fixed effects.

When using cross-sectional data, the problem is standardly implemented by the two-step routine of the command
Code:
heckman
I have been looking into past threads on Statalist (as well as on the related literature), but unfortunately I have not been able to find an exhaustive practical explanation for the code to be used.

To relate to past threads, the most useful comments about the literature seem to choose the estimator proposed in Wooldridge (1995), while some useful comments about the practical implementation can be found at the following links:

1)
HTML Code:
https://www.stata.com/statalist/archive/2008-02/msg01054.html
2)
HTML Code:
https://www.stata.com/statalist/archive/2003-08/msg00365.html
3)
HTML Code:
https://www.statalist.org/forums/forum/general-stata-discussion/general/1341593-applying-wooldridge-1995-estimator

Could you please provide a practical example to deal with this problem?
Any piece of advice on more advanced techniques than the one in Wooldridge (1995) would be appreciated.

Thanks in advance for the help.



Wooldridge, Jeffrey M. "Selection corrections for panel data models under conditional mean independence assumptions." Journal of econometrics 68.1 (1995): 115-132.

Questions on r(198)

$
0
0
Dear all,

I am trying to use the Newey-West Standard Errors to carry out my regression, however, the following popped up:

Code:
. newey  csad c.abs_r_mt##c.abs_r_mt, lag(1)
date is regularly spaced, but does not have intervals of 1
r(198);
Below is my -dataex-:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int date float(csad r_mt year abs_r_mt)
15347         .          . 2002          .
15354  4.150988  -8.779794 2002   8.779794
15361   8.47286 -11.722405 2002  11.722405
15368  2.371604   .7411363 2002   .7411363
15375  4.922579  12.524622 2002  12.524622
15382  1.898078 -.10467237 2002  .10467237
15389         0          0 2002          0
15396  1.229306  1.9515274 2002  1.9515274
15403  2.176993 -.24670455 2002  .24670455
15410  5.491458  11.407248 2002  11.407248
15417  3.275471 -2.9843094 2002  2.9843094
15424  2.618778   2.722045 2002   2.722045
15431  3.072469  -3.339813 2002   3.339813
15438    2.6599  1.5941483 2002  1.5941483
15445    2.7624   .7426223 2002   .7426223
15452  2.954676 -1.6689825 2002  1.6689825
15459  3.800143   2.567357 2002   2.567357
15466 1.5627458   .2256331 2002   .2256331
15473 2.2163022 -2.0939267 2002  2.0939267
15480 2.4541366  -4.799683 2002   4.799683
15487 3.1900074   1.408269 2002   1.408269
15494 3.8380544  -4.929328 2002   4.929328
15501 2.5736775  2.7708454 2002  2.7708454
15508 1.8126394  -1.549638 2002   1.549638
15515  4.617593   14.62258 2002   14.62258
15522 3.7301376 -2.0095348 2002  2.0095348
15529 2.0474093  1.3527323 2002  1.3527323
15536 2.1388013  -2.633168 2002   2.633168
15543 1.6265107  -.1318021 2002   .1318021
15550  1.585621 -1.1615623 2002  1.1615623
15557 2.0878482  -.6251392 2002   .6251392
15564 2.0168262  -1.122699 2002   1.122699
15571 1.4484754   .5845769 2002   .5845769
15578 1.7805477  1.5606302 2002  1.5606302
15585  1.525958  .02931488 2002  .02931488
15592 2.3180652  -2.799415 2002   2.799415
15599 1.6707025 -1.6376716 2002  1.6376716
15606 2.5378354 .026403705 2002 .026403705
15613 1.6017348 -1.8123453 2002  1.8123453
15620         0          0 2002          0
15627 2.2233071  -3.020985 2002   3.020985
15634  2.758704  -.4821299 2002   .4821299
15641 2.2093017 -1.8539804 2002  1.8539804
15648 2.1681485  2.1972647 2002  2.1972647
15655 1.6749827  -2.788559 2002   2.788559
15662  3.588643  -4.780155 2002   4.780155
15669  3.346243  -4.567672 2002   4.567672
15676 1.8651558  .03562433 2002  .03562433
15683 2.2610478   .4898008 2002   .4898008
15690 1.6952885  1.0478189 2002  1.0478189
15697  1.901793  1.8837024 2002  1.8837024
15704  3.395599  -4.671672 2002   4.671672
15711  2.772347 -1.2277025 2003  1.2277025
15718 2.1912358   3.483433 2003   3.483433
15725  3.687262   5.716919 2003   5.716919
15732 2.4519944   .3525168 2003   .3525168
15739  .9451538  .14199395 2003  .14199395
15746 1.2781053  -.9503823 2003   .9503823
15753 1.6940317   1.431836 2003   1.431836
15760 2.2230365 -1.1358991 2003  1.1358991
15767 1.9164674  2.3592293 2003  2.3592293
15774 2.4346666  -3.939136 2003   3.939136
15781 2.6690204  .04388403 2003  .04388403
15788  1.442735 .012047686 2003 .012047686
15795 1.8391362   1.584176 2003   1.584176
15802 2.3038082  -.3085499 2003   .3085499
15809  4.650578    4.98953 2003    4.98953
15816  2.918732  -1.697974 2003   1.697974
15823 4.6705866   -2.76868 2003    2.76868
15830  3.494127 -1.6048017 2003  1.6048017
15837  2.977946 -.01338571 2003  .01338571
15844 3.3964925   2.671273 2003   2.671273
15851  3.643645    1.46425 2003    1.46425
15858  4.041341   1.270017 2003   1.270017
15865  2.878992  -4.592948 2003   4.592948
15872 2.8937554  1.9754747 2003  1.9754747
15879 1.9556812 -3.3694615 2003  3.3694615
15886 3.5537255 -2.2777672 2003  2.2777672
15893  2.549982   .6448685 2003   .6448685
15900 2.0797458   1.192847 2003   1.192847
15907  3.549946 -2.6754115 2003  2.6754115
15914 2.1864173 -1.5634494 2003  1.5634494
15921 1.9790592   2.047979 2003   2.047979
15928  1.656871  -.9543859 2003   .9543859
15935  1.760976 -1.5156193 2003  1.5156193
15942  2.576479  -1.520167 2003   1.520167
15949 2.3478339  1.9608448 2003  1.9608448
15956 2.1813831  -1.797851 2003   1.797851
15963 2.5223765  -2.324635 2003   2.324635
15970 2.0894804 -.58425045 2003  .58425045
15977 2.3127463  -2.599389 2003   2.599389
15984  .8075221   .8873354 2003   .8873354
15991  1.284165    2.47579 2003    2.47579
15998 1.6533177   -3.03647 2003    3.03647
16005  3.750155  -.2284442 2003   .2284442
16012  4.875941 -1.5789025 2003  1.5789025
16019  4.833535  -2.918827 2003   2.918827
16026 2.1364899  -.8974869 2003   .8974869
16033 3.2972984     4.7895 2003     4.7895
16040  2.786816   1.797363 2003   1.797363
end
format %td date
I then tried to do it with other lags specification, unfortunately, the same problem persists:
Code:
. newey  csad c.abs_r_mt##c.abs_r_mt, lag(2)
date is regularly spaced, but does not have intervals of 1
r(198);

.
I have tried searching the error phrases both on Google and Statalist, I have come across NOTHING at all, does it mean that my case is extremely rare? Most importantly, what actually went wrong?

Sum across many columns or many rows?

$
0
0
Dear Statalisters,

I have a dataset with variables var_1:var_200 as well as a variable id that takes values 1:200 as well, so that the total dataset has 200 rows and 201 columns including the "id" variable.

Now I would like to sum first across all rows, and secondly across all but the first column (I could drop the first if necessary). How can I do that?

I've tried summing across the columns with "egen example = rowtotal()", but would need to type each of the 200 variables there? Or can I at least tell Stata more succintly to sum all of var_1 through var_200?

Thank you so much and best regards,
PM

Mac version: -graph export- vs -graph save-, and inclusion of periods in file names

$
0
0
This is a follow-up to my earlier question about the behaviour of graph export in the Mac version of Stata.

In an assignment for my intro biostats class, students are expected to export some graphs to png files. I was expecting them to use graph export, like this:

Code:
graph export "$myfolder/Figures/A.Birthday_Problem.png", as(png) replace
But some of them are using graph save instead, like this:

Code:
graph save Graph "$myfolder/Figures/A.Birthday_Problem.png", replace
As noted in the previous thread, I use the Windows version of Stata, but many of my students use the Mac version. In a meeting with one of the Mac users today, I observed that when we used graph export with a file name that included two periods (A.Birthday_Problem.png), Stata treated everything after the first period as a file extension, and execution stopped. When I became aware of that, I advised Mac users to change the first period in the file name to an underscore (A_Birthday_Problem.png), and that seemed to fix things. I concluded that the Mac OS does not allow periods in file names apart from the final period before a file extension.

But then today, with graph save (and the same file name), everything was fine. So now I suspect some inconsistency between graph export and graph save.

Can any Mac users duplicate what I have described? Here's a silly little example you can try.

Code:
clear *
sysuse auto
histogram rep78, discrete
graph export "auto.rep78.v1.png", replace as(png)
graph save Graph "auto.rep78.v2.png", replace

erase "auto.rep78.v1.png"
erase "auto.rep78.v2.png"
Thanks,
Bruce

expanding x-axis variable labels for dotplots

$
0
0
Hi All,
I have created a dot graph but I want to improve the appearance of the variable labels o n the x-axis. Any help will be most appreciated! Below is the code that I used and the table I created

Code:
graph dot imp_np310_pop cata_tot_10_pop, over(year_main, label(labsize(vsmall))) ylabel(0.00(.1).4) legend(rows(2))
Array

Graphical representation of sub-groups in panel data

$
0
0
Hi everyone,

I have panel of Chinese provinces over time. I am using the xtline command in Stata for my panel data to construct graphical representations of my data. My time identifier is Year and the ID variable is Province. Province has 31 cases, representing 31 provinces in China. Year has 14 time points, covering the timeframe 2004 to 2014.
My DV is pollution, an average measure of multiple variables.

I have grouped the 31 provinces within five geographical regions. This variable is called Regions. I would like to plot a single graph plotting variation in pollution for the five regions over time - in that one graph contains the five regions' variation in pollution over time. Is that possible?
I can create one single graph containing all provinces by using:
xtline pollution, overlay t(Year) i(Province) legend(off)

However I have not found a way to get the region-level plots together one one graph.
I have tried creating a new variable but i am not sure that this is the right way:
egen regions2 = group(regions)
sum regions2, meanonly


Would someone be as kind as to advice me whether this is the right way to go? If so, what command should I use?
Thanks!
Viewing all 73258 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>