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

variables do not uniquely identify the observations

$
0
0
Hello everyone,
I am new to Stata.
I am importing a csv file into Stata. Two of the columns are string variables [study names(study) and treatment names (trt)] to perform network meta-analysis.
On running an analysis (network setup command) it gives me the following error message:
" variables study trt do not uniquely identify the observations"

I have tried destring and encode commands. They have not worked.
I am lost !

Thanks
Praveen Roy
Stata 16.1

Box-cox regression

$
0
0
Good evening, I've run the box cox regression on my multiple regression model and this are the resultant values for theta = 0 theta = -1 and theta=1
Knowing that my alpha is 0.05, can you help me with this interpretation?
thanks for the help!

How to Run tstf command for intervention analysis

$
0
0
I am trying to run intervention analysis with an ARIMA model
I would like to use the following command: tstf OverallInflation if n<209 & n >137, arima(1,1,2) int(185) pulse
However, I receive an error message that says: the R script did not run, see what's wrong in the file tstf_to_r.R
I find this strange because I do not use R or have never used R.
Could someone provide advice on how to effectively conduct my intervention analysis?
Here is a dataex of my data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int Year str3 Month double(OverallCPI OverallInflation FoodCPI FoodInflation NonFoodCPI NonFoodInflation) float(mdate loginflation n smooth banknote rainfall ehat OverallInflationehat res1)
2012 "Dec" 412.9 34.6 342.5 34.6  562.1 34.5 635  3.543854 138 34.399998 0 0  1.5791667   1.7480047 -1.8378342
2013 "Jan" 121.6 35.1 122.5 34.2  123.7   36 636  3.558201 139    35.225 0 1   .7791666    .9447016 -1.0427294
2013 "Feb" 129.7 37.9 136.1 38.2  126.5 37.6 637  3.634951 140     35.85 0 1   3.079167    3.241398    3.23551
2013 "Mar" 129.9 36.4 134.4 34.9  125.9 37.9 638  3.594569 141 36.024998 0 1 -1.2208333  -1.0619048 -2.6936135
2013 "Apr" 127.2 35.8 129.9 33.1  126.1 38.6 639  3.577948 142    34.675 0 1  -.3208333   -.1652079 -.22772422
2013 "May"   127   31 122.2 25.4  133.8 36.6 640  3.433987 143    31.425 0 0 -4.5208335   -4.368511  -3.991645
2013 "Jun" 122.3 27.9 112.8 23.5  133.9 32.5 641 3.3286266 144        28 0 0 -2.8208334   -2.671814 -1.3643637
2013 "Jul" 119.8 25.2 107.7 19.7    134 30.7 642  3.226844 145      25.4 0 0  -2.420833  -2.2751174 -.45695695
2013 "Aug" 119.1 23.3 105.7 17.8  134.4 28.9 643 3.1484535 146      23.5 0 0 -1.6208333  -1.4784205   -.727733
2013 "Sep"   126 21.7 117.1 19.2  137.2 24.2 644  3.077312 147    22.475 0 0 -1.3208333  -1.1817237 -.26420733
2013 "Oct" 129.1 22.2 122.2 19.4  137.8 23.9 645  3.100092 148    22.375 0 0   .7791666    .9149732  1.3043317
2013 "Nov" 135.1 22.9 131.4 21.3  140.3 24.6 646  3.131137 149    22.875 0 0   .9791667     1.11167   .9789055
2013 "Dec" 140.6 23.5 139.3   22  142.9 25.1 647     3.157 150    23.525 0 0   .8791667   1.0083668  .24031304
2014 "Jan" 153.1 25.9   152 24.1    154 30.7 648  3.254243 151    24.025 0 1  2.6791666    2.805064  2.3884115
2014 "Feb" 161.6 24.6 163.9 20.4    159 29.3 649 3.2027464 152     24.15 0 1 -1.0208334   -.8982394 -2.1360464
2014 "Mar" 161.2   24 160.7 19.6  161.4 28.9 650  3.178054 153    24.025 0 1  -.3208333   -.2015426    -.35428
2014 "Apr" 157.7 23.9 152.9 19.5  162.3 28.5 651 3.1738784 154    23.875 0 1  .17916666   .29515427   .7176606
2014 "May" 165.5 22.6 145.9 19.4  130.8 26.4 652   3.11795 155     23.75 0 0 -1.0208334   -.9081489 -1.2221485
2014 "Jun" 149.9 22.5 135.2 19.9  164.4 25.7 653 3.1135154 156      23.7 0 0  .17916666   .28854796   .6004669
2014 "Jul" 146.6 22.3 129.6 20.3  163.4 24.9 654 3.1045866 157      23.7 0 0  .07916667    .1852448   .2083851
2014 "Aug" 148.3 24.5 131.1   24  165.4 25.8 655  3.198673 158      23.7 0 0   2.479167   2.5819416  2.3356376
2014 "Sep" 155.9 23.7 143.7 22.7    168 25.4 656  3.165475 159      23.7 0 0  -.5208333   -.4213615 -1.3072298
2014 "Oct" 159.2 23.3 148.5 21.5  169.8 25.6 657 3.1484535 160      23.7 0 0 -.12083333 -.024664655  -.4591624
2014 "Nov" 167.1 23.7 159.4 21.3  174.6 26.7 658  3.165475 161      23.7 0 0   .6791667    .7720322   1.149288
2014 "Dec" 174.5 24.2 170.1 22.1  178.8 27.2 659  3.186353 162    23.075 0 0   .7791666    .8687291   .3352031
2015 "Jan" 185.6 21.2 184.7 21.5  186.1 20.8 660  3.054001 163     21.45 0 1  -2.720833   -2.634574  -2.962748
2015 "Feb" 193.5 19.7   195   19  191.6 20.4 661  2.980619 164     19.85 0 1 -1.2208333  -1.1378772  -.4468955
2015 "Mar" 190.5 18.2 188.1   17  192.6 19.3 662 2.9014215 165    19.025 0 1 -1.2208333  -1.1411804 -.10337662
2015 "Apr" 187.4 18.8 180.6 18.1  193.9 19.5 663  2.933857 166 18.974998 0 1   .8791667    .9555165  1.1593035
2015 "May" 186.1 19.5 177.1 21.4  194.9 17.8 664 2.9704144 167    19.775 0 0   .9791667   1.0522133  1.0621831
2015 "Jun" 181.7 21.3   168 24.2  195.3 18.8 665  3.058707 168    21.075 0 0  2.0791667     2.14891  1.3315547
2015 "Jul" 179.1 22.2 162.4 25.3  195.6 19.6 666  3.100092 169    22.175 0 0  1.1791667    1.245607    .554446
2015 "Aug" 182.4   23 166.3 26.8  198.3 19.9 667  3.135494 170    23.075 0 0  1.0791667   1.1423038    .175477
2015 "Sep" 193.5 24.1   183 27.3  203.8 21.3 668  3.182212 171     23.95 0 0  1.3791667   1.4390007  1.1130346
2015 "Oct" 198.5 24.7 190.5 28.3  206.2 21.4 669  3.206803 172    24.475 0 0   .8791667    .9356975  .09712333
2015 "Nov" 208.2 24.6 205.5 28.9  210.5 20.6 670 3.2027464 173      24.6 0 0  .17916666   .23239437 -.16191384
2015 "Dec" 217.9 24.9 219.7 29.2  215.8 20.7 671  3.214868 174    24.325 0 0  .57916665    .6290912   .3374279
2016 "Jan" 229.2 23.5 237.3 28.4  220.5 18.5 672     3.157 175     23.75 0 1 -1.1208333   -1.074212 -1.1896832
2016 "Feb" 238.6 23.4 250.8 28.6    226 17.9 673  3.152736 176    23.375 0 1  .17916666    .2224849  .36166435
2016 "Mar" 232.5 22.1 237.8 26.5  226.8 17.8 674  3.095578 177        23 0 1 -1.0208334   -.9808183  -.6754782
2016 "Apr" 226.6 20.9 224.6 24.3  228.4 17.7 675  3.039749 178     22.45 0 1  -.9208333   -.8841214  -.8467293
2016 "May"   226 21.5 222.5 25.7  229.3 17.6 676  3.068053 179 22.300003 0 0   .8791667    .9125754  1.6336147
2016 "Jun" 222.9 22.6 214.6 27.7  230.9 18.2 677   3.11795 180     22.55 0 0  1.3791667   1.4092723   .9921772
2016 "Jul" 221.1 23.5 209.8 29.2  232.1 18.7 678     3.157 181     22.75 0 0  1.1791667    1.205969   .6445929
2016 "Aug" 223.9 22.8 214.1 28.7  233.5 17.8 679 3.1267605 182      22.4 0 0  -.4208333    -.397334 -1.0995753
2016 "Sep" 234.4 21.2 232.3   27  236.2 15.9 680  3.054001 183    21.325 0 0 -1.3208333   -1.300637 -1.1931074
2016 "Oct" 238.3 20.1 238.9 25.4  237.4 15.2 681   3.00072 184     20.35 0 0  -.8208333   -.8039403 -.28367758
2016 "Nov" 249.7 19.9 256.5 24.8  242.4 15.2 682   2.99072 185        20 0 0  .07916667   .09275654   .6497778
2016 "Dec" 261.4   20 273.4 24.4    249 15.4 683  2.995732 186      19.5 1 0  .54347825    .3894534    .348541
2017 "Jan" 270.7 18.2 287.3 21.1  253.4   15 684 2.9014215 187      18.1 1 1 -1.3565217  -1.5138497 -1.6064032
2017 "Feb" 277.1 16.1 294.8 17.5    259 14.6 685  2.778819 188 16.550001 1 1 -1.6565218   -1.817153 -1.4002457
2017 "Mar" 269.3 15.8 278.3   17  259.8 14.5 686   2.76001 189    15.575 1 1  .14347826  -.02045607  1.0343033
2017 "Apr" 259.7 14.6 257.6 14.7  261.4 14.5 687 2.6810215 190    14.325 1 1  -.7565218   -.9237592  -.7890332
2017 "May" 253.9 12.3 247.4 11.2 260.16 13.5 688  2.509599 191    12.625 1 0 -1.8565217  -2.0270624  -1.706327
2017 "Jun" 248.1 11.3 234.4  9.3  261.5 13.2 689  2.424803 192    11.275 1 0  -.5565217   -.7303655  .16750912
2017 "Jul" 243.6 10.2 225.4  7.4  261.5 12.7 690 2.3223877 193     10.25 1 0  -.6565217   -.8336686 -.21772502
2017 "Aug" 244.8  9.3 227.4  6.2  261.9 12.2 691 2.2300143 194       9.3 1 0 -.45652175   -.6369718  -.3826519
2017 "Sep" 254.2  8.4 244.3  5.1  263.8 11.6 692 2.1282318 195       8.6 1 0 -.45652175    -.640275 -.16336496
2017 "Oct"   258  8.3 250.4  4.8  265.3 11.7 693 2.1162555 196  8.275001 1 0   .3434783   .15642187   .3860808
2017 "Nov"   269  7.7 268.5  4.7  269.1   11 694 2.0412204 197  8.075001 1 0 -.15652174   -.3468813 -.20227936
2017 "Dec" 279.9  7.1 285.2  4.3  274.1   10 695 1.9600948 198     7.875 1 0 -.15652174   -.3501844  -.3452058
2018 "Jan"     0  8.1     0  7.6      0  9.6 696  2.091864 199     7.875 1 1  1.4434782   1.2465124   1.582055
2018 "Feb" 106.8  7.8 110.9  7.3  103.3  9.4 697 2.0541236 200     8.175 1 1  .14347826  -.05679074  -.5092982
2018 "Mar" 105.8  9.9 107.9 10.6    104  9.7 698 2.2925348 201       8.6 1 1   2.543478   2.3399062  2.2059016
2018 "Apr" 101.8  9.7  99.3   10  103.9  8.9 699  2.272126 202      8.85 1 1  .24347825   .03660295  -.6424274
2018 "May" 101.2  8.9  97.7  9.5  104.1  8.4 700 2.1860514 203  8.924999 1 0  -.3565217   -.5667002 -1.0424443
2018 "Jun"   101  8.6  96.5  9.1  104.6  8.2 701 2.1517622 204     8.975 1 0  .14347826  -.07000335   .4341835
2018 "Jul" 101.6    9  97.5  9.5    105  8.7 702 2.1972246 205     9.075 1 0   .8434783    .6266935   .6641505
2018 "Aug"   103  9.3 100.1 10.1  105.5  8.7 703 2.2300143 206     9.275 1 0   .7434782   .52339035   .3886841
2018 "Sep" 105.1  9.5 103.7 10.2  106.2  8.9 704 2.2512918 207       9.5 1 0   .6434783    .4200872  .13669455
2018 "Oct" 107.1  9.7 106.2 10.4  107.8  9.2 705  2.272126 208      9.65 1 0   .6434783   .41678405   .3053626
end
format %tm mdate
Thanks in advance!

Probability weights in xtlogit?

$
0
0
Hi,

Apologies if this has been cross posted, I have been looking for similar answers but found nothing that addressed exactly the same problem. I would like to run a logit regression on a panel, using a fixed effect logit model. I have probability weights, but I see that the only kind of weights allowed with xtlogit is iweights? I read that the command should specify how it uses iweights in each case, but I don't think there is anything on it on the xtlogit user manual. Any idea on what importance weights are in the xtlogit context?

I have also seen I could use ctlogit (and pweights), but it seems that it wouldn't be exactly the same thing as wights apply to the group and not to individuals.

Thanks!

Esttab coeflabels

$
0
0
Dear All,

I am estimating a set of regressions, all with the same outcome variable but different independent variables. Although the independent variables are different in each regression, they follow a similar structure and I would like their coefficient labelled the same. To illustrate, I ran:

Code:
foreach var in FirstConfirmedCase EmergDec SchoolClose StayAtHome FirstDeath{
    
    gen days_since_`var' = date - Date`var'    
    
    gen `var'_lag_lr = days_since_`var' < `ll'
    forvalues q = 15(-1)2 {
        gen lag_`var'_`q' = days_since_`var' == -`q'
    }
    forvalues q = 0/5 {
        gen lead_`var'_`q' = days_since_`var' == `q'    
    }
    gen `var'_lr = days_since_`var' > `ul' & ~missing(days_since_`var')          
            
    eststo: reghdfe totOOS_movement `var'_lag_lr lag_`var'_15-`var'_lr  if  (Date`var'<d(05apr2020) & Date`var'>d(02feb2020) & days_since_`var' > `ll' & days_since_`var' < 6)|Date`var'==., absorb(state_d date) cluster(state_d)
 
}
esttab using "$Supplementarydir\TableES_Fig5a_totOOSmove.csv", ///
keep(lag* lead*) b(a3) se(3)  nogaps  nolabel star(* 0.05 ** 0.01) ///
label title(State-level placeiq, Fig5a_totOOSmove.) ///
  mtitles("First Confirmed Case" "Emergency Declarations" "School Closure" "Stay-at-Home") coeflabels(lag_`var'_15 “15 days prior to event”  ///
  lag_`var'_14 “14 days prior to event” lag_`var'_13 “13 days prior to event”  lag_`var'_12 “12 days prior to event” lag_`var'_11 “11 days prior to event” ///
  lag_`var'_10 “10 days prior to event” lag_`var'_9 “9 days prior to event” lag_`var'_8 “8 days prior to event” lag_`var'_7 “7 days prior to event” ///
  lag_`var'_6 “6 days prior to event” lag_`var'_5 “5 days prior to event” lag_`var'_4 “4 days prior to event” lag_`var'_3 “3 days prior to event” ///
  lag_`var'_2 “2 days prior to event” lead_`var'_0 “Day of event” lead_`var'_1 “1 day after event” lead_`var'_2 “2 days after event” ///
  lead_`var'_3 “3 days after event” lead_`var'_4 “4 days after event” lead_`var'_5 “5 days after event”) stats(N) replace
The table I looks as follows:
="State-level placeiq Fig5a_totOOSmove."
(1) (2) (3) (4) (5)
First Confirmed Case Emergency Declarations School Closure Stay-at-Home est5
lag_FirstConfirmedCase_15 0.00300
(0.004)
lag_FirstConfirmedCase_14 0.00366
(0.005)
lag_FirstConfirmedCase_13 0.00449
(0.005)
lag_FirstConfirmedCase_12 0.00582
(0.006)
lag_FirstConfirmedCase_11 0.00200
(0.006)
lag_FirstConfirmedCase_10 -0.00420
(0.005)
lag_FirstConfirmedCase_9 -0.0122
(0.007)
lag_FirstConfirmedCase_8 -0.00160
(0.004)
lag_FirstConfirmedCase_7 0.00215
(0.004)
lag_FirstConfirmedCase_6 -0.000414
(0.004)
lag_FirstConfirmedCase_5 -0.00388
(0.004)
lag_FirstConfirmedCase_4 -0.00188
(0.005)
lag_FirstConfirmedCase_3 -0.00354
(0.004)
lag_FirstConfirmedCase_2 -0.00548*
(0.003)
lead_FirstConfirmedCase_0 -0.00116
(0.003)
lead_FirstConfirmedCase_1 -0.00139
(0.005)
lead_FirstConfirmedCase_2 0.000261
(0.006)
lead_FirstConfirmedCase_3 0.00429
(0.007)
lead_FirstConfirmedCase_4 0.00269
(0.008)
lead_FirstConfirmedCase_5 0.00403
(0.010)
lag_EmergDec_15 0.000609
(0.002)
lag_EmergDec_14 0.00794*
(0.004)
lag_EmergDec_13 0.00665
(0.003)
lag_EmergDec_12 0.00266
(0.004)
lag_EmergDec_11 0.00206
(0.004)
lag_EmergDec_10 -0.00385
(0.005)
lag_EmergDec_9 -0.0000292
(0.004)
lag_EmergDec_8 0.00208
(0.004)
lag_EmergDec_7 0.00364
(0.004)
lag_EmergDec_6 0.00120
(0.004)
lag_EmergDec_5 -0.00317
(0.004)
lag_EmergDec_4 -0.00301
(0.004)
lag_EmergDec_3 -0.00283
(0.003)
lag_EmergDec_2 -0.00319
(0.002)
lead_EmergDec_0 -0.000333
(0.002)
lead_EmergDec_1 0.00191
(0.005)
lead_EmergDec_2 -0.000765
(0.006)
lead_EmergDec_3 0.00259
(0.007)
lead_EmergDec_4 -0.00360
(0.009)
lead_EmergDec_5 -0.00449
(0.012)
lag_SchoolClose_15 -0.00119
(0.005)
lag_SchoolClose_14 -0.00114
(0.007)
lag_SchoolClose_13 0.00471
(0.008)
lag_SchoolClose_12 0.0109
(0.009)
lag_SchoolClose_11 0.00643
(0.009)
lag_SchoolClose_10 0.00799
(0.010)
lag_SchoolClose_9 0.00869
(0.009)
lag_SchoolClose_8 0.0134
(0.009)
lag_SchoolClose_7 0.0132
(0.010)
lag_SchoolClose_6 0.0147
(0.009)
lag_SchoolClose_5 0.0135
(0.009)
lag_SchoolClose_4 0.00812
(0.008)
lag_SchoolClose_3 0.00258
(0.007)
lag_SchoolClose_2 0.00391
(0.003)
lead_SchoolClose_0 -0.00780
(0.004)
lead_SchoolClose_1 -0.0148**
(0.005)
lead_SchoolClose_2 -0.0168*
(0.008)
lead_SchoolClose_3 -0.0285*
(0.011)
lead_SchoolClose_4 -0.0318*
(0.013)
lead_SchoolClose_5 -0.0352*
(0.016)
lag_StayAtHome_15 0.00474
(0.007)
lag_StayAtHome_14 0.00647
(0.007)
lag_StayAtHome_13 0.00292
(0.007)
lag_StayAtHome_12 0.00191
(0.008)
lag_StayAtHome_11 0.00452
(0.007)
lag_StayAtHome_10 0.00189
(0.006)
lag_StayAtHome_9 0.0000928
(0.007)
lag_StayAtHome_8 -0.00204
(0.006)
lag_StayAtHome_7 -0.00245
(0.006)
lag_StayAtHome_6 -0.000449
(0.006)
lag_StayAtHome_5 -0.00381
(0.006)
lag_StayAtHome_4 -0.00604
(0.007)
lag_StayAtHome_3 -0.00817
(0.008)
lag_StayAtHome_2 -0.00684
(0.007)
lead_StayAtHome_0 -0.00234
(0.009)
lead_StayAtHome_1 -0.000344
(0.010)
lead_StayAtHome_2 -0.000208
(0.010)
lead_StayAtHome_3 -0.00270
(0.012)
lead_StayAtHome_4 -0.00317
(0.015)
lead_StayAtHome_5 0.00123
(0.016)
lag_FirstDeath_15 0.000573
(0.002)
lag_FirstDeath_14 -0.0000687
(0.002)
lag_FirstDeath_13 0.000475
(0.003)
lag_FirstDeath_12 -0.000967
(0.004)
lag_FirstDeath_11 0.00361
(0.006)
lag_FirstDeath_10 0.00122
(0.004)
lag_FirstDeath_9 -0.00155
(0.004)
lag_FirstDeath_8 -0.00361
(0.004)
lag_FirstDeath_7 -0.00229
(0.004)
lag_FirstDeath_6 -0.00135
(0.004)
lag_FirstDeath_5 0.00104
(0.004)
lag_FirstDeath_4 0.00209
(0.004)
lag_FirstDeath_3 0.000915
(0.004)
lag_FirstDeath_2 -0.000820
(0.003)
lead_FirstDeath_0 0.00138
(0.002)
lead_FirstDeath_1 0.00205
(0.004)
lead_FirstDeath_2 0.00398
(0.005)
lead_FirstDeath_3 0.00559
(0.005)
lead_FirstDeath_4 0.00647
(0.007)
lead_FirstDeath_5 0.00547
(0.007)
N 1104 1223 1208 1716 1177
Standard errors in parentheses
="* p<0.05 ** p<0.01"
I want to override the coeflabels so that all the coefficient are next to each other with common coeflabels as I attempted to specify in the esttab command. How may I do that? Many thanks and sorry for the long post, just wanted to show the problem.
Sumedha..

deciding between xtgee and xtreg, re

$
0
0
Hello,

I have an unbalanced panel data set with N = 185 and T = 5. I have 8 dependent variables of which two do not change over time. Therefore, I think random effects is the one to use to tackle this problem. However, I am still struggling a lot at what command to use. I have been asking questions and have been strolling down the internet a lot, and many times it has been pointed out that for T < N xtreg, re is the way to go. However, I do not find an explanation of why this is the case. I have read the part of xtgee In the pdf manual, and here they state the following:" xtgee, fam(gauss) link(ident) corr(exch) is asymptotically equivalent to the weighted-GLS estimator provided by xtreg, re". However, when I run both models, both are very dissimilar. I have significant regressors for the xtgee, but not for the xtreg, re command.

Could somebody please clarify this for me, as I want to understand what I am doing.

Thank you very much,
Timea De Wispelaere

Store beta coefficients after a loop of regressions

$
0
0
I would like to know how can I store the beta coefiicients of my regression into a new variable. I am running a loop of regresions but I do not know how to modify my code to add this option and be able to keep the beta coefiicient of each regression. This is my code:

gen ESPANA_pred_13 = .
forval i = 30/58 {
reg ESPANA_INF l(13). ESPANA_fvcv Dummy_wkn if inrange(t, 0, `i') , r
predict temp
replace ESPANA_pred_13 = temp if t == `i'+1
drop temp
}

Thanks in advance

Unable to access Manage Value Labels

$
0
0
Happy Monday! I have imported my data set from excel. Starting to labels and id to items. When I access Variables Manager, the option to Manage next to Value Label is not available. Not sure what I might have broken??? lol Anyway, your help would be greatly appreciated. Obviously can't proceed without adding the values. Help~ Tam

Esttab with F statistics and associated P values

$
0
0
I am trying to create a table that includes F statistics for tests of joint significance. I found this similar question https://www.statalist.org/forums/for...ithin-possible, although it only deals with one regression results and runs a separate test for F then pulls the scalar p and adds it. My issue is that I am doing this for quite literally 48 regressions and 6 tables. I was wondering if there was a particular option that I couldn't find or if I need to use -testparm- after each regression and use -estadd-.


For example, say I have the following:

Code:
reg y x1 x2
estimates store r1
reg y x1 x2 x3
estimates store r2

esttab r*, scalar(F)
How would I add the associated p-value for the F stat to the table?

How to extract weights from the final iteration of qreg

$
0
0

I am trying to obtain an exact estimate of the omitted variable bias in the context of a quantile regression. For this purpose, I am relying on the paper “Quantile Regression under Misspecification, with an Application to the U.S. Wage Structure,” by Angrist, Chernozhukov and Fernández-Val, in Econometrica, Vol. 74, 2006.
A critical step in their procedure is to employ in the bias formula the weights of the weighted mean- squared error loss function.
My question to you is the following: is there a way to extract from the stata qreg procedure the weights used in the final iteration of the Iteratively reweighted least squares?

Testing multiple regression models

$
0
0
Hi

I'm doing a regression analysis with my panel data (n: 41, t: 20). I'm trying to measure the impact of acquisition motives on firm performance.
Since there are a lot of different way to measure firm performance I'd like to relay not only on one measure but on multiple.
My idea is to do multiple regressions with different dependent variables (e.g. ROA, Total Return, ...).
I assume that in order to make the different models comparable they should be calculated in the same way.

How should I test for things like heteroskedasticity, serial correlation and use the Hausman test?
When doing these tests for each model seperately I get different results which would lead to the models being calculated in different ways.
Also: How should I handle the same problem when doing multiple regressions with partially different independent variables?

Thank's for the help.

Kind regards

Packages for making odds ratio plot

$
0
0
Hi, I just came across an article that used Stata for all analyes and reported the following odds ratio chart. Can anyone guess which package was used to create this. I couldn't find this anywhere in the diaglog boxes.
Thank you.
Array

Looping with a condition?

$
0
0
Hi
I have the following "have" variable. On the basis of ID, if the "have" variable has the value of 1, then I want "req" variable to give me the "time" at which I had "have" variable as 1. If the "have" variable remains 0 for a particular ID, then I want the last observation of "time" variable to show up in "req" variable.


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(id time) double(sentiment have)
1  1    1 0
1  2    1 0
1  3  1.2 0
1  4 1.22 0
1  5 1.25 1
1  6  1.4 0
1  7  1.2 0
1  8  1.3 0
1  9  1.4 0
1 10  1.2 0
2  1  1.2 0
2  2   .9 0
2  3    . 0
2  4   .8 0
2  5  .95 0
2  6    1 0
2  7  1.5 1
2  8  1.2 0
2  9  1.3 0
2 10   .7 0
3  1    1 0
3  2  .11 0
3  3  1.1 0
3  4    1 0
3  5   .9 0
3  6   .2 0
3  7   .3 0
3  8   .5 0
3  9   .7 0
3 10   .8 0
end

I have created the following code. I was wondering if we can do it via a loop? if/else if statement?

Code:
g req = time if have == 1
bysort id:  replace req = req[_n-1] if req ==.
gsort id - time 
bysort id:  replace req = req[_n-1] if req ==.
sort id time 
replace req = time[_N] if req==.
Thanks

reshaping the following dataset

$
0
0
Dear all:
I have the following data set:
************************************************** *****
date usbank bankofamerica discover capitalone dummy
2010 10 20 30 40 0
2011 25 50 33 . 0
2012 1
.
.
.
2020
************************************************** *********
my goal is to reshape it as long: such as that i have the fist column with date and second column with banknames and the rest is the value of outcome. can someone help?.
Thanks.

Panel Data: two-side censored Tobit model with non-constant limits

$
0
0
Hi everyone!

I'm using a Stata/SE version 15.1

I'm using a British Household Panel Data, waves 10-18. I'm currently working on a dissertation to investigate whether the workers are able to adjust their working hours towards their stated preference and the role of the employer and job change in facilitating that adjustment.

The Panel Data is unbalanced as the requirement is for the individuals to be interviewed for at least two consecutive waves.

I observe two variables which help me to define my dependant variable:
I observe their preferences towards working hours, hrpref (1– over-employed, 2– under-employed, 3 matched)
Hours they actually work (towrkhrs)
hours they prefer to work, (only observed when hrpref==3, lower censored when hrpref==1 and upper censored when hrpref==2), but this also means that the upper and lower limit is different for each individual.

Work hour mismatches occur when preferred working hours don't match with their current working hours. I only observe the preferred working hours for individuals who are matched.

The model looks like this.
Array


Here is a sample of my data with some key variables: (empchng - changing employer; jbchng- changing job)


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long pid float(year towrkhrs hrpref hrpref_lag empchng jbchng)
10023526 2002 45 1 . 0 0
10023526 2003 32 3 1 0 0
10028005 2002 37 3 . 0 0
10028005 2003 43 3 3 0 1
10028005 2004 38 3 3 0 1
10049363 2003 36 3 . 0 0
10049363 2004 36 3 3 0 0
10049363 2005 39 3 3 0 0
10055266 2000 45 2 . 0 0
10055266 2001 47 1 2 0 1
10055266 2002 47 1 1 0 0
10055266 2003 42 1 1 0 0
10055266 2005 35 1 . 0 0
10055266 2006 55 1 1 0 0
10055266 2007 35 1 1 0 0
10055266 2008 35 1 1 0 0
10060111 2003 35 3 . 0 0
10060111 2004 35 3 3 0 0
10060111 2005 35 3 3 0 0
10060111 2006 12 2 3 1 0
end

My question is how do I generate my dependant variable 𝐻? the desired hours are censored a not observed over limits.


What I have done is:

Code:
xtset pid year
gen min=towrkhrs if hrpref==1
gen max=towrkhrs if hrpref==2

xttobit towrkhrs empchng#ib3.hrpref_lag jbchng#ib3.hrpref_lag unemp ib1.educ i.marstat i.spjb childno
i.chu5 i.jbft  if sex==1 , ll(min) ul(max)
end
Code:
xtset pid year
replace hrpref=0 if hrpref==3
replace hrpref=-1 if hrpref==2

xttobit hrpref empchng#ib3.hrpref_lag jbchng#ib3.hrpref_lag unemp ib1.educ i.marstat i.spjb childno
i.chu5 i.jbft  if sex==1 
end
However, none of these seems to do what I want. (not all control variables are included in the example)

Thank you for your assistance!


Precision when pushing to local

$
0
0
Can I enforce rounding without writing to a variable? If I export using putexcel, for certain values I lose the rounding. ie.:

Code:
local Z = round(81/100,0.01)
putexcel A1 = "`Z'"
Will export ".8100000000000001" to the cell.

Can I resolve so that the string ".81" is exported without having to write to a variable or change cell format in excel?

Serial correlation

$
0
0
Dear researchers,

I have balanced panel data for 200 firms for the years that extends from 1990-2019. I have used the following code:

Code:
reg Dep l.indep1 l.indep2 l.indep3 i.year, r
And I wanted to see if their is a serial correlation or not?
Therefore, I have used the following code:

Code:
predict resid, resid
runtest resid
And the STATA shows me a message that "resid has internal missing observations".

Accordingly, I have used the below code:
Code:
predict double resid, residuals
preserve
drop if missing(resid)
runtest resid
restore
And, I have got the following results:
Code:
. runtest resid
 N(resid <= .0169380586594343) = 2166
 N(resid >  .0169380586594343) = 2167
           obs = 4333
       N(runs) = 280
            z  = -57.36
      Prob>|z| = 0
So, does it mean that I have a serial correlation problem because the Prob is 0?

Many thanks in advance for your help.

Why doesn't -power- integrate cohen's d effect sizes well?

$
0
0
It seems like the "standard" for calculating power is using Cohen's D. However, Stata's -power- command seems to rely mostly on mean changes. And all the examples use mean changes instead of Cohen's D as the effect size. Why is that? Just curious.

stset data for survival analysis

$
0
0
In setting up my data for survival analysis, I have already created spell data, including a variable "begin", which will serve as t0 and "end" which will serve as t1 ('begin' and 'end' ==1 if true or == 0 otherwise). "end" can also be used to identify "failure". As I am looking at the length of relationships (for different groups) and have multiple years of panel data, I set exti(time .) to allow for multiple 'failures' per id (failure = end of a relationship).

After reading Mario Cleves "How do I stset my spell-type data?" https://www.stata.com/support/faqs/s...ell-type-data/ and the early chapters in "An Introduction to Survival Analysis Using Stata", I arrived at:
Code:
stset wave, id(id) origin(wave==1) failure(end==1) enter(begin==1) exit(time .)
Not sure if I needed to, but I tried to include "time0(wave==1)", but Stata reported it invalid to use "==".


FYI. I am using Stata 15.1.

extracting unique identifiers from a string variable

$
0
0
Dear all,
I am using stata 15.
I have a string variable named
seriesid
that represents
region id
and
series id
and a last element which identifies survey type, same for all regions and series. It is preceded by NSA (not seasonally adjusted).
The variable looks like:
NSA01000000000000001
.
For example:
NSA02000000000000001
represents region 2 for aggregate employment
NSA04000005000000001
represents region 4 for agricultural employment while
NSA13000008000000001
represents region 12 for public employment.
so that each region, around 8 has its respective 12 series representing the sector.
what I wanted to do is:
1. to extract a region identifier based on the the first two digit numbers next to NSA in seriesid (in bold)
2. a series identifier separated based on the series identifiers in bold in seriesid

I tried to generate the region code using the following loop, it did not change anything.
HTML Code:
gen str r_code="xx"

forval i=01/12 {
replace r_code if seriesid=="DU"
}
I also tried to use the following code
HTML Code:
local rc "AY"    "BR"    "DU"    "GO"    "HF"    "HY"    "JL"    "JN"    "KM"    "NT"    "TU"    "XR"
levelsof seriesid, l(sid)

foreach id in sid {
forval i=01/12 {
replace r_code="`rc'" if "`id'"=="NSA`i'0000000000001"
}
}
I thank you for any hint you may point me to.
Phil
Viewing all 65454 articles
Browse latest View live