Hello Stata community,
I am on Stata 17.0
I am trying to combine the coefficients from a random effects regression with coefficients from a probit model using the -nlcom- function. Do do so, I first need to run suest which does not support xtreg. Therefore, I have resorted to using xtdata to quasi-de-mean my data so that I can just run -reg- instead of -xtreg-. However, xtdata deletes the time variable "year", meaning that I cannot merge my transformed variables with untransformed data.
Is there a way to run xtdata, re and also keep my "year" variable?
Below is an example of my data. I would like to transform the following variables using -xtdata, re- while keeping the variable "year". Ideally, I would want to simply create a new variable with the suffix "_re" for each of the relevant variables and just add them to my dataset of untrasnformed variables.
Any help would be greatly appreciated.
Ammar.
I am on Stata 17.0
I am trying to combine the coefficients from a random effects regression with coefficients from a probit model using the -nlcom- function. Do do so, I first need to run suest which does not support xtreg. Therefore, I have resorted to using xtdata to quasi-de-mean my data so that I can just run -reg- instead of -xtreg-. However, xtdata deletes the time variable "year", meaning that I cannot merge my transformed variables with untransformed data.
Is there a way to run xtdata, re and also keep my "year" variable?
Below is an example of my data. I would like to transform the following variables using -xtdata, re- while keeping the variable "year". Ideally, I would want to simply create a new variable with the suffix "_re" for each of the relevant variables and just add them to my dataset of untrasnformed variables.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long dscd int year float(tax firm sector kbm property sigma obscure dummy account sox bill size) 1 1990 . . . . . . . . . . . . 1 1991 . . . . . . . . . . . . 1 1992 . . . . . . . . . . . . 1 1993 . . . . . . . . . . . . 1 1994 . . . . . . . . . . . . 1 1995 . . . . . . . 1 . 0 .4675389 . 1 1996 .06827132 .28247488 -.2377853 .3570195 .9570682 . 0 1 .09197306 0 .5772803 10.903052 1 1997 .08050481 .5287469 -.4265625 .15136847 1.0633023 . 0 1 .07325352 0 .6427687 11.079308 1 1998 .09764194 -.1032624 .22808704 .4585897 1.0760499 .03288334 0 0 .10173464 0 .6156349 11.33919 1 1999 .12015583 .4810672 .12529752 .439632 1.0760499 .04213113 0 0 .08257556 0 .4387585 11.668133 1 2000 .12714696 .7088938 .7429639 .22839764 1.0760499 .028005386 0 0 .06327638 0 .5361123 12.09174 1 2001 .1112909 .7112182 .15739095 .35216495 1.0760499 .03260713 0 0 .04906772 0 .4315735 12.542402 1 2002 .10974327 .8913331 .9152743 .1844167 .9858727 .04785552 0 0 .03526637 1 .462631 12.83869 1 2003 .10275337 -.1660253 -.020141035 .350813 .9053375 .02813827 0 0 .03267374 1 .4671313 13.040915 1 2004 .11608876 .3452228 .2476318 -.06522765 .9438437 .017745424 0 0 .033631667 1 .4678643 13.152078 1 2005 .12723213 -.2093561 .6423336 .25672773 .9904854 .0044207075 0 0 .03966927 1 .4377359 13.29151 1 2006 .13831624 .22577527 .7844977 .25763306 1.0504342 .011516624 0 0 .0395244 1 .3355944 13.465892 1 2007 .13718542 -.06030926 .9981809 .11429074 .9536193 .01895321 0 0 .03270002 1 .377109 13.710183 1 2008 .13100633 -.3604821 .4416782 .22764963 1.0760499 .017056566 0 0 .02583173 1 .5043236 13.843953 1 2009 .0865533 .033157445 -.29447246 .28160053 .6334511 .025048576 0 0 .012311707 1 .46991315 14.402662 1 2010 .09439186 -.067542076 -.14309327 .15427624 .6323314 .09779426 0 0 .011156537 1 .4494519 14.377432 1 2011 .10694411 .43660825 .02881778 -.1512037 .6401014 .009799502 0 0 .01212072 1 .4077583 14.35569 1 2012 .11587828 -.01897472 .04686461 .017466648 .651275 .011886523 0 0 .011436427 1 .3723998 14.350863 1 2013 .12130693 .0787891 .1631722 -.04746647 .6161459 .005441165 0 1 .010849985 1 .3156082 14.36222 1 2014 .13804136 1.2026787 1.1100036 -.476066 .7155417 .006035509 0 1 .0099775 1 .4440436 14.33274 1 2015 .1044141 .453383 .8181924 -.03816196 .51494074 .015142236 0 1 .007415459 1 .4604562 14.558958 1 2016 .1216084 2.2433376 .4695605 -1.0475215 .5554011 .00660054 0 1 .007786898 1 .4673943 14.498215 1 2017 .08666493 -.07331698 .6798153 .1180458 .57182974 .0023070958 0 1 .007816373 1 .4499483 14.511102 1 2018 .0820577 -.012243375 .732766 .031719226 .5224946 .0045880103 0 1 .005654944 1 .4505308 14.544703 1 2019 .09727071 2.2116845 .7935854 -1.2872292 .6067248 .00999242 0 1 .004746482 1 .4142546 14.511187 1 2020 . .027850203 .56810737 .1977691 . .009715253 0 1 . 1 . 14.565453 1 2021 . . . . . .0006394029 . 1 . 1 . . 1 2022 . . . . . . . . . . . . 2 1990 . . . . . . . . . . . . 2 1991 . . . . . . . . . . . . 2 1992 . . . . . . . . . . . . 2 1993 . . . . . . . . . . . . 2 1994 . . . . . . . . . . . . 2 1995 . . . . . . . 0 . 0 .29346532 . 2 1996 .017218772 -.406973 1.4336102 .09678893 .517906 . .002403179 0 .14413248 0 .1709194 13.578992 2 1997 .06503684 -.8997365 2.0787594 .021742364 .7691587 . .004429601 0 .172428 0 .28226674 13.55274 2 1998 .06839298 -.3461897 2.0950618 .0860855 .7031915 .12850621 .0027611144 0 .14208388 0 .3888797 13.916 2 1999 .05152812 1.0379184 1.8749213 .09886678 .53317314 .10751406 .001755646 0 .1088167 0 .3682673 14.278357 2 2000 .04967536 -.4934432 1.6080116 .14571938 .52455276 .08207563 .001334807 0 .11909623 0 .3538065 14.370873 2 2001 .05575205 -.32322 1.4386 .07718465 .5876866 .013726253 .0003019378 0 .125447 0 .3604613 14.426058 2 2002 .04877145 -.18769065 1.361667 .017926678 .4799 .0263565 .000165874 0 .10776237 1 .3299332 14.61508 2 2003 .05760473 -.3251194 .7014643 .004730362 .4615533 .072345376 .00027097273 0 .09468238 1 .3130369 14.630225 2 2004 .05973109 -.1332584 1.2570447 -.04963937 .4571556 .04239788 .0003823882 0 .0898286 1 .3073869 14.66142 2 2005 .06365935 -.27333245 1.470286 .0017494473 .4950867 .0011832936 .00028100237 0 .09454244 1 .29505908 14.672413 2 2006 .065381564 .06123233 1.6957942 .07762542 .53239733 .04778678 .0003024679 0 .10532417 1 .2850447 14.704765 2 2007 .064195916 .5573907 1.8278136 .08914489 .5719522 .02800525 .0003467095 0 .11446002 1 .42152205 14.734366 2 2008 .06494809 1.9391693 1.5737426 .22079134 .6299001 .013069242 .00022207276 0 .1184952 1 .4484891 14.802746 2 2009 .064615294 1.715584 .6552189 .14438297 .5582535 .04532163 .00012300075 0 .10966819 1 .386304 14.924898 2 2010 .070601426 1.572193 .9739217 -.1926935 .5210505 .11425154 .00004723268 0 .1024591 1 .33592466 14.990863 2 2011 .07222197 1.574854 .9818146 -.2058898 .5770534 .005542146 0 1 .10492162 1 .3367725 14.938732 2 2012 .07166606 1.1175373 .864299 -.21871363 .5569695 .003473077 .011163274 0 .10556855 1 .3315168 14.96222 2 2013 .08858132 1.7421672 1.1269654 -.25837135 .5692133 .04496575 0 1 .10987508 1 .3170344 14.966375 2 2014 .22534424 .9741219 1.5275437 -.16475818 1.0438502 .017321223 0 1 .1487561 1 .2124189 14.997185 2 2015 .07816564 -.0010165083 1.6108447 -.5296549 .4228074 .11272977 0 1 .06285053 1 .22740462 15.825655 2 2016 .09523765 -.12659927 1.8444598 -.25215 .4917447 .2165999 0 1 .07492733 1 .23095617 15.755939 2 2017 .05625645 .6939021 2.2367852 -.1627405 .4921052 .03716812 0 1 .08226254 1 .3366357 15.80351 2 2018 .0784613 .3875535 1.889197 -.10335378 .57350266 .002616597 0 1 .07373191 1 .3267034 16.011902 2 2019 .07674252 -.06164112 1.366745 -.06119016 .59550315 .035592884 0 1 .072324336 1 .27461606 16.0722 2 2020 .0771349 .4763335 2.082877 -.09141162 .56213236 .012137147 0 1 .06997908 1 .250482 16.13117 2 2021 .08461553 -.12219633 2.3539047 -.07606813 .6393373 .014676766 0 1 .07112884 1 .3686028 16.174551 2 2022 . . . . . . . . . . . . 3 1990 . . . . . . . . . . . . 3 1991 . . . . . . . . . . . . 3 1992 . . . . . . . . . . . . 3 1993 . . . . . . . . . . . . 3 1994 . . . . . . . . . . . . 3 1995 . 1.6986468 1.879179 -.0883611 . . 0 1 .0005536719 0 .04232372 . 3 1996 -.00148688 -.8777955 1.9682615 .2603249 .13071978 . 0 1 .3302339 0 .1868341 10.773755 3 1997 -.003503737 .6039063 1.5267075 .27508926 .08601495 . 0 1 .408562 0 .014423035 11.334098 3 1998 -.005526502 -.5587183 2.2056432 -.017695656 .066370405 .4017985 0 1 .3172282 0 .1494986 11.64867 3 1999 0 -.59603435 .19363996 -.14168519 .06156046 .3548914 0 1 .2418675 0 .04152538 11.57404 3 2000 0 -2.673792 1.8540876 .1944495 .06790416 .12959738 0 1 .18891492 0 .0021654635 11.292479 3 2001 0 -2.828337 2.108457 .2352159 .06505645 .010802817 0 1 .2343883 0 .073408395 10.897295 3 2002 0 -.8574261 -.0584001 .6121952 .0749236 .04841859 0 1 .2481256 1 .04280318 10.552657 3 2003 0 -.7814173 -.002815786 .10365111 .067190714 .12934795 0 1 .19290595 1 .04672774 10.49133 3 2004 0 -.7632804 1.6868526 -.5372243 .06422593 .05284505 0 0 .1903381 1 .05325622 10.32042 3 2005 0 -2.74397 2.332416 .06549879 .05911515 .05045957 0 0 .15503643 1 .04819003 10.189644 3 2006 0 -2.1009064 2.1417294 -.33834055 .012104425 .2412657 0 0 .2166654 1 .008827424 10.179376 3 2007 0 -2.07165 2.235875 -.04947115 .01883184 .07270412 0 0 .21057084 1 .004095563 10.21053 3 2008 0 -2.2919033 2.18586 .010460086 .06535836 .06533822 0 0 .29102388 1 .001188778 10.285343 3 2009 . -1.353039 .4876799 .3377949 . .2419744 0 1 . 1 . 9.953705 3 2010 . . . . . .0008089655 . 1 . 1 . . 3 2011 . . . . . . . 1 . 1 . . 3 2012 . . . . . . . 1 . 1 . . 3 2013 . . . . . . . 1 . 1 . . 3 2014 . . . . . . . 1 . 1 . . 3 2015 . . . . . . . 1 . 1 . . 3 2016 . . . . . . . 1 . 1 . . 3 2017 . . . . . . . 1 . 1 . . 3 2018 . . . . . . . 1 . 1 . . 3 2019 . . . . . . . 1 . 1 . . 3 2020 . . . . . . . 1 . 1 . . 3 2021 . . . . . . . 1 . 1 . . 3 2022 . . . . . . . . . . . . 4 1990 . . . . . . . . . . . . end label values dscd DSCD label def DSCD 1 "130042", modify label def DSCD 2 "130062", modify label def DSCD 3 "130079", modify label def DSCD 4 "130086", modify
Ammar.

Comment