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

Combine 3 IRT TCC graphs in one

$
0
0
Dear Stata group: Thank you very much for your help. I have a database with panel data of three years (2004, 2010 and 2016) and I have the irtgraph tcc for each year. I ask you for help in order to make a graph that merges the 2004, 2010 and 2016 irtgraph in one, for make visible the invariance measurement of the test, so any advice will be appreciated.

Regards
Norberto

Hausman test in nested models (Cox proportional hazards model)

$
0
0
Hello

I am comparing the results I got from two separate Cox proportional hazard models. I run two models, one for men and one for women separately to see the effect of age on men and women's entry into remarriage. The effect of age for men (HR=0.95, p<0.05) and women (HR=89, p<0.01) is significant. However, since I want to compare the degree of effect in these models, I have been advised to use a nested model and apply the Huasman test. I am completely new to this and would like someone to confirm the steps and commands used in stata:

1. Run the Cox model all observations for men and women combined (Model M1).
2. Run M1 with an added dummy variable for gender (Model M2)
3. Run model M2 such that the gender variable is made to interact with the age variable (Model M3)
4. Run a chi2 test for models M2 and M3 (df=1).

After that, I was told to use the Hausman test... my question is: How do I run the chi2 tests and what do I do with the Hausman test?

Sorting stock returns data on financial characteristics and calculating mean portfolio returns

$
0
0
Dear all,

The code below provides a Brazilian dataset where ticker is a stock, month is a date variable, monthly_returns is just the return, tercileBEME gives the book equity tercile group the stock belongs to in December t-1, and medianME gives the top 50%/low 50% group a stock belongs to June of year t. Finally, panel is the period between july t and june t+1 I need to calculate mean returns of different equally weighted portfolios sorted by the medianME at June year t and by tercileBEME December year t-1.

I would appreciate help in devising a code to calculate returns from July t to June t+1 of portfolios sorted by medianME in year t and then by tercileBEME of year t-1 (6 portfolios in total lowME/lowBE, low ME/mediumBE, lowME/highBE etc). Note that stocks that do not have BEME and ME data for perfect pairs dec t-1 and jun t do not enter portfolio returns calculations.

Many thanks in advance,

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str13 ticker float(month monthly_return tercileBEME medianME mon year panel)
"ABEV3"       419     -.05048478 2 . 12 1994  1
"ABEV3"       425      .06796126 . 1  6 1995  1
"ABEV3"       426      .04684225 . .  7 1995  2
"ABEV3"       427      .08232353 . .  8 1995  2
"ABEV3"       428    -.018263174 . .  9 1995  2
"ABEV3"       429      .03947375 . . 10 1995  2
"ABEV3"       430      .06756764 . . 11 1995  2
"ABEV3"       431      .03797462 2 . 12 1995  2
"ABEV3"       432      .14634141 . .  1 1996  2
"ABEV3"       433       .1792664 . .  2 1996  2
"ABEV3"       434     .020408137 . .  3 1996  2
"ABEV3"       435     .030808264 . .  4 1996  2
"ABEV3"       436      .15728164 . .  5 1996  2
"ABEV3"       437      .05042009 . 1  6 1996  2
"ABEV3"       438    -.015872946 . .  7 1996  3
"ABEV3"       439     .032257993 . .  8 1996  3
"ABEV3"       440    -.005258164 . .  9 1996  3
"ABEV3"       441     .004746753 . . 10 1996  3
"ABEV3"       442     -.03904742 . . 11 1996  3
"ABEV3"       443    -.032258037 3 . 12 1996  3
"ABEV3"       444      .08196729 . .  1 1997  3
"ABEV3"       445      .10757568 . .  2 1997  3
"ABEV3"       446    -.032036934 . .  3 1997  3
"ABEV3"       447              0 . .  4 1997  3
"ABEV3"       448      .04832214 . .  5 1997  3
"ABEV3"       449       .0675326 . 2  6 1997  3
"ABEV3"       450              0 . .  7 1997  4
"ABEV3"       451     -.05000007 . .  8 1997  4
"ABEV3"       452      .08517013 . .  9 1997  4
"ABEV3"       453     -.08168316 . . 10 1997  4
"ABEV3"       454    -.007194242 . . 11 1997  4
"ABEV3"       455     .007246374 2 . 12 1997  4
"ABEV3"       456      .05714296 . .  1 1998  4
"ABEV3"       457     .027026895 . .  2 1998  4
"ABEV3"       458      .04849282 . .  3 1998  4
"ABEV3"       459     -.13749643 . .  4 1998  4
"ABEV3"       460    -.069444455 . .  5 1998  4
"ABEV3"       461    -.030156095 . 2  6 1998  4
"ABEV3"       462      .04687508 . .  7 1998  5
"ABEV3"       463     -.17786516 . .  8 1998  5
"ABEV3"       464     -.14814818 . .  9 1998  5
"ABEV3"       465      .02272725 . . 10 1998  5
"ABEV3"       466       .1555555 . . 11 1998  5
"ABEV3"       467    -.009345905 2 . 12 1998  5
"ABEV3"       468       .1719255 . .  1 1999  5
"ABEV3"       469              0 . .  2 1999  5
"ABEV3"       470      .04999996 . .  3 1999  5
"ABEV3"       471     -.02243585 . .  4 1999  5
"ABEV3"       472      .06249993 . .  5 1999  5
"ABEV3"       473      .08859468 . 2  6 1999  5
"ABEV3"       474    -.032416835 . .  7 1999  6
"ABEV3"       475    -.017632298 . .  8 1999  6
"ABEV3"       476      .05882352 . .  9 1999  6
"ABEV3"       477        .063291 . . 10 1999  6
"ABEV3"       478     .035714347 . . 11 1999  6
"ABEV3"       479     -.03977276 3 . 12 1999  6
"ABEV3"       480     .035294063 . .  1 2000  6
"ABEV3"       481  .000024931056 . .  2 2000  6
"ABEV3"       482      .10121945 . .  3 2000  6
"ABEV3"       483      .04395594 . .  4 2000  6
"ABEV3"       484 -.000031703352 . .  5 2000  6
"ABEV3"       485      .26576084 . 2  6 2000  6
"ABEV3"       486      .18644065 . .  7 2000  7
"ABEV3"       487     .035714425 . .  8 2000  7
"ABEV3"       488      .07699279 . .  9 2000  7
"ABEV3"       489       .2179488 . . 10 2000  7
"ABEV3"       490     .001286974 . . 11 2000  7
"ABEV3"       491      .20546217 2 . 12 2000  7
"ABEV3"       492      .10638294 . .  1 2001  7
"ABEV3"       493     -.09259267 . .  2 2001  7
"ABEV3"       494    -.019941157 . .  3 2001  7
"ABEV3"       495        .050505 . .  4 2001  7
"ABEV3"       496              0 . .  5 2001  7
"ABEV3"       497              0 . 2  6 2001  7
"ABEV3"       498      -.0841122 . .  7 2001  8
"ABEV3"       499     -.05183346 . .  8 2001  8
"ABEV3"       500       -.205298 . .  9 2001  8
"ABEV3"       501        .083361 . . 10 2001  8
"ABEV3"       502              0 . . 11 2001  8
"ABEV3"       503      .07000004 3 . 12 2001  8
"ABEV3"       504     -.05882357 . .  1 2002  8
"ABEV3"       505      .03797463 . .  2 2002  8
"ABEV3"       506     -.02439026 . .  3 2002  8
"ABEV3"       507      .04081634 . .  4 2002  8
"ABEV3"       508     -.03117504 . .  5 2002  8
"ABEV3"       509      -.0806846 . 2  6 2002  8
"ABEV3"       510    -.005263211 . .  7 2002  9
"ABEV3"       511     .026315724 . .  8 2002  9
"ABEV3"       512      -.0278481 . .  9 2002  9
"ABEV3"       513      .19820216 . . 10 2002  9
"ABEV3"       514      .02659573 . . 11 2002  9
"ABEV3"       515     .006315801 2 . 12 2002  9
"ABEV3"       516     -.04470214 . .  1 2003  9
"ABEV3"       517     -.01928338 . .  2 2003  9
"ABEV3"       518      .10955382 . .  3 2003  9
"ABEV3"       519      .03061222 . .  4 2003  9
"ABEV3"       520  -.00001909353 . .  5 2003  9
"ABEV3"       521     -.05660372 . 2  6 2003  9
"ABEV3"       522    -.009900942 . .  7 2003 10
"ABEV3"       523      .13131316 . .  8 2003 10
"ABEV3"       524     .025624033 . .  9 2003 10
"ABEV3"       525     -.08617926 . . 10 2003 10
"ABEV3"       526       .0947369 . . 11 2003 10
"ABEV3"       527      .01599999 2 . 12 2003 10
"ABEV3"       528     .006201565 . .  1 2004 10
"ABEV3"       529      .13029832 . .  2 2004 10
"ABEV3"       530      .12826017 . .  3 2004 10
"ABEV3"       531       .0842105 . .  4 2004 10
"ABEV3"       532        .105314 . .  5 2004 10
"ABEV3"       533      .06100789 . 2  6 2004 10
"ABEV3"       534    -.033613414 . .  7 2004 11
"ABEV3"       535     .035652224 . .  8 2004 11
"ABEV3"       536      .03019577 . .  9 2004 11
"ABEV3"       537      .13636367 . . 10 2004 11
"ABEV3"       538    -.020287365 . . 11 2004 11
"ABEV3"       539     .024719125 2 . 12 2004 11
"ABEV3"       540       -.074518 . .  1 2005 11
"ABEV3"       541     .005300009 . .  2 2005 11
"ABEV3"       542     -.19540992 . .  3 2005 11
"ABEV3"       543      -.3289474 . .  4 2005 11
"ABEV3"       544     .009390827 . .  5 2005 11
"ABEV3"       545      .07717992 . 2  6 2005 11
"ABEV3"       546    -.032573253 . .  7 2005 12
"ABEV3"       547     .016767437 . .  8 2005 12
"ABEV3"       548      .09459514 . .  9 2005 12
"ABEV3"       549     -.07299267 . . 10 2005 12
"ABEV3"       550      .13960552 . . 11 2005 12
"ABEV3"       551    -.014546095 2 . 12 2005 12
"ABEV3"       552      .02866669 . .  1 2006 12
"ABEV3"       553     .012987047 . .  2 2006 12
"ABEV3"       554      .05902565 . .  3 2006 12
"ABEV3"       555      .02994017 . .  4 2006 12
"ABEV3"       556     -.02557876 . .  5 2006 12
"ABEV3"       557     -.05714281 . 2  6 2006 12
"ABEV3"       558    -.067153886 . .  7 2006 13
"ABEV3"       559      .08336007 . .  8 2006 13
"ABEV3"       560      .02036437 . .  9 2006 13
"ABEV3"       561     -.03753409 . . 10 2006 13
"ABEV3"       562      .05412103 . . 11 2006 13
"ABEV3"       563      .05666773 1 . 12 2006 13
"ABEV3"       564       .0311845 . .  1 2007 13
"ABEV3"       565     .003091111 . .  2 2007 13
"ABEV3"       566      .08166002 . .  3 2007 13
"ABEV3"       567      .09294822 . .  4 2007 13
"ABEV3"       568      .09242856 . .  5 2007 13
"ABEV3"       569      .02168979 . 2  6 2007 13
"ABEV3"       570    -.029411715 . .  7 2007 14
"ABEV3"       571     .031290084 . .  8 2007 14
"ABEV3"       572    -.023954956 . .  9 2007 14
"ABEV3"       573      .04029304 . . 10 2007 14
"ABEV3"       574     -.09180169 . . 11 2007 14
"ABEV3"       575      -.0494596 2 . 12 2007 14
"ABEV3"       576     -.06504065 . .  1 2008 14
"ABEV3"       577      .07112975 . .  2 2008 14
"ABEV3"       578      -.1039231 . .  3 2008 14
"ABEV3"       579     -.05516217 . .  4 2008 14
"ABEV3"       580     -.07982453 . .  5 2008 14
"ABEV3"       581    -.064077705 . 2  6 2008 14
"ABEV3"       582     -.09141614 . .  7 2008 15
"ABEV3"       583        .066796 . .  8 2008 15
"ABEV3"       584      .06101732 . .  9 2008 15
"ABEV3"       585     -.12208796 . . 10 2008 15
"ABEV3"       586       .0220254 . . 11 2008 15
"ABEV3"       587      .08705121 3 . 12 2008 15
"ABEV3"       588     -.09129315 . .  1 2009 15
"ABEV3"       589      .06021206 . .  2 2009 15
"ABEV3"       590       .2130719 . .  3 2009 15
"ABEV3"       591      .06249667 . .  4 2009 15
"ABEV3"       592     .065129556 . .  5 2009 15
"ABEV3"       593     -.04136873 . 2  6 2009 15
"ABEV3"       594       .0341525 . .  7 2009 16
"ABEV3"       595      .09836365 . .  8 2009 16
"ABEV3"       596      .06924691 . .  9 2009 16
"ABEV3"       597     .034961835 . . 10 2009 16
"ABEV3"       598      .06312265 . . 11 2009 16
"ABEV3"       599      .03887866 3 . 12 2009 16
"ABEV3"       600     -.01960788 . .  1 2010 16
"ABEV3"       601    -.015643595 . .  2 2010 16
"ABEV3"       602     -.07559396 . .  3 2010 16
"ABEV3"       603     .064236104 . .  4 2010 16
"ABEV3"       604     .008144515 . .  5 2010 16
"ABEV3"       605      .05050501 . 1  6 2010 16
"ABEV3"       606      .06165856 . .  7 2010 17
"ABEV3"       607     .017300209 . .  8 2010 17
"ABEV3"       608      .04797475 . .  9 2010 17
"ABEV3"       609     .073500015 . . 10 2010 17
"ABEV3"       610     .006473773 . . 11 2010 17
"ABEV3"       611       .0959596 3 . 12 2010 17
"ABEV3"       612     -.12712643 . .  1 2011 17
"ABEV3"       613    -.006631313 . .  2 2011 17
"ABEV3"       614     .032098003 . .  3 2011 17
"ABEV3"       615      .05450002 . .  4 2011 17
"ABEV3"       616     -.03902783 . .  5 2011 17
"ABEV3"       617      .06567536 . 2  6 2011 17
"ABEV3"       618      -.1067442 . .  7 2011 18
"ABEV3"       619      .20370375 . .  8 2011 18
"ABEV3"       620    .0078896005 . .  9 2011 18
"ABEV3"       621      .03136814 . . 10 2011 18
"ABEV3"       622      .05509465 . . 11 2011 18
"ABEV3"       623      .08873388 2 . 12 2011 18
"ABEV3"       624     -.04411765 . .  1 2012 18
"ABEV3"       625      .10284629 . .  2 2012 18
"ABEV3"       626      .09895296 . .  3 2012 18
"ABEV3"       627       .0498035 . .  4 2012 18
"ABEV3"       628     -.06147851 . .  5 2012 18
"ABEV3"       629      .06320825 . 2  6 2012 18
"ABEV3"       630       .0421394 . .  7 2012 19
"ABEV3"       631    -.007934029 . .  8 2012 19
"ABEV3"       632     .009579075 . .  9 2012 19
"ABEV3"       633      .05222623 . . 10 2012 19
"ABEV3"       634      .12625025 . . 11 2012 19
"ABEV3"       635      .06652226 3 . 12 2012 19
"ABEV3"       636     .071275614 . .  1 2013 19
"ABEV3"       637    -.017776279 . .  2 2013 19
"ABEV3"       638     -.05508571 . .  3 2013 19
"ABEV3"       639    -.010284308 . .  4 2013 19
"ABEV3"       640      .02613807 . .  5 2013 19
"ABEV3"       641     .029932624 . 2  6 2013 19
"ABEV3"       642      .03890302 . .  7 2013 20
"ABEV3"       643     -.04800914 . .  8 2013 20
"ABEV3"       644     .021994183 . .  9 2013 20
"ABEV3"       645     -.02191751 . . 10 2013 20
"ABEV3"       646      .04028437 . . 11 2013 20
"ABEV3"       647     -.01085099 2 . 12 2013 20
"ABEV3"       648     -.06092814 . .  1 2014 20
"ABEV3"       649      .08903228 . .  2 2014 20
"ABEV3"       650     .008928599 . .  3 2014 20
"ABEV3"       651     -.03947701 . .  4 2014 20
"ABEV3"       652    -.009369127 . .  5 2014 20
"ABEV3"       653    -.033128828 . 2  6 2014 20
"ABEV3"       654      -.0128624 . .  7 2014 21
"ABEV3"       655      .04086848 . .  8 2014 21
"ABEV3"       656     .005012559 . .  9 2014 21
"ABEV3"       657      .06627122 . . 10 2014 21
"ABEV3"       658      .04012344 . . 11 2014 21
"ABEV3"       659     .021236693 3 . 12 2014 21
"ABEV3"       660      .10762728 . .  1 2015 21
"ABEV3"       661       .0546291 . .  2 2015 21
"ABEV3"       662     .020464687 . .  3 2015 21
"ABEV3"       663    .0031779434 . .  4 2015 21
"ABEV3"       664     -.04909568 . .  5 2015 21
"ABEV3"       665     .036353737 . 2  6 2015 21
"ABEV3"       666     .018848184 . .  7 2015 22
"ABEV3"       667    -.022529496 . .  8 2015 22
"ABEV3"       668      .04594824 . .  9 2015 22
"ABEV3"       669    -.030964464 . . 10 2015 22
"ABEV3"       670     -.04897961 . . 11 2015 22
"ABEV3"       671     -.03897497 1 . 12 2015 22
"ABEV3"       672       .0842533 . .  1 2016 22
"ABEV3"       673     -.04130435 . .  2 2016 22
"ABEV3"       674      .03123282 . .  3 2016 22
"ABEV3"       675      .02810177 . .  4 2016 22
"ABEV3"       676      -.0205024 . .  5 2016 22
"ABEV3"       677    -.014994826 . 2  6 2016 22
"ABEV3"       678    -.015253428 . .  7 2016 23
"ABEV3"       679      .01000005 . .  8 2016 23
"ABEV3"       680     .007625822 . .  9 2016 23
"ABEV3"       681     -.04658228 . . 10 2016 23
"ABEV3"       682    -.064375296 . . 11 2016 23
"ABEV3"       683    -.000371504 2 . 12 2016 23
"ABEV3"       684      .05884226 . .  1 2017 23
"ABEV3"       685     .030023113 . .  2 2017 23
"ABEV3"       686     .018425457 . .  3 2017 23
"ABEV3"       687       .0144444 . .  4 2017 23
"ABEV3"       688     .007539123 . .  5 2017 23
"ABEV3"       689   -.0042029056 . 2  6 2017 23
"ABRE11SEDU3" 419              0 . . 12 1994  1
"ABRE11SEDU3" 425              0 . .  6 1995  1
"ABRE11SEDU3" 426              0 . .  7 1995  2
"ABRE11SEDU3" 427              0 . .  8 1995  2
"ABRE11SEDU3" 428              0 . .  9 1995  2
"ABRE11SEDU3" 429              0 . . 10 1995  2
"ABRE11SEDU3" 430              0 . . 11 1995  2
"ABRE11SEDU3" 431              0 . . 12 1995  2
"ABRE11SEDU3" 432              0 . .  1 1996  2
"ABRE11SEDU3" 433              0 . .  2 1996  2
"ABRE11SEDU3" 434              0 . .  3 1996  2
"ABRE11SEDU3" 435              0 . .  4 1996  2
"ABRE11SEDU3" 436              0 . .  5 1996  2
"ABRE11SEDU3" 437              0 . .  6 1996  2
"ABRE11SEDU3" 438              0 . .  7 1996  3
"ABRE11SEDU3" 439              0 . .  8 1996  3
"ABRE11SEDU3" 440              0 . .  9 1996  3
"ABRE11SEDU3" 441              0 . . 10 1996  3
"ABRE11SEDU3" 442              0 . . 11 1996  3
"ABRE11SEDU3" 443              0 . . 12 1996  3
"ABRE11SEDU3" 444              0 . .  1 1997  3
"ABRE11SEDU3" 445              0 . .  2 1997  3
"ABRE11SEDU3" 446              0 . .  3 1997  3
"ABRE11SEDU3" 447              0 . .  4 1997  3
"ABRE11SEDU3" 448              0 . .  5 1997  3
"ABRE11SEDU3" 449              0 . .  6 1997  3
"ABRE11SEDU3" 450              0 . .  7 1997  4
"ABRE11SEDU3" 451              0 . .  8 1997  4
"ABRE11SEDU3" 452              0 . .  9 1997  4
"ABRE11SEDU3" 453              0 . . 10 1997  4
"ABRE11SEDU3" 454              0 . . 11 1997  4
"ABRE11SEDU3" 455              0 . . 12 1997  4
"ABRE11SEDU3" 456              0 . .  1 1998  4
"ABRE11SEDU3" 457              0 . .  2 1998  4
"ABRE11SEDU3" 458              0 . .  3 1998  4
"ABRE11SEDU3" 459              0 . .  4 1998  4
"ABRE11SEDU3" 460              0 . .  5 1998  4
"ABRE11SEDU3" 461              0 . .  6 1998  4
"ABRE11SEDU3" 462              0 . .  7 1998  5
"ABRE11SEDU3" 463              0 . .  8 1998  5
"ABRE11SEDU3" 464              0 . .  9 1998  5
"ABRE11SEDU3" 465              0 . . 10 1998  5
"ABRE11SEDU3" 466              0 . . 11 1998  5
"ABRE11SEDU3" 467              0 . . 12 1998  5
"ABRE11SEDU3" 468              0 . .  1 1999  5
"ABRE11SEDU3" 469              0 . .  2 1999  5
"ABRE11SEDU3" 470              0 . .  3 1999  5
"ABRE11SEDU3" 471              0 . .  4 1999  5
"ABRE11SEDU3" 472              0 . .  5 1999  5
"ABRE11SEDU3" 473              0 . .  6 1999  5
"ABRE11SEDU3" 474              0 . .  7 1999  6
"ABRE11SEDU3" 475              0 . .  8 1999  6
"ABRE11SEDU3" 476              0 . .  9 1999  6
"ABRE11SEDU3" 477              0 . . 10 1999  6
"ABRE11SEDU3" 478              0 . . 11 1999  6
"ABRE11SEDU3" 479              0 . . 12 1999  6
"ABRE11SEDU3" 480              0 . .  1 2000  6
"ABRE11SEDU3" 481              0 . .  2 2000  6
"ABRE11SEDU3" 482              0 . .  3 2000  6
"ABRE11SEDU3" 483              0 . .  4 2000  6
"ABRE11SEDU3" 484              0 . .  5 2000  6
"ABRE11SEDU3" 485              0 . .  6 2000  6
"ABRE11SEDU3" 486              0 . .  7 2000  7
"ABRE11SEDU3" 487              0 . .  8 2000  7
"ABRE11SEDU3" 488              0 . .  9 2000  7
"ABRE11SEDU3" 489              0 . . 10 2000  7
"ABRE11SEDU3" 490              0 . . 11 2000  7
"ABRE11SEDU3" 491              0 . . 12 2000  7
"ABRE11SEDU3" 492              0 . .  1 2001  7
"ABRE11SEDU3" 493              0 . .  2 2001  7
"ABRE11SEDU3" 494              0 . .  3 2001  7
"ABRE11SEDU3" 495              0 . .  4 2001  7
"ABRE11SEDU3" 496              0 . .  5 2001  7
"ABRE11SEDU3" 497              0 . .  6 2001  7
"ABRE11SEDU3" 498              0 . .  7 2001  8
"ABRE11SEDU3" 499              0 . .  8 2001  8
"ABRE11SEDU3" 500              0 . .  9 2001  8
"ABRE11SEDU3" 501              0 . . 10 2001  8
"ABRE11SEDU3" 502              0 . . 11 2001  8
"ABRE11SEDU3" 503              0 . . 12 2001  8
"ABRE11SEDU3" 504              0 . .  1 2002  8
"ABRE11SEDU3" 505              0 . .  2 2002  8
"ABRE11SEDU3" 506              0 . .  3 2002  8
"ABRE11SEDU3" 507              0 . .  4 2002  8
"ABRE11SEDU3" 508              0 . .  5 2002  8
"ABRE11SEDU3" 509              0 . .  6 2002  8
"ABRE11SEDU3" 510              0 . .  7 2002  9
"ABRE11SEDU3" 511              0 . .  8 2002  9
"ABRE11SEDU3" 512              0 . .  9 2002  9
"ABRE11SEDU3" 513              0 . . 10 2002  9
"ABRE11SEDU3" 514              0 . . 11 2002  9
"ABRE11SEDU3" 515              0 . . 12 2002  9
"ABRE11SEDU3" 516              0 . .  1 2003  9
"ABRE11SEDU3" 517              0 . .  2 2003  9
"ABRE11SEDU3" 518              0 . .  3 2003  9
"ABRE11SEDU3" 519              0 . .  4 2003  9
"ABRE11SEDU3" 520              0 . .  5 2003  9
"ABRE11SEDU3" 521              0 . .  6 2003  9
"ABRE11SEDU3" 522              0 . .  7 2003 10
"ABRE11SEDU3" 523              0 . .  8 2003 10
"ABRE11SEDU3" 524              0 . .  9 2003 10
"ABRE11SEDU3" 525              0 . . 10 2003 10
"ABRE11SEDU3" 526              0 . . 11 2003 10
"ABRE11SEDU3" 527              0 . . 12 2003 10
"ABRE11SEDU3" 528              0 . .  1 2004 10
"ABRE11SEDU3" 529              0 . .  2 2004 10
"ABRE11SEDU3" 530              0 . .  3 2004 10
"ABRE11SEDU3" 531              0 . .  4 2004 10
"ABRE11SEDU3" 532              0 . .  5 2004 10
"ABRE11SEDU3" 533              0 . .  6 2004 10
"ABRE11SEDU3" 534              0 . .  7 2004 11
"ABRE11SEDU3" 535              0 . .  8 2004 11
"ABRE11SEDU3" 536              0 . .  9 2004 11
"ABRE11SEDU3" 537              0 . . 10 2004 11
"ABRE11SEDU3" 538              0 . . 11 2004 11
"ABRE11SEDU3" 539              0 . . 12 2004 11
"ABRE11SEDU3" 540              0 . .  1 2005 11
"ABRE11SEDU3" 541              0 . .  2 2005 11
"ABRE11SEDU3" 542              0 . .  3 2005 11
"ABRE11SEDU3" 543              0 . .  4 2005 11
"ABRE11SEDU3" 544              0 . .  5 2005 11
"ABRE11SEDU3" 545              0 . .  6 2005 11
"ABRE11SEDU3" 546              0 . .  7 2005 12
"ABRE11SEDU3" 547              0 . .  8 2005 12
"ABRE11SEDU3" 548              0 . .  9 2005 12
"ABRE11SEDU3" 549              0 . . 10 2005 12
"ABRE11SEDU3" 550              0 . . 11 2005 12
"ABRE11SEDU3" 551              0 . . 12 2005 12
"ABRE11SEDU3" 552              0 . .  1 2006 12
"ABRE11SEDU3" 553              0 . .  2 2006 12
"ABRE11SEDU3" 554              0 . .  3 2006 12
"ABRE11SEDU3" 555              0 . .  4 2006 12
"ABRE11SEDU3" 556              0 . .  5 2006 12
"ABRE11SEDU3" 557              0 . .  6 2006 12
"ABRE11SEDU3" 558              0 . .  7 2006 13
"ABRE11SEDU3" 559              0 . .  8 2006 13
"ABRE11SEDU3" 560              0 . .  9 2006 13
"ABRE11SEDU3" 561              0 . . 10 2006 13
"ABRE11SEDU3" 562              0 . . 11 2006 13
"ABRE11SEDU3" 563              0 . . 12 2006 13
"ABRE11SEDU3" 564              0 . .  1 2007 13
"ABRE11SEDU3" 565              0 . .  2 2007 13
"ABRE11SEDU3" 566              0 . .  3 2007 13
"ABRE11SEDU3" 567              0 . .  4 2007 13
"ABRE11SEDU3" 568              0 . .  5 2007 13
"ABRE11SEDU3" 569              0 . .  6 2007 13
"ABRE11SEDU3" 570              0 . .  7 2007 14
"ABRE11SEDU3" 571              0 . .  8 2007 14
"ABRE11SEDU3" 572              0 . .  9 2007 14
"ABRE11SEDU3" 573              0 . . 10 2007 14
"ABRE11SEDU3" 574              0 . . 11 2007 14
"ABRE11SEDU3" 575              0 . . 12 2007 14
"ABRE11SEDU3" 576              0 . .  1 2008 14
"ABRE11SEDU3" 577              0 . .  2 2008 14
"ABRE11SEDU3" 578              0 . .  3 2008 14
"ABRE11SEDU3" 579              0 . .  4 2008 14
"ABRE11SEDU3" 580              0 . .  5 2008 14
"ABRE11SEDU3" 581              0 . .  6 2008 14
"ABRE11SEDU3" 582              0 . .  7 2008 15
"ABRE11SEDU3" 583              0 . .  8 2008 15
"ABRE11SEDU3" 584              0 . .  9 2008 15
"ABRE11SEDU3" 585              0 . . 10 2008 15
"ABRE11SEDU3" 586              0 . . 11 2008 15
"ABRE11SEDU3" 587              0 . . 12 2008 15
"ABRE11SEDU3" 588              0 . .  1 2009 15
"ABRE11SEDU3" 589              0 . .  2 2009 15
"ABRE11SEDU3" 590              0 . .  3 2009 15
"ABRE11SEDU3" 591              0 . .  4 2009 15
"ABRE11SEDU3" 592              0 . .  5 2009 15
"ABRE11SEDU3" 593              0 . .  6 2009 15
"ABRE11SEDU3" 594              0 . .  7 2009 16
"ABRE11SEDU3" 595              0 . .  8 2009 16
"ABRE11SEDU3" 596              0 . .  9 2009 16
"ABRE11SEDU3" 597              0 . . 10 2009 16
"ABRE11SEDU3" 598              0 . . 11 2009 16
"ABRE11SEDU3" 599              0 . . 12 2009 16
"ABRE11SEDU3" 600              0 . .  1 2010 16
"ABRE11SEDU3" 601              0 . .  2 2010 16
"ABRE11SEDU3" 602              0 . .  3 2010 16
"ABRE11SEDU3" 603              0 . .  4 2010 16
"ABRE11SEDU3" 604              0 . .  5 2010 16
"ABRE11SEDU3" 605              0 . .  6 2010 16
"ABRE11SEDU3" 606              0 . .  7 2010 17
"ABRE11SEDU3" 607              0 . .  8 2010 17
"ABRE11SEDU3" 608              0 . .  9 2010 17
"ABRE11SEDU3" 609              0 . . 10 2010 17
"ABRE11SEDU3" 610              0 . . 11 2010 17
"ABRE11SEDU3" 611              0 . . 12 2010 17
"ABRE11SEDU3" 612              0 . .  1 2011 17
"ABRE11SEDU3" 613              0 . .  2 2011 17
"ABRE11SEDU3" 614              0 . .  3 2011 17
"ABRE11SEDU3" 615              0 . .  4 2011 17
"ABRE11SEDU3" 616              0 . .  5 2011 17
"ABRE11SEDU3" 617              0 . .  6 2011 17
"ABRE11SEDU3" 618     -.06500004 . .  7 2011 18
"ABRE11SEDU3" 619     -.22110286 . .  8 2011 18
"ABRE11SEDU3" 620       .2158536 . .  9 2011 18
"ABRE11SEDU3" 621      .00959596 . . 10 2011 18
"ABRE11SEDU3" 622   .00050048507 . . 11 2011 18
"ABRE11SEDU3" 623     .022388024 1 . 12 2011 18
"ABRE11SEDU3" 624      .13189448 . .  1 2012 18
"ABRE11SEDU3" 625      .07731088 . .  2 2012 18
"ABRE11SEDU3" 626      .06707311 . .  3 2012 18
"ABRE11SEDU3" 627     .016071456 . .  4 2012 18
"ABRE11SEDU3" 628     .022963744 . .  5 2012 18
"ABRE11SEDU3" 629     -.01095405 . 2  6 2012 18
"ABRE11SEDU3" 630      .14391136 . .  7 2012 19
"ABRE11SEDU3" 631      .05249436 . .  8 2012 19
"ABRE11SEDU3" 632      .05572756 . .  9 2012 19
"ABRE11SEDU3" 633      .05916311 . . 10 2012 19
"ABRE11SEDU3" 634     .001335092 . . 11 2012 19
"ABRE11SEDU3" 635      .06466208 2 . 12 2012 19
"ABRE11SEDU3" 636      .06931906 . .  1 2013 19
"ABRE11SEDU3" 637       .1011236 . .  2 2013 19
"ABRE11SEDU3" 638    -.024079626 . .  3 2013 19
"ABRE11SEDU3" 639     -.10397997 . .  4 2013 19
"ABRE11SEDU3" 640     -.04041542 . .  5 2013 19
"ABRE11SEDU3" 641     -.10241657 . 1  6 2013 19
"ABRE11SEDU3" 642     -.09768637 . .  7 2013 20
"ABRE11SEDU3" 643     -.06779661 . .  8 2013 20
"ABRE11SEDU3" 644   -.0003014249 . .  9 2013 20
"ABRE11SEDU3" 645     -.02446483 . . 10 2013 20
"ABRE11SEDU3" 646      .05969689 . . 11 2013 20
"ABRE11SEDU3" 647     -.01764706 2 . 12 2013 20
"ABRE11SEDU3" 648      -.1152782 . .  1 2014 20
"ABRE11SEDU3" 649      .05551495 . .  2 2014 20
"ABRE11SEDU3" 650      -.0479452 . .  3 2014 20
"ABRE11SEDU3" 651     .031499296 . .  4 2014 20
"ABRE11SEDU3" 652      .08578178 . .  5 2014 20
"ABRE11SEDU3" 653      .11281563 . 1  6 2014 20
"ABRE11SEDU3" 654      .08664567 . .  7 2014 21
"ABRE11SEDU3" 655     .013712853 . .  8 2014 21
"ABRE11SEDU3" 656  -.00051451084 . .  9 2014 21
"ABRE11SEDU3" 657     -.09842524 . . 10 2014 21
end
format %tm month

How to create a variable whose values are a variable name

$
0
0
Hi, hopefully I didn't mess up the terminology.
Basically what I'm trying to do is create variables, in a loop, whose values will be the varname of a range of variables.

So for example, if I have variables whose names are John Charles Nancy, I want to create a variable (e.g., Johnname) where all the values are "John", and a variable (e.g., Charlesname) where all the values are "Charles", etc.

I hope that makes sense. Thanks for your help.

How the graph the (parallel) trend in difference-in-differences

$
0
0
Dear all,

I am currently working on a DiD comparing Dutch firms to firms in a group of ontrol countries. The objective is to find out whether a law change in NL in 2008 has an effect ('year' runs from 2005 -2012).

I ran several xtreg regressions. An example would be:

Code:
xtreg ROAni TA N_empl i.year i.POST##i.NL, robust cluster(sector) fe i(ID_BvD)


For this purpose, I would like to graph the (parallel) time trend. Other discussions on this forum indicate I should use:

graph twoway connect

but I am struggling with the code.


Could anyone provide me with a suggestion?


Thank you for your help!



Below a snapshot of my dataset.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long ID_BvD str89 company_name int year double(RDexp ROAni Turnover N_empl TA) long(country sector) float(POST NL survivor)
1440 "CCR LOGISTICS SYSTEMS AG"                           2005          0   5.27            32931    49            15959 2 15 0 0 1
2093 "GASCOGNE"                                           2005          0 -5.312           605450  2760           494247 3 19 0 0 1
 639 "COMPUGROUP MEDICAL AG"                              2005          0 10.934           119731   786           140774 2 15 0 0 1
1926 "LISI"                                               2005      10100  5.144           622630  5863           691484 3 10 0 0 1
1678 "EUROPACORP S.A."                                    2005          0  2.494           148079    63           230972 3 11 0 0 1
 567 "E.ON SE"                                            2005      24000  5.852         53390000 79947        126562000 2  6 0 0 1
2269 "KARDAN N.V."                                        2005          0  2.975 463449.184728858  6120 1499164.65273744 4 11 0 1 1
1666 "SEQUANA"                                            2005      17000  6.957          4092000 14305          5002000 3 19 0 0 1
 445 "HYRICAN INFORMATIONSSYSTEME AG"                     2005          0  6.689            63459    76            30736 2 18 0 0 1
 487 "CLAAS KGAA MBH"                                     2005      71526  3.355          2193738  8134          1611703 2  9 0 0 1
 335 "TUI AG"                                             2005          0  2.979         18514700 62947         15328400 2 11 0 0 1
2232 "EUROPEAN ASSETS TRUST NV"                           2005          0 27.156              158     .           206295 4  1 0 1 0
1356 "EVI AUDIO GMBH"                                     2005 3080.26226      0      74073.43437   477      33062.35534 2  9 0 0 0
 568 "TIPTEL AG"                                          2005          0 -2.944            31733   257            17223 2  9 0 0 0
2046 "UNIBAIL-RODAMCO"                                    2005       1300 15.965           515700   953          8677200 3 11 0 0 1
1516 "SPIR COMMUNICATION SA"                              2005          0 11.778           568714  4100           420200 3 15 0 0 1
1541 "VISIODENT SA"                                       2005          0  7.282             9169    70             5122 3 11 0 0 1
1795 "THEOLIA S.A."                                       2005          0   .074            14245    55            75924 3  6 0 0 1
1833 "SAM"                                                2005          0  3.693            33080   223            33878 3 10 0 0 1
1620 "EUROGERM S.A."                                      2005          0 14.233            35599   134            20481 3  5 0 0 1
  76 "REALCO"                                             2005          0  9.644             5333    31             3007 1 11 0 0 0
1459 "EINHELL GERMANY AG"                                 2005          0  5.626           392473   926           207397 2  9 0 0 1
 773 "FRAPORT AG"                                         2005          0  4.079          2108800 25781          3951600 2 17 0 0 1
1952 "VM MATERIAUX SA"                                    2005          0  6.068           459464  2000           243974 3  2 0 0 1
 934 "SOLAR-FABRIK AG"                                    2005          0   .776            51311   165            43833 2  9 0 0 1
  36 "PICANOL NV"                                         2005          0 -1.656           398384  2331           284706 1  9 0 0 1
2102 "SABETON SA"                                         2005          0  -3.15            20070   178            85535 3  5 0 0 1
 156 "PROGEO HOLDING AG"                                  2005          0   .457             1689    17             6130 2  9 0 0 1
2204 "EXACT HOLDING NV"                                   2005          0 11.601           224528  2698           276123 4 15 0 1 1
2171 "HYDRATEC INDUSTRIES N.V."                           2005          0  9.886            32979   287            18390 4  2 0 1 1
 210 "DEINBOCK IMMOBILIEN-VERMOGENSVERWALTUNG AG"         2005          0      0             2110     .            22099 2 11 0 0 0
1507 "SOCIETE INTERNATIONALE DE PLANTATIONS D' HEVEAS SA" 2005          0 14.441            95497  5506           108903 3 13 0 0 1
 943 "HEIDELBERGCEMENT AG"                                2005      43000  3.473          7958646 41260         11934651 2  2 0 0 1
1884 "GROUPE VIAL"                                        2005          0 12.144            63080   178            45461 3 19 0 0 1
1339 "ZF FRIEDRICHSHAFEN AG"                              2005     550000  3.416         11014000 53940          7230000 2  9 0 0 1
 493 "AHLERS AG"                                          2005          0  4.311           244447  3827           212280 2 16 0 0 1
 649 "OVB HOLDING AG"                                     2005          0 15.288           157610     .           100692 2 11 0 0 1
1542 "CEGID GROUP"                                        2005          0  2.934           225878  2067           334935 3 11 0 0 1
1515 "PIERRE ET VACANCES SA"                              2005          0  3.173          1239813  8637          1328780 3  7 0 0 1
2166 "MECO INTERNATIONAL B.V."                            2005       3390   .419            40720   147            39610 4 11 0 1 0
 329 "ITRON ZAEHLER & SYSTEMTECHNIK GMBH"                 2005     90.647      .        30397.281     .        32739.288 2  9 0 0 1
end

Getting different results from logit regression using what I believe are the exact same data

$
0
0
I'm using Stata/SE 15.1.

I begin a do file with use DSN1.dta. I then: a) create some new variables; b) sort by X1 X2; c) by X1: gen VAR1=_n d) keep if VAR1==1; e) save DSN1_n; f) merge m:1 by X1 with DSN1 as the master and DSN1_n as the using data set. The logits are run on these merged data.

Then I do the same thing except for the the highlighted difference.

I begin a do file with use DSN1.dta. I then: a) create some new variables; b) save DSN1_b; c) sort by X1 X2; d) by X1: gen VAR1=_n e) keep if VAR1==1; f) save DSN1_n; g) merge m:1 by X1 with DSN1_b as the master and DSN1_n as the using data set. The logits are run on these merged data.

That is, all I do is write one additional data set (DSN1_b). Summarizing both DSN1 and DSN1_b for variables in both show their identical.

But the logit results are similar, but not the same. One key coefficient is about half the other, yet its p-value < 0.001. I know the log likelihood function iterations never start at the exact same spot, but there appears to be a systematic difference between these two ways of merging the data. The sample size is the same. The merge results (matched, etc.) are identical.

Finally, I'm estimating robust se's, which generates pseudo log likelihoods. But the same issue exists when I remove the robust option.

Might setting the starting value for the LL function matter? If so, how does one do that?

Thanks in advance.

Compare the fit of two mixed effects models estimated with robust standard errors

$
0
0
Dear all,

I'm using Stata 14.

I'm trying to compare the fit of two mixed effects models estimated with robust standard errors.

I know that lrtest doesn't work when the models are estimated with robust standard errors. Below I provide a code that exemplifies this:

Code:
mixed performance i.profit i.feedback i.behavior || id: R.profit, vce(r)
estimates store A
mixed performance i.profit i.feedback || id: R.profit, vce(r)
estimates store B
lrtest A B
(Where performance captures some performance metric from my sample of participants, profit is a factor variable that captures three profit levels (e.g., low, medium, high), feedback is a factor variable that captures three feedback types (e.g., simple, normal, complex), behavior is a factor variable that captures four behavioral patterns from my sample of participants (e.g., pattern A, B, C, D) and id identifies my participants)

Stata would show the following error:

Code:
LR test likely invalid for models with robust vce
r(498);
I know I can make lrtest run by using the option force:

Code:
lrtest A B, force
But I understand that this approach could be questionable.

If I estimate those two models without robust standard errors and compare their fit with lrtest, the command works fine.

Is there a command analogous to lrtest or a set of commands that allow to compare the fit of two mixed effects models estimated with robust standard errors?

Thanks!

Mean of the response variable given specific values of the predictors

$
0
0
Hello,

I have a data set where y is the number of games won by a specific team, and the x values are x2 is passing yardage, x7 is rushing plays and x8 is opponents yard rushing. I ran my multiple regression with these variables, and now I have a question that asks "Find a 95% confidence interval on the mean number of games won by a team when x2=2300, x7=56.0 and x8=2100. I did the command margins, at(x2=2300) at(x7=56.0) at(x8=2100). This gives me 3 confidence intervals. I only need 1 for these specific values of x. How do I do it?

How to reference &quot;the next variable-in-the-list's name&quot; in a program?

$
0
0
I have some survey data in which there are multiple sets of three variables each. I'd like to make a loop that does some things for each set of three. For example, the first column in each set of three will be given a string variable, and then I want to use matchit to see if the string variable in the second and third variable of each set of three variables fuzzy matches the first variable.

So something like this:

foreach var of varlist (varlist) {
matchit `var1' `var2', generate('var1'sim2)
matchit `var1' `var3', generate('var1'sim3)
}
But after the first iteration I'd want it to use var4, var5, and var6.

I think maybe tokenize will be useful here? But I haven't used tokenize before and am having difficulty figuring it out.

Thanks for any help!

Pooled OLS with clustered standard errors or Random Effects (Panel Data)

$
0
0
Hi all,

I would appreciate it very much if someone could clarify how to choose between Pooled OLS with clustered standard errors or Random Effects. Since composite error term in panel data consists of two term (u(i) + e(i)) the need to cluster with fixed effect regression is clear: although u(i) is removed but we still have e(i,t) to worry about and thus we cluster. However, when comparing random effects (xtreg, re cluster()) and pooled OLS with clustered standard errors (reg, cluster()), I have hard time understanding how one should choose between the two. Random effects don’t get rid of u(i) and therefore clustering addresses heteroskedasticity and autocorrelation for both terms i.e u(i) and e(i.t) but so should pooled OLS with clustered standard errors. Is there a difference and what should be the guiding principle for choosing one over the other.

Thanks

Deleting observations based on a condition

$
0
0
Hi all,

I have been working with this data set and trying to delete the observations for which I got a perfect match and also with the observations with values non-zero for the variable 'd', provided there is one observation with value 0 for the variable 'd'.

In the following example data attached, I tried to find matches for candidate_m. Stata has produced a lot of perfect matches with the same name which are given in candidate_u. But not all the matches are exactly right even though they have a similarity score of 1 from the 'matchit' command. What I would like to do now is, within each identifier variable 'id' (combination of year_m, const_m and candidate_m), I have to check whether d is zero. If it is zero, then delete the other observations within it that are non-zero. If none of the observation has the value of 0 for d within an id, then do not delete anything within that id.


For ex, there are three ids in the given example below: 17782, 18156 and 19101. The last two ids have a value of zero for the variable 'd'. but the id 17782 does not have a value of zero for the variable 'd'. Therefore, none of the observations within 17782 should be deleted but for the ids 18156 and 19101, all the observations that are non-zero for 'd' should be deleted. To execute this, I have written the following lines of code.

egen id = group( year_m const_m candidate_m )
xtset id
bysort id : gen cum_simil=sum(similscore) // to take care of duplicates
by id, sort: gen has_perfect_match = 1 if d==0 & cum_simil>1
drop if has_perfect_match & d!=0

But the above set of commands delete even those ids which have non-zero value for 'd' i.e. the id 17782 has been deleted altogether, which I don't want to be deleted. There is some mistake in the set of codes and I have tried different combinations for a couple of hours already, but in vain. Any suggestion would be helpful.

Regards


***************************** Example dataset is as below


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(year_m year_u) str26 const_m long ac_m str26 const_u float(order_m order_u) str55 candidate_m float id byte dup double d float(cum_simil has_perfect_match) double similscore str55 candidate_u
1991 1993 "Garautha" 139 "Bangarmau"  3 10 "CHANDRA PAL SINGH" 17782 6 107.89971231641277 7 . 1 "CHANDRA PAL SINGH"
1991 1993 "Garautha" 139 "Chhibramau" 3 22 "CHANDRA PAL SINGH" 17782 6  43.09548223868419 2 . 1 "CHANDRA PAL SINGH"
1991 1993 "Garautha" 139 "Kanth"      3  4 "CHANDRA PAL SINGH" 17782 6  64.94923194380358 4 . 1 "CHANDRA PAL SINGH"
1991 1993 "Garautha" 139 "Kasganj"    3 26 "CHANDRA PAL SINGH" 17782 6  51.19461464844054 6 . 1 "CHANDRA PAL SINGH"
1991 1993 "Garautha" 139 "Kashipur"   3 34 "CHANDRA PAL SINGH" 17782 6            49.9999 5 . 1 "CHANDRA PAL SINGH"
1991 1993 "Garautha" 139 "Shahabad"   3  3 "CHANDRA PAL SINGH" 17782 6            49.9999 1 . 1 "CHANDRA PAL SINGH"
1991 1993 "Garautha" 139 "Siana"      3 16 "CHANDRA PAL SINGH" 17782 6 113.41941735080039 3 . 1 "CHANDRA PAL SINGH"
1991 1993 "Kanth"    205 "Bangarmau"  3 10 "CHANDRA PAL SINGH" 18156 6 167.82627376584603 5 . 1 "CHANDRA PAL SINGH"
1991 1993 "Kanth"    205 "Chhibramau" 3 22 "CHANDRA PAL SINGH" 18156 6 104.90555977626428 4 . 1 "CHANDRA PAL SINGH"
1991 1993 "Kanth"    205 "Kanth"      3  4 "CHANDRA PAL SINGH" 18156 6                  0 2 1 1 "CHANDRA PAL SINGH"
1991 1993 "Kanth"    205 "Kasganj"    3 26 "CHANDRA PAL SINGH" 18156 6 13.355054613263283 6 . 1 "CHANDRA PAL SINGH"
1991 1993 "Kanth"    205 "Kashipur"   3 34 "CHANDRA PAL SINGH" 18156 6            49.9999 7 . 1 "CHANDRA PAL SINGH"
1991 1993 "Kanth"    205 "Shahabad"   3  3 "CHANDRA PAL SINGH" 18156 6            49.9999 3 . 1 "CHANDRA PAL SINGH"
1991 1993 "Kanth"    205 "Siana"      3 16 "CHANDRA PAL SINGH" 18156 6 47.062286729680835 1 . 1 "CHANDRA PAL SINGH"
1991 1993 "Shahabad" 371 "Bangarmau"  2 10 "CHANDRA PAL SINGH" 19101 6            49.9999 7 . 1 "CHANDRA PAL SINGH"
1991 1993 "Shahabad" 371 "Chhibramau" 2 22 "CHANDRA PAL SINGH" 19101 6            49.9999 3 . 1 "CHANDRA PAL SINGH"
1991 1993 "Shahabad" 371 "Kanth"      2  4 "CHANDRA PAL SINGH" 19101 6            49.9999 5 . 1 "CHANDRA PAL SINGH"
1991 1993 "Shahabad" 371 "Kasganj"    2 26 "CHANDRA PAL SINGH" 19101 6            49.9999 6 . 1 "CHANDRA PAL SINGH"
1991 1993 "Shahabad" 371 "Kashipur"   2 34 "CHANDRA PAL SINGH" 19101 6            49.9999 2 . 1 "CHANDRA PAL SINGH"
1991 1993 "Shahabad" 371 "Shahabad"   2  3 "CHANDRA PAL SINGH" 19101 6                  0 4 1 1 "CHANDRA PAL SINGH"
1991 1993 "Shahabad" 371 "Siana"      2 16 "CHANDRA PAL SINGH" 19101 6            49.9999 1 . 1 "CHANDRA PAL SINGH"
end


Assign observation to groups from big database

$
0
0
Hi everybody, I'm having a problem with a big database. I have a form of 4,500 healthcare workers who have been screened for susceptibility to measles. The objective of my study is to define the proportions of immune subjects in two groups: subjects who had measles disease in infant age and fully vaccinated subjects. The sample size has to be of 500 units for each group and the groups have to be homogeneous for age of subjects at enrollment, gender, allergies (yes/no) and year of access to the clinic. I'm having issues on this last point.
The computer scientist in my department has created a code for the randomization of the two groups, but this code is very anti-intuitive and cumbersome and, I think, not well working.

I ask for help from you, any suggestion is appreciated
Thank you in advance,
Francesco

Compute cross-section autoregression coefficient AR(1)

$
0
0
Dear Stata Community:
I have annual panel set data defined by company id and year. I have 3 variables x, y, and z for which I would like to compute the first-order autocorrelations. I would like to do this in two ways:
1. Compute the time-series averages of the annual AR(1) autocorrelations.
2. Compute pooled AR(1) autocorrelations.
Can you please give me a sample code.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(id year x y z)
  2677 1996  -.03803680981595092  .03214723926380368  -.0027484662576687116
 13894 1996   .08422743334404112  .09900417603597815      .1635721169290074
 31366 1996   .06156753139392985 .051286593446968204    .015969242477922554
  7835 1997   .26745091928949827  .06437859429445593  -.0007011530071673419
 31366 1997 -.024543729219880423  .05363946403344797     .01875026755518772
 65910 1997   .06126731933502544  .25655756731662027    -.03905604542518514
  7835 1998   .13827106708238915  .04947704152131011     .01718268921278249
 31366 1998  .012275752005585717 .055287194174895624     .01873779905669787
  2677 1999   -.1698500591053319 .043986810178560314   -.020904622659117775
  5686 1999   .07179028785495473  .08227626219891598    .014290879790317223
  7835 1999   .15438850070938048  .08274440322118683    .013388307544744255
 30234 1999   .11792313488072596  .12300476963366425  -.0031200108868464985
 31366 1999   .04629862297718364  .05114835661875565     .02047944517036888
  7835 2000   .16406783431323782  .07946649529923905     .01035001591121849
 11555 2000   .04999428295874285 .042465188190084165    .003705779040971656
 25874 2000   .27488203004622497  .07687307395993837    .005609591679506934
 31366 2000    .1685417399117153 .058270505358282224     .09353229943878016
  6403 2001   .10427880667822279  .07763890156007663   .0010035580695192045
  7835 2001   .14713623028775377  .07672816428548733      .0377326018576376
  8049 2001   .38074914159143874  .19974046715911362     .06222133493045851
 11555 2001   .04979094076655052  .03557491289198606  -.0010104529616724739
 25874 2001   .35650171407636144  .21339160320658765    .006960981864810405
 31366 2001   .07252358151645964  .04260480194975024   -.055229404096051135
  6403 2002    .1461297810071652  .09657886769603391     .10868907054193158
  7835 2002   .19195656534443592   .0728473769523097     .02559890708605071
  8049 2002   .24713401362662765  .18541625575705986    .032675531933299425
 11555 2002   .06047570061410892  .04632313974874528   .0016209981607905484
 31366 2002   .10620586152001178  .04617402220336486    .037344572939386075
  1678 2003    .2179343218649682  .08661711390493299    .006725044510662987
  1995 2003   .06835773098660185  .03797300119614953  -.0015189200478459815
  5475 2003    .0769515627314472  .13062262380881845    -.04151236853799437
  6403 2003   .14920385295852173  .09779830941615883    .024080990760762727
  7835 2003   .12655269484259174  .06403148642900498    .048993227645734654
  8049 2003   .35270124470408676  .23468146973301612 -.00018364706373387871
 10840 2003   .11816855070182496  .07706957229778444  -.0019433059910180398
 14114 2003   .05332110091743119  .10868313338038108    -.06160903316866619
 14622 2003  -.11392227732481577 .022218486453167464    .025916897817376928
 14633 2003   .20708175154388483   .1396202539027192    -.04228115906533009
 25874 2003   .18801591981132076  .15664119194484763    .004563906023222062
 30865 2003   .06697777481254966  .03609083966902955   -.007206425063845658
 64741 2003    .1859412352374496  .08319656045955685    .010467584828914975
124361 2003   .19999353915173101  .12784504463032845   .0021714507229083505
141982 2003   .23432482715850886  .19497438959965085     .05455130119208949
142460 2003   .03576733364708021  .04592458901210451   .0015737846490659086
150699 2003    .2561278100279575   .1102087130109198    .005659782398188472
  1678 2004   .20845174449507434  .07899529623647314    .005531631068061369
  1995 2004   .06265024125069897  .03808705777911006    .003666318865977599
  5475 2004   .11516454070952076  .10118067379350769        .18360454405895
  6403 2004    .1412040225926436  .07742113238738119     .03299352527896404
  8341 2004   .10386650338956238  .05104557892084771   .0076462902309121054
 10585 2004  -.08790581614504527 .017493562687478433   -.000617185633511189
 10840 2004   .15133371954647543  .06697991786787516  -.0022116885600052512
 10877 2004   .19861484690207365  .08114756982453947   .0027181137209520536
 14633 2004    .2751155326815895  .11760324066093723   -.016367471906884354
 14934 2004   .16195856873822975  .07701103040086091   .0042036588646758135
 20488 2004  .055163388324873094  .03210659898477158   .0005908946700507614
 24005 2004    .1982185545403936 .059344401873137505    .048334806955496606
 28564 2004   .20292164018243777  .10332995587334799    .003852501105225727
 30234 2004  -.09151646176286725 .019543133986247133     .06504219629089393
 30865 2004   .05559914397753032 .036897563974917905  -.0017190932483940903
 63742 2004   .04484023895925361  .04362387840437755    .025578950560502987
 64741 2004   .19692497913079315  .08847845145246186   .0009081161131233256
123500 2004    .0985631750184477  .08273587911719327    .009625651260034437
124361 2004   .19091674479182505  .12534721890365277   .0032608383995217784
129418 2004   .11064828395423877  .08989248408943079     .04702896425064088
141982 2004    .1107573082679694  .15614259956415072    .023858851475357854
142460 2004   .04592632107768242  .04507321409149528    -.01357477561230779
150699 2004   .32625564704200843  .11239897742630578     .00796149246548452
  1678 2005   .22479845677071306  .07365322879092329    .005305473345608267
  5475 2005  -.03322079411841385  .07512318481633079    -.06209427223192637
  7309 2005   .15607868429538857  .06256046436633343    .005697086961195313
  8049 2005    .2744047162004214   .1888101149189936     .01827271719007277
  8341 2005    .1467068234996522  .04760323784228167     .12764418516410547
 10840 2005   .09637246844535317  .05963076553009802   .0003848698057610199
 10877 2005   .21822008728226647  .07848811457256755   .0030497289168002913
 14633 2005    .3002730325704999  .11650226941055608  -.0007233981628700822
 14934 2005   .18537971129389225  .07237472335084068    .011231130049879431
 24005 2005   .15780447376626788  .08618482595637832    .002182725288431556
 25691 2005   -.1057264478155765  .00677048663420103     .10821392285323898
 25874 2005    .1696294064477252  .10461213989385125    .009622917004658492
 28460 2005  -.20933894056472832 .018706884050465084    .022166518199332935
 28564 2005    .2154881730136237  .11279917881323187   .0034621039780555873
 30234 2005   .17200394469575797  .06898556555358211     .12519257376679194
 30865 2005   .03893617988741879 .040297566026032655    -.00794131226594162
 61662 2005  .013085514252375396  .05338768582642561   -.004303747594296019
 63742 2005  .014902358377255575  .03336206531108254    .006827671720668654
 64741 2005    .1692282619267297  .09074277062353618    .005690973563916336
 65220 2005   .10138057587946782 .055792075718935734     .02762456897789356
 65226 2005    .1109646390751981 .036413591961099605    -.02609455655188732
 65827 2005   .10665708282649565   .0481587968594493     .05280327325002765
 66515 2005 -.028501536010922746 .028160200250312892      .1076914324724087
137024 2005     .199592721301843  .07459800344899056    .008628513130914749
141982 2005   .05291327724114824  .08932544918866227    .004580200858742139
142460 2005   .10256251964753095  .04714706904810066    .007501744744531747
150699 2005    .1685831398679771  .06178619656080194     .00600549955924585
160838 2005   .10364546860487996  .11158125453541486     .01202532850684094
160913 2005    .1475570816201557  .03937319569591462     .00484756364272592
  5475 2006   .18748052321632613  .08144691527698983   .0062885041031090945
  6845 2006    .1646245641095811  .06360993975279156    .002661989526190743
  8512 2006   .07620828984255111  .04017360879442986   .0022345686411764506
end

Compare three groups

$
0
0
Dear Statalisters,

I am wondering if there is someone who can help me figure the right statistical technique to use.

I have this dataset looking for a binary outcome. The dataset is generated from a three arm study. 1 intervention A only, 2 combined intervention A and B and 3 Control. want to know the effect of intervention A only.

Regards,
Christian.

Do I have to &quot;tell&quot; stata that my DV has a lower limit at zero before testing/running regression models (OLS, fixed-, random effects)?

$
0
0
Dear research community,


I am about to run a panel regression for 30 countries and a period of 14 years. My dependent variable is OECD Triadic Patent Families which measures the number of patents taken at the EPO, JPO, USPTO. It becomes manifest in fractional count data as a patent will be allocated to multiple countries if there are multiple inventors with different nationalities. As such I treat it as a continuous variable. before testing for appropriate regression models (OLS, fixed-, random effects)/ running different regression models do I have to "inform" stata that the DV has a lower bound at zero? If yes how can I do that?

Mismatching observations

$
0
0
Hi all,
I guess it will be quite a long post since I need to explain the context. So...I started with a dataset like the following consisting of an unbalanced panel of products, which I call here DB A:

Code:
clear
input double(idproduct idfirm Year) int data_lancio double salesmnf
12012 1 2008 2008  15396.326336404796
 8687 1 2008 2008   82539.41606320994
 4088 1 2008 2008                   .
 3051 1 2008 2008   6406.222920983277
 3051 1 2009 2008                   .
 4088 1 2009 2008    4277.70772452764
12012 1 2009 2008                   .
 8687 1 2009 2008   73704.63999568677
 4088 1 2010 2008   2812.048892451227
 8687 1 2010 2008   98557.57209063334
12012 1 2010 2008                   .
 3051 1 2010 2008  4018.8839710146035
16087 1 2010 2010  34.893052778160126
 3051 1 2011 2008  -71780.24736053024
12012 1 2011 2008 -350276.11353135726
18347 1 2011 2011   4.269736733465339
 4088 1 2011 2008  2415.0413907246884
 8687 1 2011 2008                   .
10080 1 2011 2011                   .
16087 1 2011 2010  10.592082975818183
 7193 1 2012 2012  61.464584762025524
 8687 1 2012 2008  -86536.18061094767
 6051 1 2012 2012                   .
 7657 1 2012 2012                   .
12012 1 2012 2008   377677.0599400542
 3051 1 2012 2008                   .
16087 1 2012 2010 -56.826416447160895
 4088 1 2012 2008                   .
10080 1 2012 2011  16617.494724577948
 1474 1 2013 2013   639.7037842639306
 4088 1 2013 2008    1930.34399138424
 3051 1 2013 2008  -61366.80444077954
16087 1 2013 2010  -181.8308088090259
 6051 1 2013 2012  503.09757693788134
10080 1 2013 2011    3454.50789670565
12012 1 2013 2008  147876.99475143052
11757 1 2013 2013   900.8486835362314
  287 1 2013 2013 -1124.6834404804501
21124 1 2013 2013   4.560467010248697
11192 1 2013 2013  49.597287071095884
 7657 1 2013 2012  284.60841423983527
 7193 1 2013 2012   2888.522379077397
 8687 1 2013 2008   82561.30327447035
 4088 1 2014 2008   9738.263410350755
  287 1 2014 2013 -3177.3688851437196
16087 1 2014 2010  32279.242490909957
21428 1 2014 2014                   .
 6051 1 2014 2012                   .
11757 1 2014 2013                   .
10080 1 2014 2011  -2824.445545520929
 8087 1 2014 2014   4.001643313697048
 8687 1 2014 2008   25709.80144590244
 3051 1 2014 2008 -181450.56736708918
21124 1 2014 2013 -29.061904310891833
11192 1 2014 2013   617.0967487450646
10237 1 2014 2014  58269.863830056944
 7193 1 2014 2012   9270.437285333577
 7657 1 2014 2012   87.69915348798118
19783 1 2014 2014  20.008216568485242
12012 1 2014 2008   86582.84950321584
 3026 1 2014 2014  1984.1354848809628
 1474 1 2014 2013   7088.723366027008
10080 1 2015 2011   5145.073920110006
 3026 1 2015 2014                   .
 7657 1 2015 2012  -571.9141415536579
 3051 1 2015 2008  100497.35362196501
10237 1 2015 2014  25833.494600162452
11192 1 2015 2013   35.18426008205207
21124 1 2015 2013  126.02557490064751
 7193 1 2015 2012   6220.801943658451
  287 1 2015 2013  4075.4597383424634
 4088 1 2015 2008  -8296.622744321847
11757 1 2015 2013   342.6494068681445
 6051 1 2015 2012                   .
 1474 1 2015 2013   4550.801553581108
19783 1 2015 2014   302.3608408431739
21428 1 2015 2014   993.2654746298192
12012 1 2015 2008                   .
 8087 1 2015 2014  29.024492207392203
16087 1 2015 2010   24885.03302008349
 4632 2 2004 2002   40303.89394907451
 2669 2 2004 1975  142395.83790396014
 1691 2 2004 2002  440297.07712877344
 1690 2 2004 2002  2081716.7850969036
19459 2 2004 1988  202902.99798259253
19458 2 2004 1976  151721.50534611402
19459 2 2005 1988                   .
 1690 2 2005 2002   9129213.943887338
19458 2 2005 1976  -292205.8605050109
 1691 2 2005 2002   643979.8269345053
 2669 2 2005 1975  173012.23232488259
 4632 2 2005 2002   83798.15604166387
 1691 2 2006 2002   605838.1666728614
 4632 2 2006 2002  148905.13305957624
 2669 2 2006 1975    89184.2804009437
 1690 2 2006 2002                   .
19458 2 2006 1976 -150632.22355181634
19459 2 2006 1988  297894.20704815397
 1690 2 2007 2002   4368323.171890425
 1691 2 2007 2002   856429.8400239134
end
This was the result of a collapse by(idproduct Year) after having dropped the sales=0, of a reshaped dataset of products and firms of this type (DB B here):

Code:
clear
input double(idproduct idfirm trimestre Year salesmnf)
13953 808 176 2004   7256815.63032673
13953 808 177 2004  8030709.503351643
13953 808 178 2004   9992083.91675233
13953 808 179 2004 12449462.810000002
13953 808 180 2005 14547058.630251253
13953 808 181 2005 15571641.181141142
13953 808 182 2005  18127552.72880558
13953 808 183 2005 19007421.644095417
13953 808 184 2006 21053797.091691196
13953 808 185 2006  22027868.90966712
13953 808 186 2006 23336168.843872026
13953 808 187 2006  24446645.60241845
13953 808 188 2007 25523160.396202978
13953 808 189 2007  26478002.96708627
13953 808 190 2007  27641542.40729251
13953 808 191 2007  28828877.48947615
13953 808 192 2008  32131532.80763707
13953 808 193 2008 30327306.646768637
13953 808 194 2008 33436975.554169096
13953 808 195 2008 34656797.488343805
13953 808 196 2009  40872202.68129731
13953 808 197 2009  41676909.55687167
13953 808 198 2009   44890729.6703414
13953 808 199 2009 45429140.016624466
13953 808 200 2010  52691594.98112469
13953 808 201 2010 52060087.860828206
13953 808 202 2010 50675523.940462194
13953 808 203 2010  53790652.08346875
13953 808 204 2011  55721011.18584333
13953 808 205 2011  56211953.39699873
13953 808 206 2011   54441929.8115007
13953 808 207 2011  55031226.25178449
13953 808 208 2012  57681491.69610122
13953 808 209 2012  56901482.73766654
13953 808 210 2012   53804665.7002145
13953 808 211 2012 56531566.264653355
13953 808 212 2013  57151209.02664664
13953 808 213 2013  55536385.88381136
13953 808 214 2013   57310004.5270682
13953 808 215 2013  57558720.51815264
13953 808 216 2014  63619620.43781556
13953 808 217 2014 63595514.855420984
13953 808 218 2014  61937905.50562193
13953 808 219 2014 66240586.340213776
13953 808 220 2015  68548434.86275928
13953 808 221 2015   69856174.9620182
13953 808 222 2015  70637788.99355544
13953 808 223 2015  71785787.53821875
13953 808 176 2004   480863.948901982
13953 808 177 2004 443538.37249424285
13953 808 178 2004 493034.57773983444
13953 808 179 2004  517630.7633333335
13953 808 180 2005  570435.1510552763
13953 808 181 2005  602069.2779707403
13953 808 182 2005   608964.845538297
13953 808 183 2005  610254.4742348397
13953 808 184 2006  579281.9850551476
13953 808 185 2006  576809.7998625375
13953 808 186 2006  557526.9811353568
13953 808 187 2006  592764.6790329489
13953 808 188 2007  628868.7422926143
13953 808 189 2007    614512.60666115
13953 808 190 2007  623469.1840395499
13953 808 191 2007  605250.6504832387
13953 808 192 2008  643666.4166070041
13953 808 193 2008  618145.5762210166
13953 808 194 2008  616933.3936836625
13953 808 195 2008  571926.6398216188
13953 808 196 2009  586404.2227352844
13953 808 197 2009  592030.1826263306
13953 808 198 2009  578107.5589057507
13953 808 199 2009  667321.4017232646
13953 808 200 2010  684665.2575330996
13953 808 201 2010  614350.5858132946
13953 808 202 2010  582823.1437436048
13953 808 203 2010  543069.1564959331
13953 808 204 2011  559173.2620880879
13953 808 205 2011  513156.1149227039
13953 808 206 2011 434377.83859707596
13953 808 207 2011 446008.49404089013
13953 808 208 2012    433738.43179489
13953 808 209 2012 374941.98302506923
13953 808 210 2012  433405.9320486771
13953 808 211 2012  400983.6824802481
13953 808 212 2013 464123.06267918675
13953 808 213 2013 464450.97302678385
13953 808 214 2013 504087.30858979886
13953 808 215 2013  493541.5914549431
13953 808 216 2014 393116.41464294546
13953 808 217 2014  455538.4691830468
13953 808 218 2014  552322.7803182581
13953 808 219 2014  529139.2961918175
13953 808 220 2015  638849.8156277174
13953 808 221 2015  573233.7522831999
13953 808 222 2015  673646.1468416121
13953 808 223 2015  788430.7504760622
13953 808 176 2004                  0
13953 808 177 2004                  0
13953 808 178 2004                  0
13953 808 179 2004                  0
end
format %tq trimestre
Now, again, I needed, in order to find the average sales for firms, to collapse DB A by(idfirm Year) as follows:
Code:
gen avsales=salesmnf
gen avsales_existing=salesmnf if ageprod>1
gen avsales_new=salesmnf if ageprod==1

collapse (mean) avsales avsales_existing avsales_new (first) ageprod idprod salesmnf data_lancio anno_numeric firstpos atc4 crp prd internationalp, by(idfirm Year)
I obtained DB C, consisting of 9605 observations. Now the point...: from DB B I needed to basically do a collapse (again after having drop the sales=0 as in the previous case) in which instead of doing like I did to obtain DB A (I collapsed by(idproduct Year)), I had to collapse by(idfirm Year). What I expected to obtain was a dataset consisting of 9605 observations ready to be merged with DB C, but instead I obtained a dataset of 9681 observations. What am I doing wrong? My advisor told me I should obtain a perfect match in the number of observations...

Many thank,

Federico

How to measure multicollinearity

$
0
0
Hello,

I am trying to test for multicollinearity in multilevel longitudinal logistic regression models. I am using the gllamm command, a user contributed command that can be used for multilevel models.

​​​​​​​I am not having success using vif after my gllamm commmand.

I have tried running my regression model, then trying various various syntx for vif with the following error messages:


Code:
. xi: gllamm Garden_Active_ i.Year LCommunity_Garden LMarket_Garden LPickups_ i.r_L_volunteer_3_max LUR_Curr_Yr_or_Prior_ , i(Garden_ID) family(binomial) link(logit) nip(10) adapt
. vif
not appropriate after regress, nocons;
use option uncentered to get uncentered VIFs
r(301);

. vif, uncentered
variable _cons not found
r(111);

. estat vif
subcommand estat vif is unrecognized
r(321);
Is there a way that I can get VIF to work with gllamm? Or is there another method that I can use to test for multicollinearity?

Thank you,
alyssa

Predict Using a subset of observations

$
0
0
Hi All,

I have a dataset that is a much bigger version of:



Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(y X1 X2 X3)
 12 1   2  2
  2 0   3  3
132 0  32  3
213 1  32  2
123 0  32  3
123 0  32  4
123 0 324  3
123 0  32  4
123 1   3  3
 12 1   2 23
 21 1   4  3
end

In the above, I have information on y, and 3 regressors of interest. I wish to generate a prediction of not y, but a variable z that is based on the coefficients estimated in the linear regression of

Code:
reg y X1 X2 X3
of simply x1 and x2. In other words, z=x1*b1+x2*b2 , where the b are estimated from a full regression of y on X1, X2 and X3. One potential solution can be found in the thread:

https://www.stata.com/statalist/arch.../msg00374.html
However, in my original dataset, the number of covariates is very high, and the chance that I make a mistake would increase as I manually enter the variable names under subset. Is there any way of combining this with the predict command?

Thanks,
CS

head table: Freq. and % titles with asdoc

$
0
0
Hi all.

I wonder if its posible get the head for 1 way tabulate using asdoc.

sysuse auto, clear
asdoc tab foreign, replace

Dont show headers for Obs, %, and % Acum.

Tabulation of foreign
Domestic 52 70.27 70.27
Foreign 22 29.73 100.00
Total 74 100.00
In the original stata out show headers:

Car type | Freq. Percent Cum.
------------+-----------------------------------
Domestic | 52 70.27 70.27
Foreign | 22 29.73 100.00
------------+-----------------------------------
Total | 74 100.00

Regards

Number of dummy variable within one year

$
0
0
Hey Guys,

I am new to Stata and would like to know how I can count how often a dummy variable (=1) occured wihtin one year per fund.
After that I want to know the mean number of counts per fund.
So basically I created a dummy variable which shows me that a fund was bought (=1) and in my dataset I have the year the FundID and the ID of the Stock.
So I want to know the mean number of Stocks bought per fund and year.
I would be very happy if someone could help me.

Kind Regards,
John Lei
Viewing all 65147 articles
Browse latest View live


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