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

Interpreting coefficient vs. margins from three-way interaction

$
0
0
Hello,

I have a question regarding the interpretation of a three-way interaction in a GEE model with a continuous outcome. I am doing this with multiply imputed data. The interaction is between a dichotomous group indicator (x1) and two continuous predictors (x2 and x3). Something like this:

Code:
mi est: xtgee y i.x1##c.x2##c.x3, corr(exch)
The coefficient of the three-way interaction is not significant in the output. However, my particular research question is whether the effect of x2 is significant at higher levels of x3, and whether this interaction differs between the two groups I am considering (signified by the x1 group indicator). So I used margins (or actually, Daniel Klein's great mimrgns command) to obtain the marginal effects of x2 on y at meaningful values of x3, and tested whether those effects differed between the two groups (x1). Something like:

Code:
mimrgns, dydx(x2) at(x1=(0 1) x3=0)) pwcompare
mimrgns, dydx(x2) at(x1=(0 1) x3=1)) pwcompare
mimrgns, dydx(x2) at(x1=(0 1) x3=2)) pwcompare
mimrgns, dydx(x2) at(x1=(0 1) x3=3)) pwcompare
My question is how to interpret these results: there are significant group differences in the effect of x2 at higher levels of x3 (determined with mimrgns and dydx), but the overall three-way interaction is not significant in the regression output. Does this mean that the three-way interaction is significant only at a certain part of the range of x3 and not over the whole range? Or should I not be reporting the significant marginal effects because the overall three-way interaction is not significant.

Thanks for your help,
Robbie

How to plot regression in an interval

$
0
0
Hi all,

can any of you tell me if the below representation of regression analysis is possible in STATA and how is it called ? I am running analysis of marital status on life satisfaction.

Thank you!

Regards,
Gabriela

Homogeneity test (Hsiao test) on panel data balanced with many missing values

$
0
0
Dear all,
I'm new on Stata community and I'm using stata 12. I'm trying to determine whether governance has a direct effect on the economic growth of a panel of 33 countries over 15 years.
To make sure I can use panel fixed effect models I am trying to perform a homogeneity test on my dataset. My panel is balanced but with many missing values.

When I perform the Hsiao test (1986) it displays the error message "no observation r(2000)". I think it's because of the missing values. Am I right? Stata still displays a result can I take it into account ? If not, how to perform this test for a panel with missing data?


The Hsiao test command used :

* Calcul de SCR1 non contraint: Estimation équation par équation
set more off
local SCR1=0
scalar N=33
scalar T=15
scalar K=5
forvalues i=1/33 {
qui reg tc_pibh wgi_igg caphum ide com pop if i==`i'
local SCR1=`SCR1'+e(rss)
}
di `SCR1'

* Calcul de SCR1C contraint: Estimation sur le modèle empilé
qui reg tc_pibh wgi_igg caphum ide com pop

local SCR1C=e(rss)
di `SCR1C'

*Calcul de la statistique de Fisher F1 N=33 T=15 K=5
local F1=((`SCR1C'-`SCR1')*(N*T-N*(K+1)))/(`SCR1'*(N-1)*(K+1))
*La P_value de F1
di "dof1 = " (N-1)*(K+1) " dof2 = " (N*T-N*(K+1))
local PVF1=Ftail((K+1)*(N-1),(N*T-N*(K+1)),`F1')

* Calcul de SCR1CP: estimation du modèle à effets individuels
xtreg tc_pibh wgi_igg caphum ide com pop laid,fe

local SCR1CP=e(rss)
di `SCR1CP'
*Calcul de la statistique de Fisher F2
local F2=((`SCR1CP'-`SCR1')*(N*T-N*(K+1)))/(`SCR1'*(N-1)*K)

*La P_value de F2
di "dof1 = " K*(N-1) " dof2 = " (N*T-N*(K+1))
local PVF2=Ftail(K*(N-1),(N*T-N*(K+1)),`F2')

*Calcul de la statistique de Fisher F3
local F3=(`SCR1C'-`SCR1CP')*(N*(T-1)-K)/(`SCR1CP'*(N-1))

*La P_value de F3
di "dof1 = " (N-1) " dof2 = " (N*(T-1)-K)
local PVF3=Ftail((N-1),(N*(T-1)-K),`F3')

*Affichage des résultats
di in y " SCR1 = " in gr `SCR1'
di in y " SCR1C = " in gr `SCR1C'
di in y " SCR1CP = " in gr `SCR1CP'

di in y "F1 = " in gr `F1'
di in y "F2 = " in gr `F2'
di in y "F3 = " in gr `F3'

di in y "PvalF1 = " in gr `PVF1'
di in y "PvalF2 = " in gr `PVF2'
di in y "PvalF3 = " in gr `PVF3'

In attachments you will find xtdescribe, xtsum and the error message.

Thank you very much for your help,
Kindy

Omit range of values on the x-axis in a histogram

$
0
0
Hi,
I'm trying to plot a histogram of a variable for Spanish data. Since Spain was a dictatorship between 1939 to 1975, I'd like to omit these years but still keep observations between 1900 and 1938, and well as those between 1976 until 2016. Do you know if it is possible to do that in a histogram?
Thank you
Best,

Teresa

geodist - calculating distance

$
0
0
Hi Statalists,

I have data with id (i.e. addresses), year (i.e. 2006, 2007 and 2008), devision (i.e. from 1 to 9), latitude and longitude. I would like to calculate as follows:

- For a given year, for each address, I would like to calculate the sum distance between that address to other addresses but conditioning they are in the same devision (for example with id_000361105, calculate distances from id_000361105 to id_001547108, from id_000361105 to id_002896207, from id_000361105 to id_013078100, since these ids are in the same devision 3, then sum the distances up and divided by the number of pairs to obtain the average distance for id_000361105).

I have read some people that showed the code for geodist command, but it is a bit complicated for my case (i.e. geodist within groups with conditions). Can anyone help me out with this please?

I really appreciate your help.

Thank you


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str10 id double year byte devision 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

Significance levels of combined coefficients

$
0
0
Dear Stata users,

My regression looks as follows: y = x0 x1 x2 x3 x4 x5

Where x4 = x3 * dummy (indicating top quartile) and x5 = x3 * dummy (indicating bottom quartile)
I follow the methodology by Easterwood & Nutt (1999) where they sum up the coefficients to get the total effect of the top (x3 + x4) and bottom (x3+x5) quartiles.
I don't know how to compute the significance levels of these combined coefficients though.

All help is greatly appreciated!

Kind regards,

Frank

LCA gsem output tables and intercept significance

$
0
0
Hello dear all,
I was trying to understand the output tables especially the first one, mlogit model for C (I have attached the output below). I have searched on Stata documentation on SEM Release 15 and LCA example 50g, but to no avail. Ex 50g ignores those tables and continues with the output result from –estat lcmean- My questions are
  1. what does the p-value for _cons in the first table indicate (in my case they are insignificant)? AIC and BIC values for 3 class solution are smaller than one class solution in my analysis
  2. if the intercept coeficient for an item (x) remains insignificant as in:
    Code:
    bin_ettor_life  //in my third class
    for one class but significant in the other classes, what does this indicate? This is related to the table output of logistic regression models of the third classes
The documentation for LCA is a bit lacking (subjective opinion) in practical examples wrt to other SEM documentations, or it may be that I am novice user.
thank you for your help

Code:
Generalized structural equation model           Number of obs     =      2,669
Log likelihood = -17965.754

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.C          |  (base outcome)
-------------+----------------------------------------------------------------
2.C          |
       _cons |   -.054045   .0738337    -0.73   0.464    -.1987563    .0906663
-------------+----------------------------------------------------------------
3.C          |
       _cons |  -.0547762   .0774471    -0.71   0.479    -.2065697    .0970174
------------------------------------------------------------------------------


Class          : 3

Response       : bin_problemDays_me~l           Number of obs     =      2,654
Family         : Bernoulli
Link           : logit

Response       : bin_sed_regUse_life            Number of obs     =      2,081
Family         : Bernoulli
Link           : logit

Response       : m_depress_life                 Number of obs     =      2,665
Family         : Bernoulli
Link           : logit

Response       : m_anxiety_life                 Number of obs     =      2,664
Family         : Bernoulli
Link           : logit

Response       : m_violence_life                Number of obs     =      2,663
Family         : Bernoulli
Link           : logit

Response       : bin_problemDays_drug           Number of obs     =      2,189
Family         : Bernoulli
Link           : logit

Response       : polydrug_life_wo_s~2           Number of obs     =      2,603
Family         : Bernoulli
Link           : logit

Response       : bin_reg_alkonsetage            Number of obs     =      2,656
Family         : Bernoulli
Link           : logit

Response       : bin_abuse_alkonset~e           Number of obs     =      2,367
Family         : Bernoulli
Link           : logit

Response       : bin_fam_conflict               Number of obs     =      2,632
Family         : Bernoulli
Link           : logit

Response       : bin_f2f5_combine               Number of obs     =      2,633
Family         : Bernoulli
Link           : logit

Response       : bin_ettor_life                 Number of obs     =      2,652
Family         : Bernoulli
Link           : logit

Response       : bin_problemDays_alc            Number of obs     =      2,637
Family         : Bernoulli
Link           : logit

---------------------------------------------------------------------------------------------
                            |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
----------------------------+----------------------------------------------------------------
bin_problemDays_medical     |
                      _cons |  -.1611242   .0762826    -2.11   0.035    -.3106353    -.011613
----------------------------+----------------------------------------------------------------
bin_sed_regUse_life         |
                      _cons |  -2.811561   .2081087   -13.51   0.000    -3.219446   -2.403675
----------------------------+----------------------------------------------------------------
m_depress_life              |
                      _cons |  -2.438758   .2544036    -9.59   0.000    -2.937379   -1.940136
----------------------------+----------------------------------------------------------------
m_anxiety_life              |
                      _cons |  -2.448186     .24694    -9.91   0.000    -2.932179   -1.964192
----------------------------+----------------------------------------------------------------
m_violence_life             |
                      _cons |  -2.656828   .1686088   -15.76   0.000    -2.987295    -2.32636
----------------------------+----------------------------------------------------------------
bin_problemDays_drug        |
                      _cons |  -5.713981    1.22993    -4.65   0.000    -8.124599   -3.303362
----------------------------+----------------------------------------------------------------
polydrug_life_wo_sed_cutat2 |
                      _cons |  -4.463023   .4840727    -9.22   0.000    -5.411788   -3.514258
----------------------------+----------------------------------------------------------------
bin_reg_alkonsetage         |
                      _cons |  -.4409185   .0859805    -5.13   0.000    -.6094371   -.2723998
----------------------------+----------------------------------------------------------------
bin_abuse_alkonsetage       |
                      _cons |   -.473027   .0947681    -4.99   0.000    -.6587691   -.2872849
----------------------------+----------------------------------------------------------------
bin_fam_conflict            |
                      _cons |   -2.16245   .1306248   -16.55   0.000     -2.41847    -1.90643
----------------------------+----------------------------------------------------------------
bin_f2f5_combine            |
                      _cons |  -1.205164   .0966388   -12.47   0.000    -1.394572   -1.015755
----------------------------+----------------------------------------------------------------
bin_ettor_life              |
                      _cons |    .076515   .0784798     0.97   0.330    -.0773027    .2303327
----------------------------+----------------------------------------------------------------
bin_problemDays_alc         |
                      _cons |   .5939501   .0790166     7.52   0.000     .4390803    .7488199
---------------------------------------------------------------------------------------------

ML estimation goes forever in longitudinal analysis

$
0
0
Hi statisticians,

I am running a saturated model (-mixed-) for preliminarily assess the effect of intervention for two time points (baseline and time-1).

Outcome variable: meanscore_body (continuous, ranging from 1-5)
Group indicator: studygroup (0: control; 1: intervention)
Time indicator: time (1: baseline; 2: time-1)

I am running the codes:
Code:
global restrict = "t1dropcase == 0 & t2dropcase == 0 &  _merge2 == 3"
mixed meanscore_body i.time##i.studygroup if $restrict || surid: , residual(uns, t(time)) var ml
And it is already on the ~300 iterations with messages:
Code:
Iteration 270: log likelihood = -5412.7565  (backed up)
Iteration 271: log likelihood = -5412.7565  (backed up)
Iteration 272: log likelihood = -5412.7565  (backed up)
Iteration 273: log likelihood = -5412.7565  (backed up)
Iteration 274: log likelihood = -5412.7565  (backed up)
Iteration 275: log likelihood = -5412.7565  (backed up)
Iteration 276: log likelihood = -5412.7565  (backed up)
Iteration 277: log likelihood = -5412.7565  (backed up)
Iteration 278: log likelihood = -5412.7565  (backed up)
Iteration 279: log likelihood = -5412.7565  (backed up)
Iteration 280: log likelihood = -5412.7565  (backed up)
They all indicate on the same log likelihood values. My questions are:
1) What the "backed up" mean in my case?
2) Does long-time of iteration process suggest model mis-specification?
3) How can I modify to get it converged?

Thanks so much in advance!!

Best,
Mengmeng

Stata update error: 'Could not move java to .old/' r(695)

$
0
0
Greetings,

I'm running Stata 15.1 on OSX. I really bought a new computer and (using OSX's 'migration assistant') migrated all of my software (including Stata) from the old to new computer. I've since been having problems when trying to update Stata. At first, the error prompts related to the folder permissions (the authorization settings I subsequently modified). Having resolved those, I'm now getting an r(695) error that reads 'Could not move java to .old/'.

Does anyone have any idea what might be going wrong here? If not, who might I be able to turn to for help? Thanks in advance!

Create a var with some conditions in a same column

$
0
0
Hi,


I want to create a var with some conditions in a same column. For example,

This is the original data

Id var1

01 c
01 d
02 m
02 f

I want to create a var (var2) =1, if i have "c" and "d" in my Id "01"

Id var1 var2

01 c 1
01 d 1
02 m .
02 f


I hope you can help me
Kind Regards,

S.

Sample selection in the control function approach

$
0
0
I am trying to understand which sample it is correct to use in the first stage when estimating the models using the control function (CF) approach and lagged explanatory variables. Below, I explain in detail what I mean.

The CF approach is an alternative to xtivreg, fe estimation. Suppose X is an endogenous independent variable. In the CF approach, we first run
xtreg X Z C1 C2, fe, where
C1 and C2 are controls from the first stage and Z is an instrument); then predict residuals with
predict CF, resid
and then insert CF in the first stage:
xtreg Y X C1 C2 CF, fe
In this case, coefficients for X, C1, and C2 should be the same in both xtreg Y X C1 C2 CF, fe and xtivreg Y C1 C2 (X = Z), fe, while standard errors will differ if we do not adjust the ones from xtreg, fe via bootsrapping (I did not use bootstrapping in order not to create additional confusion).

Indeed, here are the results of xtreg, fe and xtivreg, fe I derived using the nlswork data:

xtreg, fe (errors not bootstrapped)
Code:
webuse nlswork, clear
quietly xtreg tenure union south age c.age#c.age not_smsa, fe
predict cf, resid
xtreg ln_w tenure age c.age#c.age not_smsa cf, fe

Fixed-effects (within) regression               Number of obs     =     19,007
Group variable: idcode                          Number of groups  =      4,134

R-sq:                                           Obs per group:
     within  = 0.1328                                         min =          1
     between = 0.2365                                         avg =        4.6
     overall = 0.2073                                         max =         12

                                                F(5,14868)        =     455.53
corr(u_i, Xb)  = 0.2033                         Prob > F          =     0.0000

------------------------------------------------------------------------------
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      tenure |   .2403531   .0151385    15.88   0.000     .2106797    .2700264
         age |   .0118437   .0036499     3.24   0.001     .0046894     .018998
             |
 c.age#c.age |  -.0012145   .0000798   -15.22   0.000    -.0013709    -.001058
             |
    not_smsa |  -.0167178   .0137527    -1.22   0.224    -.0436748    .0102393
          cf |  -.2227325   .0151602   -14.69   0.000    -.2524484   -.1930167
       _cons |   1.678287   .0659452    25.45   0.000     1.549027    1.807548
-------------+----------------------------------------------------------------
     sigma_u |  .38999138
     sigma_e |  .25552281
         rho |  .69964877   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(4133, 14868) = 8.30                 Prob > F = 0.0000
xtivreg, fe:
Code:
xtivreg ln_w age c.age#c.age not_smsa (tenure = union south), fe

Fixed-effects (within) IV regression            Number of obs     =     19,007
Group variable: idcode                          Number of groups  =      4,134

R-sq:                                           Obs per group:
     within  =      .                                         min =          1
     between = 0.1304                                         avg =        4.6
     overall = 0.0897                                         max =         12

                                                Wald chi2(4)      =  147926.58
corr(u_i, Xb)  = -0.6843                        Prob > chi2       =     0.0000

------------------------------------------------------------------------------
     ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      tenure |   .2403531   .0373419     6.44   0.000     .1671643    .3135419
         age |   .0118437   .0090032     1.32   0.188    -.0058023    .0294897
             |
 c.age#c.age |  -.0012145   .0001968    -6.17   0.000    -.0016003   -.0008286
             |
    not_smsa |  -.0167178   .0339236    -0.49   0.622    -.0832069    .0497713
       _cons |   1.678287   .1626657    10.32   0.000     1.359468    1.997106
-------------+----------------------------------------------------------------
     sigma_u |  .70661941
     sigma_e |  .63029359
         rho |  .55690561   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F  test that all u_i=0:     F(4133,14869) =     1.44      Prob > F    = 0.0000
------------------------------------------------------------------------------
Instrumented:   tenure
Instruments:    age c.age#c.age not_smsa union south
------------------------------------------------------------------------------
As you could see, coefficients are the same, just standard errors differ (standard errors equalize once bootstrapped that confirms that both approaches yield the exact same results when the same instrument is used).

However, my question is which sample in the first stage it is correct to use once our explanatory variables are lagged?

When explanatory variable are (one year) lagged, fixed-effects IV estimator produces the following:
Code:
xtivreg ln_w l.age cl.age#cl.age l.not_smsa (l.tenure = l.union l.south), fe

Fixed-effects (within) IV regression            Number of obs     =      7,500
Group variable: idcode                          Number of groups  =      3,294

R-sq:                                           Obs per group:
     within  =      .                                         min =          1
     between = 0.0685                                         avg =        2.3
     overall = 0.0571                                         max =          6

                                                Wald chi2(4)      =   80781.56
corr(u_i, Xb)  = -0.5474                        Prob > chi2       =     0.0000

------------------------------------------------------------------------------
     ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      tenure |
         L1. |   .1755435   .0389611     4.51   0.000     .0991811    .2519059
             |
         age |
         L1. |   .0106753   .0134104     0.80   0.426    -.0156085    .0369592
             |
      cL.age#|
      cL.age |  -.0008867   .0002305    -3.85   0.000    -.0013384   -.0004351
             |
    not_smsa |
         L1. |  -.0452809   .0509685    -0.89   0.374    -.1451773    .0546154
             |
       _cons |   1.671945   .2302329     7.26   0.000     1.220697    2.123194
-------------+----------------------------------------------------------------
     sigma_u |  .59050356
     sigma_e |  .54146412
         rho |  .54324114   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F  test that all u_i=0:     F(3293,4202) =     1.08       Prob > F    = 0.0089
------------------------------------------------------------------------------
Instrumented:   L.tenure
Instruments:    L.age cL.age#cL.age L.not_smsa L.union L.south
------------------------------------------------------------------------------
The following CF model provides the same results:
Code:
quietly xtreg l.tenure l.union l.south l.age cl.age#cl.age l.not_smsa, fe
predict cf, resid
xtreg ln_w l.tenure l.age cl.age#cl.age l.not_smsa cf, fe

Fixed-effects (within) regression               Number of obs     =      7,500
Group variable: idcode                          Number of groups  =      3,294

R-sq:                                           Obs per group:
     within  = 0.1351                                         min =          1
     between = 0.1783                                         avg =        2.3
     overall = 0.1770                                         max =          6

                                                F(5,4201)         =     131.21
corr(u_i, Xb)  = 0.1436                         Prob > F          =     0.0000

------------------------------------------------------------------------------
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      tenure |
         L1. |   .1755435   .0205221     8.55   0.000     .1353094    .2157776
             |
         age |
         L1. |   .0106753   .0070637     1.51   0.131    -.0031732    .0245239
             |
      cL.age#|
      cL.age |  -.0008867   .0001214    -7.30   0.000    -.0011247   -.0006488
             |
    not_smsa |
         L1. |  -.0452809   .0268467    -1.69   0.092    -.0979147    .0073528
             |
          cf |  -.1641325    .020582    -7.97   0.000     -.204484   -.1237809
       _cons |   1.671945   .1212711    13.79   0.000      1.43419    1.909701
-------------+----------------------------------------------------------------
     sigma_u |  .41441731
     sigma_e |   .2852065
         rho |  .67859444   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(3293, 4201) = 3.72                  Prob > F = 0.0000
However, if I do not use lags in the first stage and lag the residual in the second stage instead, the coefficients differ (because different samples were used in the first stage).

Code:
quietly xtreg tenure union south age c.age#c.age not_smsa, fe
predict cf, resid
xtreg ln_w l.tenure l.age cl.age#cl.age l.not_smsa l.cf, fe

Fixed-effects (within) regression               Number of obs     =      7,500
Group variable: idcode                          Number of groups  =      3,294

R-sq:                                           Obs per group:
     within  = 0.1353                                         min =          1
     between = 0.1785                                         avg =        2.3
     overall = 0.1767                                         max =          6

                                                F(5,4201)         =     131.45
corr(u_i, Xb)  = 0.1454                         Prob > F          =     0.0000

------------------------------------------------------------------------------
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      tenure |
         L1. |   .2566965   .0304213     8.44   0.000     .1970547    .3163383
             |
         age |
         L1. |   .0144529    .006859     2.11   0.035     .0010056    .0279002
             |
      cL.age#|
      cL.age |  -.0013382   .0001577    -8.48   0.000    -.0016475    -.001029
             |
    not_smsa |
         L1. |  -.0346281    .027326    -1.27   0.205    -.0882015    .0189453
             |
          cf |
         L1. |  -.2452925   .0305005    -8.04   0.000    -.3050896   -.1854954
             |
       _cons |   1.710315   .1238945    13.80   0.000     1.467417    1.953214
-------------+----------------------------------------------------------------
     sigma_u |  .41454272
     sigma_e |  .28517027
         rho |  .67878182   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(3293, 4201) = 3.72                  Prob > F = 0.0000
Is it completely incorrect to do this
Code:
quietly xtreg tenure union south age c.age#c.age not_smsa, fe
predict cf, resid
xtreg ln_w l.tenure l.age cl.age#cl.age l.not_smsa l.cf, fe
instead of this?
Code:
quietly xtreg l.tenure l.union l.south l.age cl.age#cl.age l.not_smsa, fe
predict cf, resid
xtreg ln_w l.tenure l.age cl.age#cl.age l.not_smsa cf, fe
Sorry for a long post. I just wanted to demonstrate my reasoning with examples.

Subpop MLM: Xtmixed

$
0
0

Hi all,
I am running a multi-level modeling using complex survey data, which used a stratified, clustered, and unequally sampling design. For my research questions, I have to select a subsample, but due to the weight issues, I think I am not able to create a new tiny dataset which only includes my subsample. For regular regression analyses, I use SVY, subpop (): regress command, but I wonder if it would be possible to use a similar command for MLM with a subpop and continuous outcomes in Stata. If not possible, any thoughts on another approach to deal with it?

Thank you so much!

How to compare prognostic models with a survivaldecision curve analysis for survival outcomes?

$
0
0
Hello,
i am currently using the dca (stdca) command in stata 14.0
I research a dataset of patients with a prognostic marker and would like to compare the recurrence free survival at one year, 3 years and 5 years of the standard model with a "full" model that includes the marker (so one more covariate basically).
I know how to compare the two models for recurrence in general and i know how to do a dca for survival outcomes. But i can not figure out how to create the graph to compare the two models for survival outcomes at different follow-up points. I am familiar with the pdf of Vickert et al. https://www.mskcc.org/sites/default/...-2015-2-26.pdf , but i feel like it does not cover what i attempt. Does anyone have an idea on how to do it? i know that it is possible in R as well, but i have very (and i mean VERY) limited knowledge in R. Is it even possible in stata?
I hope somebody can help me and that its not too dumb a question.

Cheers,

Florian

Exporting underlying data behind stata generated graphs

$
0
0
Hi, i was able to export the underlying data behind a graph i created using a dataset (below)
but when i do, i only get the mediam values and not the ci (confidence intervals). How can i modify the code so that the exported excel dataset also includes values for CIs?

sts graph, failure ci
serset use
export excel "hazard.xlsx",sheetreplace
serset clear


Replace missing observations in VAR1 with observations from VAR2 f

$
0
0
Dear forum,

I am trying to replace the missing observation(s) in ExportMarkets with the value in MirrorExportMarkets. May I ask what the command is for this?

ExportMarkets MirrorExportMarkets
1991 . 45 67
1992 . . 58
1993 . 97 89

Kind regards,
Ray

problema with local extended_fcn local list : dir . files "*"

$
0
0
Hello everyone.

this is my first post in Statalist, so please forgive any mistake on it.

I'm trying to capture the filenames of several files in any given directory using:

local filename : dir . files "*"

This actually works and it creates a local named `filename' containing the names of every file in the directory. The problem is that it does not separates the filenames from eachother, so I get a string: fosis.xlsxjunaeb.xlsxmatriz2019.xlsxmineduc.xlsxse nama.xlsxsename.xlsxsence.xlsxsernameg.xlsxssmds.x lsxsstrabajo.xlsx (names are arbitrary)

Thus, I am unable to work with each file separatedly as I would like. Does anyone knows how to solve this?

I appreciate your answers.

**Im currently working with STATA 14 running in Windows 10 in a Lenovo Thinkpad 51 signature edition**

Problems with Nesting in Panel Regression "panels are not nested within clusters"

$
0
0
Hi,

I am not sure how to overcome this error message I am receiving "panels are not nested within clusters". The code I am trying to run is:

xtset acode qdate
xtreg recycling loginc logpopden loghhsize md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25 md26 md27 md28 md29 md291 wasteavg dryavg quarter2 quarter3 quarter4, fe vce(cluster acode)


I am regressing the recycling rate on income, population density, household size, dummies for method, waste and dry average frequencies, quarter dummies.

Below is a sample of my data.

Furthermore I am having trouble even when I don't cluster and just have the below code, my quarter dummy variables are omitted for collinearity. Why is this happening?

xtreg recycling loginc logpopden loghhsize gcses alevels unitary md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25 md26 md27 md28 md29 md291 wasteavg dryavg quarter2 quarter3 quarter4, fe vce(robust)

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str43 name str9 code int year byte quarter float(qdate quarter2 quarter3 quarter4 recycling loginc logpopden loghhsize)
"Hartlepool Borough Council"           "E06000001" 2012 1 208 0 0 0  31.64322 9.576926 2.2529745 .8586616
"Hartlepool Borough Council"           "E06000001" 2012 2 209 1 0 0  29.11372 9.576926  2.261659 .8586616
"Hartlepool Borough Council"           "E06000001" 2012 3 210 0 1 0 24.318804 9.576926  2.261659 .8586616
"Hartlepool Borough Council"           "E06000001" 2012 4 211 0 0 1  23.49204 9.576926  2.261659 .8586616
"Hartlepool Borough Council"           "E06000001" 2013 1 212 0 0 0  29.75906  9.58011 2.2631164 .8628899
"Hartlepool Borough Council"           "E06000001" 2013 2 213 1 0 0 25.608576  9.58011 2.2631164 .8628899
"Hartlepool Borough Council"           "E06000001" 2013 3 214 0 1 0  19.14898  9.58011 2.2631164 .8628899
"Hartlepool Borough Council"           "E06000001" 2013 4 215 0 0 1 26.363016  9.58011 2.2631164 .8628899
"Hartlepool Borough Council"           "E06000001" 2014 1 216 0 0 0  29.21854 9.606159 2.2677865 .8671005
"Hartlepool Borough Council"           "E06000001" 2014 2 217 1 0 0 22.891203 9.606159 2.2631164 .8671005
"Hartlepool Borough Council"           "E06000001" 2014 3 218 0 1 0 22.664324 9.606159 2.2677865 .8671005
"Hartlepool Borough Council"           "E06000001" 2014 4 219 0 0 1    19.374 9.606159 2.2677865 .8671005
"Hartlepool Borough Council"           "E06000001" 2015 1 220 0 0 0  25.64599 9.642772 2.2669578 .8671005
"Hartlepool Borough Council"           "E06000001" 2015 2 221 1 0 0 24.093536 9.642772 2.2669578 .8671005
"Hartlepool Borough Council"           "E06000001" 2015 3 222 0 1 0 23.910435 9.642772 2.2669578 .8671005
"Hartlepool Borough Council"           "E06000001" 2015 4 223 0 0 1  22.74303 9.642772 2.2669578 .8671005
"Hartlepool Borough Council"           "E06000001" 2016 1 224 0 0 0 25.628105 9.620527  2.265921 .8712934
"Hartlepool Borough Council"           "E06000001" 2016 2 225 1 0 0 21.490993 9.620527  2.265921 .8712934
"Hartlepool Borough Council"           "E06000001" 2016 3 226 0 1 0  20.56008 9.620527  2.265921 .8712934
"Hartlepool Borough Council"           "E06000001" 2016 4 227 0 0 1  19.26644 9.620527  2.265921 .8712934
"Middlesbrough Borough Council"        "E06000002" 2012 1 208 0 0 0  15.01909 9.554639  3.262778 .8586616
"Middlesbrough Borough Council"        "E06000002" 2012 2 209 1 0 0 14.171424 9.554639  3.234316 .8586616
"Middlesbrough Borough Council"        "E06000002" 2012 3 210 0 1 0 13.453314 9.554639  3.234316 .8586616
"Middlesbrough Borough Council"        "E06000002" 2012 4 211 0 0 1  13.24626 9.554639  3.234316 .8586616
"Middlesbrough Borough Council"        "E06000002" 2013 1 212 0 0 0  14.57947 9.564863  3.236794 .8628899
"Middlesbrough Borough Council"        "E06000002" 2013 2 213 1 0 0 14.828068 9.564863  3.236794 .8628899
"Middlesbrough Borough Council"        "E06000002" 2013 3 214 0 1 0 14.709766 9.564863  3.236794 .8628899
"Middlesbrough Borough Council"        "E06000002" 2013 4 215 0 0 1  20.44064 9.564863  3.236794 .8628899
"Middlesbrough Borough Council"        "E06000002" 2014 1 216 0 0 0 34.159927 9.601301 3.2381685 .8671005
"Middlesbrough Borough Council"        "E06000002" 2014 2 217 1 0 0  24.25953 9.601301  3.236794 .8671005
"Middlesbrough Borough Council"        "E06000002" 2014 3 218 0 1 0  24.04574 9.601301 3.2381685 .8671005
"Middlesbrough Borough Council"        "E06000002" 2014 4 219 0 0 1    24.127 9.601301 3.2381685 .8671005
"Middlesbrough Borough Council"        "E06000002" 2015 1 220 0 0 0  27.94404 9.626811  3.239502 .8671005
"Middlesbrough Borough Council"        "E06000002" 2015 2 221 1 0 0 23.334343 9.626811  3.239502 .8671005
"Middlesbrough Borough Council"        "E06000002" 2015 3 222 0 1 0  19.43632 9.626811  3.239502 .8671005
"Middlesbrough Borough Council"        "E06000002" 2015 4 223 0 0 1  23.32905 9.626811  3.239502 .8671005
"Middlesbrough Borough Council"        "E06000002" 2016 1 224 0 0 0  23.50695 9.613669   3.24228 .8712934
"Middlesbrough Borough Council"        "E06000002" 2016 2 225 1 0 0 20.070557 9.613669   3.24228 .8712934
"Middlesbrough Borough Council"        "E06000002" 2016 3 226 0 1 0 19.601873 9.613669   3.24228 .8712934
"Middlesbrough Borough Council"        "E06000002" 2016 4 227 0 0 1  21.82984 9.613669   3.24228 .8712934
"Redcar and Cleveland Borough Council" "E06000003" 2012 1 208 0 0 0  23.51096 9.537339  1.728642 .8586616
"Redcar and Cleveland Borough Council" "E06000003" 2012 2 209 1 0 0  20.10306 9.537339  1.712536 .8586616
"Redcar and Cleveland Borough Council" "E06000003" 2012 3 210 0 1 0  19.72007 9.537339  1.712536 .8586616
"Redcar and Cleveland Borough Council" "E06000003" 2012 4 211 0 0 1 22.403687 9.537339  1.712536 .8586616
"Redcar and Cleveland Borough Council" "E06000003" 2013 1 212 0 0 0 24.170063 9.545955  1.710911 .8628899
"Redcar and Cleveland Borough Council" "E06000003" 2013 2 213 1 0 0  23.99578 9.545955  1.710911 .8628899
"Redcar and Cleveland Borough Council" "E06000003" 2013 3 214 0 1 0 24.617693 9.545955  1.710911 .8628899
"Redcar and Cleveland Borough Council" "E06000003" 2013 4 215 0 0 1  30.60893 9.545955  1.710911 .8628899
"Redcar and Cleveland Borough Council" "E06000003" 2014 1 216 0 0 0  36.69286 9.575816 1.7105495 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2014 2 217 1 0 0  23.24818 9.575816  1.710911 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2014 3 218 0 1 0  28.21425 9.575816 1.7105495 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2014 4 219 0 0 1    33.378 9.575816 1.7105495 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2015 1 220 0 0 0 34.828026 9.600556  1.711272 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2015 2 221 1 0 0 26.965475 9.600556  1.711272 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2015 3 222 0 1 0 18.484371 9.600556  1.711272 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2015 4 223 0 0 1   22.8024 9.600556  1.711272 .8671005
"Redcar and Cleveland Borough Council" "E06000003" 2016 1 224 0 0 0 25.000637 9.583902  1.713077 .8712934
"Redcar and Cleveland Borough Council" "E06000003" 2016 2 225 1 0 0  23.34894 9.583902  1.713077 .8712934
"Redcar and Cleveland Borough Council" "E06000003" 2016 3 226 0 1 0  20.75586 9.583902  1.713077 .8712934
"Redcar and Cleveland Borough Council" "E06000003" 2016 4 227 0 0 1 25.922733 9.583902  1.713077 .8712934
"Stockton-on-Tees Borough Council"     "E06000004" 2012 1 208 0 0 0  20.72435 9.607841   2.19778 .8586616
"Stockton-on-Tees Borough Council"     "E06000004" 2012 2 209 1 0 0  19.85636 9.607841 2.1946657 .8586616
"Stockton-on-Tees Borough Council"     "E06000004" 2012 3 210 0 1 0 17.278917 9.607841 2.1946657 .8586616
"Stockton-on-Tees Borough Council"     "E06000004" 2012 4 211 0 0 1  20.15345 9.607841 2.1946657 .8586616
"Stockton-on-Tees Borough Council"     "E06000004" 2013 1 212 0 0 0  22.03593 9.608176  2.197891 .8628899
"Stockton-on-Tees Borough Council"     "E06000004" 2013 2 213 1 0 0 18.222332 9.608176  2.197891 .8628899
"Stockton-on-Tees Borough Council"     "E06000004" 2013 3 214 0 1 0  17.56083 9.608176  2.197891 .8628899
"Stockton-on-Tees Borough Council"     "E06000004" 2013 4 215 0 0 1  19.13032 9.608176  2.197891 .8628899
"Stockton-on-Tees Borough Council"     "E06000004" 2014 1 216 0 0 0 21.184946 9.632138  2.201991 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2014 2 217 1 0 0 13.187984 9.632138  2.201991 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2014 3 218 0 1 0 16.005465 9.632138  2.201991 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2014 4 219 0 0 1    18.041 9.632138  2.201991 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2015 1 220 0 0 0 20.246767 9.662816  2.206735 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2015 2 221 1 0 0 16.660748 9.662816  2.206735 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2015 3 222 0 1 0  15.44666 9.662816  2.206735 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2015 4 223 0 0 1 18.055502 9.662816  2.206735 .8671005
"Stockton-on-Tees Borough Council"     "E06000004" 2016 1 224 0 0 0 17.611841 9.641798 2.2102504 .8712934
"Stockton-on-Tees Borough Council"     "E06000004" 2016 2 225 1 0 0 14.851618 9.641798 2.2102504 .8712934
"Stockton-on-Tees Borough Council"     "E06000004" 2016 3 226 0 1 0 14.507548 9.641798 2.2102504 .8712934
"Stockton-on-Tees Borough Council"     "E06000004" 2016 4 227 0 0 1  17.83563 9.641798 2.2102504 .8712934
"Darlington Borough Council"           "E06000005" 2012 1 208 0 0 0  42.36351 9.570878 1.6325684 .8586616
"Darlington Borough Council"           "E06000005" 2012 2 209 1 0 0 32.836056 9.570878  1.678964 .8586616
"Darlington Borough Council"           "E06000005" 2012 3 210 0 1 0  31.34309 9.570878  1.678964 .8586616
"Darlington Borough Council"           "E06000005" 2012 4 211 0 0 1   32.1052 9.570878  1.678964 .8586616
"Darlington Borough Council"           "E06000005" 2013 1 212 0 0 0 28.556936 9.597573 1.6757873 .8628899
"Darlington Borough Council"           "E06000005" 2013 2 213 1 0 0 30.584833 9.597573 1.6757873 .8628899
"Darlington Borough Council"           "E06000005" 2013 3 214 0 1 0  28.63693 9.597573 1.6757873 .8628899
"Darlington Borough Council"           "E06000005" 2013 4 215 0 0 1  21.55379 9.597573 1.6757873 .8628899
"Darlington Borough Council"           "E06000005" 2014 1 216 0 0 0  20.11268 9.606159 1.6770965 .8671005
"Darlington Borough Council"           "E06000005" 2014 2 217 1 0 0 26.908495 9.606159 1.6757873 .8671005
"Darlington Borough Council"           "E06000005" 2014 3 218 0 1 0  25.60923 9.606159 1.6770965 .8671005
"Darlington Borough Council"           "E06000005" 2014 4 219 0 0 1  30.62015 9.606159 1.6770965 .8671005
"Darlington Borough Council"           "E06000005" 2015 1 220 0 0 0 31.480186  9.65098 1.6769096 .8671005
"Darlington Borough Council"           "E06000005" 2015 2 221 1 0 0  29.34417  9.65098 1.6769096 .8671005
"Darlington Borough Council"           "E06000005" 2015 3 222 0 1 0   29.5002  9.65098 1.6769096 .8671005
"Darlington Borough Council"           "E06000005" 2015 4 223 0 0 1 25.388384  9.65098 1.6769096 .8671005
"Darlington Borough Council"           "E06000005" 2016 1 224 0 0 0  29.34344 9.647757 1.6770965 .8712934
"Darlington Borough Council"           "E06000005" 2016 2 225 1 0 0  27.49854 9.647757 1.6770965 .8712934
"Darlington Borough Council"           "E06000005" 2016 3 226 0 1 0  28.14532 9.647757 1.6770965 .8712934
"Darlington Borough Council"           "E06000005" 2016 4 227 0 0 1  28.00815 9.647757 1.6770965 .8712934
end
format %tq qdate

Struggling with Collinearity in Panel Data

$
0
0
Hi,

I am struggling with how to set up my regression robustness check. I am currently running a regression of recycling rates on income, population density and several other variables.

I have panel data of 350 local authorities over 20 quarters so have used
xtset acode qdate
xtreg recycling loginc logpopden loghhsize (unitary) md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25 md26 md27 md28 md29 md291 wasteavg dryavg quarter2 quarter3 quarter4, fe vce(robust)


Some local authorities are Unitary and some are not. I would like to test whether unitary authorities have a higher recycling rate, however whenever I include my dummy for Unitary (takes the value one if that local authority is unitary), I get collinearity. Have I missed something?
Should I run two separate regressions for if Unitary= 1 and Unitary =0 and test if they are statistically different?

Below is a sample of my data.
Thank you!

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str43 name str9 code int year byte quarter float(qdate quarter2 quarter3 quarter4 recycling loginc logpopden loghhsize) byte unitarydummy
"Hartlepool Borough Council"           "E06000001" 2012 1 208 0 0 0  31.64322 9.576926 2.2529745 .8586616 1
"Hartlepool Borough Council"           "E06000001" 2012 2 209 1 0 0  29.11372 9.576926  2.261659 .8586616 1
"Hartlepool Borough Council"           "E06000001" 2012 3 210 0 1 0 24.318804 9.576926  2.261659 .8586616 1
"Hartlepool Borough Council"           "E06000001" 2012 4 211 0 0 1  23.49204 9.576926  2.261659 .8586616 1
"Hartlepool Borough Council"           "E06000001" 2013 1 212 0 0 0  29.75906  9.58011 2.2631164 .8628899 1
"Hartlepool Borough Council"           "E06000001" 2013 2 213 1 0 0 25.608576  9.58011 2.2631164 .8628899 1
"Hartlepool Borough Council"           "E06000001" 2013 3 214 0 1 0  19.14898  9.58011 2.2631164 .8628899 1
"Hartlepool Borough Council"           "E06000001" 2013 4 215 0 0 1 26.363016  9.58011 2.2631164 .8628899 1
"Hartlepool Borough Council"           "E06000001" 2014 1 216 0 0 0  29.21854 9.606159 2.2677865 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2014 2 217 1 0 0 22.891203 9.606159 2.2631164 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2014 3 218 0 1 0 22.664324 9.606159 2.2677865 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2014 4 219 0 0 1    19.374 9.606159 2.2677865 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2015 1 220 0 0 0  25.64599 9.642772 2.2669578 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2015 2 221 1 0 0 24.093536 9.642772 2.2669578 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2015 3 222 0 1 0 23.910435 9.642772 2.2669578 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2015 4 223 0 0 1  22.74303 9.642772 2.2669578 .8671005 1
"Hartlepool Borough Council"           "E06000001" 2016 1 224 0 0 0 25.628105 9.620527  2.265921 .8712934 1
"Hartlepool Borough Council"           "E06000001" 2016 2 225 1 0 0 21.490993 9.620527  2.265921 .8712934 1
"Hartlepool Borough Council"           "E06000001" 2016 3 226 0 1 0  20.56008 9.620527  2.265921 .8712934 1
"Hartlepool Borough Council"           "E06000001" 2016 4 227 0 0 1  19.26644 9.620527  2.265921 .8712934 1
"Middlesbrough Borough Council"        "E06000002" 2012 1 208 0 0 0  15.01909 9.554639  3.262778 .8586616 1
"Middlesbrough Borough Council"        "E06000002" 2012 2 209 1 0 0 14.171424 9.554639  3.234316 .8586616 1
"Middlesbrough Borough Council"        "E06000002" 2012 3 210 0 1 0 13.453314 9.554639  3.234316 .8586616 1
"Middlesbrough Borough Council"        "E06000002" 2012 4 211 0 0 1  13.24626 9.554639  3.234316 .8586616 1
"Middlesbrough Borough Council"        "E06000002" 2013 1 212 0 0 0  14.57947 9.564863  3.236794 .8628899 1
"Middlesbrough Borough Council"        "E06000002" 2013 2 213 1 0 0 14.828068 9.564863  3.236794 .8628899 1
"Middlesbrough Borough Council"        "E06000002" 2013 3 214 0 1 0 14.709766 9.564863  3.236794 .8628899 1
"Middlesbrough Borough Council"        "E06000002" 2013 4 215 0 0 1  20.44064 9.564863  3.236794 .8628899 1
"Middlesbrough Borough Council"        "E06000002" 2014 1 216 0 0 0 34.159927 9.601301 3.2381685 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2014 2 217 1 0 0  24.25953 9.601301  3.236794 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2014 3 218 0 1 0  24.04574 9.601301 3.2381685 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2014 4 219 0 0 1    24.127 9.601301 3.2381685 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2015 1 220 0 0 0  27.94404 9.626811  3.239502 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2015 2 221 1 0 0 23.334343 9.626811  3.239502 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2015 3 222 0 1 0  19.43632 9.626811  3.239502 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2015 4 223 0 0 1  23.32905 9.626811  3.239502 .8671005 1
"Middlesbrough Borough Council"        "E06000002" 2016 1 224 0 0 0  23.50695 9.613669   3.24228 .8712934 1
"Middlesbrough Borough Council"        "E06000002" 2016 2 225 1 0 0 20.070557 9.613669   3.24228 .8712934 1
"Middlesbrough Borough Council"        "E06000002" 2016 3 226 0 1 0 19.601873 9.613669   3.24228 .8712934 1
"Middlesbrough Borough Council"        "E06000002" 2016 4 227 0 0 1  21.82984 9.613669   3.24228 .8712934 1
"Redcar and Cleveland Borough Council" "E06000003" 2012 1 208 0 0 0  23.51096 9.537339  1.728642 .8586616 1
"Redcar and Cleveland Borough Council" "E06000003" 2012 2 209 1 0 0  20.10306 9.537339  1.712536 .8586616 1
"Redcar and Cleveland Borough Council" "E06000003" 2012 3 210 0 1 0  19.72007 9.537339  1.712536 .8586616 1
"Redcar and Cleveland Borough Council" "E06000003" 2012 4 211 0 0 1 22.403687 9.537339  1.712536 .8586616 1
"Redcar and Cleveland Borough Council" "E06000003" 2013 1 212 0 0 0 24.170063 9.545955  1.710911 .8628899 1
"Redcar and Cleveland Borough Council" "E06000003" 2013 2 213 1 0 0  23.99578 9.545955  1.710911 .8628899 1
"Redcar and Cleveland Borough Council" "E06000003" 2013 3 214 0 1 0 24.617693 9.545955  1.710911 .8628899 1
"Redcar and Cleveland Borough Council" "E06000003" 2013 4 215 0 0 1  30.60893 9.545955  1.710911 .8628899 1
"Redcar and Cleveland Borough Council" "E06000003" 2014 1 216 0 0 0  36.69286 9.575816 1.7105495 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2014 2 217 1 0 0  23.24818 9.575816  1.710911 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2014 3 218 0 1 0  28.21425 9.575816 1.7105495 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2014 4 219 0 0 1    33.378 9.575816 1.7105495 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2015 1 220 0 0 0 34.828026 9.600556  1.711272 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2015 2 221 1 0 0 26.965475 9.600556  1.711272 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2015 3 222 0 1 0 18.484371 9.600556  1.711272 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2015 4 223 0 0 1   22.8024 9.600556  1.711272 .8671005 1
"Redcar and Cleveland Borough Council" "E06000003" 2016 1 224 0 0 0 25.000637 9.583902  1.713077 .8712934 1
"Redcar and Cleveland Borough Council" "E06000003" 2016 2 225 1 0 0  23.34894 9.583902  1.713077 .8712934 1
"Redcar and Cleveland Borough Council" "E06000003" 2016 3 226 0 1 0  20.75586 9.583902  1.713077 .8712934 1
"Redcar and Cleveland Borough Council" "E06000003" 2016 4 227 0 0 1 25.922733 9.583902  1.713077 .8712934 1
"Stockton-on-Tees Borough Council"     "E06000004" 2012 1 208 0 0 0  20.72435 9.607841   2.19778 .8586616 1
"Stockton-on-Tees Borough Council"     "E06000004" 2012 2 209 1 0 0  19.85636 9.607841 2.1946657 .8586616 1
"Stockton-on-Tees Borough Council"     "E06000004" 2012 3 210 0 1 0 17.278917 9.607841 2.1946657 .8586616 1
"Stockton-on-Tees Borough Council"     "E06000004" 2012 4 211 0 0 1  20.15345 9.607841 2.1946657 .8586616 1
"Stockton-on-Tees Borough Council"     "E06000004" 2013 1 212 0 0 0  22.03593 9.608176  2.197891 .8628899 1
"Stockton-on-Tees Borough Council"     "E06000004" 2013 2 213 1 0 0 18.222332 9.608176  2.197891 .8628899 1
"Stockton-on-Tees Borough Council"     "E06000004" 2013 3 214 0 1 0  17.56083 9.608176  2.197891 .8628899 1
"Stockton-on-Tees Borough Council"     "E06000004" 2013 4 215 0 0 1  19.13032 9.608176  2.197891 .8628899 1
"Stockton-on-Tees Borough Council"     "E06000004" 2014 1 216 0 0 0 21.184946 9.632138  2.201991 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2014 2 217 1 0 0 13.187984 9.632138  2.201991 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2014 3 218 0 1 0 16.005465 9.632138  2.201991 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2014 4 219 0 0 1    18.041 9.632138  2.201991 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2015 1 220 0 0 0 20.246767 9.662816  2.206735 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2015 2 221 1 0 0 16.660748 9.662816  2.206735 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2015 3 222 0 1 0  15.44666 9.662816  2.206735 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2015 4 223 0 0 1 18.055502 9.662816  2.206735 .8671005 1
"Stockton-on-Tees Borough Council"     "E06000004" 2016 1 224 0 0 0 17.611841 9.641798 2.2102504 .8712934 1
"Stockton-on-Tees Borough Council"     "E06000004" 2016 2 225 1 0 0 14.851618 9.641798 2.2102504 .8712934 1
"Stockton-on-Tees Borough Council"     "E06000004" 2016 3 226 0 1 0 14.507548 9.641798 2.2102504 .8712934 1
"Stockton-on-Tees Borough Council"     "E06000004" 2016 4 227 0 0 1  17.83563 9.641798 2.2102504 .8712934 1
"Darlington Borough Council"           "E06000005" 2012 1 208 0 0 0  42.36351 9.570878 1.6325684 .8586616 1
"Darlington Borough Council"           "E06000005" 2012 2 209 1 0 0 32.836056 9.570878  1.678964 .8586616 1
"Darlington Borough Council"           "E06000005" 2012 3 210 0 1 0  31.34309 9.570878  1.678964 .8586616 1
"Darlington Borough Council"           "E06000005" 2012 4 211 0 0 1   32.1052 9.570878  1.678964 .8586616 1
"Darlington Borough Council"           "E06000005" 2013 1 212 0 0 0 28.556936 9.597573 1.6757873 .8628899 1
"Darlington Borough Council"           "E06000005" 2013 2 213 1 0 0 30.584833 9.597573 1.6757873 .8628899 1
"Darlington Borough Council"           "E06000005" 2013 3 214 0 1 0  28.63693 9.597573 1.6757873 .8628899 1
"Darlington Borough Council"           "E06000005" 2013 4 215 0 0 1  21.55379 9.597573 1.6757873 .8628899 1
"Darlington Borough Council"           "E06000005" 2014 1 216 0 0 0  20.11268 9.606159 1.6770965 .8671005 1
"Darlington Borough Council"           "E06000005" 2014 2 217 1 0 0 26.908495 9.606159 1.6757873 .8671005 1
"Darlington Borough Council"           "E06000005" 2014 3 218 0 1 0  25.60923 9.606159 1.6770965 .8671005 1
"Darlington Borough Council"           "E06000005" 2014 4 219 0 0 1  30.62015 9.606159 1.6770965 .8671005 1
"Darlington Borough Council"           "E06000005" 2015 1 220 0 0 0 31.480186  9.65098 1.6769096 .8671005 1
"Darlington Borough Council"           "E06000005" 2015 2 221 1 0 0  29.34417  9.65098 1.6769096 .8671005 1
"Darlington Borough Council"           "E06000005" 2015 3 222 0 1 0   29.5002  9.65098 1.6769096 .8671005 1
"Darlington Borough Council"           "E06000005" 2015 4 223 0 0 1 25.388384  9.65098 1.6769096 .8671005 1
"Darlington Borough Council"           "E06000005" 2016 1 224 0 0 0  29.34344 9.647757 1.6770965 .8712934 1
"Darlington Borough Council"           "E06000005" 2016 2 225 1 0 0  27.49854 9.647757 1.6770965 .8712934 1
"Darlington Borough Council"           "E06000005" 2016 3 226 0 1 0  28.14532 9.647757 1.6770965 .8712934 1
"Darlington Borough Council"           "E06000005" 2016 4 227 0 0 1  28.00815 9.647757 1.6770965 .8712934 1
end
format %tq qdate

Bysort

$
0
0
Hello,

I have reproduced a simple replica of a bigger problem.

I have data which looks as attached. I need, the value against HS 3201 as the sum of values against HS 32010, 32011, 32012, 32013 and similarly for HS 3202 to be the addition of values against 32021, 32022, 32023, 32024.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(HS Value Desired)
 3201  .  10
32010  1  10
32011  2  10
32012  3  10
32013  4  10
 3202  . 110
32021 11 110
32022 22 110
32023 33 110
32024 44 110
end

Request your help for the relevant bysort / any other command to perform this.

Thanks in advance!

Average Partial Effects (APE) after Dynamic Probit Model ala (Wooldridge, 2005)

$
0
0
I am trying to calculate the average partial effects of the state dependence and some other covariates after running a dynamic probit model. I am mainly following Wooldridge (2005), Contoyannis et al (2004), Capellari and Jenkins (2009), and Skrodal et al (2013). Assuming my model to be similar to the above papers, I am running

Code:
global var varlist           /*Covariate list*/
global var_mean varlist           /*Longitudinal Mean of $var */
global var_0 varlist           /*Initial observed values of $var */

meprobit y i.year y_0 $var_mean $var_0 $var y_lag z_lag || id: , intpoints(12)
z_lag is treatment whose effect I want to extract from the state dependence y_lag. Now I want to study the average partial effects of z_lag & y_lag on the predicted values of y. Following Wooldridge (2005), Contoyannis writes;
In this case the partial effects are averaged over the population distribution of heterogeneity and computed using the population averaged parameters ... Wooldridge shows that computing the partial effect at the observed values of the regressors for each observation and averaging the estimates over the observations provides a consistent estimate of the APE
From my understanding, this what is done by the "margins, dydx()" command after the meprobit. I want to confirm that I am correct in assuming that the following code will calculate the APE of y_lage and z_lag on the outcome, as calculated by Wooldridge and Contoyannis

Code:
margins, dydx(y_lag z_lag) nose
Thanks
Soumya
Viewing all 65082 articles
Browse latest View live


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