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

Outreg2 with rdrobust

$
0
0
Hi everyone,

I am using the following code to run a list of rdrobust commands:

Code:
local variables post_ui_wage wage_diff ue_dau_TM Y1 Y3 Y6 Y12 Y15 Y18 Y22 Y1L Y3L Y6L Y12L Y15L Y18L Y22L Y1N Y3N Y6N Y12N Y15N Y18N Y22N
local bandwidths 10 12

foreach b of local bandwidths {
    foreach v of local variables {
        rdrobust `v' X42, kernel(triangular) vce(cluster X42) h(`b' `b')
    }
}
I need to use outreg2 so that I can visualize my output in the following form:
A table with 3 columns. Column 1 is called outcomes and its rows list all the outcome variables I have in my local called "variables". Columns 2 and 3 are called 10 months and 12 months respectively, and their rows contain the RD Estimates (with the stars and the SEs in parenthesis below the estimates) for each outcome in the 10- and 12-month bandwidths respectively. So it would look something like this:
Outcomes 10 months 12 months
post_ui_wage 0.76***
(0.02)
0.77***
(0.03
wage_diff ... ...
... ... ...
and so on.

This may seem like a trivial question, but I could not use the outreg2 package properly to be able to create such a table. Any help is much appreciated.

Thanks a lot!

Double robust method omits estimates, DID, Callaway and Sant’Anna, 2021

$
0
0
I am using Callaway and Sant’Anna 2021 estimating the treatment effects of a staggered treatment on school enrollment.
I used the outcome regression method. I can get the estimates for all groups. However, when I use the double robust method (dripw), the estimates for group 1994 are omitted. I did the following checks.
  1. The covariates for g1994 are all missing: No, the missing situation is similar to other groups.
  2. The overlapping of the covariates is worse for g1994: It seems not the case too.
Might you have any insights on why the estimates for g1994 are missing? Please see the attached codes, data, and results for more details. Thanks!

Here is my code.
Code:
use "$path\analysis\temp\data_reg_sample.dta",clear
global cov_mix dist_rev_pupil dist_total_race dist_white city sub town schl_total_race schl_white
csdid total_race $cov_mix if sample_exist_allyears==1&flag_gap==0&flag_state==0, ivar(schlid) time(year) gvar(policy_time) method(dripw)
estat event, estore(cs)
Here is the policy_time variable.
Code:
policy_time |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    726,245       48.64       48.64
       1992 |     44,733        3.00       51.64
       1993 |     27,118        1.82       53.46
       1994 |    135,837        9.10       62.55
       1996 |     78,182        5.24       67.79
       1997 |     37,739        2.53       70.32
       1998 |     46,189        3.09       73.41
       1999 |    208,806       13.99       87.40
       2000 |    169,442       11.35       98.75
       2001 |     18,733        1.25      100.00
------------+-----------------------------------
      Total |  1,493,024      100.00
Here is my data.
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float schlid int(year policy_time) float total_race long dist_rev_pupil float dist_total_race long dist_white float(city sub town schl_total_race) int schl_white
1 1990 1996   . . 439 150 1 0 0   .  .
1 1991 1996   . . 439 150 1 0 0   .  .
1 1992 1996   . . 439 150 1 0 0   .  .
1 1993 1996   . . 439 150 1 0 0   .  .
1 1994 1996   . . 439 150 1 0 0   .  .
1 1995 1996 123 . 439 150 1 0 0   .  .
1 1996 1996 127 . 439 150 1 0 0   .  .
1 1997 1996   . . 439 150 1 0 0   .  .
1 1998 1996   . . 439 150 1 0 0   .  .
1 1999 1996   . . 439 150 1 0 0   .  .
1 2000 1996   . . 439 150 1 0 0   .  .
1 2001 1996   . . 439 150 1 0 0   .  .
1 2002 1996   . . 439 150 1 0 0   .  .
2 1990 1996   . . 439 150 1 0 0   .  .
2 1991 1996   . . 439 150 1 0 0   .  .
2 1992 1996   . . 439 150 1 0 0   .  .
2 1993 1996   . . 439 150 1 0 0   .  .
2 1994 1996   . . 439 150 1 0 0   .  .
2 1995 1996   . . 439 150 1 0 0   .  .
2 1996 1996   . . 439 150 1 0 0   .  .
2 1997 1996   . . 439 150 1 0 0   .  .
2 1998 1996   . . 439 150 1 0 0   .  .
2 1999 1996   . . 439 150 1 0 0   .  .
2 2000 1996   . . 439 150 1 0 0   .  .
2 2001 1996   . . 439 150 1 0 0   .  .
2 2002 1996   . . 439 150 1 0 0   .  .
3 1990 1996   . . 439 150 1 0 0   .  .
3 1991 1996   . . 439 150 1 0 0   .  .
3 1992 1996   . . 439 150 1 0 0   .  .
3 1993 1996   . . 439 150 1 0 0   .  .
3 1994 1996   . . 439 150 1 0 0   .  .
3 1995 1996   . . 439 150 1 0 0   .  .
3 1996 1996   . . 439 150 1 0 0   .  .
3 1997 1996   . . 439 150 1 0 0   .  .
3 1998 1996   . . 439 150 1 0 0   .  .
3 1999 1996   . . 439 150 1 0 0   .  .
3 2000 1996   . . 439 150 1 0 0   .  .
3 2001 1996   . . 439 150 1 0 0   .  .
3 2002 1996   . . 439 150 1 0 0   .  .
4 1990 1996   . . 439 150 1 0 0   .  .
4 1991 1996   . . 439 150 1 0 0   .  .
4 1992 1996   . . 439 150 1 0 0   .  .
4 1993 1996   . . 439 150 1 0 0   .  .
4 1994 1996   . . 439 150 1 0 0   .  .
4 1995 1996   . . 439 150 1 0 0   .  .
4 1996 1996   . . 439 150 1 0 0   .  .
4 1997 1996   . . 439 150 1 0 0   .  .
4 1998 1996   . . 439 150 1 0 0   .  .
4 1999 1996   . . 439 150 1 0 0   .  .
4 2000 1996   . . 439 150 1 0 0   .  .
4 2001 1996   . . 439 150 1 0 0   .  .
4 2002 1996   . . 439 150 1 0 0   .  .
5 1990 1996 115 . 439 150 1 0 0 115 53
5 1991 1996 104 . 439 150 1 0 0 115 53
5 1992 1996   . . 439 150 1 0 0 115 53
5 1993 1996   . . 439 150 1 0 0 115 53
5 1994 1996   . . 439 150 1 0 0 115 53
5 1995 1996   . . 439 150 1 0 0 115 53
5 1996 1996   . . 439 150 1 0 0 115 53
5 1997 1996   . . 439 150 1 0 0 115 53
5 1998 1996   . . 439 150 1 0 0 115 53
5 1999 1996   . . 439 150 1 0 0 115 53
5 2000 1996   . . 439 150 1 0 0 115 53
5 2001 1996   . . 439 150 1 0 0 115 53
5 2002 1996   . . 439 150 1 0 0 115 53
6 1990 1996 205 . 439 150 1 0 0 205 68
6 1991 1996 196 . 439 150 1 0 0 205 68
6 1992 1996 224 . 439 150 1 0 0 205 68
6 1993 1996 255 . 439 150 1 0 0 205 68
6 1994 1996 260 . 439 150 1 0 0 205 68
6 1995 1996 258 . 439 150 1 0 0 205 68
6 1996 1996 328 . 439 150 1 0 0 205 68
6 1997 1996   . . 439 150 1 0 0 205 68
6 1998 1996   . . 439 150 1 0 0 205 68
6 1999 1996   . . 439 150 1 0 0 205 68
6 2000 1996   . . 439 150 1 0 0 205 68
6 2001 1996 624 . 439 150 1 0 0 205 68
6 2002 1996   . . 439 150 1 0 0 205 68
7 1990 1996 119 . 439 150 1 0 0 119 29
7 1991 1996 126 . 439 150 1 0 0 119 29
7 1992 1996 231 . 439 150 1 0 0 119 29
7 1993 1996 228 . 439 150 1 0 0 119 29
7 1994 1996 127 . 439 150 1 0 0 119 29
7 1995 1996 128 . 439 150 1 0 0 119 29
7 1996 1996 138 . 439 150 1 0 0 119 29
7 1997 1996   . . 439 150 1 0 0 119 29
7 1998 1996   . . 439 150 1 0 0 119 29
7 1999 1996   . . 439 150 1 0 0 119 29
7 2000 1996   . . 439 150 1 0 0 119 29
7 2001 1996   . . 439 150 1 0 0 119 29
7 2002 1996   . . 439 150 1 0 0 119 29
8 1990 1996   . . 439 150 1 0 0   .  .
8 1991 1996   . . 439 150 1 0 0   .  .
8 1992 1996   . . 439 150 1 0 0   .  .
8 1993 1996   . . 439 150 1 0 0   .  .
8 1994 1996   . . 439 150 1 0 0   .  .
8 1995 1996   . . 439 150 1 0 0   .  .
8 1996 1996   . . 439 150 1 0 0   .  .
8 1997 1996   . . 439 150 1 0 0   .  .
8 1998 1996   . . 439 150 1 0 0   .  .
end

Here are part of my results
Code:
g1994        |
 t_1990_1991 |          0  (omitted)
 t_1991_1992 |          0  (omitted)
 t_1992_1993 |          0  (omitted)
 t_1993_1994 |          0  (omitted)
 t_1993_1995 |          0  (omitted)
 t_1993_1996 |          0  (omitted)
 t_1993_1997 |          0  (omitted)
 t_1993_1998 |          0  (omitted)
 t_1993_1999 |          0  (omitted)
 t_1993_2000 |          0  (omitted)
 t_1993_2001 |          0  (omitted)
 t_1993_2002 |          0  (omitted)
-------------+----------------------------------------------------------------
g1996        |
 t_1990_1991 |  -1.677059    1.28799    -1.30   0.193    -4.201473    .8473537
 t_1991_1992 |  -.0237585   1.247963    -0.02   0.985    -2.469721    2.422204
 t_1992_1993 |   .3585908   1.332869     0.27   0.788    -2.253785    2.970967
 t_1993_1994 |   3.328838   1.225954     2.72   0.007     .9260135    5.731663
 t_1994_1995 |   .9417342   1.151133     0.82   0.413    -1.314445    3.197914
 t_1995_1996 |   .0195993   1.584956     0.01   0.990    -3.086857    3.126055
 t_1995_1997 |  -1.333024   1.964771    -0.68   0.497    -5.183904    2.517857
 t_1995_1998 |  -.6728093   2.307083    -0.29   0.771    -5.194609    3.848991
 t_1995_1999 |   4.063073   2.714508     1.50   0.134    -1.257266    9.383412
 t_1995_2000 |   5.373174   2.984525     1.80   0.072    -.4763882    11.22274
 t_1995_2001 |   5.737148   3.264699     1.76   0.079    -.6615453    12.13584
 t_1995_2002 |   2.819582    3.49881     0.81   0.420     -4.03796    9.677124
-------------+----------------------------------------------------------------
g1997        |
 t_1990_1991 |  -6.304111   3.434251    -1.84   0.066    -13.03512    .4268978
 t_1991_1992 |  -3.871075   2.257694    -1.71   0.086    -8.296073    .5539239
 t_1992_1993 |  -6.056548   5.125531    -1.18   0.237     -16.1024    3.989307
 t_1993_1994 |   .6657653   2.421522     0.27   0.783     -4.08033    5.411861
 t_1994_1995 |   9.628556   2.580237     3.73   0.000     4.571384    14.68573
 t_1995_1996 |    8.05734   2.149519     3.75   0.000      3.84436    12.27032
 t_1996_1997 |   1.352238   5.222472     0.26   0.796    -8.883618    11.58809
 t_1996_1998 |    8.04696   6.274062     1.28   0.200    -4.249976     20.3439
 t_1996_1999 |   12.79983   11.83289     1.08   0.279    -10.39221    35.99187
 t_1996_2000 |   11.29332    14.7753     0.76   0.445    -17.66574    40.25239
 t_1996_2001 |   5.736991   22.44627     0.26   0.798    -38.25689    49.73087
 t_1996_2002 |  -.3827442   27.14797    -0.01   0.989    -53.59179     52.8263

How to Keep Only First and Last duplicates?

$
0
0
Dear All,

I have a dataset wherein there are varying numbers of duplicates (sorted by Applicant Name), (ie. some people might appear 5 times, some appear 3, some appear 1, etc). I used gen dup = cond(_N==1,0,_n) and have sorted these by the date they appear but now I want to only keep the first and last times they appear as duplicates, so I can subtract the first time from the last time and get the duration between appearances.

How can I keep only the first and last duplicates? This would be so much easier if each one appeared an equal amount of times, but they don't.

Any help appreciated!

Psmatch - low match even for one variable

$
0
0
Hello,

I am having an issue running the psmatch2 code and getting a decent match. My full sample has 1 million + observations, and from 1 million observations even if I limit my characteristics to just SEX (male and female), I still only get 170 matches? My variable is tabulated very clearly:

'msgender' | Freq. Percent Cum.
------------+-----------------------------------
0 | 863,931 80.33 80.33
1 | 211,500 19.67 100.00
------------+-----------------------------------
Total | 1,075,431 100.00


Similar with age, when dropping variables to just include age and treatment, I get very few matches. So the issue is not with the variable... I think. My code for using matching based on just sex is:



psmatch2 treatment i.sex
psgraph
pstest i.sex

sum i.sex if treatment ==1 [aw =_weight]
sum i.sex if treatment ==0 [aw =_weight]


Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input byte sex float(mar tax_year age treatment)
0  1 2011 60 1
1  1 2010 41 1
1  1 2011 42 1
0  1 2010 52 1
0 .a 2011 53 1
0  1 2010 57 1
0  1 2011 58 1
1  1 2011 34 1
1  1 2010 38 1
1  1 2011 39 1
0  1 2010 34 1
0  1 2011 35 1
0  2 2010 66 1
0  2 2011 67 1
0  2 2010 62 1
0  2 2011 63 1
0  1 2010 36 1
0  2 2010 21 1
0  2 2010 64 1
0  2 2011 65 1
0  1 2010 61 0
0  1 2011 62 0
0  3 2010 48 0
0  3 2011 49 0
0  2 2010 30 0
0  2 2011 31 0
0  1 2010 34 0
0  1 2011 35 0
0  1 2010 45 0
0  1 2011 46 0
end
label values mar marLbl
label def marLbl 1 "Couple", modify
label def marLbl 2 "Single", modify
label def marLbl 3 "Wid_Div_Sep", modify
label def marLbl .a "Missing/Invalid", modify
------------------ copy up to and including the previous line ------------------


Please help!

Time Series Analysis: Forecasting Traded Value of the Stock Market

$
0
0
I need to forecast the traded value of the stock market. This is a snapshot of the data I have:
date Log (Value traded) Value traded Var1 Var2 Var3 Var4 Var5
1/1/20 21.89 3232351921 3.30700 0 0.2999 0.12424 0.17105
1/2/20 21.96 3470961343 3.31386 0 0.2793 0.12453 0.17030
1/5/20 22.16 4233572750 3.25174 0 0.2290 0.12388 0.17446
1/6/20 22.12 4072469510 3.24897 0 0.2380 0.12416 0.17422
1/7/20 22.03 3713679651 3.23655 0 0.2610 0.12460 0.17427
The data includes 1000 rows.
The forecasting should not only rely on previous values of the traded value but also consider the possible relationships between the traded value and five other variables:
  • Var1: Whole market capitalization/GDP
  • Var2: The number of newly listed companies quarterly
  • Var3: Institutions’ traded value/total traded value
  • Var4: Market capitalization of free float/whole market capitalization
  • Var5: Foreign investors' holdings/market capitalization of free float
How can I forecast the traded value of the stock market for the next 3 to 5 years using STATA? Which model should I use?

Thanks in advance!

Sector difference in a regression

$
0
0
Hi,
I'm doing research on determinants for a buy-out of a company and the sectoral differences between determinants. I have data on 138 buyouts across 7 different sectors. The number of observations per sector varies from 5 to 30. Furthermore, I have a lot of observations of non-buyouts.

I want to test the effect of ROA, size and D/A ratio on the odds of a buyout across different sectors using a regression. Furthermore I have divided ROA in quartiles so that the highest and lowest quartile are both an independent variable. I have come across two methods to compare across sectors.

1) Estimate a separate regression for each industry and then compare the coefficients.

2)Estimate one regression with interaction variables.

I was wondering if anyone knows which is the best method to use in my situation with the limited number of buyout observations?

Kind regards,
Joris

Identifying optimal cut-point with continuous variables help

$
0
0
Hi folks!

I am trying to find optimal BMI for CVD risk using a continuous risk score. I'm familiar with ROC curves and Youden index, but do not want to reduce my continuous values to a binary variable. Any suggestions on a data-driven approach or package I should be using in STATA?

Thanks!

What does the SEM command (for a simple latent measurement model) do with missing values when 'predict' into a linear variable?

$
0
0
If I use the SEM command to construct a fairly simple latent measurement model and then use 'predict' to construct a linear variable out of the new latent variable, it creates real values for the missing observations. But the SEM command is supposed to use listwise deletion for missings (or so I thought) when not specifying FIML. What am I missing here? I have attached a log file with just these actions (as PDF). See the number of obs for the model and then the final number at the bottom of the 'tab1 *, m' at the end of the log. That final number is my total sample. Array

XTABOND vs XTA

$
0
0
Hello all,

I am using dynamic panel estimators xtabond and xtdpsys in Stata 18.
I would like to know why the number of observations is different when I use the above two estimators. The codes are as follows


Code:
xi: xtdpdsys f.delta_alt_w1 i.year ln_totalasset_w score_avg_state_alt_w ROA_w growth_w boardsize_w ESGValueScore_w  political_proposal_fy_w score_avg_3N_alt_w  capital_intensity_w ln_pol_contribution_fy_w tnic3hhi_w CPA_outperform_3N_alt_w1 CPA_short_3N_alt_w1,  vce(r)
HTML Code:
i.year            _Iyear_2008-2021    (naturally coded; _Iyear_2008 omitted)
note: _Iyear_2009 omitted from div() because of collinearity.
note: _Iyear_2010 omitted from div() because of collinearity.
note: _Iyear_2019 omitted from div() because of collinearity.
note: _Iyear_2020 omitted from div() because of collinearity.
note: _Iyear_2021 omitted from div() because of collinearity.
note: _Iyear_2009 omitted because of collinearity.
note: _Iyear_2010 omitted because of collinearity.
note: _Iyear_2011 omitted because of collinearity.
note: _Iyear_2012 omitted because of collinearity.
note: _Iyear_2020 omitted because of collinearity.
note: _Iyear_2021 omitted because of collinearity.

System dynamic panel-data estimation            Number of obs     =      1,839
Group variable: f_id                            Number of groups  =        401
Time variable: year
                                                Obs per group:
                                                              min =          1
                                                              avg =   4.586035
                                                              max =          8

Number of instruments =     56                  Wald chi2(21)     =     165.44
                                                Prob > chi2       =     0.0000
One-step results
------------------------------------------------------------------------------------------
                         |               Robust
          F.delta_alt_w1 | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
-------------------------+----------------------------------------------------------------
            delta_alt_w1 |  -.0252575   .0210547    -1.20   0.230    -.0665239    .0160088
             _Iyear_2013 |    .904637   .2434117     3.72   0.000     .4275588    1.381715
             _Iyear_2014 |   1.023469   .2685259     3.81   0.000     .4971677     1.54977
             _Iyear_2015 |   1.648656   .4327655     3.81   0.000     .8004515    2.496861
             _Iyear_2016 |   1.716354   .4211236     4.08   0.000     .8909666    2.541741
             _Iyear_2017 |   1.999446   .4554555     4.39   0.000     1.106769    2.892122
             _Iyear_2018 |   2.174236   .4795256     4.53   0.000     1.234383    3.114089
             _Iyear_2019 |   2.902416   .5566939     5.21   0.000     1.811316    3.993516
         ln_totalasset_w |   .1034448   .4016108     0.26   0.797    -.6836979    .8905875
   score_avg_state_alt_w |  -.0236885   .0185764    -1.28   0.202    -.0600976    .0127206
                   ROA_w |   2.956396   1.306307     2.26   0.024     .3960812     5.51671
                growth_w |   9.20e-07   8.33e-06     0.11   0.912    -.0000154    .0000172
             boardsize_w |   -.050731    .076449    -0.66   0.507    -.2005683    .0991063
         ESGValueScore_w |  -1.818897   1.326591    -1.37   0.170    -4.418968    .7811737
 political_proposal_fy_w |   .0889893   .1260127     0.71   0.480    -.1579911    .3359696
      score_avg_3N_alt_w |  -.1462523   .0194679    -7.51   0.000    -.1844086    -.108096
     capital_intensity_w |     3.4919   2.835968     1.23   0.218    -2.066495    9.050295
ln_pol_contribution_fy_w |   .0133927   .0106158     1.26   0.207     -.007414    .0341994
              tnic3hhi_w |  -1.317324   .4846862    -2.72   0.007    -2.267292   -.3673568
CPA_outperform_3N_alt_w1 |  -.1134739   .0159907    -7.10   0.000    -.1448151   -.0821327
     CPA_short_3N_alt_w1 |   .1712967   .0208966     8.20   0.000     .1303401    .2122532
                   _cons |   3.746604   4.296416     0.87   0.383    -4.674217    12.16742
------------------------------------------------------------------------------------------
Instruments for differenced equation
        GMM-type: L(2/.).F.delta_alt_w1
        Standard: D._Iyear_2011 D._Iyear_2012 D._Iyear_2013 D._Iyear_2014 D._Iyear_2015
                  D._Iyear_2016 D._Iyear_2017 D._Iyear_2018 D.ln_totalasset_w
                  D.score_avg_state_alt_w D.ROA_w D.growth_w D.boardsize_w
                  D.ESGValueScore_w D.political_proposal_fy_w D.score_avg_3N_alt_w
                  D.capital_intensity_w D.ln_pol_contribution_fy_w D.tnic3hhi_w
                  D.CPA_outperform_3N_alt_w1 D.CPA_short_3N_alt_w1
Instruments for level equation
        GMM-type: D.delta_alt_w1
        Standard: _cons

.
end of do-file

Code:
xi: xtabond f.delta_alt_w1 i.year ln_totalasset_w score_avg_state_alt_w ROA_w growth_w boardsize_w ESGValueScore_w  political_proposal_fy_w score_avg_3N_alt_w  capital_intensity_w ln_pol_contribution_fy_w tnic3hhi_w CPA_outperform_3N_alt_w1 CPA_short_3N_alt_w1,  vce(r)
HTML Code:
i.year            _Iyear_2008-2021    (naturally coded; _Iyear_2008 omitted)
note: _Iyear_2009 omitted from div() because of collinearity.
note: _Iyear_2010 omitted from div() because of collinearity.
note: _Iyear_2019 omitted from div() because of collinearity.
note: _Iyear_2020 omitted from div() because of collinearity.
note: _Iyear_2021 omitted from div() because of collinearity.
note: _Iyear_2009 omitted because of collinearity.
note: _Iyear_2010 omitted because of collinearity.
note: _Iyear_2011 omitted because of collinearity.
note: _Iyear_2012 omitted because of collinearity.
note: _Iyear_2020 omitted because of collinearity.
note: _Iyear_2021 omitted because of collinearity.

Arellano–Bond dynamic panel-data estimation     Number of obs     =      1,434
Group variable: f_id                            Number of groups  =        362
Time variable: year
                                                Obs per group:
                                                              min =          1
                                                              avg =   3.961326
                                                              max =          7

Number of instruments =     49                  Wald chi2(21)     =     141.96
                                                Prob > chi2       =     0.0000
One-step results
                                               (Std. err. adjusted for clustering on f_id)
------------------------------------------------------------------------------------------
                         |               Robust
          F.delta_alt_w1 | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
-------------------------+----------------------------------------------------------------
            delta_alt_w1 |  -.0159495   .0175571    -0.91   0.364    -.0503608    .0184619
             _Iyear_2013 |   .9016302   .2315005     3.89   0.000     .4478977    1.355363
             _Iyear_2014 |   1.004152    .255041     3.94   0.000     .5042813    1.504024
             _Iyear_2015 |   1.651665   .4274178     3.86   0.000     .8139415    2.489389
             _Iyear_2016 |   1.715784   .4129452     4.15   0.000     .9064258    2.525141
             _Iyear_2017 |   1.964593   .4396862     4.47   0.000     1.102824    2.826362
             _Iyear_2018 |   2.169019   .4722926     4.59   0.000     1.243343    3.094696
             _Iyear_2019 |     2.8611   .5401609     5.30   0.000     1.802404    3.919796
         ln_totalasset_w |   .4475541   .3441132     1.30   0.193    -.2268954    1.122004
   score_avg_state_alt_w |  -.0228492   .0177869    -1.28   0.199    -.0577108    .0120124
                   ROA_w |   2.833357   1.368295     2.07   0.038     .1515482    5.515166
                growth_w |  -1.09e-06   8.29e-06    -0.13   0.895    -.0000173    .0000152
             boardsize_w |  -.0673055   .0781641    -0.86   0.389    -.2205044    .0858934
         ESGValueScore_w |  -1.360737   1.275509    -1.07   0.286    -3.860689    1.139215
 political_proposal_fy_w |   .1034184   .1291833     0.80   0.423    -.1497763     .356613
      score_avg_3N_alt_w |  -.1529579   .0200951    -7.61   0.000    -.1923436   -.1135722
     capital_intensity_w |   3.890721   3.833003     1.02   0.310    -3.621827    11.40327
ln_pol_contribution_fy_w |   .0170141   .0085031     2.00   0.045     .0003484    .0336799
              tnic3hhi_w |  -1.134279   .4437712    -2.56   0.011    -2.004054   -.2645029
CPA_outperform_3N_alt_w1 |  -.1188579   .0167534    -7.09   0.000    -.1516938   -.0860219
     CPA_short_3N_alt_w1 |   .1760453   .0216054     8.15   0.000     .1336994    .2183912
                   _cons |   .1569741   3.861243     0.04   0.968    -7.410923    7.724871
------------------------------------------------------------------------------------------
Instruments for differenced equation
        GMM-type: L(2/.).F.delta_alt_w1
        Standard: D._Iyear_2011 D._Iyear_2012 D._Iyear_2013 D._Iyear_2014 D._Iyear_2015
                  D._Iyear_2016 D._Iyear_2017 D._Iyear_2018 D.ln_totalasset_w
                  D.score_avg_state_alt_w D.ROA_w D.growth_w D.boardsize_w
                  D.ESGValueScore_w D.political_proposal_fy_w D.score_avg_3N_alt_w
                  D.capital_intensity_w D.ln_pol_contribution_fy_w D.tnic3hhi_w
                  D.CPA_outperform_3N_alt_w1 D.CPA_short_3N_alt_w1
Instruments for level equation
        Standard: _cons

.
end of do-file

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float delta_alt_w1 double year float(ln_totalasset_w ROA_w growth_w) int boardsize_w double ESGValueScore_w float(political_proposal_fy_w ln_pol_contribution_fy_w) double tnic3hhi_w float(CPA_outperform_3N_alt_w1 CPA_short_3N_alt_w1)
          . 2015  7.749114           .        .  .                  . 0         0           . 12.333333         0
     .03125 2016  9.751296 -.031239634 3012.611  .                  . 0         0           .      9.75         0
          . 2017   9.74184  .020136975 1302.891  .                  . 0         0           .         .         .
          . 2018  9.753165  -.03539827  266.337 12  .1555077710513583 0         0 .3838179222         .         .
          . 2019  9.685558   -.0263715  543.818 11  .1941982272998987 0         0 .3302832737         .         .
          . 2020  9.687626  -.03922538   189.13 11 .24982679330691193 0         0 .5605535151         .         .
          . 2021  9.734735  -.02017361   -7.676 12 .36695518788930726 0         0 .4895962289         .         .
          . 2012  11.78367  .021862175     3193 14  .6102775498617466 1         0 .1142957992 24.666666         0
-.029411765 2013  11.70608   .02603312    -1425 14  .5968221269136472 0         0 .0460800989 12.333333         0
          0 2014 11.693303   .02463951    -1211 12  .5584765325011157 0         0 .0478295262        14         0
          0 2015 11.680945   .02141239    -1824 13  .5296724349422801 0         0  .062697926         9         0
          0 2016 11.773896  .020482363     1470 13  .5154328983362487 0         0 .0962821763 15.833333         0
          0 2017  11.82932  .033552695     -674 15  .6048361022853835 0         0 .0408819999        13         0
  .03030303 2018 11.852294   .02079683       68 12  .5492936938663266 0         0 .0532723242 16.166666         0
-.029411765 2019 11.936676  .021627566      601 11  .5926075220805899 0         0 .1385639629  9.666667         0
          0 2020 12.014222   .02894249      346 11   .530323647633256 0         0 .1485800449  8.666667         0
          . 2021 11.967447  .027452996    -1678 11  .5390995917719975 0         0 .0718635537         .         .
          . 2012  10.64137 -.021802533      772 11  .4820770921921533 0         0 .0427758323         .         .
          . 2013 10.606857  .002821014    -2155 12  .4625525629917007 0         0 .0337432054         .         .
          . 2014 10.570445  .019735154     1255 12  .5385435225369882 0         0 .0500065232         .         .
          . 2015  10.51461  .008303935    -2280 10  .5921660900917453 0         0 .0358916575         .         .
        4.4 2016 10.494575 -.031285472    -1280 10  .6465284848454079 0         0 .0310609873         .         .
  .05555556 2017  10.40765 -.035062816    -3056 10  .6062257909636658 0         0 .0402249633         .         .
          0 2018 10.389642   .03699148      206 10  .6540216299159198 0         0 .0441972487         .         .
          0 2019  10.42371  .009004992     -547 10  .6915820998610493 0         0 .0515756886         .         .
          0 2020 10.451695 .0013293645     -529 10  .7230116624628844 0 12.911645  .036256181         .         .
          . 2021  10.40314 -.012407851     1481 11  .7415453921777238 0         0 .0571510106         .         .
          0 2012 12.514715   .02667499      711 12  .6664318863711056 2         0 .1631564392         0       3.5
  1.2380953 2013  12.53461   .06569422     1318 14  .6654143751358915 2  15.40273 .1877636515        20         0
 -.04255319 2014 12.587344  .021254726     3695 15  .6373118384330541 2  15.77629 .1912309825        16         0
  .15555556 2015 12.905878  .033141118    14354 15  .6459996691769385 2 15.168892  .199908462 16.333334         0
  .03846154 2016 12.908727   .03213305    16962 14  .6049431326501389 2  15.77629 .1914303256 17.666666         0
 -.11111111 2017 13.003798   .06631434    -2974 13  .6258264757650418 2  15.77629 .2037224948         2         0
       .125 2018 13.184143  .036419086    10016 13  .6349010292370355 1  15.77629 .1831834946       7.5         0
   .2777778 2019 13.220703  .025201706    10460 14  .6866705817628004 1  15.69479 .1279349315      17.5         0
          0 2020 13.172602 -.009844777    -9505 14  .7379864394349797 0 15.671705 .1643480534 29.333334         0
          . 2021 13.220618   .03640355    -2896 13  .7214643674656367 2         0 .1742764737         .         .
   .8461539 2012  11.11595    .0886878 1022.651 12  .8057128481136637 1 13.313687 .1307484903 22.166666         0
  .08333334 2013 10.667862   .05997253   -11547 11  .7711674257147759 1 12.634687 .3393328724 17.333334         0
  .03846154 2014 10.628013   .05533616    -1601 11  .7354207368789126 1 13.087877 .2485701272 13.666667         0
          0 2015 10.627334   .10723204      158 11  .8015516760391339 0 12.052636 .2304300794      21.5         0
          0 2016 10.871725  .026582615      448 12  .7934518925750189 0   12.3417 .2258542081 13.916667         0
 .037037037 2017 11.241773  .006255738     6537 12  .8189123159637816 0 11.943857 .4371972373 13.636364         0
          0 2018 11.115026   .03525226     3188 13  .7760097421335387 0 12.059884 .2550446595  22.46154         0
 .017857144 2019   11.1256   .05431084     1326 15  .8040399444762671 0  12.11611 .2338781285 23.333334         0
          0 2020 11.192003   .06195898     2704 15  .8178891200004429 1 12.183556 .2708156984 22.294117         0
          . 2021 11.227854   .09403425     8467 13  .8081530413591038 1         0 .3005667109         .         .
          . 2012 10.203888    .1953125  936.049  .                  . 0         0           .         .         .
          . 2013 10.281856   .14137955      410  9  .4517397286759887 0   10.9768 .0862772424         .         .
          . 2014  10.22365   .06439903     1170  9  .6133276240575489 0  12.33579  .083052535 15.666667         0
          0 2015  10.87899   .09696513     2899  9  .6786291678714086 0 15.316918 .0843889553   21.9375         0
          0 2016 11.098908   .09006187     2779  9  .7511602529817795 1 14.850392 .0930728195  22.05882         0
 .015873017 2017 11.167417    .0750007     2578 10  .7991271179965028 1 13.004032     .090408        26         0
          0 2018 10.991241   .09581817     4537 11  .7541276864659012 1 12.941084 .0965050575  22.31579         0
          0 2019 11.397683   .08844751      513 11  .7823523652426244 1 12.721889 .1040870363  19.61111         0
          0 2020  11.92215  .030657856    12518 12  .8064472766716309 1  12.79719 .0634100897 19.235294         0
          . 2021 11.894979    .0787694    10413 13  .8027819504415102 1         0 .0730326821         .         .
          . 2012  6.169849   .08831817   31.749  .                  . 0         0 .0876544396         .         .
          . 2013  6.169849  .035787486   25.519  .                  . 0         0  .086133981         .         .
          . 2014  6.169849    .2717677   46.668  .                  . 0         0 .0796202904         .         .
          . 2015  6.169849   .08998398   99.232  8                  . 0         0 .0632431096         .         .
          . 2016  6.310671    .0946851  115.761  9 .21013227080699623 0         0  .068539994         .         .
          . 2017  6.667434   .14264187  148.445  8  .2613484181292542 0         0 .0588474439         .         .
          . 2018  6.960676    .2456651  175.683  7 .20354418439977875 0         0 .0619311623         .         .
          . 2019  7.103702    .1668848   71.451  7 .20335330166377644 0         0 .0749990967         0      23.6
          0 2020  7.309453   .15091754    6.639  7 .23317581712809135 0         0 .1238038972         0 24.294117
          . 2012  9.560997    .0809155      101 12 .15122554552433962 0         0 .1776840981         .         .
          . 2013  9.547669  .072081074     -273  7 .40640506467998117 0         0 .4194478905         .         .
          . 2014  9.598727   .05662553     -175  8 .42013154935051267 0         0 .3516205646         .         .
          . 2015  9.632401   .05848797      256  9  .5745485183483238 0         0 .2129662255         .         .
          . 2016   9.76721   .05535182     1944  9  .5281378121209034 0         0 .3602605789         0  24.26923
         .2 2017  9.834566  .014623956      409  9 .44211096986772486 0         0 .3506583375         0  21.22222
 -.16666667 2018  9.788918   .10165405      483 10    .52473471122077 0         0 .3064910917         0     21.75
          0 2019  9.895707   .07573696    -1011 10  .5985821767595451 0         0 .7013642662         0  21.03226
       -.75 2020 10.047977   .09507118     1597 10  .6729393420878621 1         0 .4238736489         0  28.22857
          . 2021  10.12887   .10771871      717 10  .7090544115781713 1         0 .7827431244         .         .
          . 2012  7.459857  .066958375      138  .                  . 0         0 .5308039868         .         .
          . 2013  7.551607   .06691879    155.4  .                  . 0         0 .5128052248         .         .
          . 2014  7.681606   .08108482    304.4 10  .1654493005638838 0         0 .4982653225         .         .
          . 2015  7.795482   .09141423    313.2 11   .311196019748818 0         0 .4995656502         .         .
          . 2016  7.988882   .09864315    584.6 10  .3053531629795233 0         0  .465305053         .         .
          . 2017  7.972328   .11094633    213.8 11  .4182826307717656 0         0 .5858438553         .         .
       -.75 2018  8.002627   .11697003      175 11   .411689457078758 0         0           1         .         .
          . 2019  8.062243   .10414828     -7.4 10  .6158972947761268 0         0 .9654010416         .         .
          . 2020  8.158144   .07111149   -346.4 12  .5818434980089872 0         0 .8458912314         .         .
          . 2021  8.181748   .08567593    134.7 10  .6293355822741981 0         0           1         .         .
          . 2012  9.207789    .0834902  187.419 12  .6860462520636819 0         0 .0738893447         .         .
          . 2013  9.247664  .027936095 -348.437 13  .7405852020142666 0 13.910822 .1000704907         .         .
          . 2014  9.285989   .02488404   91.825 13  .7026174808711698 0 13.997833 .0917740198         0         4
  .10714286 2015  9.369604   .05368631  648.446 13  .7506520244338267 0 13.910822 .1046419655     7.375         0
   .1935484 2016  9.449917   .09197856 1058.919 10  .7861359508264556 0 14.077875  .144173851  8.961538         0
          0 2017  9.584353   .11653864 1447.075 10  .7858290850267025 0 13.910822 .1282191388 10.925926         0
  .13513513 2018  9.839945   .13803707 1728.503 11   .785571053411965 0  13.73213 .0874815865 16.571428         0
-.023809524 2019  9.940899     .142154 2141.289 11  .6560987821223934 0  14.10818 .1157108881 16.129032         0
          0 2020 10.097573    .2166035 1696.703 11  .7454801962481726 0 14.054528 .1086949367 12.914286         0
          . 2021  10.21248    .1770126     2917 10  .7463923622090778 1         0 .1271563833         .         .
          . 2012 8.4368105   .08402376   34.541 10  .4388238456772243 0         0 .0713739086         .         .
          . 2013  8.624211   .07039963  288.811  9  .4554833238653906 0         0 .0663247445         .         .
          . 2014   8.98248   .06201994 3350.047 10 .38746859581930465 0         0 .1206197452         .         .
          . 2015  9.003878   .05819586 -106.843 14 .30015848425023506 0         0 .0560887612         .         .
          . 2016  9.025821   .05527603 -169.339 11 .33369833852679837 0         0 .1198861903         0        17
          6 2017  9.045737   .05605849 -193.895 11  .5502233839686952 0         0 .2950055673         0      11.5
       -.75 2018  9.109487   .04688237   206.77 10  .6294117470549816 0         0 .2030133361         0      17.5
         14 2019  9.327992   .04328532  128.449 11 .43305700805818564 0         0  .273813859         0         3
          0 2020  9.379209   .04164157  397.318 11  .5591737059061923 0         0 .2446405442         0       3.5
          . 2021  9.408716   .05052464  891.668  9  .6278120240281531 0         0 .2491511255         .         .
          . 2012  8.294049  -.21671093    -1146 12  .6578137132076772 0  8.160804 .1744318645         .         .
          . 2013  8.374938  -.01913765     -123 10  .6592924953827164 0  7.601402 .1512262546         .         .
          . 2014  8.234035  -.10698168      207 12  .6370966454846023 0  7.824446 .1316588995         .         .
          . 2015  8.042056   -.2122869    -1515  9  .8012715240613594 0  7.313887 .1606274159         .         .
          . 2016  8.108021   -.1496537      281  9  .7172747584726359 0         0 .1455634861         .         .
          . 2017  8.171882  .012146893     1057 10  .7077292009648519 0         0  .161274949         0         8
          0 2018    8.4242  .073968396     1146  9  .6850730945852896 0  6.216606 .1206272111         0         7
  -.5714286 2019   8.70417   .05656934      256  8  .6626197792118176 0         0 .1201150964         0   16.5625
          0 2020  9.100749    .2717677     3032  8  .6613324018203032 0 10.328788 .1042720503         0 16.777779
          . 2021  9.426983   .25460988     6671  8  .7130802864622029 0         0 .1166049562         .         .
          . 2012 10.633316   .03995469   2816.1 12   .574455724820841 0 14.564932 .1003090547 4.6666665         0
 .018867925 2013  10.81721   .03837038    10689 12   .594537269211212 0 14.416787 .0950097358         0  3.666667
          0 2014 10.885606   .03821573  10718.3 13  .6687265767532701 0  14.73064 .1060737861         0         1
          0 2015 10.886017   .04474011   2223.7 13    .64524253011939 0 14.601192 .0978144722         0       5.4
   .0925926 2016 11.143975   .03284355   2928.1 12  .6381331150438662 0 14.640782 .1391009468  7.666667         0
          0 2017  10.91783  .034523398    -2708 12  .6575046070856906 0 14.508409 .1327386894         5         0
          . 2012  8.730222   .02812303    100.7 10 .30568513707028655 0         0 .2145074142         .         .
          . 2013  8.751285   .05705197    383.3 10  .2953224164201151 0         0 .0813643289         .         .
          . 2014  8.948729   .05872878    322.1 11  .3794336185045618 0         0 .1160561643         .         .
          . 2015 8.9599285   .06628301    -26.4  9  .3804728934935791 0         0 .1050281977         0    22.125
          1 2016  9.076706   .05403984   -289.9  9  .4060185692801264 0         0 .1672667904         0    30.625
        -.5 2017   9.07132   .07923375    110.4  9  .4346663709019733 0         0 .0814620539         0 37.285713
          0 2018  9.014216   .02963828     73.4 11  .5354129201728836 0         0 .1602151693         0        40
          0 2019  8.942919  .002051349   -138.8 11  .5177113790915282 0         0 .0976513347         0        51
          . 2020  8.973212   .02563095   -212.1  6  .5449539176735618 0         0 .0533764779         .         .
          . 2021  9.091151   .06373079    384.9  8  .6012299326133204 0         0 .0635488156         .         .
          . 2012  9.262553   .10943432      232  9  .7717908305368468 0         0 .1297670987         .         .
          . 2013   9.27669    .0677522      -76  9   .769378832027809 0         0 .1214670204         .         .
          . 2014  9.290168    .0465331      199  9  .8297878483007792 0         0 .1572050401         0        12
          0 2015  8.919854   .05361679    -2943 11  .7809494088880002 0         0 .1652562325         0 15.142858
   .1818182 2016  8.962135   .05921559      164 10   .884762239735611 0         0 .1900307842         0    10.625
          0 2017  9.039078    .0811773      270 11  .8763995996934478 0         0 .2426955132         0      13.7
  -.4615385 2018  9.052633   .03699801      442 10  .8876690513988897 0         0 .2216868346         0      15.7
          0 2019  9.153981   .11330935      249 11  .8788510366829416 0         0 .2731669679         0 15.181818
          0 2020  9.172327   .07468578      176 11  .8663586187976943 0         0 .2008298759         0      17.5
          . 2021  9.278466    .1130313      980 11  .8778561893663059 0         0 .2449295187         .         .
          . 2012  9.737539   .06890059   -470.3 11  .8442895640271936 0 11.453716 .2715728872        14         0
  .11764706 2013  9.789764   .05569717    568.7 15  .7550968950206038 0         0 .2612319348         0        13
  .07017544 2014  9.785779   .05577898    258.6 11  .7879753149327128 0 11.566476  .205012715         0         9
 .032786883 2015  9.766413   .07328206   -544.1  8  .7939736120241484 0 11.635152   .17825809         0        10
 -.06349207 2016  9.801194  .034953725   -370.5  8  .7312856908157517 0   12.0131  .263572127         0        14
  -.6440678 2017  9.823751   .16247185  -1336.8  8  .7926088076829463 0 11.248322 .5977855545         0        33
 -.04761905 2018  9.861535   .07809868    742.6  8  .8530798050400724 0 11.258046 .0999403584         0      34.5
          0 2019  9.849179   .09291129    -11.3  8  .7993179460218472 0         0 .1853595218         0      36.5
end
.
I was under the impression that xtdp is an extension of xtabond and is a generalized function that allows for autocorrelated errors, therefore I am not sure why the number of observations get changed. I will really appreciate if anyone shares their thoughts or suggests some useful resources.

How to apply variance adjustment factor after/with regression analysis

$
0
0
Hello everyone,

​​​​​I need your help for the stata code/tech for the application of variance adjustment factor.
.I am running an OLS regression in stata and want to apply variance adjustment factor. But not sure how to.do that.

I will appreciate it kf you kindly help me with this matter.

Thank.you in advance,

Iqbal Chowdhury

Running latent growth curve model in Stata

$
0
0
Hello everyone,

I am trying to run latent growth curve models in Stata with the sem command. And I have two questioins that I am hoping to get help with.

Below is my code for an unconditional linear LCM:

sem (Int@1 Lin@0 -> health1) ///
(Int@1 Lin@1 -> health2) ///
(Int@1 Lin@2 -> health3) ///
(Int@1 Lin@3 -> health4), ///
noconstant mean(Int Lin) method(mlmv)

My first question is about adding categorical predictors and covariates in the model. As far as I know, sem does not work with factor coding. Does that mean I have to dummy out all the categorical variables and list them in the model? How about for a time-varying covariate that has three categories? Do I need to dummy out the variable at each wave and put in all the 12 (3*4) binary variables? I wonder if there is a easier way to include categorical vars. Please let me know!

My second question is about the TIME indicator. My sample involves four waves of data. At the first wave, respondents' age is between 20 to 30. I am wondering whether I can use AGE rather than survey WAVE as my time indicator, and how does that lead to a difference in my code?? I am used to using mixed command for growth analysis where there is a time variable in the code. But for the sem commend, how do we let Stata know which time indicator we want to use?

Thanks for any help!!






question about PSM

$
0
0
Hi, everyone!

I am investigating the relationship between the independent variable X and ESG performance. My data is such that not all firms disclose ESG reports, but there is a third-party rating agency that give ESG performance scores for all firms, and I use this ESG score as my dependent variable.

However, the reviewer believes that there is a potential selection bias here in that there may be a significant difference in ESG scores between companies that disclose ESG reports and those that do not, so they recommend that I use either the PSM or the Heckman model to address this bias.

Is it possible to use PSM in this case? Match firms that disclose ESG reports with firms that do not disclose ESG reports and then regress X and ESG performance?

(I don't think PSM can solve this problem because I think whether or not one chooses to disclose an ESG report is not the independent variable that I care about. Is my understanding wrong?

Automatized report of changes in observations?

$
0
0
Dear list members,

a curiosity: does anyone know if there is a user-written command, or at any rate a sample method (i.e. not involving the dissemination of count throughout the do file), to generate a log/report of all the (commands who produced) changes in observations in memory occurring during the execution of a range of commands? Such a command, to be turned on and off, like timer, could ease keeping track of changes in sample size, which might become laborious to keep track of when data management is long and complex. My impression is that the habit of reporting the flow of steps which determine the analysis sample, well established in some disciplines but not in others, is currently spreading - so such a command might be helpful. It's easy to imagine optional info and visualization for it.

asclogit can't convergence

$
0
0
Hi everyone,

I've recently encountered a problem with a logit model that can't converge. My research topic is about understanding whether a company's characteristics influence people's choices among different alternatives.

I have four alternatives, each under two conditions: with and without a companion. This setup results in eight dummy variables (4 alternatives * 2 conditions). I included seven of these dummy variables in my model. However, the model fails to converge even after I tried increasing the maximum number of iterations and changing the base dummy variable. The log likelihood keeps repeating when it reaches a certain value.

Below are my data and the command I used. Can someone give me some advice on this? Thanks!

(alternative1-4 stands for terminal, cargo offsite, neither sequently)
gen accompany_terminal=accompany*const1
gen accompany_cargo=accompany*const2
gen accompany_offsite=accompany*const3
gen accompany_neither=accompany*const4

gen Dnoaccompany_terminal=0
replace Dnoaccompany_terminal=1 if accompany_terminal==0 &alt==1
gen Dnoaccompany_cargo=0
replace Dnoaccompany_cargo=1 if accompany_cargo==0 &alt==2
gen Dnoaccompany_offsite=0
replace Dnoaccompany_offsite=1 if accompany_offsite==0 &alt==3
gen Dnoaccompany_neither=0
replace Dnoaccompany_neither=1 if accompany_neither==0 &alt==4

gen Dwaccompany_terminal=0
replace Dwaccompany_terminal=1 if accompany_terminal>0 &alt==1
gen Dwaccompany_cargo=0
replace Dwaccompany_cargo=1 if accompany_cargo>0 &alt==2
gen Dwaccompany_offsite=0
replace Dwaccompany_offsite=1 if accompany_offsite>0 &alt==3
gen Dwaccompany_neither=0
replace Dwaccompany_neither=1 if accompany_neither>0 &alt==4

asclogit AW dailydiscountedcharge totaltime Ddaily Dhourlim indoormix contact spaceprob contactspace Dnoaccompany_terminal Dwaccompany_terminal Dnoaccompany_cargo Dwaccompany_cargo Dnoaccompany_offsite Dwaccompany_offsite Dnoaccompany_neither ,case(scenario) alternatives(alt) vce (cluster num) nolog

(I remove some column of variable since the Message Board can't fit in )
number ver circum scenario alt accompany days AW const1 const2 const3 const4 accompany_terminal accompany_cargo accompany_offsite accompany_neither Dnoaccompany_terminal Dnoaccompany_cargo Dnoaccompany_offsite Dnoaccompany_neither Dwaccompany_terminal Dwaccompany_cargo Dwaccompany_offsite Dwaccompany_neither
1 1 1 1 5 5 0 1 0 0 0 5 0 0 0 0 0 0 0 1 0 0 0
1 1 1 2 5 5 1 0 1 0 0 0 5 0 0 0 0 0 0 0 1 0 0
1 1 1 3 5 5 0 0 0 1 0 0 0 5 0 0 0 0 0 0 0 1 0
1 1 1 4 5 5 0 0 0 0 1 0 0 0 5 0 0 0 0 0 0 0 1
1 2 2 1 5 3 0 1 0 0 0 5 0 0 0 0 0 0 0 1 0 0 0
1 2 2 2 5 3 1 0 1 0 0 0 5 0 0 0 0 0 0 0 1 0 0
1 2 2 3 5 3 0 0 0 1 0 0 0 5 0 0 0 0 0 0 0 1 0
1 2 2 4 5 3 0 0 0 0 1 0 0 0 5 0 0 0 0 0 0 0 1
1 3 3 1 0 7 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
1 3 3 2 0 7 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0
1 3 3 3 0 7 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0
1 3 3 4 0 7 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0
2 1 4 1 3 6 1 1 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0
2 1 4 2 3 6 0 0 1 0 0 0 3 0 0 0 0 0 0 0 1 0 0
2 1 4 3 3 6 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0 1 0
2 1 4 4 3 6 0 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0 1
2 2 5 1 3 7 0 1 0 0 0 3 0 0 0 0 0 0 0 1 0 0 0
2 2 5 2 3 7 0 0 1 0 0 0 3 0 0 0 0 0 0 0 1 0 0
2 2 5 3 3 7 1 0 0 1 0 0 0 3 0 0 0 0 0 0 0 1 0
2 2 5 4 3 7 0 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0 1
2 3 6 1 0 11 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
2 3 6 2 0 11 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0
2 3 6 3 0 11 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0
2 3 6 4 0 11 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0



Array

reshape

$
0
0
Hello,

I'm reshaping my data from long to wide as follows:

Code:
reshape wide x, i(id) j(yearMonth)
The names of the j variables do not come as x_2001m1 x_2001m2, and so on. Ho can I get the names in this format? An example dataset:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int year byte month float(x id temp)
2000  1  -1.4952 1 480
2000  2  -1.5653 1 481
2000  3    -1.53 1 482
2000  4  -1.5038 1 483
2000  5  -1.5184 1 484
2000  6  -1.8732 1 485
2000  7  -.53273 1 486
2000  8  -.33476 1 487
2000  9  -.38694 1 488
2000 10  -.60296 1 489
2000 11  -.61594 1 490
2000 12  -.61234 1 491
2001  1  -.59847 1 492
2001  2    -.644 1 493
2001  3  -.61931 1 494
2001  4  -.60525 1 495
2001  5  -.63979 1 496
2001  6 -.024683 1 497
2001  7  -.40757 1 498
2001  8  -.30469 1 499
2001  9  -.30957 1 500
2001 10  -.27522 1 501
2001 11    -.284 1 502
2001 12  -.25536 1 503
2002  1  -.24324 2 504
2002  2  -.22428 2 505
2002  3  -.26123 2 506
2002  4  -.27012 2 507
2002  5   -.3093 2 508
2002  6 -.060188 2 509
2002  7  -1.2304 2 510
2002  8  -1.3403 2 511
2002  9  -1.1992 2 512
2002 10  -1.2654 2 513
2002 11  -1.2676 2 514
2002 12  -1.2278 2 515
2003  1  -1.2483 2 516
2003  2  -1.2374 2 517
2003  3  -1.2214 2 518
2003  4   -1.205 2 519
2003  5  -1.2098 2 520
2003  6  -1.7511 2 521
2003  7   .12341 2 522
2003  8   .73705 2 523
2003  9   .75044 2 524
2003 10   .77955 2 525
2003 11   .79881 2 526
2003 12   .81725 2 527
2004  1   .83258 3 528
2004  2   .81351 3 529
2004  3   .74627 3 530
2004  4   .76489 3 531
2004  5   .84338 3 532
2004  6   .95598 3 533
2004  7  -.20344 3 534
2004  8  -.12863 3 535
2004  9  -.16902 3 536
2004 10  -.10092 3 537
2004 11  -.11268 3 538
2004 12  -.10501 3 539
end
format %tm temp
Thank you.

How to add a (empty) category to a variable?

$
0
0
Dear community,

I conducted a survey with the software "limesurvey". I successfully exported the data to excel and imported the data to stata. By viewing the data I noticed a problem that not every possibility of respones is available:

For example:
"What is your gender (according to birth registry)?" with response options 1: "male", 2: "female", 3: "divers", and 4: "unspecified according to birth registry".

Option 4 was not used by the paticipants, so that in Stata the variable "gender" only has the scale from 1 to 3. For completness and for descriptive Statistics, I would like to add catecory 4 in retrospect. How can I do it?

Now:
. tab gender

gender | Freq. Percent Cum.
------------+-----------------------------------
1 | 20 31.75 31.75
2 | 39 61.90 93.65
3 | 4 6.35 100.00
------------+-----------------------------------
Total | 63 100.00

My goal is to tablulate gender and see it like this:

. tab gender

gender | Freq. Percent Cum.
------------+-----------------------------------
1 | 20 31.75 31.75
2 | 39 61.90 93.65
3 | 4 6.35 100.00
4 0 .... ....
------------+-----------------------------------
Total | 63 100.00

Can anyone help? I tried so hard, but cound not fix it. Many thanks in advance!

Note: This is only one (short) example among others.

reshape with dummy variables for values?

$
0
0
Hi there, thanks all in advance for your help!

I have a simple dataset that looks like this:
* Example generated by -dataex-. For more info, type help dataex
clear
input str14 id str15 County
"1003027012" "Kern"
"1003068206" "Los Angeles"
"1003223124" "San Diego"
"1003223124" "Los Angeles"
"1003223124" "Orange"
"1003316290" "Sacramento"
"1003351610" "San Diego"
"1003351610" "Riverside"
"1003351610" "Orange"
"1003352220" "Los Angeles"
"1003412743" "Los Angeles"
"1003413600" "Fresno"
"1003413600" "Madera"
"1003413600" "Kings"
"1003413600" "Tulare"
end
[/CODE]

I've been asked to reorganize the data such that each row is a unique id, and each column is a dummy variable for whether that county is associated with that id (see below). Reshaping wide is close to what I want, but that command simply creates new variables with the first county that appears for each id variable, rather than creating dummies. I could just create the county variables one by one, but I'd also love to learn about a better solution if it's out there.

This is what I want the data to look like eventually, in case I haven't been clear:
ID Kern Los Angeles Orange San Diego Sacramento Riverside Fresno Kings Madera Tulare
1003027012 1
1003068206 1
1003223124 1
1003223124 1
1003223124 1
1003316290 1
1003351610 1
1003351610 1
1003351610 1
1003352220 1
1003412743 1
1003413600 1
1003413600
1003413600 1
1003413600 1

Thanks so much! Any suggestion welcome and appreciated, and feel free to redirect me to a pre-existing thread if I've overlooked it.


Custom subgroup means in meta forest

$
0
0
Hello all, I am trying to include custom diamonds for each subgroup in my meta analysis that uses the option subgroup(). I know of the customoverall() option but cannot find one for each group.
Any ideas on how I could achieve this using the meta suite?

Thank you

Replace using regex not working

$
0
0
I have a dataset with a string variable, rdm_code, that needs to match a certain pattern. In order to verify if the pattern is fine, I created a dummy variable that is called bad_scanning. The bad_scanning is equal to one if the pattern is not matched. However, if I run my code all together, the replaces with the regex does not work. If I run line by line, it works fine. I already tried to add the sleep command, but it does not work as well. Does someone knows how to fix this?



Code:
gen bad_scanning = 1
replace bad_scanning = 0 if regexm(rdm_code, "s([0-9]{2}|[0-9]{3}|[1-4])c[0-9]{3}\-([0-9]{3}|[0-9]{2}T)\-[0-1]")
replace bad_scanning = 0 if regexm(rdm_code, "s[1-2]c[0-9]{2}\-[0-9]{3}|[0-9]{2}T\-[0-1]")


here's the correct example, when I run line by line
Code:
rdm_code        bad_scanning
s4c064-136-0       0
s30c110-114-0      0
s34c252-11T-1      0
s2c63-149-1        0
s2c57-070-0        0
123456             1



here's the wrong example, when I run the whole do-file

Code:
rdm_code        bad_scanning
s4c064-136-0       1
s30c110-114-0      1
s34c252-11T-1      1
s2c63-149-1        1
s2c57-070-0        1
123456             1


Thank you!!

Search within do-files on Mac OS

$
0
0
Dear community,

I wish to search within do-files on my Macbook. In particular, to search for commands/snippets I have used before in other files with the usual Spotlight search in the Finder.

This does not seem to work by default (Stata 18, Macbook Pro M3 2023, OS 14.4.1).

I have no recall if this ever was different on Mac but was wondering if someone knows more about this.

Surprisingly, I didn't find any threads on this on Statalist.

Best,

John
Viewing all 65052 articles
Browse latest View live


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