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

how to get x-standardized coefficient in logistic regression, i.e., reproduce results from "listcoef" command

$
0
0
I was trying to get the standardized coefficient from ologit model. "listcoef" can produce the table nicely, but I want to reproduce the regression table with just x-standardized coefficients.
So, what I was doing is, first, standardize the X variables, then, regress the Y on standardized Xs. But the standardized coefficients from my model are different from the "listcoef" results for the categorical variables. Standardize categorical variables will literally yield the same thing, so I kept using
Code:
i.foreign i.hdroom
rather than standardized variables. Please look at my code below:

Code:
sysuse auto,clear

* drop missing data
drop if rep78==.

* recode headroom into three categories
recode headroom (1.5 2 2.5 =1 "small") ///
(3 3.5 =2 "medium") ///
(4 4.5 5 =3 "large"), ///
gen(hdroom) label(headroom)
tab hdroom,mi

* unstandardized coefficient
ologit rep78 price i.foreign i.hdroom

* get standardized coefficient using "listcoef"
listcoef, std help

* standardize X variables
foreach v in price foreign hdroom {
egen std`v' = std(`v')
}

* get x-standardized coefficient
ologit rep78 stdprice i.foreign i.hdroom

Did I misunderstand x-standardized coefficient? How does "listcoef" work?

locals vs. scalars

$
0
0
There is an interesting current thread on Twitter about the use of locals vs. scalars. Stata experts won't be surprised with the content, but those with lower levels of expertise (e.g. me) may find this to be a particularly valuable reminder.

The thread is at https://twitter.com/nomadj1s/status/1143505196775104512

The thread's essence is
Code:
. do "/var/folders/d5/6w9t_lzx3plbpmk6zpyz93dm0000gp/T//SD05991.000000"

. local j=-2

. di `j'
-2

. local i=`j'^2

. di `i'
-4

. local i=(`j')^2

. di `i'
4

. scalar k=-2

. di k
-2

. di k^2
4

.
end of do-file

How to filter dates within an interval from a set of observation

$
0
0
Hello,

i have a dataset of around 900,000 observations from about 130,000 ids. The variables i am working with are mostly dates. i wanted to take just the first event date that happened during 1 year period after the interview date. Some of the dates recorded can come from the events that happened before the interview date.

my data would look like this
ID intdate effdate1 effdate2 effdate3 dureffdate1 dureffdate2
1 8/01/2010 28-Apr-10 28-Jul-11 110 566
2 30/08/2010 20-Dec-11 477
3 6/01/2010 31-Jul-10 206
4 13/01/2010 16-Apr-10 93
5 4/08/2010 27-Jul-10 14-Apr-11 -8 253
6 11/03/2010 22-Dec-10 286
7 20/10/2010 23-Sep-10 -27
8 3/11/2010 8-Dec-11 400
9 16/06/2010 6-Sep-11 447
10 29/06/2010 6-Dec-10 25-Jan-11 160 210
11 1/11/2010 6-Oct-11 339
12 15/02/2010 9-Aug-10 175
13 12/11/2010 27-Sep-11 319
14 2/02/2010 10-Mar-11 401
15 14/02/2010 8-Aug-11 540
from intdate and effdate1 to 8 i calculated the interval which resulted in dureffdate1 to 8

i wanted to take just the first date of event which happened during 1 year period after intdate.
how do i do that without deleting other observations as i need them for other analysis.

thank you

Estimation output for Svy: meologit and melogit commands

$
0
0
Hi all,

I am using Stata 14.1 and i am getting an odd but of output.

I am estimating a series of mixed effect ordered logit and binary logit using the svy prefix.

My results are given me very small values for my random effect (10^-34) which make me suspect the model is estimating poorly, partly because their are no random effects (likely based on the model trying to control for the relevant variables)

So in order to exam this, i want to examine the log to see if the results are non-concaved (a standard check), but i was shocked to find i had no iteration log in my log files. I then issued the following command

Code:
 svy: meologit dep_var ind_var fixed_effects || id: , log
But I still don't get any estimation output. Is it not possible with the svy prefix or have i missed something

Thanks in advance


interaction effects: Poisson or Double-limit Tobit

$
0
0
Hi All,

I am working with the DHS data across five countries and looking at relationship between women's empowerment and children's dietary diversity after adjusting for some important exogenous variables. So, my DV is Food Groups (ranging from 1 to 7) and my IVs include 3 different domains of women's empowerment, wealth index, location, age of child, seasonal droughts, etc. I am trying to also examine if the effect of women's empowerment on number of food groups consumed will differ across different socioeconomic group hence I am investigation an interaction between women'e empowerment and wealth index. Please find the codes I used below and my Stata outputs. I ran both DL-Tobit and Poisson and estimated the margins command afterwards but I am struggling to interpret the margins. I think DL-Tobit might be a better model since the DV variable is count with a lower and upper limit. Please, what am I doing wrong and how can I interpret the interactions after running the -margins- command

Code:
tobit food_group c.att_score#b4 c.att_score#v190 b19 v025 built_population_2014 growing_season_length irrigation drought_episodes [pw=sample_weight] if ID=="MOZ", ll(1) ul(7) cluster (dhsclust)
Code:
Tobit regression                                Number of obs    =      2,303
F(  12,   2291)    =      64.43
Prob > F    =     0.0000
Log pseudolikelihood = -4916.4141               Pseudo R2    =     0.0107

(Std. Err. adjusted for 576    clusters in dhsclust)
    
Robust
food_group       Coef.          Std. Err.      t    P>t    [95% Conf. Interval]
    
b4#c.att_score 
male              .4682713    .2814429     1.66   0.096    -.0836382    1.020181
female          .3964391    .2830491      1.40   0.161    -.1586201    .9514983
                      
v190#c.att_score 
poorest        -.1941122   .3194032      -0.61   0.543    -.8204618    .4322374
poorer          -.2820354   .2949845     -0.96   0.339    -.8604999    .2964291
middle         -.3193704   .3110293      -1.03   0.305    -.9292989     .290558
richer          -.6558261    .301876       -2.17   0.030    -1.247805   -.0638473
richest            0  (omitted)
                      
b19             .0724426   .0110004       6.59   0.000    .0508708     .0940143
v025           -.2106143   .1878946     -1.12   0.262    -.5790755    .1578469
built_pop    .0001429    .0000382      3.74   0.000    .000068       .0002178
grwing_sea .000125   .0000238        5.25   0.000    .0000783     .0001716
irrigation    -.0000334    .000032      -1.04   0.297    -.0000962     .0000294
drought_epi -.0000109   .0000295    -0.37   0.712    -.0000688    .0000471
_cons          2.417986   .3833341      6.31   0.000    1.666268      3.169704
    
/sigma    2.035057   .0595378    1.918304    2.151811
    
330  left-censored observations at food_group <= 1
1,859     uncensored observations
114 right-censored observations at food_group >= 7
Code:
margins, dydx(*) atmeans predict  (e(1,.))
Code:
        
 Delta-method
                 dy/dx          Std. Err.          z    P>z     [95% Conf.    Interval]
        
b4 
female    -.0234546     .0444658    -0.53   0.598     -.110606    .0636968
att_score    .0905979   .0646847     1.40   0.161    -.0361817    .2173775
                      
v190 
poorer    -.0288767     .0680193     -0.42   0.671     -.162192    .1044386
middle     -.041052     .0765348     -0.54   0.592    -.1910574    .1089534
richer    -.1484396      .0759134     -1.96   0.051     -.297227    .0003479
richest     .0647657    .106857        0.61   0.544      -.14467    .2742015
                      
b19         .0467903      .0069769      6.71   0.000     .0331159    .0604647
v025       -.1360349      .1214412    -1.12   0.263    -.3740553    .1019856
built_pop .0000923       .0000248     3.72   0.000     .0000436    .000141
grwng_seas .0000807   .0000155     5.21   0.000     .0000504    .0001111
irrigation   -.0000216     .0000207    -1.04   0.297    -.0000621    .000019
drought_epi  -7.04e-06   .0000191    -0.37   0.713    -.0000445    .0000304
        
Note: dy/dx for factor    levels is the discrete change from the base level.
Code:
poisson food_group c.att_score#b4 c.att_score#v190 b19 v025 built_population_2014 growing_season_length irrigation drought_episodes [pw=sample_weight] if ID=="RWA", irr cluster (dhsclust)
Code:
margins, dydx(*)

Create a two-way line graph/bar chart

$
0
0
Hi all

I want to create a line graph/bar chart which looks at the consumption of 3 main fertilizers- UREA, TSP and MOP over a 3 year period across two seasons. I want to include all the three fertilizers in the same graph.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int Sur_yr str10 Cult_idHhidVdsid byte(Season Name_mat) str1 Unit_mat double Qty_mat
2012 "BBG12A0005" 1 22 "3"  5
2012 "BBG12A0007" 4 22 "3" 14
2012 "BBG12A0007" 1 25 "3"  5
2012 "BBG12A0007" 4 25 "3"  5
2012 "BBG12A0007" 4 22 "3" 10
2012 "BBG12A0007" 4 22 "3" 10
2012 "BBG12A0007" 4 22 "3" 14
2012 "BBG12A0007" 1 26 "3"  5
2012 "BBG12A0007" 1 22 "3"  2
2012 "BBG12A0007" 1 25 "3" 21
2012 "BBG12A0007" 1 26 "3" 20
2012 "BBG12A0007" 1 22 "3" 10
2012 "BBG12A0008" 1 26 "3" 12
2012 "BBG12A0008" 1 22 "3" 10
2012 "BBG12A0008" 4 25 "3" 10
2012 "BBG12A0008" 1 22 "3"  8
2012 "BBG12A0008" 4 22 "3" 10
2012 "BBG12A0008" 4 22 "3" 10
2012 "BBG12A0008" 1 25 "3"  7
2012 "BBG12A0008" 4 22 "3" 24
2012 "BBG12A0008" 1 25 "3" 14
2012 "BBG12A0008" 1 22 "3" 15
2012 "BBG12A0008" 1 22 "3"  7
2012 "BBG12A0008" 1 25 "3" 24
2012 "BBG12A0008" 4 26 "3"  8
2012 "BBG12A0008" 4 22 "3"  8
2012 "BBG12A0008" 4 22 "3" 12
2012 "BBG12A0008" 1 22 "3" 12
2012 "BBG12A0008" 1 22 "3" 15
2012 "BBG12A0010" 4 22 "3" 15
2012 "BBG12A0010" 1 22 "3" 15
2012 "BBG12A0010" 4 22 "3"  8
2012 "BBG12A0011" 1 25 "3" 25
2012 "BBG12A0011" 4 26 "3" 15
2012 "BBG12A0011" 1 26 "3" 20
2012 "BBG12A0011" 4 22 "3"  8
2012 "BBG12A0011" 4 22 "3" 10
2012 "BBG12A0013" 1 22 "3"  8
2012 "BBG12A0013" 1 25 "3" 15
2012 "BBG12A0013" 4 25 "3"  5
2012 "BBG12A0013" 4 26 "3"  5
2012 "BBG12A0013" 1 22 "3"  5
2012 "BBG12A0015" 1 26 "3" 10
2012 "BBG12A0015" 1 22 "3" 10
2012 "BBG12A0015" 4 22 "3" 10
2012 "BBG12A0015" 4 26 "3"  7
2012 "BBG12A0015" 1 22 "3"  8
2012 "BBG12A0015" 4 26 "3"  4
2012 "BBG12A0015" 1 25 "3"  7
2012 "BBG12A0015" 1 22 "3" 12
2012 "BBG12A0015" 1 25 "3" 10
2012 "BBG12A0016" 4 22 "3"  5
2012 "BBG12A0019" 1 25 "3"  3
2012 "BBG12A0019" 1 26 "3"  2
2012 "BBG12A0019" 1 22 "3"  3
2012 "BBG12A0019" 4 26 "3"  5
2012 "BBG12A0019" 4 22 "3"  8
end
label values Season Seasonname
label def Seasonname 1 "RABI", modify
label def Seasonname 4 "KHARIF", modify
label values Name_mat inputnames
label def inputnames 22 "UREA", modify
label def inputnames 25 "TSP", modify
label def inputnames 26 "MP", modify
How should I go about with it? Any help would be appreciated.

Thanks!
Enakshi

Taking the average of observations within a specific date range

$
0
0
Hi,


I want to compute the average of a variable (teamsize) for observations within a specific time period. I have a date variable formatted as such that I would like to use. Specifically, I have data on companies and their teams at different points in time. I want to calculate the average team size for a specific company within a given time period, always between the current date and 365 days prior to the observation.


. bysort company: egen mean(teamsize) if inrange()

is my best guess (sorry, new to stata and related programs in general!). I do not know how to specify inrange so that it takes the average of all observations with a date (variable is DATE, formatted as %td) in the range of the observation date and the 365 previous days. For example, if the teamsize was 55 on June 1st 2011, I want to create variable with a mean that takes into account all teamsizes from June 1st 2010 to June 1st 2011, including the team size of June 1st 2011.

It would be awesome if someone could help me out!

Best,
Julian

unbalanced panel

$
0
0
Hi everyone
I'm running a regression with fixed effects of individuals:
reg y x i.firm i.year i.individual
I have an unbalanced panel dataset which is like below:
firm date individual y x
1 may 1992 1 12 390
1 may 1992 2 12 390
1 may 1992 3 12 390
1 december 1993 3 56 1234
1 december 1993 4 56 1234
2 march 1992 5 111 234
2 march 1992 6 111 234
2 may 1992 2 111 234
2 may 1992 7 111 234
the problem is I want to run the regression at firm-date level, but it's like I'm running the regression at firm-date-individual with this data and observations on x and y(which is unique for every year and every firm) are considering several times in regression. what should I do for regressing only at firm-date level and not losing the data of individuals? (the number of unique indivudals is about 2000)

Using suest to compare coefficients

$
0
0
Hi statalist,
I am running an ordinal regression model separately for each sex because I expect that the effects of the predictors (specifically the interaction) to be different for men and women. The models are testing the likelihood that men/women would have a traditional ideology.

Code:
svyset qid [pweight=wt]
svy: ologit id3 i.education 1.work 0.spouse#i.economic i.religion  i.listen political i.economic i.marital i.region logincome age agesq i.cohort i.period if gender==1, or
est store man
svy: ologit id3 i.education 1.work 0.spouse#i.economic i.religion  i.listen political i.economic i.marital i.region logincome age agesq i.cohort i.period if gender==2, or
est store woman
suest man woman
Code:
Simultaneous survey results for man, woman

Number of strata   =         1                  Number of obs     =      2,680
Number of PSUs     =     1,987                  Population size   = 2,655.2312
                                                Design df         =      1,986

-----------------------------------------------------------------------------------------------------------------
                                                |             Linearized
                                                |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------------------------------------+----------------------------------------------------------------
man_id3                                         |
                                      education |
                                    Elementary  |   .0787633   .1806598     0.44   0.663    -.2755394     .433066
                                     Secondary  |   .0117818   .1726825     0.07   0.946    -.3268761    .3504397
                                    University  |   .1053516   .2021198     0.52   0.602    -.2910376    .5017408
                                                |
                                           work |
                                        1. yes  |  -.1116036   .1737101    -0.64   0.521    -.4522767    .2290695
                                                |
                                spouse#economic |
         Spouse works#Covers expenses (secure)  |   1.160649   .3581059     3.24   0.001     .4583466    1.862952
Spouse works#Doesn't cover expenses (insecure)  |  -.4648882   .2072134    -2.24   0.025    -.8712666   -.0585098
                                                |
                                       religion |
                                  2. christian  |  -.0182428   .2704264    -0.07   0.946    -.5485919    .5121064
                                                |
                                         listen |
                                  2. sometimes  |  -.3539208   .1319334    -2.68   0.007    -.6126632   -.0951785
                                     3. rarely  |  -.4853662   .1459226    -3.33   0.001    -.7715436   -.1991889
                                                |
                                      political |   .2089263   .0620367     3.37   0.001     .0872625      .33059
                                                |
                                       economic |
             Doesn't cover expenses (insecure)  |   .0729956   .1575337     0.46   0.643    -.2359531    .3819442
                                                |
                                        marital |
                                    2. married  |  -.0432063   .1904298    -0.23   0.821    -.4166694    .3302567
                                                |
                                         region |
                      Lower Egypt governorates  |  -.1365269   .1599036    -0.85   0.393    -.4501234    .1770695
                      Upper Egypt governorates  |  -.2274291   .1685498    -1.35   0.177     -.557982    .1031238
                                                |
                                      logincome |   .1551783   .0958476     1.62   0.106    -.0327941    .3431508
                                            age |   .0128797    .051374     0.25   0.802    -.0878728    .1136323
                                          agesq |  -.0001043   .0005008    -0.21   0.835    -.0010865    .0008779
                                                |
                                         cohort |
                                     1964-1973  |   .1119754   .2476741     0.45   0.651     -.373753    .5977037
                                     1974-1983  |   .3115691   .3595084     0.87   0.386    -.3934841    1.016622
                                     1984-1993  |   .4088195   .5206053     0.79   0.432    -.6121704    1.429809
                                                |
                                         period |
                                     2012-2014  |   .6442029   .1490939     4.32   0.000     .3518061    .9365997
                                     2016-2017  |   .7775735   .1686798     4.61   0.000     .4467656    1.108381
------------------------------------------------+----------------------------------------------------------------
/man                                            |
                                           cut1 |  -.7401549    1.46927                     -3.621628    2.141318
                                           cut2 |   .5665118   1.464685                     -2.305969    3.438993
                                           cut3 |   2.077412   1.467121                     -.7998457     4.95467
------------------------------------------------+----------------------------------------------------------------
woman_id3                                       |
                                      education |
                                    Elementary  |   .2780877   .1916926     1.45   0.147    -.0978519    .6540274
                                     Secondary  |   .3179796   .1865287     1.70   0.088    -.0478329     .683792
                                    University  |   .4554928   .2570505     1.77   0.077    -.0486242    .9596097
                                                |
                                           work |
                                        1. yes  |   .2620603   .2351785     1.11   0.265    -.1991622    .7232829
                                                |
                                spouse#economic |
         Spouse works#Covers expenses (secure)  |  -.3328209   .3344589    -1.00   0.320    -.9887481    .3231063
Spouse works#Doesn't cover expenses (insecure)  |  -.1385766   .2600382    -0.53   0.594     -.648553    .3713997
                                                |
                                       religion |
                                  2. christian  |   .2921078    .378534     0.77   0.440    -.4502576    1.034473
                                                |
                                         listen |
                                  2. sometimes  |  -.7402079   .1633234    -4.53   0.000    -1.060511   -.4199048
                                     3. rarely  |  -.4795959   .1657152    -2.89   0.004    -.8045897    -.154602
                                                |
                                      political |   .4714854    .054928     8.58   0.000     .3637628     .579208
                                                |
                                       economic |
             Doesn't cover expenses (insecure)  |  -.0602975   .2918711    -0.21   0.836    -.6327033    .5121082
                                                |
                                        marital |
                                    2. married  |   .0447678   .2589441     0.17   0.863    -.4630628    .5525984
                                                |
                                         region |
                      Lower Egypt governorates  |  -.2900283   .1768335    -1.64   0.101    -.6368269    .0567704
                      Upper Egypt governorates  |  -.3901754   .1939057    -2.01   0.044    -.7704554   -.0098955
                                                |
                                      logincome |   .0190685   .1196309     0.16   0.873    -.2155468    .2536839
                                            age |   .0013179   .0545291     0.02   0.981    -.1056223    .1082581
                                          agesq |   .0003056    .000605     0.51   0.614    -.0008809    .0014921
                                                |
                                         cohort |
                                     1964-1973  |   .5862433   .3077719     1.90   0.057    -.0173463    1.189833
                                     1974-1983  |    1.01426   .4388562     2.31   0.021     .1535936    1.874927
                                     1984-1993  |   1.402392   .5997558     2.34   0.019      .226175    2.578608
                                                |
                                         period |
                                     2012-2014  |  -.0401117    .181343    -0.22   0.825    -.3957542    .3155308
                                     2016-2017  |   .2895471   .1937657     1.49   0.135    -.0904583    .6695524
------------------------------------------------+----------------------------------------------------------------
/woman                                          |
                                           cut1 |  -2.069591   1.625566                     -5.257586    1.118403
                                           cut2 |  -.4816368   1.625974                     -3.670431    2.707158
                                           cut3 |   1.003396   1.620462                     -2.174587    4.181379
-----------------------------------------------------------------------------------------------------------------
I am testing whether the coefficients for the interaction terms are equal to each other and these are the results.

Code:
test [man_id3]0.spouse#0.economic  = [woman_id3]0.spouse#0.economic

Adjusted Wald test

 ( 1)  [man_id3]0.spouse#0b.economic - [woman_id3]0.spouse#0b.economic = 0

       F(  1,  1986) =    9.34
            Prob > F =    0.0023

. 
. test [man_id3]0.spouse#1.economic  = [woman_id3]0.spouse#1.economic

Adjusted Wald test

 ( 1)  [man_id3]0.spouse#1.economic - [woman_id3]0.spouse#1.economic = 0

       F(  1,  1986) =    1.00
            Prob > F =    0.3172
Am I correct in interpreting those as:
  • The first test means we can reject the null that both coefficients are equal to one another
  • We cannot reject the null that both coefficients are equal to each other. Specifically, having a spouse that works and being financially insecure leads to a more traditional ideology for both men and women. As in there is no difference between the two coefficients and both coefficients are negatively associated with ideology.

Lagged dependent variable in mixed models?

$
0
0
Hi everyone,
I have some questions. I have a dataset of about political parties in 30 countries and roughly 15 elections for each. I want to use mixed models (three levels: one, parties, two, country-years and three, countries) as I plan to test the effects of both party level (ideology etc.) and country-year level variables (economy etc.). My dataset is highly unbalanced as the election dates in each country is different from each other and between elections there are yearly gaps within each country. Heteroscedasticity and autocorrelation are also present. So two questions:
First, I use robust SEs and first lagged of the dependent variable on the right side (that is vote shares is my DV and I use previous vote shares as a control). Some similar papers also used lagged DV of votes, but use them in FE models. I read in a few places that using lag value of DV might lead to severe biases in mixed models. Is that correct?
Second, a reviewer recommended me to use dynamic panel model. I am not sure if it would work with such unbalanced data. Also I have no familiarity with the model itself. Is it a sound advice for my dataset?
Best

lincom value meaning?

ODBC / Access problem with Stata 16

$
0
0
I can describe and query a database but am unable to load a table from Access using ODBC in Stata 16. Using the Northwind database:
Code:
.  odbc describe "Employees", dsn("Northwind")

DataSource: Northwind (query)
Table:      Employees (load)
-------------------------------------------------------------------------------
Variable Name                               Variable Type
-------------------------------------------------------------------------------
ID                                          COUNTER
Company                                     VARCHAR
Last Name                                   VARCHAR
First Name                                  VARCHAR
E-mail Address                              VARCHAR
Job Title                                   VARCHAR
Business Phone                              VARCHAR
Home Phone                                  VARCHAR
Mobile Phone                                VARCHAR
Fax Number                                  VARCHAR
Address                                     LONGCHAR
City                                        VARCHAR
State/Province                              VARCHAR
ZIP/Postal Code                             VARCHAR
Country/Region                              VARCHAR
Web Page                                    LONGCHAR
Notes                                       LONGCHAR
Attachments                                 LONGCHAR
-------------------------------------------------------------------------------

. odbc query "Northwind"

DataSource: Northwind
Path      : C:\Users\marty\Documents\Northwind.accdb
-------------------------------------------------------------------------------
Customers
Employee Privileges
Employees
Inventory Transaction Types
Inventory Transactions
Invoices
Order Details
Order Details Status
Orders
Orders Status
Orders Tax Status
Privileges
Products
Purchase Order Details
Purchase Order Status
Purchase Orders
Sales Reports
Shippers
Strings
Suppliers
-------------------------------------------------------------------------------

. odbc load, table("Employees")
The ODBC driver reported the following diagnostics
[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
SQLSTATE=42000
r(682);
If I set debug on there is no additional output, and as far as I can find SQLSTATE=42000 appears to be a generic error.

I would be grateful for any suggestions on how to resolve this.

Thank you,
Martyn

Non-linear relationship

$
0
0
Hello,

I have a quick question: In order to justify propensity score matching, I need to assume a non linear relationship between outcome and covariates.
Would you see this as a non linear relationship?

Array

Kind regards
Dominik

Parallel trend assumption using leads and lags

$
0
0
I am running some robustness checks to my diff-in-diff specification. In particular, I am trying to check if the parallel trend assumption is satisfied. I am following the suggestion reported here https://stats.stackexchange.com/ques...mon-trend-betw.

Thus, given my dataset, I am running an -xtreg, fe- where log_GON is my dependent variable and the diff-in-diff variable would be treated_decr*post_decr, i.e. the interaction between the dummy of being in the treated group and being post the date of implementation of the policy I am interested in. The year of implementation is 1995. Thus following the suggestion in the link I am running a diff-in-diff model with leads and lags for the diff-in-diff term and I am planning to test if the two pre-treatment terms, i.e. the ones in 1994 and 1993 are jointly non significant.

The code and the outcomes are the following


Code:
xtreg log_GON treated_decr#1994.year treated_decr#1993.year treated_decr#1996.year ///
treated_decr#1997.year treated_decr#1998.year c.year c.year#i.state ///
if (state == 2|state == 5|state == 6|state == 8) & year >= 1985, cluster(state) fe basel
Code:
Fixed-effects (within) regression               Number of obs     =        128
Group variable: state                           Number of groups  =          4

R-sq:                                           Obs per group:
     within  = 0.3827                                         min =         32
     between = 0.1068                                         avg =       32.0
     overall = 0.0748                                         max =         32

                                                F(3,3)            =          .
corr(u_i, Xb)  = -0.9994                        Prob > F          =          .

                                       (Std. Err. adjusted for 4 clusters in state)
-----------------------------------------------------------------------------------
                  |               Robust
          log_GON |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
treated_decr#year |
          0 1993  |          0  (base)
          0 1994  |  -.4768764   .1315696    -3.62   0.036    -.8955894   -.0581633
          0 1996  |  -.4627052   .4205494    -1.10   0.352    -1.801081    .8756705
          0 1997  |  -.0429162   .4332989    -0.10   0.927    -1.421867    1.336034
          0 1998  |  -.0507665   .2062129    -0.25   0.821    -.7070279    .6054949
          1 1993  |  -.7470444   3.39e-08 -2.2e+07   0.000    -.7470445   -.7470443
          1 1994  |  -.8624563   2.99e-08 -2.9e+07   0.000    -.8624564   -.8624562
          1 1996  |  -.6488787   2.18e-08 -3.0e+07   0.000    -.6488787   -.6488786
          1 1997  |  -.5308411   1.78e-08 -3.0e+07   0.000    -.5308412   -.5308411
          1 1998  |  -.1217581   1.38e-08 -8.8e+06   0.000    -.1217582   -.1217581
                  |
             year |   .0501079   4.00e-09  1.3e+07   0.000     .0501078    .0501079
                  |
     state#c.year |
              SA  |  -.0288139   .0015684   -18.37   0.000    -.0338051   -.0238227
             Tas  |  -.0237483   .0015684   -15.14   0.001    -.0287395    -.018757
              WA  |  -.0365106   .0015684   -23.28   0.000    -.0415019   -.0315194
                  |
            _cons |  -52.61188   2.378725   -22.12   0.000    -60.18204   -45.04172
------------------+----------------------------------------------------------------
          sigma_u |  31.831812
          sigma_e |  .47882443
              rho |  .99977378   (fraction of variance due to u_i)
-----------------------------------------------------------------------------------
and then the test gives me

Code:
test 1.treated_decr#1993b.year 1.treated_decr#1994.year
Code:
( 1)  1.treated_decr#1993b.year = 0
 ( 2)  1.treated_decr#1994.year = 0
       Constraint 2 dropped

       F(  1,     3) = 4.9e+14
            Prob > F =    0.0000
My main doubt is about the specification. It makes sense to me but I am not 100% sure about it because I removed treated_decr#1992.year on purpose to keep it as a baseline but I would add treated_decr#1995.year, the real diff-in-diff coefficient of interest.

Do you have any hint?



Threshold VAR - imposing restrictions and generating GIRFs

$
0
0
Dear Stata users,

I am using threshold in Stata 15.1 in order to estimate a fiscal policy threshold VAR (TVAR) model. For the post purposes, I am using a quarterly time-series from 2000q1 to 2018q4 with 3 variables - D.aggregate consumption, D.govt_spending and D.vat_receipts - resulting in 66 observations. Theoretical model is in the vein of Blanchard & Perotti, whereas some of the TVAR references used are Mirdala&Kamenik (2017) and Baum&Koester (2011).

My questions would be the following:

1) How do I impose SVAR-like restrictions within TVAR? Within svar it is pretty straightforward, however I haven't seen it in the threshold manual guide anything like that.
2) Is there a Stata code to automatically generate generalized impulse response functions (GIRFs)? The algorithm for computing GIRF can be found in Myrdala&Kamenik at page 23.
3) Did I miss a Stata code for Tsay's non-linearity test?

Thanks for your help,

Mateo


References
Mirdala & Kamenik (2017) - https://mpra.ub.uni-muenchen.de/7991...aper_79919.pdf
Baum&Koester (2011) - https://core.ac.uk/download/pdf/6670964.pdf

warning: variance matrix is nonsymmetric or highly singular

$
0
0
Dear all,

I have performed multinomial regression that is comprised of a dependent variable (4 categories; coding starts from 0 to 3) and 32 independent variables of company characteristics and owners. However, when it comes to estimating the marginal effect average for each category of the dependent variables I got for the third category STATA software warning which says: 'variance matrix is nonsymmetric or highly singular' I searched to understand and solve the problem but could not find a clear solution. An example of the problem is attached.

Please, could you advise me what to do in this situation? How to solve it please?

My research objective is to identify the determinants of the factors that would affect approaching bank financing. Therefore and in case if the problem of the variance matrix not solve, can I use the estimated coefficient s to interpret the analysis instead of the average marginal effect estimation?




Best regards,
Rabab

Identifying sessions in time series data

$
0
0
Hi All,

I have time series data identifying the start time and the identity of the two players in a game. The same players will often play a "session" of games against each other within a short period of time. I define a session of games as a series of games where each game occurs no more than 60 minutes after the previous game. I want to create a variable that identifies the order of these games per player pair per sessions.

In the example below, players A and B played 5 games against each other, the order of which are indicated by the PlayerOpponent_GameNum variable. However, these 5 games occur across two different "sessions" - the MinuteDifference variable shows the number of minutes between the current game and the previous game.

The variable I want to create is the PlayerOpponent_GameNum_Session, which shows the order of the games played between players A and B within each session, with sessions consisting of games that start no more than 60 minutes after one another.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str20 Player double DateTime str20 Opponent float(PlayerOpponent PlayerOpponent_GameNum MinuteDifference PlayerOpponent_GameNum_Session)
"A" 1.7692939e+12 "B" 1 1 . 1
"A" 1769294348000 "B" 1 2 7.466667 2
"A" 1769879610000 "B" 1 3 9754.366 1
"A" 1769880061000 "B" 1 4 7.516667 2
"A" 1769880121000 "B" 1 5 1 3
"A" 1.7692867e+12 "C" 2 1 . 1
"A" 1769287148000 "C" 2 2 7.466667 2
end
format %tc DateTime
label var PlayerOpponent "group(Player Opponent)"
Any help is greatly appreciated. Thanks!

[mixlogit] constraint in the parameters distribution

$
0
0
Dear all,

I'm using the 'mixlogit' command to estimate a RPL model. I want to put interactions to a variable that is random, with a parameter with a log-normal distribution. But I want the interactions to be fixed. However, I need their parameters to be log-normal, to be sure that when adding to the random variable that has a log-normal parameter, the values are still positive.

I didn't find a straight way to restrict parameters distribution (neither in this command or anywhere in stata). I find a way following an answer by Arne Risa Hole (author on -mixlogit- ) to how to constraint parameter values, that was very useful. Following that, I constructed the example below to my end, but I wander if that is the right way to do it. Any advice is very welcome.

Code:
 use http://fmwww.bc.edu/repec/bocode/t/traindata.dta  *this inverts price variable, because I will want to put it log-norma gen mprice=-1*price  *this creates a variable that vary by individual, but not by option attribute. That is, is an observed feature of the individual gen obs_feat = rnormal() bysort pid: replace obs_feat= obs_feat[1]  *generate the interaction of the price and the observed feature  gen int1=mprice*obs_feat  gen int2=price*obs_feat  * Define constraints constraint 1 [SD]int1 = 0  * Generate starting values clogit y contract local wknown int2 price , group(gid) matrix start = e(b),0,0,0,0,0  * Run mixed logit model mixlogit y , group(gid) id(pid) /// rand(contract local wknown int1 mprice) constraints(1) ln(2) from(start, copy)


thanks,
Matías

How to extract a certain portion of a string variable?

$
0
0
Hello

I have a string variable (PERIOD_END) for date:

Code:
31mar2014 00:00:00
28feb2014 00:00:00
There are numerous possibilities for the date, but in each case the year makes up characters 6-9 of the variable. I tried to extract only these characters using the following code:

Code:
gen year = substr("PERIOD_END",6,9)
That only assigned the characters "D_EN" to a variable called year. I also unsuccessfully tried the regexm command:

[code]gen year=2014 if regexm("PERIOD_END", "2014") == 1
[/code

I have a feeling I'm supposed to use the regexm command, but that I am using it incorrectly. Thanks.

What is the lomackinlay test result mean?

$
0
0
. lomackinlay csx, robust

Lo-MacKinlay modified overlapping Variance Ratio statistic for csx
[ 1 - 1835 ]

q N VR R_s p>z
2 1819 1.034 1.0246 0.3056
4 1819 0.982 -0.2994 0.7646
8 1819 0.908 -0.9378 0.3483
16 1819 0.876 -0.8699 0.3844

Test statistics robust to heteroskedasticity

Hi there, as you can see I just run a lomackinlay test to analysis the random walk hypothesis. But I am a little confused about the result. Is the result shows there is no evidence to reject the null hypothesis? So it follows a random walk? And what should I do if I want to get the probability about rejection? Thanks a lot.
Viewing all 65055 articles
Browse latest View live


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