This is a specific problem emerged in my previous post "Reshape wide".
The data are the following:
What I am trying to do is multiple imputation after having reshaped wide. Having discovered the need to declare xtset, clear before mi-setting in the forum I produced the following code:
which however produces the following error:
Can anyone help me please?
Federico
The data are the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(idfirm Year) float(inflow_ratio outflow_ratio avsales) double tot_sales 1 2008 . . 94701.45 211591.55354704778 1 2009 0 0 83603.08 308746.0587639413 1 2010 .25 0 91092.75 407237.1453954251 1 2011 .4 0 118792.94 598549.0481277383 1 2012 .2857143 0 104542.8 664061.6305459269 1 2013 .5555556 0 73541.766 608140.67505112 1 2014 .3571429 0 48557.22 715163.0758130773 1 2015 0 .05263158 52369.71 768412.7578732732 2 2004 . . 2039558.8 12237352.38962967 2 2005 0 0 2109991 11513177.507807251 2 2006 0 0 2050668.5 12304011.532418355 2 2007 0 0 6330808 11406777.403632266 2 2008 .16666667 0 2734569.5 12355367.684264863 2 2009 0 0 1841746.4 12892224.398947667 2 2010 0 .14285715 5212612 10897763.444727022 2 2011 0 0 5262992 10580189.86100467 2 2012 0 0 2037856.5 10967562.283051893 2 2013 0 0 1823603.5 9124157.813647183 2 2014 0 .3333333 1785749 7133930.997182059 2 2015 0 0 1356981 5427924.711631365 3 2004 . . 53702.81 2464566.2638161103 3 2005 .23913044 0 81622.65 4406664.46751826 3 2006 0 .03508772 67388.88 1843225.499704768 3 2007 0 .14545454 11123.49 476002.8259390887 3 2008 0 .21276596 7850.393 160865.5648153848 3 2009 0 .1081081 6033.619 82650.9899064962 3 2010 .3030303 0 4410.1416 126687.58501765266 3 2011 0 .372093 2412.5247 35362.49685707843 3 2012 0 .4074074 1075.685 16035.562916347304 3 2013 .1875 0 3456.24 22272.424034809985 3 2014 0 .2105263 1496.9843 21090.64112449751 3 2015 0 .26666668 4020.239 23837.82400447101 4 2004 . . 56691.86 8398246.263306491 4 2005 .03947368 0 78010.12 8251045.135936161 4 2006 .0949367 0 94482.98 9847010.316997783 4 2007 .2485549 0 126469.87 13503137.133153718 4 2008 .1712963 0 78780.68 13768126.595234673 4 2009 .07509881 0 73256.164 13834060.86932386 4 2010 .025735294 0 62012.55 12531817.194234656 4 2011 .014336918 0 70322.5 12433251.178176137 4 2012 .03180212 0 64410.49 11206517.411851741 4 2013 .05821918 0 79104 14594676.742348071 4 2014 .05825243 0 119126.19 26481277.906628065 4 2015 0 .0091743115 176931.8 29946995.67406721 5 2007 . . 157.76617 39.4415442669969 6 2004 . . 28066686 28066686.19154623 6 2005 0 0 5704382 5704381.338495776 6 2006 0 0 496491.9 496491.87314146105 6 2007 0 0 9421.785 9421.785319502253 6 2008 0 0 1577.368 394.3420099042942 6 2009 0 0 5520.829 1380.2071011962253 7 2007 . . 35459.79 35459.78814655074 7 2008 0 0 42076.49 42076.49109553711 7 2009 0 0 381988.5 381988.536163157 7 2010 0 0 1804061.4 451015.3511721381 7 2011 0 0 270585.6 270585.60116440145 7 2012 0 0 1318229 329557.26253078564 7 2013 0 0 1220001.8 305000.4474947418 7 2014 0 0 693862.8 173465.68589452517 7 2015 0 0 31625.557 31625.55690904084 8 2004 . . 11277370 1499855855.865098 8 2005 0 .03007519 18729456 1689540069.7170644 8 2006 0 .1627907 18472182 1598121054.119387 8 2007 0 .0462963 32214094 1656992400.409758 8 2008 0 .03883495 36879372 2142910992.52344 8 2009 0 .1010101 34457748 2201020370.9059067 8 2010 0 .0786517 35879268 2181284539.324025 8 2011 .024390243 0 32816464 2029940306.3960855 8 2012 .11904762 0 27333772 2225894374.1270456 8 2013 .05319149 0 46580236 2727305730.021949 8 2014 0 0 33949468 2359259573.3842134 8 2015 0 .05050505 29031148 2370530389.480409 9 2004 . . 300541632 9917874207.75519 9 2005 0 0 398063520 10607521709.816193 9 2006 0 .03030303 711789248 11125455014.939121 9 2007 0 0 485468992 10999908825.891459 9 2008 .0625 0 471612384 11020835162.138296 9 2009 0 0 619878528 11052308521.725805 9 2010 0 0 775569536 11844314656.874342 9 2011 0 0 471647968 12248782762.78322 9 2012 0 .029411765 423355936 12198970579.756456 9 2013 0 .0909091 670351680 11978041077.652853 9 2014 .1 0 574183808 13100594403.908373 9 2015 .03030303 0 532608064 16695333854.076557 10 2004 . . 10196.007 20392.013641854945 11 2008 . . 830263.1 1020956.3147491836 11 2009 0 0 1215518.4 2431036.790986024 11 2010 0 0 302000.13 514778.3255435499 11 2011 0 0 133911.64 66955.82008718849 11 2012 0 .5 1857.2793 1857.2792628005145 11 2013 0 0 229202.33 57300.58370722538 11 2014 0 0 124664.38 31166.09542619379 12 2012 . . 5597.375 1399.3437130821144 12 2013 0 0 46875.85 46875.852646417305 12 2014 0 0 92413.03 92413.03425338621 12 2015 0 0 120786.42 120786.41920184325 13 2004 . . 3551802 3551802.0606248565 13 2005 0 0 5632205 5632204.502071029 13 2006 1 0 3682722 6445605.7851592805 13 2007 0 0 11139598 5607216.736637451 end
What I am trying to do is multiple imputation after having reshaped wide. Having discovered the need to declare xtset, clear before mi-setting in the forum I produced the following code:
Code:
xtset, clear mi set mlong drop data_lancio_molecola inflow outflow internationalproduct molecule mi reshape wide inflow_ratio outflow_ratio nprod avsales avsales_existing avsales_new agefirm tot_sales recalled_dummy_byfirm newmolfirm newmolmarket, i(idfirm) j(Year) mi register imputed inflow_ratio* outflow_ratio* agefirm* mi impute chained (logit) inflow_ratio* (regress) outflow_ratio* (regress) agefirm*(regress) = avsales* tot_sales* newmolfirm* newmolmarket*, add(10) rseed (091107)
Code:
at least one imputation variable required: (method ...) ivar(s) -- above applies to specification (regress ) mi impute chained: invalid specification; see above error messages
Federico
Comment