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

GE_gravity: a new stata module for general equilibrium trade policy analysis

$
0
0
Dear Stata users,
Based on some of the topics of discussion that tend to come up frequently on this forum, it's become apparent to me that there is a large number of people using Stata for some sort of trade policy analysis. Typically, I'm used to fielding questions about the application of Poisson PML estimation to so-called "structural gravity" models of trade. However, thanks to contributions such as the recent Advanced Guide to Trade Policy Analysis put out by the WTO and UNCTAD, it is becoming increasingly well known that empirical trade policy analysis using the structural gravity model can be easily extended to a general equilibrium setting, such that "partial" gravity estimates of trade agreements, tariff changes, and other changes in trade policy conditions can be mapped to changes in national welfare, trade diversion, and many other related general equilibrium objects that may be of interest. As such, GE simulations based on structural gravity are becoming an increasingly common component of modern trade policy analysis.

Interestingly, while there are some excellent commands available in Stata for estimating gravity equations, there have not been until now any dedicated Stata modules available for performing GE welfare analysis post-estimation. To that end, I have decided to share a new Stata command called GE_gravity, which can be used to perform a simple general equilibrium trade policy analysis based on a one-sector general equilibrium trade model (such as the models used in, e.g., Eaton and Kortum 2002 or Anderson and van Wincoop, 2003). For those not already familiar with this type of analysis, there is an online help file that clarifies the details behind the model and provides some standard references on the subject. The algorithm itself is a slightly streamlined version of some earlier code shared by Keith Head and Thierry Mayer. It is programmed to run in Mata, so it is quite fast in typical applications. I envision it being ideal for situations where a researcher wants to quickly construct bootstrapped confidence intervals of changes in general equilibrium variables based on prior gravity estimates (as opposed to, say, obtaining bootstrapped gravity estimates in Stata first and then passing them to MATLAB for the GE analysis.)

If you decide to use this command in your research, I would appreciate it if you would cite
  • Baier, Scott L., Yoto V. Yotov, and Thomas Zylkin. “On the widely differing effects of free trade agreements: Lessons from twenty years of trade integration." Journal of International Economics 116 (2019): 206-226.
The algorithm used in the command was specifically written for the exercises performed in this paper. Also see Section 6 of the paper for a more detailed description of the underlying model and its connection to the wider literature.

The command is available for download via ssc: to obtain the latest version, type "ssc install GE_gravity, replace". There is also an example .do file and data set you can use to learn the syntax and options.

If you have any suggestions or run into any errors, please feel free to get in touch. I hope the community finds this command useful.

Regards,
Tom

Hiring Stata Tutors $33-133 an hour (remote work)

$
0
0
Hello Stata listers.
I worked privately as a stata tutor for the past five year racking up thousands of hours through large tutoring sites. Earlier this year I started my own website, www.StataTutor.com. It has been more successful than I could have anticipated. I will be quitting my day job to tutor full time. I'm looking for tutors in many disciplines, particularly biostats and epidemiology. Pay is based on experience, education, and ability. We're looking for folks with a passion and excitement for quantitative research, Stata, and most of all helping people. This is a great way of making extra income while in grad school or supplementing your main job. You can work from anywhere in the world with a strong internet connection and set your own hours.

Please feel free to pass this on to people you think would be interested.

Please send current resumes, cover letter, research/writing samples, and code samples if available to Mark.Lester.Davis@gmail.com.

I also want to give a big thank you to stata corp and stata list. I've learned so much about programming stata from this site and I wouldn't have my career or business without your support. I think we have the best community of all of the stats packages.

Weighting coefficients by standard errors

$
0
0
Dear Starlist members,
i running a two step regression with fixed effects. I would poke to use the predicted coefficients from stage 1 as dependent variable for stage 2. I would like to know how i can weight the coefficients using the standard errors. What command can i use for this in stata.i have predicted both the coefficients and their standard errors from my regression.

Thanks,
Bridget

cf viewing

$
0
0
Hello,
I am trying to compare my output of a large amount of stata files to one someone else created using the "cf" command. I added the verbose suffix in an attempt to view the distinct changes between the observations, but the only thing that it gave me was the difference in number of observations between the two data files. As of now my code looks like this:

use "filepath"
cf varlist using "filepath 2", verbose

But I can't seem to track the individual changes. I was hoping to view them so I could fix them to make the two outputs match perfectly but to no avail. Any help would be appreciated, thanks.

r(322) after running the margins command

$
0
0
Hello,

I am running two sets of identical models, but one set (with the SUD tx outcome, below) is producing the following error code when I try to run margins: "missing predicted values encountered within the estimation sample r(322)". Note that I have had to use some extra features (startgrid, startvalues) because of challenges getting this model to converge. Why am I getting this error code?

PHP Code:
mepoisson sudtx_flag i.gender i.AUDITCfyearirr

Iteration 0
:   log likelihood = -1274882.3 
Iteration 1
:   log likelihood = -550683.57 
Iteration 2
:   log likelihood = -537880.67 
Iteration 3
:   log likelihood = -537841.85 
Iteration 4
:   log likelihood = -537841.84 

Poisson regression                              Number of obs     
=    1405734

                                                Wald chi2
(8)      =     642.59
Log likelihood 
= -537841.84                     Prob chi2       =     0.0000
------------------------------------------------------------------------------
  
sudtx_flag |        IRR   StdErr.      z    P>|z|     [95ConfInterval]
-------------+----------------------------------------------------------------
 
1.gender |   1.774197   .1016804    10.00   0.000     1.585692    1.985111
             
|
 
AUDITCfyear |
     
FY2011  |   .9462272   .0098929    -5.29   0.000     .9270347    .9658169
     FY2012  
|   .9534917   .0098788    -4.60   0.000      .934325    .9730516
     FY2013  
|   .9826134   .0100135    -1.72   0.085      .963182    1.002437
     FY2014  
|   .9951467    .009859    -0.49   0.623     .9760098    1.014659
     FY2015  
|   .9500294   .0092587    -5.26   0.000      .932055    .9683504
     FY2016  
|   .8844245   .0083442   -13.02   0.000     .8682205    .9009309
     FY2017  
|   .8532117   .0080798   -16.76   0.000     .8375217    .8691957
             
|
       
_cons |   .1322888   .0009592  -278.97   0.000     .1304221    .1341822
------------------------------------------------------------------------------
Note_cons estimates baseline incidence rate (conditional on zero random effects).

matrix b=e(b)

meglm sudtx_flag i.tg_status i.AUDITCfyear ||station:, family(poissonlink(logvce(robustfrom(bstartvalues(constantonlystartgrid(2irr

Fitting fixed
-effects model:

Iteration 0:   log likelihood = -1274882.3 
Iteration 1
:   log likelihood = -550683.57 
Iteration 2
:   log likelihood = -537880.67 
Iteration 3
:   log likelihood = -537841.85 
Iteration 4
:   log likelihood = -537841.84 

Refining starting values
:

Grid node 0:   log likelihood = -539160.07
Grid node 1
:   log likelihood = -539160.06

Fitting full model
:

Iteration 0:   log pseudolikelihood = -539160.06 
Iteration 1
:   log pseudolikelihood = -539160.06  (backed up)
Iteration 2:   log pseudolikelihood = -537887.07 
Iteration 3
:   log pseudolikelihood = -535945.22 
Iteration 4
:   log pseudolikelihood = -532746.99 
Iteration 5
:   log pseudolikelihood = -528701.99 
Iteration 6
:   log pseudolikelihood = -527383.35 
Iteration 7
:   log pseudolikelihood = -526721.44 
Iteration 8
:   log pseudolikelihood =  -526698.7 
Iteration 9
:   log pseudolikelihood = -526697.58 
Iteration 10
:  log pseudolikelihood = -526697.46 
Iteration 11
:  log pseudolikelihood = -526697.46 

Mixed
-effects GLM                               Number of obs     =    1405734
Family
:                 Poisson
Link
:                       log
Group variable
:         station                 Number of groups  =        129

                                                Obs per group
:
                                                              
min =      2,255
                                                              avg 
=   10,897.2
                                                              max 
=     32,362

Integration method
mvaghermite                 Integration pts.  =          7

                                                Wald chi2
(8)      =     224.89
Log pseudolikelihood 
= -526697.46               Prob chi2       =     0.0000
                              
(StdErradjusted for 129 clusters in station)
------------------------------------------------------------------------------
             |               
Robust
  sudtx_flag 
|        IRR   StdErr.      z    P>|z|     [95ConfInterval]
-------------+----------------------------------------------------------------
 
1.gender |   1.810606   .0933954    11.51   0.000     1.636503    2.003231
             
|
 
AUDITCfyear |
     
FY2011  |   .9477507   .0138904    -3.66   0.000     .9209132    .9753702
     FY2012  
|   .9556829   .0192247    -2.25   0.024     .9187363    .9941152
     FY2013  
|   .9872037   .0217104    -0.59   0.558     .9455561    1.030686
     FY2014  
|   1.001445   .0244817     0.06   0.953     .9545929    1.050596
     FY2015  
|   .9583612   .0224713    -1.81   0.070      .915315    1.003432
     FY2016  
|   .9040257   .0229442    -3.98   0.000     .8601562    .9501328
     FY2017  
|   .8767459   .0252131    -4.57   0.000     .8286961    .9275818
             
|
       
_cons |   .1647606   .0034821   -85.32   0.000     .1580752    .1717287
-------------+----------------------------------------------------------------
station      |
   var(
_cons)|   5.13e+08   2.98e+07                      4.58e+08    5.74e+08
------------------------------------------------------------------------------
NoteEstimates are transformed only in the first equation.
Note_cons estimates baseline incidence rate (conditional on zero random effects).

margins i.gender
missing predicted values encountered within the estimation sample
r
(322); 
Thank you,
Amy









Do-file editor language color schemes

$
0
0
Has anyone tried these (in Stata 16) yet? I am finding they do not work like I think they should.

For instance in a document where I have selected the Markdown color scheme, text that is marked as a Header does *not* show up as a Custom blue (the default). When I try changing the language to something else and then changing back to markdown, I get varying results - different color schemes that I sometimes can and sometimes can't reproduce.

Please tell me it is not just me!

Storing mean/scalar in a loop

$
0
0
Hi. I am analyzing a set of data and would like to know the weighted average age of observations in each state. I am having trouble writing a loop that correctly and effectively incorporates the idiosyncratic weights. For instance, I want to do the following:
mean weight if state==1
*store this weight somehow as weight_state1
gen weighted_age=weight*age/weight_state1 if state==1
mean weighted_age
*I want to do this for all states

I have been doing this for binary variables such as sex. I used:
mean weight if sex==1
*output is, for example, 5000
gen weighted_age_male=weight*age/5000 if sex==1
mean weighted_age_male

But to do this for all states is a monumental task (because there are variables other than age I want to analyze) and I'm sure there is an easier way to do it in a loop. So far, I know that I can do summ and svret to store the scalars (including the mean) into a table, but I don't know how to extract that one number to use in the next line of code...

Any help is appreciated!

Setting default to round to one decimal

$
0
0
Hello! Is there a way to set a default for Stata to round to one decimal for all the tabs I'm doing on a particular project in a single .do file? I believe I know the way to do it one by one, but if I end up having a large enough number of tabs where it would be easier to just do it once.

I doubt this necessitates example code, but here is some just in case:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte knowl1
.
4
.
.
.
.
.
3
4
4
3
.
.
.
.
3
3
.
1
2
1
.
.
2
1
4
.
.
2
.
.
3
.
.
2
4
3
.
.
3
4
.
.
4
3
3
.
.
.
.
1
1
2
.
.
.
1
1
3
.
2
4
2
.
.
2
4
.
3
4
2
3
3
1
1
3
.
2
3
.
2
.
2
2
3
2
2
3
4
2
.
.
3
.
.
4
3
.
3
4
end

First difference with dummy variable set: interpretation of coefficients

$
0
0
Dear all,

I am using Stata (version 15.1) to estimate a first difference regression. My question is more conceptual in nature. Therefore, I am not providing any Stata output.

My research question is whether the work intensity of a household increases (decreases) after the household started (stopped) using formal childcare for its youngest child. Each household in my sample is observed at exactly two time points. My dependent variable (WORK) is a continuous variable capturing the work intensity of a household (as a percent). My main independent variable is a categorical variable with three levels represented by three dummy variables: "no formal child care" (ECEC1); "part-time formal child care" (ECEC2); "full-time formal child care" (ECEC3).

Between t1 and t2, I observe six types of transitions in my sample (Δ gives the first difference for each dummy variable):
ECEC1 ECEC2 ECEC3
1) t1 1 0 0
t2 0 1 0
Δ -1 1 0
2) t1 1 0 0
t2 0 0 1
Δ -1 0 1
3) t1 0 1 0
t2 1 0 0
Δ 1 -1 0
4) t1 0 1 0
t2 0 0 1
Δ 0 -1 1
5) t1 0 0 1
t2 1 0 0
Δ 1 0 -1
6) t1 0 0 1
t2 0 1 0
Δ 0 1 -1
Lines 1), 2), 3), and 5) describe transitions between ECEC1 and ECEC2/ECEC3, whereas lines 4) and 6) describe transitions between ECEC2 and ECEC3. If I type:

Code:
reg D.(WORK ECEC1 ECEC2 ECEC3), nocons
in Stata, Stata will drop the coefficient for ECEC1 and report two coefficients for ECEC2 and ECEC3. I am unsure how to interpret these two coefficients. My general idea is that the coefficients describe the average change on WORK that is associated with a transition from ECEC1 to ECEC2/from ECEC1 to ECEC3. However, this would imply that Stata ignores transitions 4) and 6) in its estimation of the coefficients for ECEC2 and ECEC3.

Is my interpretation correct? I would be happy if someone could provide a definitive answer to my question, since most book chapters and journal articles on panel regression remain vague with regard to the interpretation of dummy variable sets in first difference and fixed effects regression.

Many thanks in advance,
Antonino

geodist observations too large when calculating pairwise

$
0
0
I am trying to calculate pairwise distances similar to those in the post here:

https://www.statalist.org/forums/for...ating-distance

The code for that post is pasted here for ease.

Code:
clear
input str10 id double year byte division float(latitude longitude)
"000361105" 2006 3   41.9663  -87.98085
"000361105" 2007 3   41.9663  -87.98085
"000361105" 2008 3   41.9663  -87.98085
"000886309" 2006 4  44.86384  -93.43001
"000886309" 2007 4  44.86384  -93.43001
"000886309" 2008 4  44.86384  -93.43001
"000957100" 2006 2  40.70963  -74.01297
"000957100" 2007 2  40.70963  -74.01297
"000957100" 2008 2  40.70963  -74.01297
"001084102" 2006 5   33.9743  -84.14539
"001084102" 2007 5   33.9743  -84.14539
"001084102" 2008 5   33.9743  -84.14539
"00130H105" 2006 5  38.87373  -77.11727
"00130H105" 2007 5  38.87373  -77.11727
"00130H105" 2008 5  38.87373  -77.11727
"001547108" 2008 3  39.34669  -84.41348
"001744101" 2006 9 32.945763 -117.21492
"001744101" 2007 9 32.945763 -117.21492
"001744101" 2008 9 32.945763 -117.21492
"00206R102" 2006 7  32.77925  -96.80477
"00206R102" 2007 7  32.77925  -96.80477
"00206R102" 2008 7  32.77925  -96.80477
"002567105" 2008 9 37.603153 -122.01864
"002824100" 2006 3  42.32403   -87.8567
"002824100" 2007 3  42.32403   -87.8567
"002824100" 2008 3  42.32403   -87.8567
"002896207" 2006 3  40.08307   -82.7989
"002896207" 2007 3  40.08307   -82.7989
"002896207" 2008 3  40.08307   -82.7989
"004498101" 2006 5 26.190046  -81.76478
"004498101" 2007 5 26.190046  -81.76478
"004498101" 2008 5 26.190046  -81.76478
"00508Y102" 2006 5 33.799896   -84.3858
"00508Y102" 2007 5 33.799896   -84.3858
"00508Y102" 2008 5 33.799896   -84.3858
"00724F101" 2006 9  37.34652 -121.90983
"00724F101" 2007 9  37.34652 -121.90983
"00724F101" 2008 9  37.34652 -121.90983
"00738A106" 2006 6   34.7608  -86.68575
"00738A106" 2007 6   34.7608  -86.68575
"00738A106" 2008 6   34.7608  -86.68575
"00751Y106" 2006 5 35.822914  -78.56207
"00751Y106" 2007 5 35.822914  -78.56207
"00751Y106" 2008 5 35.822914  -78.56207
"00770F104" 2006 4  38.64421  -90.65141
"00770F104" 2007 4  38.64421  -90.65141
"00770F104" 2008 4  38.64421  -90.65141
"007800105" 2006 9  33.91714 -118.40427
"007800105" 2007 9  33.91714 -118.40427
"007800105" 2008 9  33.91714 -118.40427
"007903107" 2006 9  37.39349 -121.96467
"007903107" 2007 9  37.39349 -121.96467
"007903107" 2008 9  37.39349 -121.96467
"007973100" 2006 8  40.52986 -105.03664
"007973100" 2007 8  40.52986 -105.03664
"007973100" 2008 8  40.52986 -105.03664
"008190100" 2006 2  40.77724 -74.392944
"008190100" 2007 2  40.77724 -74.392944
"008190100" 2008 2  40.77724 -74.392944
"00846U101" 2006 9  37.34864 -121.98438
"00846U101" 2007 9  37.34864 -121.98438
"00846U101" 2008 9  37.34864 -121.98438
"009158106" 2006 2  40.58427  -75.62479
"009158106" 2007 2  40.58427  -75.62479
"009158106" 2008 2  40.58427  -75.62479
"009363102" 2006 2  40.06187  -75.40246
"009363102" 2007 2  40.06187  -75.40246
"009363102" 2008 2  40.06187  -75.40246
"00971T101" 2007 1    42.362  -71.08159
"00971T101" 2008 1    42.362  -71.08159
"011659109" 2006 9  47.44657  -122.2721
"011659109" 2007 9  47.44657  -122.2721
"011659109" 2008 9  47.44657  -122.2721
"012348108" 2006 1  43.30168  -70.99177
"012348108" 2007 1  43.30168  -70.99177
"012348108" 2008 1  43.30168  -70.99177
"012653101" 2006 5 35.178715  -80.85399
"012653101" 2007 5 35.178715  -80.85399
"012653101" 2008 5 35.178715  -80.85399
"013078100" 2008 3  41.90414  -87.86066
end

egen group= group(year division), label
preserve
rename (*) (*2)
rename group2 group
tempfile file2
save `file2'
restore
joinby group using `file2'
bys group: egen count= count(id)
drop if id==id2 & count>1

geodist latitude longitude latitude2 longitude2, gen(dist)
bys id year group: egen tot_dist= total(dist)
bys id year group: egen pairs= count(id)
bys id year group: gen avg_dist= tot_dist/pairs

keep id year group tot_dist avg_dist division
duplicates drop id year group, force
My problem is that when I

Code:
joinby group using `file2'
The number of observations is > 2B.

Is there a way to split up and speed up the job?

Is it possible to:
i) do a loop by group to calculate the total and average distance for each group (year division)
ii) then collapse the data at the group level
iii) save the file
iv) append all the group files once all groups are complete

Or if there is an easier way to do this, that is fine too? I don't know how to tackle this. This is a very unusual problem for me.

Thanks in advance.


Error for merging summary stats back to the main data

$
0
0
Hi Statalists,

I've tried many methods to merge the average values of several variables back to the main dataset but failed. Would you mind have a look for me? Many thanks for your help!

They both have 100,000 observations so should be merged together at least 80,000 observations. However, I only can merge them to be 50,000 observations. Do you possibly know why? Any ideas will be very much appreciated!

Data A:

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long gvkey double fyear float(dc de)
1000 1972            .             .
1000 1973   -.22959568     .04523377
1000 1974   -.01801909     -1.001482
1000 1975    .28682637     1.8572217
1000 1976    .19203255      .4877907
1000 1977   -.24621645     -.3187987
1001 1985            .             .
1003 1987            .             .
1003 1988    -.0490942    -2.0168355
1004 1973            .             .
1004 1974     .4895051   -.017922383
1004 1975   -1.1206219    .033943113
1004 1976    .12433314      .2703054
1004 1977     .1969116     .19600694
1004 1978  -.029974015      .3969602
1004 1979    .10055578      .2999694
1004 1980  -.005022294    -.01004459
1004 1981   -.12765215     .06834605
1004 1982   -.07468212      .0960625
1004 1983     .3463928    .030518433
1004 1984   -.10752616     .05390986
1004 1985  -.007702183     .07965732
1004 1986  -.012904686     .04910802
1004 1987   .023610715     .04624939
1004 1988  -.011590066    .072830044
1004 1989  -.002092601    .003538544
1004 1990  -.013751525     -.0913088
1004 1991   .021458264    -.07602914
1004 1992  -.016853161    -.08258223
1004 1993    .12766725     .12903117
1004 1994   .032500036  -.0014360995
1004 1995    .07515048     .03740965
1004 1996     .0813249      .0280519
1004 1997    -.1041381     .06100367
1004 1998  -.018910004     .03641419
1004 1999   -.01928659   -.008376142
1004 2000    .04837449     -.1079958
1004 2001    .07831483     -.4384201
1004 2002   -.02306361      .3236768
1004 2003    .11269116      .1847865
1004 2004    .03997531     .07574653
1004 2005     .1758296     .06068583
1004 2006   -.05921251     .05592986
1004 2007    .02942764    .013544516
1004 2008 .00011669762    .011242983
1004 2009   -.06886577    -.10322487
1004 2010   -.03343056     .11701991
1004 2011    .01130368   -.006266636
1004 2012    .01771378    -.02780923
1004 2013    .01947967 -.00014014152
1004 2014   -.03934547    -.23664308
1004 2015  -.021621333      .1215395
1004 2016   -.02590993    .005702664
1004 2017    .02693942    .010758554
1005 1975            .             .
1005 1976     .2041991      .6691447
1005 1977   -.11887328     -.5511397
1005 1978     -.374802      .3435685
1005 1979     .4516379     1.1511961
1005 1980     .7908764      .7498233
1005 1981   -.11737662     .23382536
1007 1977            .             .
1007 1978            .             .
1007 1979            .             .
1007 1980    1.2469934    .008790487
1007 1981   -2.3039556    -1.3691857
1007 1982     .8106416      3.463923
1007 1983    -5.341037     -4.857088
1008 1985            .             .
1009 1986            .             .
1009 1987   -.03348368    -.11672223
1009 1988    .07921765     .15555465
1009 1989   -.06229712     .11050524
1009 1990 -.0019170502     .10139065
1009 1991   .005550219    -.05007263
1009 1992   .002531099     .12416446
1009 1993   .020587796      .1146006
1009 1994  -.009253239       .073477
1010 1964            .             .
1010 1965   -.04692795      .1023616
1010 1966    .25252217      .1618314
1010 1967    .34171075     -.1695898
1010 1968    -.9047028      .0812904
1010 1969   -.20173892     .09522914
1010 1970     .0865992   -.016951822
1010 1971   -.05033485     .02109729
1010 1972    .13494572     .13319345
1010 1973   -.19728447     .14919177
1010 1974  -.018232418     .16825874
1010 1975   .067861795     .09522504
1010 1976  -.017555976     .04730523
1010 1977   .006419752      .0843092
1010 1978  -.001895087     .13969146
1010 1979   .005930668     .13700454
1010 1980  -.009942725     .03826443
1010 1981   .072601125     .15984416
1010 1982   -.06118059    -.12688096
1010 1983   .012026044    -.53885096
1011 1985            .             .
1011 1986    .12850639     -.4357051
end
------------------ copy up to and including the previous line ------------------

Listed 100 out of 168898 observations


Data B:

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(gvkey fyear) float(p_dc p_de)
1004 1996  -.016972471     .6068336
1004 1997 -.0009705835    .09103958
1004 1998    .06460689    .06015029
1004 1999   .006923824  .0020664372
1004 2000    .01495476  -.006880293
1004 2001 -.0010173314    -.4317098
1004 2002   -.03142991   -.13165739
1004 2003      .160884   -.10480762
1004 2004    -.0679172   .032028932
1004 2005   -.13319089    .04567152
1004 2006     .1063403   -.09514127
1004 2007  -.020104256   -.07780945
1004 2008   .021198357    -.0638665
1004 2009     -.223568      .752196
1004 2010  -.000953041     .0790241
1004 2011   -.04841547   .017772233
1004 2012   .026159434    .10575087
1004 2013   .028624203   -.04336542
1004 2014   .000889315     .0324204
1004 2015   -.02799788   -.29572266
1004 2016  -.009789365    .20785473
1004 2017   .013364382  -.014350595
1004    .            .            .
1013 1996    .05612111  .0018894288
1013 1997    .06098711   .032989442
1013 1998  .0013020803   -.02589297
1013 1999    .10743794    .03961814
1013 2000     .1564454   -.07004827
1013 2001   -.09892263  -.026496664
1013 2002   -.10051884     .3869057
1013 2003   -.05169741     .6027072
1013 2004   .034743823    .05719011
1013 2005  -.015270562    .03523292
1013 2006   .006518017    .07212752
1013 2007 -.0019574158   -.00571608
1013 2008    -.0531714   -.03988286
1013 2009  -.018608356    .23264848
1013 2010    .02165826    .25405338
1013    .            .            .
1021 1998   -.52420956    -.3012189
1034 1996     .1581224     .0193479
1034 1997    .08070384   .028907146
1034 1998   .010324656    .05639834
1034 1999    .02562452    .04288518
1034 2000    .06175233  -.032948956
1034 2001    .04469726  -.012426628
1034 2002   -.01983158  -.008117882
1034 2003    .26817462    .08883627
1034 2004   .011760935  -.011197326
1034 2005   .005491525   -.01148821
1034 2006   .027650466  -.006898577
1034 2007   .015620373   .008387797
1034    .            .            .
1036 1999   .022252636    .02678252
1036    .            .            .
1038 1996   .015285124   .034575928
1038 1997     .1702858   -.05709178
1038 1998   -.03873836   -.29459515
1038 1999   -.13263848   -.06309974
1038 2000  -.013043234   -.05295146
1038 2001  .0044387444  .0032957615
1038 2002   .014119712    -.0209228
1038 2003   .019830747   -.07761617
1038 2004    .09934308  -.018496258
1038    .            .            .
1043 1996     .6621441    2.1322525
1043    .            .            .
1045 1996    .04157064   -.13025405
1045 1997    .08677582    .09447137
1045 1998    .06093945    .18050386
1045 1999    .02906814    .08441044
1045 2000    .07667764    -.1268195
1045 2001    .19016138    -.4432393
1045 2002     .1796264     .1166111
1045 2003     .7832436     .7659459
1045 2004   -.06168986    -.3020669
1045 2005    .19903533    .03924605
1045 2006   .015697101     .1707353
1045 2007   -.06125787   .021613557
1045 2008    -.1964355   -.09378213
1045 2009   -.02957071     1.225102
1045 2010   -.03347183   -.07214125
1045 2011    -.0549909   -.14121222
1045 2013   -.04273575  -.006126647
1045 2014  -.007579254     .0255266
1045 2015  -.005087815    .07733705
1045 2016  -.018390637   -.04224721
1045 2017   .012233567    .02520783
1045    .            .            .
1050 1996    .02550435  -.018393217
1050 1997  -.013316247    .09186345
1050 1998   -.10286165   -.05925254
1050 1999    .05805288    .03537869
1050 2000     .0373623   -.02905324
1050 2002    .02753035 -.0011894767
1050 2003     .0578198   .007910307
1050 2004    .03659712  -.013706294
1050 2005   -.03795916    .03530699
1050 2006   .003866833   .036890563
1050 2007    .02236141  -.023730934
end
------------------ copy up to and including the previous line ------------------

Listed 100 out of 100630 observations

POmeans for both treatment groups under ATET

$
0
0
Hello,
After calling
Code:
teffects *, atet
the output produces the POmean for treatment==0 and the associated SE, 95% CI, etc. But
Code:
teffects *, pomeans
yields the POmeans for ATE.

How do I obtain these same estimates for treatment==1 for ATET, not ATE?

Thanks,
Michael



Example:

Code:

Treatment-effects estimation                    Number of obs     =     17,749
Estimator      : IPW regression adjustment
Outcome model  : probit
Treatment model: probit
--------------------------------------------------------------------------------------
                     |               Robust
              arrest |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
---------------------+----------------------------------------------------------------
ATET                 |
              bl_hsp |
           (1 vs 0)  |    .015012   .0038861     3.86   0.000     .0073953    .0226286
---------------------+----------------------------------------------------------------
POmean               |
              bl_hsp |
                  0  |   .0483701   .0021456    22.54   0.000     .0441647    .0525754
--------------------------------------------------------------------------------------

Treatment-effects estimation                    Number of obs     =     17,749
Estimator      : IPW regression adjustment
Outcome model  : probit
Treatment model: probit
--------------------------------------------------------------------------------------
                     |               Robust
              arrest |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
---------------------+----------------------------------------------------------------
ATE                  |
              bl_hsp |
           (1 vs 0)  |    .013148   .0039398     3.34   0.001     .0054261    .0208699
---------------------+----------------------------------------------------------------
POmean               |
              bl_hsp |
                  0  |   .0502359   .0018927    26.54   0.000     .0465263    .0539455
--------------------------------------------------------------------------------------

Treatment-effects estimation                    Number of obs     =     17,749
Estimator      : IPW regression adjustment
Outcome model  : probit
Treatment model: probit
--------------------------------------------------------------------------------------
                     |               Robust
              arrest |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
---------------------+----------------------------------------------------------------
POmeans              |
              bl_hsp |
                  0  |   .0502359   .0018927    26.54   0.000     .0465263    .0539455
                  1  |   .0633839   .0035402    17.90   0.000     .0564451    .0703227
--------------------------------------------------------------------------------------

creating a variable that is the sum of 2 categorical variables

$
0
0
Hi, I have two categorical variables that I have collected data on and inputted into STATA:

hospital_visits_within_30_days

hospital_visits_within_30_to_90_days

Both are yes and no questions. I would like to sum the two so I can have a variable that is hospital visits within 90 days. Can someone tell me what the command is for this? I know how to create new variables but I'm not sure what to type so that I can "sum" these two categorical variables. Any advice is appreciated. Thank you!!

creating means of neighbours' values without without coordinates (cross-section data)

$
0
0
Dear all,

I am trying to create a variable which is the mean of another variable of all observation but the current one in the same location. In the data I have the following variables; observation_id, location_id, and rate, which are all numeric. In the data below for example, I want to create n_rate(label as neighbours' rate) i.e. I want the average rate of neighbours assuming that observations with the same location id are neighbours.
Observation_id Location_id rate n_rate
1 1 5 4.5
2 1 6 4
3 1 3 5.5
4 2 2 4.5
5 2 4 3.5
6 2 5 3
7 3 7 2.75
8 3 3 3.75
9 3 5
10 3 2
11 3 1
12 4 3
13 4 4
14 5 2
15 5 6
16 5 3
17 5 5
18 6 4
19 6 1
Code:
bys location_id: egen Neighbours_rate=mean(rate)
gives me the mean of all observations in each location but I want to exclude current observations in each case.

I would be grateful for assistance.
Thank you.

creating means of neighbours' values without spatial coordinates (cross-section data)

$
0
0
Dear all,

I am trying to create a variable which is the mean of another variable of all observation but the current one in the same location. In the data I have the following variables; observation_id, location_id, and rate, which are all numeric. In the data below for example, I want to create n_rate(label as neighbours' rate) i.e. I want the average rate of neighbours assuming that observations with the same location id are neighbours.
Observation_id Location_id rate n_rate
1 1 5 4.5
2 1 6 4
3 1 3 5.5
4 2 2 4.5
5 2 4 3.5
6 2 5 3
7 3 7 2.75
8 3 3 3.75
9 3 5
10 3 2
11 3 1
12 4 3
13 4 4
14 5 2
15 5 6
16 5 3
17 5 5
18 6 4
19 6 1
Code:
bys location_id: egen Neighbours_rate=mean(rate)
gives me the mean of all observations in each location but I want to exclude current observations in each case.

I would be grateful for assistance.
Thank you.

creating means of neighbours' values without spatial coordinates (cross-section data)

$
0
0
Dear all,

I am trying to create a variable which is the mean of another variable of all observation but the current one in the same location. In the data I have the following variables; observation_id, location_id, and rate, which are all numeric. In the data below for example, I want to create n_rate(label as neighbours' rate) i.e. I want the average rate of neighbours assuming that observations with the same location id are neighbours.
Observation_id Location_id rate n_rate
1 1 5 4.5
2 1 6 4
3 1 3 5.5
4 2 2 4.5
5 2 4 3.5
6 2 5 3
7 3 7 2.75
8 3 3 3.75
9 3 5
10 3 2
11 3 1
12 4 3
13 4 4
14 5 2
15 5 6
16 5 3
17 5 5
18 6 4
19 6 1
Code:
bys location_id: egen Neighbours_rate=mean(rate)
gives me the mean of all observations in each location but I want to exclude current observations in each case.

I would be grateful for assistance.
Thank you.

Making the subheading bold or italic and indent spacing in METAN forestplot

$
0
0
Hi,
Good morning.
I wanted to create a forestplot in METAN. Not actually running a meta-analysis rather only displaying ORs of different subgroups in one plot. Sample date is following:
Exposure Subgroups OR LCL UCL
Overweight vs. Normal Papillary Thyroid Cancer 1.50 1.20 1.89
Obese vs. Normal Papillary Thyroid Cancer 1.71 1.35 2.17
Overweight vs. Normal Follicular Thyroid Cancer 1.71 0.99 2.95
Obese vs. Normal Follicular Thyroid Cancer 1.57 0.88 2.80
Overweight vs. Normal BRAF positive Thyroid Cancer 1.74 1.30 2.33
Obese vs. Normal BRAF positive Thyroid Cancer 2.20 1.64 2.94
Overweight vs. Normal BRAF negative Thyroid Cancer 1.39 1.02 1.90
Obese vs. Normal BRAF negative Thyroid Cancer 1.28 0.92 1.79
I used the following code:

metan logor loglcl logucl, eform by (Subgroups) lcols (Exposure) effect(OR) astext(40) textsize(200) nooverall nobox nosubgroup xlab(1, 2, 3)

The code works fine. But for better clarity of the graph, I wanted to make the heading bold or italic. An indent spacing would also serve my purpose.

I found a post suggesting admetan for this purpose. But it comes up with an additional column that I don't want.



Any help is much appreciated.

Cheers
Sabbir

Is there any stata command to apply 'Multiple Discrete Continuous Extreme Value (MDCEV)' model ?

$
0
0
Dear all,

I had been looking for stata command which let me run 'MDCEV' model but I failed.

Could you give me some advises on the issue?

Thanks you for reading this post!



xtlogit command generating outcome does not vary in any group r(2000); despite the fact that dependent var has values 0 & 1

$
0
0
Hello guys,

I'm new to Stata, and I wanted to do a panel logit regression on var selfemployed. The dataset I'm using is a labor panel data covering 18 waves with around 13k participants each year.

Exact command was: xtlogit selfemployed p010101 edulv p010107 selfempintention parentselfempatage14 lagunemployed2, fe collinear ,
where p010101 is gender, edulv education level acheived, selfempintention whether an individual obtained any training with intention to become self employeed, parentselfempatage14 whether an individual's parents were self-employed at his/her age of 14, lagunemployed2 whether an individual was unemployed 2 years ago.

When I tried running this regression it returned r(2000); despite the fact that dependent var was binary with values 0 & 1. However, if an individual was unemployed or not in the labor force, it was left blank.

Can anyone point me in the right direction?

Thank you so much in advance!

Piecewise regression

$
0
0
Dear stalist

I am running a piecewise regression. I want to use a dataset that contains two different years, 2016 and 2017. I will include a if function to tell STATA which year to run the regression on. However when i run the regression i get an error message saying: " starting values invalid or some RHS variables have missing values". Any ideas on how to solve this?

This is my function: nl (KOSTBHG = SIZE*{b1} + (SIZE>{c})*( SIZE-{c})*{b2} if Year==2017), variables(SIZE) initial(b1 0 c 0 b2 0) noconstant trace
Viewing all 65443 articles
Browse latest View live