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

can't delete a post?

$
0
0
wish I could delete a post that seems rather silly now with more understanding.

Setting up data for competing risk analysis

$
0
0
Hello,

So I used a cox proportional regression model and I am pretty sure the assumptions have been violated mainly due to my Kaplan Meier curve showing a protective effect for the curve with the lowest survival. I researched STATA's stcrreg command which will probably work for me. However, I do not see any information on how to set-up the data first. For example, my data as death and transplant and the competing events but these are two separate variables as shown in my data example below. Do I recode death=2 if a patient had transplant? Or better yet, how do I know which variable is the competing risk variable. Thank you in advance.



----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id str1(transplant cancer) float(died time)
 1 "Y" "N" 1 2.3
 2 "Y" "Y" 1 4.8
 3 "Y" "N" 0   7
 4 "N" "N" 1 3.3
 5 "Y" "Y" 0   7
 6 "N" "Y" 1 2.8
 7 "Y" "N" 1 2.2
 8 "Y" "Y" 0   5
 9 "N" "Y" 1 2.5
10 "N" "N" 0   5
end

Group mean and separating data into 3 groups

$
0
0
Hi, I have a large set of data sets and multiple variables. I want to do the following:

1. First I want to divide my variables into three groups (pre, post and between) based on year. For example, If the year is less than in 1990 it is pre_period. If the year is more than in 1995 it is post_period and if the year is between 1990 and 1995 then this group is "between". I don't know how to do that in STATA.

2. I want to find mean difference of many variables such as ROA, ROE, TA, CASH, R&D, CAPX and many others variables between pre and post period. I can do ttest for each variable separately but is there any way I can do them all together and find the mean difference in one table? There is another problem. Since I have three groups of data in my data set how can I do that pre post difference?

3. I want to get the output of mean difference in an excel table with significant result. Can I do that with Outreg2? if so,
how is that?

Can anyone please help me?

calculating the growth rate of a phenomenon from its columns

$
0
0
I'm trying to calculate the transmission rate of the virus by country as new column variables. I want to subtract the first reported number of cases (in the total_cases column) from the latest number of cases (in the total_cases column) and divide the answer by the number of days that have passed since the first case was reported by that country. I also want to calculate the first 15 days growth rate of the virus by subtracting the first reported cases from the number of total cases on the 15th day divided by 15. The new variables to be named fifteen_day_rate and average_rate.
I appreciate any help.


. dataex

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str10 date str32 location int(new_cases new_deaths) long total_cases int total_deaths
"12/31/2019" "Afghanistan"  0 0  0 0
"1/1/2020"   "Afghanistan"  0 0  0 0
"1/2/2020"   "Afghanistan"  0 0  0 0
"1/3/2020"   "Afghanistan"  0 0  0 0
"1/4/2020"   "Afghanistan"  0 0  0 0
"1/5/2020"   "Afghanistan"  0 0  0 0
"1/6/2020"   "Afghanistan"  0 0  0 0
"1/7/2020"   "Afghanistan"  0 0  0 0
"1/8/2020"   "Afghanistan"  0 0  0 0
"1/9/2020"   "Afghanistan"  0 0  0 0
"1/10/2020"  "Afghanistan"  0 0  0 0
"1/11/2020"  "Afghanistan"  0 0  0 0
"1/12/2020"  "Afghanistan"  0 0  0 0
"1/13/2020"  "Afghanistan"  0 0  0 0
"1/14/2020"  "Afghanistan"  0 0  0 0
"1/15/2020"  "Afghanistan"  0 0  0 0
"1/16/2020"  "Afghanistan"  0 0  0 0
"1/17/2020"  "Afghanistan"  0 0  0 0
"1/18/2020"  "Afghanistan"  0 0  0 0
"1/19/2020"  "Afghanistan"  0 0  0 0
"1/20/2020"  "Afghanistan"  0 0  0 0
"1/21/2020"  "Afghanistan"  0 0  0 0
"1/22/2020"  "Afghanistan"  0 0  0 0
"1/23/2020"  "Afghanistan"  0 0  0 0
"1/24/2020"  "Afghanistan"  0 0  0 0
"1/25/2020"  "Afghanistan"  0 0  0 0
"1/26/2020"  "Afghanistan"  0 0  0 0
"1/27/2020"  "Afghanistan"  0 0  0 0
"1/28/2020"  "Afghanistan"  0 0  0 0
"1/29/2020"  "Afghanistan"  0 0  0 0
"1/30/2020"  "Afghanistan"  0 0  0 0
"1/31/2020"  "Afghanistan"  0 0  0 0
"2/1/2020"   "Afghanistan"  0 0  0 0
"2/2/2020"   "Afghanistan"  0 0  0 0
"2/3/2020"   "Afghanistan"  0 0  0 0
"2/4/2020"   "Afghanistan"  0 0  0 0
"2/5/2020"   "Afghanistan"  0 0  0 0
"2/6/2020"   "Afghanistan"  0 0  0 0
"2/7/2020"   "Afghanistan"  0 0  0 0
"2/8/2020"   "Afghanistan"  0 0  0 0
"2/9/2020"   "Afghanistan"  0 0  0 0
"2/10/2020"  "Afghanistan"  0 0  0 0
"2/11/2020"  "Afghanistan"  0 0  0 0
"2/12/2020"  "Afghanistan"  0 0  0 0
"2/13/2020"  "Afghanistan"  0 0  0 0
"2/14/2020"  "Afghanistan"  0 0  0 0
"2/15/2020"  "Afghanistan"  0 0  0 0
"2/16/2020"  "Afghanistan"  0 0  0 0
"2/17/2020"  "Afghanistan"  0 0  0 0
"2/18/2020"  "Afghanistan"  0 0  0 0
"2/19/2020"  "Afghanistan"  0 0  0 0
"2/20/2020"  "Afghanistan"  0 0  0 0
"2/21/2020"  "Afghanistan"  0 0  0 0
"2/22/2020"  "Afghanistan"  0 0  0 0
"2/23/2020"  "Afghanistan"  0 0  0 0
"2/24/2020"  "Afghanistan"  0 0  0 0
"2/25/2020"  "Afghanistan"  1 0  1 0
"2/26/2020"  "Afghanistan"  0 0  1 0
"2/27/2020"  "Afghanistan"  0 0  1 0
"2/28/2020"  "Afghanistan"  0 0  1 0
"2/29/2020"  "Afghanistan"  0 0  1 0
"3/1/2020"   "Afghanistan"  0 0  1 0
"3/2/2020"   "Afghanistan"  0 0  1 0
"3/8/2020"   "Afghanistan"  3 0  4 0
"3/11/2020"  "Afghanistan"  3 0  7 0
"3/15/2020"  "Afghanistan"  3 0 10 0
"3/16/2020"  "Afghanistan"  6 0 16 0
"3/17/2020"  "Afghanistan"  5 0 21 0
"3/18/2020"  "Afghanistan"  1 0 22 0
"3/19/2020"  "Afghanistan"  0 0 22 0
"3/20/2020"  "Afghanistan"  0 0 22 0
"3/21/2020"  "Afghanistan"  2 0 24 0
"3/9/2020"   "Albania"      2 0  2 0
"3/10/2020"  "Albania"      4 0  6 0
"3/11/2020"  "Albania"      4 0 10 0
"3/12/2020"  "Albania"      1 1 11 1
"3/13/2020"  "Albania"     12 0 23 1
"3/14/2020"  "Albania"     10 0 33 1
"3/15/2020"  "Albania"      5 0 38 1
"3/16/2020"  "Albania"      4 0 42 1
"3/17/2020"  "Albania"      9 0 51 1
"3/18/2020"  "Albania"      4 0 55 1
"3/19/2020"  "Albania"      4 1 59 2
"3/20/2020"  "Albania"     11 0 70 2
"3/21/2020"  "Albania"      0 0 70 2
"12/31/2019" "Algeria"      0 0  0 0
"1/1/2020"   "Algeria"      0 0  0 0
"1/2/2020"   "Algeria"      0 0  0 0
"1/3/2020"   "Algeria"      0 0  0 0
"1/4/2020"   "Algeria"      0 0  0 0
"1/5/2020"   "Algeria"      0 0  0 0
"1/6/2020"   "Algeria"      0 0  0 0
"1/7/2020"   "Algeria"      0 0  0 0
"1/8/2020"   "Algeria"      0 0  0 0
"1/9/2020"   "Algeria"      0 0  0 0
"1/10/2020"  "Algeria"      0 0  0 0
"1/11/2020"  "Algeria"      0 0  0 0
"1/12/2020"  "Algeria"      0 0  0 0
"1/13/2020"  "Algeria"      0 0  0 0
"1/14/2020"  "Algeria"      0 0  0 0
end

IRA syntax

$
0
0
halo everyone, if I want to adjust the null distribution to perform rWG (interrater agreement).
I have installed ira module and in the help menu, the syntax is:
ira judge_id rating [if] [in] [, item(item_id) group(group_id) options(#) distribution(#)]

question: what # in the option distribution(#) means? Is it the correct option to change the null distribution?

many thanks.
Andy

problem with reshape, always show that "variable demacity-2001 implied name too long"

$
0
0
I have tried many times without success with "reshape long demacity- demanation, i(citycode_s ) j(year)"
It always show that "variable demacity-2001 implied name too long",why
many thanks for kindly guys.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(citycode_s demacity2001 demacity2005 demacity2010 undemacity2001 undemacity2005 undemacity2010 demanation2001 demanation2005 demanation2010)
1100    .02000062486995376   .023090715008419284   .15928207577014655   -.007811453489032042   -.01358161624039658   -.13161947652104344    .2731945083666961  -.05749517095397304  -.10393346104293384
1200  -.029857292390218945     .0757122451955909  -.05744057014209189    .007104473758962886  -.025690480700915157   .029042912691038456   2.7500534257666436   -.7075350428603924   1.7947110727435598
1301    .08379923726205893  .0008584498362568188   .08075491764893876    -.04868597927287028   .011072762047219041   -.05762105287691779   -.5271144885258346    .9964305939443858  -.49038291795365513
1302   -.05057238284012947     .2860610289675229  .012871507155237267    .007662728374994464   -.06010311138492896 -.0032140161871804934   -.5094631375149119    .8426107942848683   -.3049178568955304
1303   -.10805056916984486     .2010230105290625   .12276622935587785   -.012875115884429278  -.055846519637822584  -.017777704865286327   -.6153040296507275    1.192276674260052  -.20292503217799773
1304    1.0127051573458776     .6897040121830953  -.11805662148488354    -.19834821180920859   -.10663056566220698    .06480792031341477    .9114140105940657    .3009844979384577   -.3969816918598409
1305    -.1089480666293561    .17782920261076351   .39054458292417593    .006339195570080058  -.028826861200505913  -.052238071036653996   -.6407826921559593   1.5863971488505237   -.3324247218088402
1306     .1463818341662537    .08170956337788184    .0983672775747338   -.027846625099879285  -.022769472341683715  -.014407733413532802   -.4801019148340075    .8854113183399331    -.487791307264141
1307   -.13275622958008262    .34299327768232696   .08552504171343879  -.0006103804855940101    .07408745619352258   -.07337867040522193   -.6605236976366567   1.0582170399564363  -.45490648002667977
1308     .6028291126545572   -.10197759122351742  -.07275508054786738     -.1089917171148209   .032284431496008965    .05357939784526251  -.41604836393040295   1.1903085269131424   -.4263311144998655
1309    .23040351300308498   -.06469723236414318  .015417966573802733    -.03655705572778736   .017425662190456864   -.01535289098941449   -.3852103875457466    .6303422743210922    -.283054498361367
1310   -.19014470987938345     .2254634187931466   .08291521902945098    .031079894575829128    -.0823723257682709   .006892191125993297    -.480214153209058    .5456884961920154   -.1877219135195837
1401    .06332764950483495    .04823396078272028   .09302314701254047   -.030193777708176633   -.01936035858571311  -.051869660478807776    .2459513902482437   -.2614138150248429    .4351273177227912
1402   -.16469638054229332    .05777308835209067  -.10796339766057107     .03980617462911336  -.020508903068674453    .04928288650020114   .03392662158540894   -.2900423210530056   .41537771328098677
1403   -.18927436942142825     .3404697191692713  -.08361446231230849    .024317601774671536   -.02265561507563996  -.017766128535631455    .4894345761700162   -.2816525467822523    .6563927512745429
1404    .06257041042671134  -.024577715431320608  .027780337173617487    -.03547596559005393   .039665750879058125    -.0513525300767189    .7143955438345188   -.5270975772518475    .6542486954053927
1405    -.2447449545002999   -.03496157643488668    .3759893054888391   -.002333005151237182  -.019567134844391168   -.03793047250632008 .0021997660446852227   -.3325045551976134    .7140737720400079
1406   -.02912668865014354  -.038292930018651625   -.1314376966766063    -.06160053894975707   .014918722620416101    .03717876492869631   .22281977367643316   -.3105990636907059    .5301582591112575
1407   -.11106055510610552     .2013641304293923    .2695498888562964    .016126249190736366   -.06323166258448472   .015594248657109209   .15323742063742474   -.3717720854757584   .45134868327540706
1408   -.49046797311184887     .6549268242532842  .011798155055265852     .09845400495635476   -.08811968856441989    .09674802910663663   .41475732314808933  -.17396435485054243    .3303880283549835
1409     .3287634096278223   .025747180893750287   -.2118888786909988     -.1300388316977393    .12038113913610876  -.055641519920471845    .7593818036122241  -.32730096602968983    .4790742957533397
1411                     .   -.13214772081649737  -.17641662907007089                      .    .07288802847062417  -.022934713635326162                    .   -.5481088191591308    .5373633479207026
1501    .24640312470462108   -.12846823224012793   .13660745797989188    -.08498542062359689    .11081292346980788   -.07770250872468763  -.09308642569826255    .3386330808173969  -.11258528409766606
1502   .003969113248555849   -.07895344838147532   .08038938033733577   -.020656306555963923    .03326024995950997  -.039006850930543534   -.2761860240917961   .07847218893970348  -.08752965884094414
1503   -.12265429051051646    .15668286320418326  -.16099271755879288   .0018218215440762105  -.008293004121887038   .012938431045943574   1.3265068107596958    -.536140140324272    .4082990906831613
1504  -.016737408932530836    .22813393319365652  -.01361327419696991  -.0040749180009604065   -.05138895783370083   -.02277782555872861  -.36150588154547525    .9776260056096328  .050757039384248595
1505   -.03002695505063177  .0030225885008276633    .2821496228081745   -.009524185344978791    .09946221765307796   -.12136044410979996   -.4369031461529181    .7945000714523308  -.05747124599053546
1506                     .     .2417107512832506   .13994244174390238                      .   -.03564756612717116   -.00790221231557155                    .   .04816960924265347  -.02805439105703836
1509                     .      .365013670326878   .29621724581358516                      .     .0098322763983141    .01975949276165857                    .    .5754695326010927    .1974970129917892
2101  -.023852196510928503     .0796049096022071  .026178530671900128   -.010186592468363566  -.031247841227885747  -.012084952499734177  -.46397108164770534     .910016470897233   -.4443059706329732
2102   .014388965962260771    .09145044018174121   .19535316420168938   -.003771755553487748  -.028149298778051175   -.07323132999139993    -.431124839688414    .8769877037429831  -.38419065901197297
2103    .03292689119364516   -.08771394721249692   .22437747260224092   -.011621866241850269   .023308162449770617  -.056114741240059426   -.5140413181557176    .4796070633972433  -.22025790229529926
2104   -.18616513545918895    .22551836491547234   .13924913604197156    .027154716879579065   -.05265201490421154  -.026387723782833154   -.4657723983574488   .49621857104851197  -.20002918640799947
2105    -.1021878313331809    .06386954367626249 .0014725571335946657     -.0381969176559848  -.007409196345982473   .049700169721013605  -.32930541790728074    .3008858284625292   .05978269683731181
2106    .02434617411828321   -.04599561501232747   .01735679717803693    -.03267664304140271   .008282449440853108   .013889997055183163  -.46229623345714993    .6256029761056285   -.4019595211044486
2107   -.11212179123138878     .3047075886277251    -.139809110154912    .013325882409500795   -.07168878053503877    .06715669004963844  -.45722599761068966    .7390600978911651  -.32798777552513353
2108   -.17800747614175777    .15619224143509292   .38394205469210313     .02178935166316849  -.035207081698889635   -.08685297152664116  -.36877451181571896    .7579123924121555    .5704885571823397
2109   -.05953471027304244   .029054404682033064  .021368489737360687     .01608131038354683  -.024882511251539684     .1174527582297899   -.4919466401132136    .7738790502037809  -.06696628590965642
2110    .28622539667535785 -.0028728584361676635  -.15976459220356176    -.08582617767911056   .013278554438692296     .1648198503609378   -.1891062015724112    .3532003051451768   -.1449088898187056
2111  -.026635754081090857    .09455751542993697   .07961464652059536     -.0677101959679056  -.012031390769678208  .0006020461096410201   -.5161371323023927    .6685476810143841    .3815810139362312
2112    .01365135483594127   .013595549505164835  -.08011731574265621   -.026952333328037172    .06698113460429632   .002014965454465477   -.4049957647542227 -.043677564037547016  -.24084408623557615
2113   -.10129918264412731    .40230054642363977   .03558085540574327    .002660020566162484   -.06131573970079322   -.01305182501061676  -.34560065047355165   .43238588740955386    .0912806979803286
2114    .10851907743047504   -.07607394811284172   .05124748682224789   -.026263533742509983    .04567529462884368   -.03007448259534306   -.3374341514557037   .14346406760685707   -.2563057327231472
2201  -.040374233222148954    .14386607620960395  .035804665089239754    .002714131328068477   -.05179821638474201  -.016348439074155063  -.08760509063786867   .03330272463689317   -.5029532858924307
2202 -.0008199985103199556    .13330159386023246 -.014227815537770416   -.015854016144129703   -.02871045260660285  -.002784747272075651   -.2798629238072778   .04356186646986495  -.10295418202599456
2203    .04647958133990826    .08530190925195442  -.04298607358593925   -.018163779645779456  -.017614895925296793   .026035543645069728   -.1511160668010967 -.020810258583382535  -.01841251747363501
2204    -.3684523595789661      .591547994368435  -.06349383622110898   -.010143325007438917   -.05516496727476225   -.11736764376060568   -.2860656792734472  -.08830665159708198  -.20228484536109634
2205    .20337366379260813    -.1533457597094319   .05512275639975051    -.06267827951804214    .05538608909708833 -.0026396243510680138   .22095584347358546  -.33806398885895356   .44752032479281767
2206    .45563031739502324   -.16395732783191733   .03498332957091162    -.01985161087725188  -.035204020631139164    .03567745825379889   .21033450790073605    .0784226548851563    .4493345523982871
2207    .01126385809312642      .360008738886133  -.08821967654986526     .14011102199996855    -.0583399585686048   -.08410764647467726  .025443907820402258  -.22166442372419917    .7977370242712852
2208     .3837342312742769     .0983921767062746   -.1403550196167396   -.051013919859150644  -.015281615909729424    .23035859925623245    .7703235392136536   -.3694294205895156  -.20631664267560318
2301   .005880048755031179    .17906727749706475  -.07014156015554772  -.0032679529345921777   -.06524409310836453    .05038338295579387  -.40024325597001825    .7701140473004172   -.6181689514936972
2302   -.08943950845977462    .25134428176203777  -.11325595664699953   .0024790378452850216   -.04848560568330887   .045399519611229545  -.17620366889340752  -.19718438998371074  -.25719825370844845
2303   -.06551366808092307    .05376500107786548  -.04343372232645137    -.04163998481955011  -.016770748455276364     .0746419838482522  -.14741502646652999  -.24521260077707258    .0317715221742327
2304     .0869888860842808   .027288954736153302 -.030865739597797034    -.05213448752511255  -.004610247340200304   .022245006215142325    .1341988787526551  -.12774395965801108   .10309133700034197
2305   -.07291531473069432      .233371454107629  -.05017389430881374   -.005056475655747683   -.08301324064586176    .10005159881778616  -.19308846269177252  -.06609428333304135    .2700233911120168
2306    .11440109725258242   -.02332868349009426 -.046430673396143374   -.020865712743575324 -.0032944751392112045    .07350121200587202  -.43118942142727007    .6931122975044177  -.19149300661950508
2307   .046251972178555284   -.01009868547250704   .03356978511717251  -.0006574783492192987  .0031037438728984223   -.05014692467760721  -.45540420563678136   .14054716520180602    .3223910413660489
2308  -.037963257556199274   .011316038771136508 -.012889988331555417    -.01441770821303001   .014556430499079951  .0016092658812391855   -.1667215928055924  -.10848979049943064   .16331940365587347
2309   -.36947967065614123     .4308390022675736   .06120618426956455     -.0107559403559403  -.009648347527987593  -.006129794213887013   -.6358244405632375   1.0616379809594174    .3946644357361214
2310    -.2827885671328633    .39809337190453786   .08579988955503563     .08847364636483596   -.05564489596428286   -.06020944005330608   -.4244398020665905    .4246557136177981 -.024556189273154484
2311   -.14712653830300884    .15662728170896423    .2300686501863787   -.004593578039748948  .0053237639219203626   -.10609741761997399    -.215630689182538  -.21491292791663955    .5691675724465737
2312    -.1492659315112817    .36201630279951075   -.1986124367089803   .0006356266378452751   -.04492315671435353    .05358886635944154  -.20776682404606697   .38604965527758744   -.5882135443162779
3100    .07809279283536497    .08221004088840918    .2007113581682032   -.017725876752115188  -.028467508281515265    -.1066073914932847     1.01231707145744   -.3420479531021163    .7416671181774634
3201    .11224700586660916    .09646884489742723   .06537199926340369   -.030302072365636014  -.043270203855681665  -.033703570179184024  -.28474031624017354   1.0784595758365076   -.3055566697051208
3202   -.09151753061685214   .025112067238156562   .13090865025406442   .0012559281666755053  -.005551088547381942   -.04012272943311551   -.4932579810681468    1.800877196742817   -.4205197434195724
3203   -.07645803039860734     .2881304562940337  .024720449670016388 -.00048181925437554247  -.044243946164686104 -.0016498417255543458  -.47479596011006653   1.0540804002706152  -.43883896302702485
3204    .15570676309712828 -.0033864798354466363    .2157626479996092    -.02748099334059942  -.003961391195696417   -.06342411733856063  -.24171297891406038    .5866767309871647   -.2312660451533521
3205   .016600518099218604    .17005783951538678   .06009994471375663    -.00889205461131339   -.02675999546101847  -.021841037126642756   -.3707573669598044    2.016750157933332   -.5446682953879288
3206    .03688614672975652    .19113557159673875  .050729215198249175   -.008078262512474677    -.0353877747524597  -.009792745205105114   -.4242029811720421   1.0029277790578692  -.42475987603310994
3207   -.11166234597394017   -.10550727054028068   .11072095827706178    .029654741321624937   .035372021526281876   -.03463310187471895   -.5943543979897187   1.5447203832819665 -.028600764826229735
3208   -.18661681650257192    .23383333205589335   .12829380855336395    .030272517503922663   -.03890617235180688    .01973746204936653  -.23750906177341363    .9086079350083498   -.2672464323770287
3209   -.03140157002986028    .21451604054360648   .11547667683804826   -.011773010540158113   -.06597289381004087   .050314262962637066   -.4887300971416917   1.0633022113552537  -.38321307073574196
3210   -.04552137867202128    .10284149219129057   .08366324664658253   .0015296927631849916  -.021431579466192775   .005459119036306447  -.45065614749353483    .8196492143585014  -.22001765399703646
3211    -.1161565569230396    .36062902042340367   .06553666535492018      .0326949613910514  -.056901315416588834  -.033928031586189886   -.5528171096730713   1.5624453143935055  .009198152258380037
3212     .1315574979807891    -.1299911855262449   .31028838070639514   -.024563259209614524    .02829296512394182   .015678782367924003   -.5464093922022403   1.0018073980571107   -.1168437320074287
3213   -.14796296296296285    .12359980223973638    .3214203521283588     .04500354551900948   -.08648463411129348  .0033109526984537105   -.4134710268225992   2.0605488558145377  -.06085308762022189
3301    .15853745039360667     .0798215620259606   .15051725077075895    -.04270147192685208   -.02612911939124458   -.07296919310511711    -.379774020337235   1.1435207359950195    -.411601520580462
3302   -.15236550572832458     .2688478988241093    .2344290168868603     .01324369615461344  -.034585686790110225   -.06545401569508472   -.0976557475141692    .7692517167422326  -.42113039155939724
3303   -.07904560204312956   -.12438613387654163   .41653945855022195   -.009381510167915058   .008486888218488479   -.05729654428495266  -.37293518406120013    1.221978499212342   -.3241805994138636
3304   -.47731202506266146     1.481259192334287  -.04866213257270795     .02131702744797536   -.07086081661134311   .031234368754565416   -.5038995192036884   2.7319691949807012  -.24765317138130483
3305    -.5529666773874632     .6499457677548337    .7590956218060065     .08363860067076254   -.02890450154526661   -.10623284000594939    -.471965928167877    .6579219585501799    .1530901686418902
3306    -.1380239059107851     .8450819011235894 -.046613775396677264   -.007253289648917072   -.07318132417441903    .01795533914014305  -.38610629532238144    1.264074145497094  -.15896165611592045
3307   -.03744781127956727    .40398119554011847  .011788285742606562  -.0055877498389332895   -.03827345280379941  -.003675270392434649  -.31783876557815177   1.2577549091640674   -.3206752958326537
3308  -.016816691400689615    .12640784109791814  -.17365915708040927   -.015911779735460752   -.03871381166187329    .07202434946012434   -.5337410143980297   1.5176758394527399   .03284577163043404
3309  -.018415619295151484   -.05152716094214396  .038948397295259916   -.032309428985245574   .033034628752860035    .04254398477861629   -.3378841179609802     .638790134735182    .1530888288177572
3310     .1624869341902601     .3364068668532811   .10577206158448169   -.023323857445409792   -.03266808901695987  -.025036836441388044   -.3674565680831082   1.1308137301999581   -.4153568076625816
3311   -.25925230619301265     .3813631052057739  -.07475966049143305    .020790307759399405    -.1308275816387992    .06537379446820472   -.3923822634106867    1.682023545667085 -.060413568665745196
3401   -.20728335480852228    .13853780920525285  .048176011652270576     .02546539389371965  -.046802365904316946  -.023627059300970657  -.46026761720671094   1.2164949806047056   -.3265011039203393
3402     .3771713634054329   -.21839307268399338  .044513474668263664    -.09260399406814425    .07781879118407614  -.028307256590414054   .06663208616044577   .28194886993059864   .03713094461285684
3403   -.09026691142775473    .05274145036396479   .08639204076344353     .01735470363330154   -.02604170704044735   .012110822928997704   -.5910955797346592     .740414053552357  -.15575149387405307
3404    -.3115784463089991     .6725443001024841  -.16585852657554537    .008594449809501395   -.05906665714188387    .06768344976046801   -.5669766557253744    .7900702827374111   -.1511878578296826
3405    -.3918425193206534     .7519031941315774   .03768728831540035    .030489980383687824    -.0950646313327644   -.02063943356299323   -.7084876584290236   1.4225055255626027   .47769874163144604
3406   -.11269906025943877     .3033926072039465  .019337939722094254    -.01734627391285347   -.08144496880907337   -.06129298508972363   -.4147945425578703    .5450145369397685     .505951589496288
3407    .09903291204509365  -.041205660252821304  -.07575845299305328   -.038147172708198764     .0317623857104059    .10313158535355896   -.2212708981866046   .02613188635722894    .7249935836946187
3408     .2597801876122031  -.003818312830519474  .024425212680899193   -.033639546787281656   .003186661392083842  -.016955464163133496   -.4097165655849221    .8887904281885273   .39444317347672914
3410    .04495335029686175   -.19894282550557846   .16120597899023548    -.13749453825789698     .1450472641066012   -.13035279642656547  -.37644760326655063    .5946424627798256    1.403302432234995
3411    -.3065340436222492     .9583321319465054  -.11496614644978234    .021784563566518013   -.15400672424399023    .05456068707773957   -.5882293725591072    1.749528765910974  -.21172660584030753
3412   .012434768714326284    .19789026745243005   .28980151077528027   -.017217457513584767   -.03721161359690956    .08778367084357096   -.3117363146336762   .06014537415730524  -.27851275363058353
3413   -.10209399685083584     .2000166719176644   .11583530945348146    .009909579326912854   -.07409323305518961     .3903262857531627   -.4976199325464344    1.409217045885116   -.1796418958668094
end

Simulteneously executing multiple do files

$
0
0
Suppose I have three do files with following commands in them
File diX.do : di "X"
File diY.do : di "Y"
File diZ.do : di "Z"
How do I execute them simultaneously in separate instances of Stata?
I created a do file as follows
do diX.do
do diY.do
do diZ.do
but it executes them in a single instance one after another.
I looked into package parallel but could not find the install package, I looked into multishell package which seemed to be geared toward running simulations, I looked into batch processing but that requires entering commands separately. I tried winexec command but that simply open the do file but does not execute it. What am I missing? I am sure there is a way.

Store Coefficient after loop regressions

$
0
0
Dear all,

For our master paper, we need to replicate the Fama and French three factor model. We started with the one factor model to try the different regressions. We are struggling to do certain regressions and afterwards extract the different coefficients.
At the moment, we have 520 variables. We have one dependent variable: MktRF (Fama and French one factor model) and 519 independent variables (companies) with the daily excess returns over 20 years.
We were able to do our loop regression (for our 519 firms: from the variable SOLVAY to ADDECOGROUP), by executing the following command:

foreach x of varlist SOLVAY-ADDECOGROUP{
regress `x' MktRF
}

The problem now is that we need to list all the coefficients of MktRF and _cons and generate these coefficients as 2 different variables called ‘coefficientMktRF’ and ‘coefficient_cons’.

We were able to use the Statsby command, but this command only lists the two coefficients of our last regression (our last firm) and not of our 519 regressions.

Is there anyone who can help us to proceed our master thesis?

SIR Model

$
0
0
Hi everyone!! Is there any way to fit SIR Models in Stata?

How do i open one of these .dat files?

define constraints for baseoutcome in mlogit

$
0
0
I want to estimate a mlogit model
Code:
mlogit depvar ibn.fvar1 othervars
there are categories in my factor variable fvar1 that do not occur for certain alternatives in depvar.
if i
Code:
tab depvar fvar1
Alt1 Alt2 Alt3 Alt4
Group1 100 80 0 0
Group2 0 50 40 0
Group3 0 0 60 40
I wrote now a script to define constraints for the deterministic outcomes. In this example they would give

Code:
constraint define 1 [Alt1]2.group = -99999
constraint define 2 [Alt1]3.group = -99999
constraint define 3 [Alt2]3.group = -99999
constraint define 4 [Alt3]1.group = -99999
constraint define 5 [Alt4]1.group = -99999
constraint define 6 [Alt4]2.group = -99999
when i estimate the model now with
Code:
mlogit depvar ibn.fvar othervariables, constraint(1/6)
then the constraints are correctly applied, however the constraints defined to the base-outcome are ignored and are set to 0 by stata automatically.
so it adds the constraint
Code:
constraint define 1997 [Alt2]1o.group = 0
constraint define 1998 [Alt2]2o.group = 0
constraint define 1999 [Alt2]3o.group = 0
but in the end ignores my constraint numer 3 (constraint define 3 [Alt2]3.group = -99999)

and estimates the model internally with constraints 1 2 4/6 1997/1999

I got estimates for the coefficients.
Stata returns for example coefficients like 20 and 19 for group3 in the equations for Alt3 and Alt4 (and uses 0 for Alt2 internally), so that the prediction results in reasonable values (10E-6 probability for Alt2 and 0.6 and 0.4 for Alt3 and Alt4). but the standard errors and z-values for the coefficients are not useful.

I could define another baseoutcome with
Code:
mlogit ibn.fvar othervariables, constraint(1/6) baseoutcome(1)
but that does not help, because in my dataset for all alternatives there is at least one "0" in the table above.

Is it somehoe possible not to define a baseoutcome at all for mlogit (or other similar commands) and to define all constraints for the baseoutcome manually?
So in this case:
keep the -99999 as a constraint for [Alt2]1.group
and define manually a different baseoutcome for group 3 (taking Alt3 instead of Alt2)
So using the following constraints:

Code:
constraint define 1 [Alt1]2.group = -99999
constraint define 2 [Alt1]3.group = -99999
constraint define 3 [Alt2]3.group = -99999
constraint define 4 [Alt3]1.group = -99999
constraint define 5 [Alt4]1.group = -99999
constraint define 6 [Alt4]2.group = -99999
constraint define 1997 [Alt2]1o.group = 0
constraint define 1998 [Alt2]2o.group = 0
constraint define 1999 [Alt3]3o.group = 0
Any help and idea is apreciated,
I hope you all stay healthy these days,

Max

Cleaning data of Globar Entrepreneurship Monitor

$
0
0
Dear All,

I am currently dealing with cross-sectional studies derived from the Global Entrepreneurship Monitor (GEM) from 2004 to 2016. This study investigates the entrepreneurial activity across countries based on individual surveys. I am using a multi-level research design as I take the individual-level data from GEM and merge them with country-level factors such as corruption, the competitiveness of a country, etc. I investigate the country-level factors' impact on certain individual-level factors. My question relates to the cleaning phase.

After I selected my variables from GEM and appended the separate datasets from 2004 to 2016, I arrived at more than 2 million observations. In my initial dataset for the individual factors, I have around 16 variables and most of the observations are not complete, implying missing values. If I only keep the complete observations, I am left with approximately 9 000 observations. However, as I mentioned above, I would like to merge the individual-level data with country-level variables to obtain country-level effects. As a result of deleting the incomplete observations, some countries dropped out of certain years in the observations. For example, Germany is not presented in 2006 and 2007. Indeed, only a few countries (approx. 5) have complete data in all the examined years (2004-2016). This arose the question of whether I can still investigate differences between country despite the fact that not all the countries are completly presented in the dataset. Do you have anny suggestions how to overcome this issue?

This is the -datex- before dropping out the missing values:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(country yrsurv gemhhinc gemeduc omexport omnowjob gender age estbbuso knowenyy suskilyy frfailyy teayyopp teayynec eb_cust eb_tech eb_yytec eb_jobgr)
1 2016    33 1212 . . 2 63 0 0 1 1 0 0 . . -2 .
1 2016 68100 1316 . . 1 52 0 0 1 1 0 0 . . -2 .
1 2016  3467 1316 . . 2 64 0 0 0 0 0 0 . . -2 .
1 2016  3467 1316 6 2 2 70 1 0 0 0 0 0 2 3  0 0
1 2016  3467 1316 . . 1 -2 0 0 0 1 0 0 . . -2 .
end
label values country country
label def country 1 "United States", modify
label values gemhhinc GEMHHINC
label def GEMHHINC 33 "Lowest 33%tile", modify
label def GEMHHINC 3467 "Middle 33%tile", modify
label def GEMHHINC 68100 "Upper  33%tile", modify
label values gemeduc GEMEDUC
label def GEMEDUC 1212 "SECONDARY DEGREE", modify
label def GEMEDUC 1316 "POST SECONDARY", modify
label values omexport omexport
label def omexport 6 "10% or less", modify
label values omnowjob omnowjob
label values gender gender
label def gender 1 "Male", modify
label def gender 2 "Female", modify
label values age age
label def age -2 "Refused", modify
label values estbbuso ESTBBUSO
label def ESTBBUSO 0 "No", modify
label def ESTBBUSO 1 "Yes", modify
label values knowenyy KNOWENyy
label def KNOWENyy 0 "No", modify
label values suskilyy SUSKILyy
label def SUSKILyy 0 "No", modify
label def SUSKILyy 1 "Yes", modify
label values frfailyy FRFAILyy
label def FRFAILyy 0 "No", modify
label def FRFAILyy 1 "Yes", modify
label values teayyopp TEAyyOPP
label def TEAyyOPP 0 "No", modify
label values teayynec TEAyyNEC
label def TEAyyNEC 0 "No", modify
label values eb_cust EB_CUST
label def EB_CUST 2 "Some", modify
label values eb_tech EB_TECH
label def EB_TECH 3 "No new technology (more than 5 years)", modify
label values eb_yytec EB_yyTEC
label def EB_yyTEC 0 "No/low technology sector", modify

This is the -datex- after dropping out the missing values:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(country yrsurv gemhhinc gemeduc omexport omnowjob gender age estbbuso knowenyy suskilyy frfailyy teayyopp teayynec eb_cust eb_tech eb_yytec eb_jobgr)
1 2016 68100 1212 6  1 2 36 1 0 1 0 1 0 3 3 0 0
1 2016 68100 1316 6  3 2 64 1 0 1 0 1 0 3 3 0 0
1 2016 68100 1316 6  0 2 59 1 1 1 0 1 0 2 3 0 0
1 2016  3467 1720 5  0 1 55 1 1 1 1 1 0 3 3 0 0
1 2016 68100 1316 6 24 1 66 1 1 1 0 1 0 3 3 0 6
end
label values country country
label def country 1 "United States", modify
label values gemhhinc GEMHHINC
label def GEMHHINC 3467 "Middle 33%tile", modify
label def GEMHHINC 68100 "Upper  33%tile", modify
label values gemeduc GEMEDUC
label def GEMEDUC 1212 "SECONDARY DEGREE", modify
label def GEMEDUC 1316 "POST SECONDARY", modify
label def GEMEDUC 1720 "GRAD EXP", modify
label values omexport omexport
label def omexport 5 "11 to 25%", modify
label def omexport 6 "10% or less", modify
label values omnowjob omnowjob
label values gender gender
label def gender 1 "Male", modify
label def gender 2 "Female", modify
label values age age
label values estbbuso ESTBBUSO
label def ESTBBUSO 1 "Yes", modify
label values knowenyy KNOWENyy
label def KNOWENyy 0 "No", modify
label def KNOWENyy 1 "Yes", modify
label values suskilyy SUSKILyy
label def SUSKILyy 1 "Yes", modify
label values frfailyy FRFAILyy
label def FRFAILyy 0 "No", modify
label def FRFAILyy 1 "Yes", modify
label values teayyopp TEAyyOPP
label def TEAyyOPP 1 "Yes", modify
label values teayynec TEAyyNEC
label def TEAyyNEC 0 "No", modify
label values eb_cust EB_CUST
label def EB_CUST 2 "Some", modify
label def EB_CUST 3 "None", modify
label values eb_tech EB_TECH
label def EB_TECH 3 "No new technology (more than 5 years)", modify
label values eb_yytec EB_yyTEC
label def EB_yyTEC 0 "No/low technology sector", modify

Thank you so much for your help and time!

Sample selection for a panel: struggling with panel bootstrap in the program

$
0
0
Dear Statalisters,

I am using Stata 15.1 and I would like to address the sample selection problem in a panel data set. The approach seems not complicated (as explained in the textbook of Wooldridge: Econometric Analysis of Cross Section and Panel Data. ch. 19. You can also check: Wooldridge, J. M. (1995), ‘‘Selection Corrections for Panel Data Models under Conditional Mean Independence Assumptions,’’ Journal of Econometrics 68, 115-132.).
Very briefly: I have some firms that innovate or not (y1=1 or y1=0), and those that innovate will report their sales from innovations (y2), and thus will show a missing for those firms reporting y1=0. For accounting for sample selection I must to do first a probit model for y1 with respect to the independent variables in the second stage plus some exclusion restrictions (for each year as Wooldridge advice) and then calculate the yearly inverse Mill`s ratios and include them into the second stage. Since these ratios are generated in a previous step, the standard error must to be corrected in the second stage. However, since I am working with a panel data, I cannot just put "bootstrap" before the regression, but to do it in a program.
After two days trying by my self, I cannot understand what am I doing wrong or even how to continue. I will show you the program I created following the guide of Professor Clyde Schechter in post #2:
HTML Code:
https://www.statalist.org/forums/forum/general-stata-discussion/general/1477399-boostrap-for-xtqreg
as well as a short example (dataex) for if it is helpful to see the kind of dataset I am working with.
From the program I need the table (with correction for the standard errors) from the second stage (do not know how to do it). And also to do some Wald tests for the IMR`year' to check if they are jointly zero (also do not know how to do it).
This is the process I want to implement in the program:
Code:
    forvalues year=2005/2015 {
    probit y1 main1 main2 x1 x2 x3 z1 z2 z3 if year==`year'    /* selection equation */
    predict acltxb1_`year' , xb
    predict acltpr1_`year', pr
    gen acltndenxb1_`year' = normalden(acltxb1_`year')
    gen acltnxb1_`year' = normprob(acltxb1_`year')
    gen acltlambda1`year' = acltndenxb1_`year' / acltnxb1_`year'
          }
 forvalues i = 2005/2015 {
          gen year`i' = year==`i'
          }

    forvalues i = 2005/2015 {
          generate IMR`i' = acltlambda1`i'*year`i'  /* generating IMR*time dumies */
          }
  
 xtreg y2 main1 main2 x1 x2 x3 i.year IMR2005-IMR2015 if y1==1, fe /*main equation */
test IMR2005 IMR2006 IMR2007 IMR2008 IMR2009 IMR2010 IMR2011 IMR2012 IMR2013 IMR2014 IMR2015
And this is what I try to build (of course it is wrong but do not know why)
Code:
xtset, clear
capture program drop xtq_diff
program define xtq_diff, rclass
    xtset id
    forvalues year=2005/2015 {
    probit y1 main1 main2 x1 x2 x3 z1 z2 z3 if year==`year'    /* selection equation */
    local predict acltxb1_`year' , xb
    local predict acltpr1_`year', pr
    local gen acltndenxb1_`year' = normalden(acltxb1_`year')
    local gen acltnxb1_`year' = normprob(acltxb1_`year')
    local gen IMR`year' = acltndenxb1_`year' / acltnxb1_`year'
          }
 xtreg y2 main1 main2 x1 x2 x3 i.year `IMR2005' `IMR2006' `IMR2007' `IMR2008' `IMR2009' `IMR2010' `IMR2011' `IMR2012' `IMR2013' `IMR2014' `IMR2015' if y1==1, fe /*main equation */
    return scalar diff = `IMR2005'-`IMR2006'-`IMR2007'-`IMR2008'
    exit
end

bootstrap diff = r(diff), reps(50) seed(10101) cluster(id) idcluster(newid): xtq_diff
After several tries with a more simple program, I realized that the condition
Code:
if y1==1
in the main equation is problematic (do not why). And also, the fact that the variable y2 present missings for when y1==0 is also problematic (the most simple program does not run, as it did without the missings).

Please, I am very sorry for posting this long post, any help will be much much appreciated.

Here you have a descriptive of the data (I just realize that for the dataex below, if you run the first code --what I want to implement-- will not run properly with such small amount of data)
Code:
    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
          y1 |    117,559    .4539168    .4978739          0          1
          y2 |     53,720    16.03345    27.13275          0        100
       main1 |    117,555    177.5277    3387.195          0   513079.3
       main2 |    117,555    978.8756    19434.76          0    5731453
          x1 |     83,642    .3838383    .4863222          0          1
-------------+---------------------------------------------------------
          x2 |    117,462    .0698244    .2497444          0          2
          x3 |    117,555    4.151557    1.718149          0   10.63367
          z1 |    117,559     .548206     .344792          0          1
          z2 |    117,559    .4623664    .3309483          0          1
          z3 |    117,559    .3635735    .2682159          0          1
-------------+---------------------------------------------------------
          id |    117,559    6243.006    3690.662          1      12844
        year |    117,559    2009.019    3.316198       2004       2015
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(id year) byte y1 double y2 byte x1 double(x3 x2) float(z1 z2 z3 main1 main2)
 1 2004 1   15 0 2.9444389791664403   .11628050303189412 .4444444        0        0         0         0
 1 2005 1   25 0  3.091042453358316   .11155810978566506 .1111111        0        0         0         0
 1 2006 1   30 0 3.1780538303479458    .2181349936661966 .1111111        0        0         0         0
 1 2007 1   25 0 3.1780538303479458   .06591904929668757 .1111111        0        0         0         0
 1 2008 1   25 0 3.2188758248682006   .08327321246305641 .1111111        0        0         0         0
 1 2009 1   25 0  3.258096538021482   .09046644551097324 .1111111        0        0         0         0
 1 2010 1   10 0  3.295836866004329   .20395702599256194        1 .3333333 .3333333         0         0
 1 2011 1   20 0  2.995732273553991   .31468851173081386        1 .6666666 .4166667         0         0
 1 2012 1   25 0  2.995732273553991     .694693505873705        1 .8333333 .4166667         0         0
 1 2013 1   33 0 2.9444389791664403   1.4777636434095467        1 .8333333 .1666667         0         0
 1 2014 1   70 0 2.6390573296152584    1.465341156936412        1 .6666666        0         0         0
 1 2015 1   40 0 2.5649493574615367   1.2855846532976578        1 .6666666        0         0         0
 2 2004 0    . . 2.3978952727983707                    0        1 .6666666 .8333333         0         0
 2 2005 0    . .  2.302585092994046                    0 .8888889 .8333333 .8333333         0         0
 2 2006 0    . .  2.302585092994046                    0 .8888889 .8333333 .6666666         0         0
 2 2007 1    0 0  2.302585092994046                    0 .7777778        1 .5833334         0         0
 2 2008 1    0 0  2.302585092994046                    0 .8888889 .8333333 .5833334         0         0
 2 2009 1    0 0 2.0794415416798357                    0 .3333333 .6666666        0         0         0
 2 2010 0    . . 2.0794415416798357                    0 .6666666 .6666666      .25         0         0
 2 2011 0    . . 2.0794415416798357                    0 .3333333        1       .5         0         0
 2 2012 0    . 1 2.0794415416798357                    0        1        1 .8333333         0       373
 2 2013 0    . 0 2.0794415416798357                    0 .5555556 .8333333       .5         0         0
 2 2014 0    . 0 2.0794415416798357                    0 .5555556 .6666666 .5833334         0         0
 2 2015 0    . . 2.0794415416798357                    0 .5555556 .6666666 .5833334         0         0
 3 2004 1    0 0   3.58351893845611  .057618833395396696 .7777778 .8333333 .6666666         0         0
 3 2005 0    . 0  3.912023005428146                    0        1 .6666666 .5833334         0         0
 3 2006 0    . .  3.912023005428146                    0        0        0        0         0         0
 3 2007 0    . .   4.07753744390572                    0 .6666666 .8333333        1         0         0
 3 2008 0    . .  2.995732273553991                    0 .6666666 .8333333 .8333333         0         0
 3 2009 0    . .  3.295836866004329                    0        1 .6666666      .75         0         0
 3 2010 0    . . 3.6888794541139363                    0 .6666666 .6666666 .6666666         0         0
 3 2011 0    . .  2.772588722239781                    0 .6666666 .8333333 .8333333         0         0
 3 2012 0    . . 3.9512437185814275                    0        1        0       .5         0         0
 3 2013 0    . .  3.044522437723423                    0        1 .8333333       .5         0         0
 4 2004 0    . 0  .6931471805599453   .14064971291086337 .6666666       .5       .5         0         0
 4 2005 1    0 1  .6931471805599453                 .087        1        1        1         0         0
 4 2006 1    0 0                  0                    0        1        1        1         0       994
 4 2007 0    . 0                  0                    0        1        1      .75         0         0
 4 2008 0    . .                  0                    0 .8888889 .8333333      .75         0         0
 4 2009 0    . .                  0                    0        1        1        1         0         0
 4 2010 0    . .                  0                    0        1        1        1         0         0
 4 2011 0    . .                  0                    0        1        1        1         0         0
 4 2012 0    . .                  0                    0        1        1        1         0         0
 4 2013 1   30 0  .6931471805599453   .07507884950336581        1        1        1         0         0
 5 2004 1   80 0 1.9459101490553132   .17195091086838932 .2222222       .5        0         0         0
 5 2005 1   20 0 1.9459101490553132   .09699191448540496 .2222222       .5        0         0         0
 5 2006 1 29.5 0  1.791759469228055   .17754350477437011 .2222222       .5        0         0  913.9235
 5 2007 1  4.6 0  1.791759469228055    .3837559064739411 .2222222       .5        0         0  1359.132
 5 2008 1    5 1 1.6094379124341003    .2130664092965216 .8888889       .5 .6666666         0    4371.1
 5 2009 1   10 1 1.0986122886681098   .07197761143795689 .7777778       .5 .6666666         0  6209.525
 5 2010 1   10 1 1.3862943611198906    .1939692474419783 .7777778       .5 .6666666         0         0
 5 2011 1   10 1 1.6094379124341003   1.0774121445424065 .7777778       .5 .6666666         0         0
 5 2012 1   80 1  1.791759469228055   .30190804450969133 .8888889 .8333333       .5         0  712.4927
 5 2013 1    6 0 1.6094379124341003                    0        1 .6666666       .5         0         0
 5 2015 1   95 1 1.3862943611198906                    0        1 .6666666       .5         0         0
 6 2004 1    0 0  3.044522437723423  .023363215803786804        1 .6666666 .3333333         0         0
 6 2005 1    0 0  3.091042453358316   .02488418510019133        1 .6666666 .3333333         0 36.946365
 6 2006 1    0 0 3.1780538303479458   .02203491203379804        1 .6666666 .3333333         0  38.22866
 6 2007 1    0 0 3.2188758248682006   .02197197542778446        1 .6666666 .3333333         0         0
 6 2008 1    0 0  3.258096538021482  .024768402432117524        1 .6666666 .3333333         0         0
 6 2009 1    0 0 2.8903717578961645  .043628161799596756        1 .6666666 .3333333         0         0
 6 2010 1    0 0 2.8903717578961645  .047617787730093966        1 .6666666 .3333333         0         0
 6 2011 0    . 0 2.3978952727983707                    0        1 .6666666 .3333333         0         0
 6 2012 0    . . 2.0794415416798357                    0        1        0 .3333333         0         0
 7 2004 0    . .  5.783825182329737                    0        0        0        0         0         0
 7 2005 0    . .  5.730099782973574                    0 .1111111        0        0         0         0
 7 2006 1    0 1  5.181783550292085                    0        0        0        0         0         0
 7 2007 1    0 0  4.844187086458591                    0 .4444444       .5       .5         0         0
 7 2008 1    0 0  4.762173934797756                    0 .8888889 .8333333      .75         0         0
 7 2009 0    . .  4.762173934797756                    0 .8888889 .8333333      .75         0         0
 7 2010 0    . .  4.727387818712341                    0 .5555556 .3333333 .3333333         0         0
 7 2011 0    . .  4.727387818712341                    0 .8888889        0        0         0         0
 7 2012 0    . .  4.700480365792417                    0        0        0        0         0         0
 7 2013 0    . .  4.727387818712341                    0 .2222222        0        0         0         0
 7 2014 0    . .  4.770684624465665                    0 .7777778        1       .5         0         0
 7 2015 0    . . 4.7535901911063645                    0        0 .1666667        0         0         0
 8 2004 1   77 1 1.9459101490553132   .23924395665200565        1 .3333333 .3333333         0         0
 9 2004 1    0 0  2.772588722239781                    0 .1111111        0        0         0  1527.875
 9 2005 0    . 0 2.4849066497880004   .08102188765002487 .3333333 .3333333 .3333333         0  406.1347
 9 2006 0    . 0 2.4849066497880004                    0 .3333333        0      .25         0         0
 9 2007 0    . 0 2.5649493574615367                    0 .2222222        0        0         0         0
 9 2008 1    1 0 2.5649493574615367 .0037338232374995446 .3333333        0        0         0         0
11 2004 1    0 1 3.2188758248682006  .020868634055714878 .5555556       .5 .3333333  4717.745         0
11 2005 1    0 1  3.295836866004329     .022795597436482 .5555556       .5 .3333333 4528.9175         0
11 2006 1   20 1 3.4965075614664802  .012718997364693722 .7777778 .3333333 .4166667  3297.949         0
11 2007 1    0 1 3.5553480614894135  .008183939809835146 .5555556 .3333333      .25 2851.6885  58.19772
11 2008 1   20 1 3.4011973816621555   .01709749583382931 .5555556 .3333333      .25         0 3072.7476
11 2009 1   20 1 3.4011973816621555   .01871897821983031 .5555556 .3333333      .25         0  3206.669
20 2004 1   .5 1  4.204692619390966  .017469072190368716 .6666666       .5 .4166667 1461.2487  186.1568
20 2005 0    . 1  4.174387269895637  .046790002310655526 .6666666 .6666666 .5833334 1339.4368         0
20 2006 1    0 1 4.1588830833596715   .03908659000351231 .6666666 .8333333 .6666666 1520.8528         0
20 2007 1  4.6 1  4.143134726391533   .04142966294820746 .6666666 .8333333 .6666666 2200.8137         0
20 2008 1  4.6 1  4.143134726391533    .0453161594348968 .6666666 .8333333 .6666666   2288.92         0
20 2010 1   20 1  4.330733340286331   .02959460778214954 .6666666        0       .5  8027.119  4961.746
20 2011 1   20 1 5.0238805208462765   .10545263729220362 .6666666        0       .5         0         0
20 2012 1   20 1  4.543294782270004   .06503342386711894 .5555556 .6666666 .6666666  6628.726  17475.73
20 2013 1   20 1   4.61512051684126    .0751187815657481 .6666666 .6666666 .6666666 21016.836  34786.49
20 2014 0    . 1   4.61512051684126   .07284496273083095 .6666666 .6666666 .6666666  22037.18  36475.33
21 2004 0    . .  7.774015077250727                    0 .1111111        0        0         0         0
21 2005 0    . .  7.419979923661835                    0        0        0        0         0         0
end

Survey data

$
0
0
Good morning
I need some advice for my master thesis please.

My data is a cross-sectional survey. About 11000 households. I'm studying the effect of some disease on the investment in human capital of the siblings of the children who are sick.
I have the disease status of children under 5 years old in each household. I've created a dummy variable which takes the values 0, 1 or 2 if there is 0,1 or 2 sick children in the household. My equation looks like this:
EDUij = i + 𝜸j + 𝜷1 STATUSj + 𝜷2 EDU_MOTHERij + 𝜷3 WEALTH_INDEXj +... + 𝛆ij
i for a child, j for a household.
I am wondering how to specify to Stata that my right-hand-side variable is valid only for children who are NOT sick, so that i can see if they have been impacted in terms of education due to the sickness of their siblings.

I hope it's clear enough.

Thank you for your help

Roc curve after beta regression

$
0
0
Hi everyone, I want to perform Roc analysis after beta regression and fractional regression. I have estimated predict value but it tells me that pr must be 0 or 1 for applying Roc curve. Any suggestion?

tebalance summarize coefplot

$
0
0
Hi everyone,

I am working (still in process on the matching model) on a project using teffects psmatch with a number of outcome and treatment variables. The number variables has prompted me to get creative with how I display my diagnostics. Following a teffects psmatch estimation and in checking for the balance of the match, I use the
Code:
tebalance summarize
command. One example result (sorry for the X var placement) is
PHP Code:
.
Treatment-effects estimation                   Number of obs      =      5,357
Estimator      
propensity-score matching     Matchesrequested =          1
Outcome model  
matching                                     min =          1
Treatment model
logit                                        max =          2
---------------------------------------------------------------------------------------
                      |              
AI Robust
          Yvar 
|      Coef.   StdErr.      z    P>|z|     [95ConfInterval]
----------------------+----------------------------------------------------------------
ATE                   |
Treatment |
         (
yes vs No)  |   .1712712   .0297238     5.76   0.000     .1130136    .2295289
---------------------------------------------------------------------------------------

tebalance summarize
note
refitting the model using the generate() option

  Covariate balance summary
                                                   Raw      Matched
                          
-----------------------------------------
                          
Number of obs =        5,357       10,714
                          Treated obs   
=        3,915        5,357
                          Control obs   
=        1,442        5,357
                          
-----------------------------------------

  -----------------------------------------------------------------
                  |
Standardized differences          Variance ratio
                  
|        Raw     Matched           Raw    Matched
  
----------------+------------------------------------------------
                  |
           
X1  |   .0239846   -.0216856      1.003129   .9976267
                  
|
              
x2|  -.0883955   -.0084951      1.072024   1.040323
              x3
|     .03316    .0037765      .9799571   .9515908
             x4 
|   .0745632   -.0019823      1.018004   1.045509
                  
|
            
X5  |   .2021603    .0005313      .6816709   .9989242
                  
|
    
x6          |  -.1715681   -.0101372      1.098919   .9468103
          x7    
|   .0766124    .0212042      .9688859   .9993285
   x8           
|   .0059114    .0452078        1.0091   .9892231
  x9            
|   .0704363    .0558643       1.03551   .9940278
      x10      
|   .1198441    .0224827      .9024419   .8567823
                  
|
                  |
       
x11     |  -.1158196    .0448593      .7736173    1.11359
          x12  
|   .1435748    .0308307      1.398567   1.069149
          x13  
|   .0225676   -.0165485      1.057586   .9601829
         x14   
|  -.1680311    .0230644      .6564869   1.063654
   x15         
|  -.1101453      -.0098      .7807659   .9771978
          x16  
|   .0683352   -.0480281        1.1599   .9064829
     x17       
|   .1115147   -.0112496      1.277536   .9771073
  
----------------------------------------------------------------- 
What I would like to do is use the coefplot command to take the standardized differences (raw and match) and variance ratios (raw and matched) and plot them with an xline(0) line for standardized differences and an xline(1) for the variance ratios. Then, for each tebalance summarize table, combine into a single, two pane graphic. I have been playing with coefplot command, but cannot get it to work. Any advice on doing so would be greatly appreciated.

Sincerely,

Eric

Conditions for a logistic regression?

$
0
0
Hey everyone,

I have a question considering the conditions on how you should prepare your data for logistical regression in Stata.

We have an assignment, where we have to use the logit-command for a binary logistical regression.

In a regular regression, you would need to control for multi-correlation , white-test, etc.

What would one need to check for a logit-command?

programming a dummy

$
0
0
hello,

I am struggling a lot with how to program my dummy. I want to generate a dummy that equals 1 if the firm was an SME at the end of 2012, and 0 if the firm was not. In order to be an SME, a firm has to be between certain boundaries for a couple of years before. Therefore, I already programmed whether or not the firm was within these boundaries from 2010 to 2012, I named these SME2010 SME2011 SME2012. The firm will have the status 'SME' at the end of 2012 if the firm has exceeded these limits for no more than one of these three years. I, however, have no idea how to program this correctly. Could you please help me?

thanks a lot!
Timea De Wispelaere

xtlogit, margins dydx with interaction terms

$
0
0
I am working with a logit panel data model with interaction terms.

My objective is to estimate the marginal effect of one of the regressors (call it X1) on my dep. variable Y. My regressor of interest also appears interacted with other regressors (say X2). My model has both groups and time fixed effects (for simplicity I will drop the time fixed effects from my explanation below since I believe they are not a concern for my main argument).

I can easily compute margins, dydx under the assumption that the groups fixed effects are 0. However, I would like to keep the fixed effects in the margin calculation. I am following the Mundlak-Chamberlain method (see https://www.stata.com/meeting/spain1...s14_pinzon.pdf ). However this "transformed" model contains interaction terms which prevent the use of margins in the usual manner (see on this the last page of https://journals.sagepub.com/doi/10....867X1301300105).

The turnaround that I follow is instead to write down and plug-in my model as an expression() within the margin command; specifically after estimating the model I manually write down

dp/dX1 = e^(-g(Y,X1,X2))/(1+e^(-g(Y,X1,X2))) * g'(Y,X1,X2)

and the command becomes:

margins, expression(dp/dX1) , over(year ID)

where ID is the group variable and year is the time.

I want to compute the marginal effect of a change in X1 for each possible level of X2 and this is why I include the over(year ID).--on a side note, is this equivalent to specifying at() in my case?

Is my approach correct for what concerns estimates and (delta est) standard error? If not, are there other solutions?






Recoding to a categorical variable_'the number of new and transformed varnames should be the same r(198)'

$
0
0
Hi there,
I am trying to recode age in my dataset (min 40, max 70) into 7 categories;

recode age 40/44 = 40-44 45/49 = 45-49 50/54 = 50-54 55/59 = 55-59 60/64 = 60
> -64 65/69 = 65-69 70/74 = 70-74, generate(Age groups)

OR

recode age 40/44 = A 45/49 = B 50/54 = C 55/59 = D 60/64 = E 65/69 = F 70/74
> = G, generate(Age groups)


but then getting this error message;

the number of new and transformed varnames should be the same
r(198);

Please assist?

Thank you.


Viewing all 65187 articles
Browse latest View live


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