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

Potential problems with probit models and Solutions

$
0
0
Dear all users of Statalist,

I'm currently working on the my master thesis with the topic of farmers' use of personal protective equipment (PPE) during pesticide applications in Ghana. I want to estimate the determinants of the PPE use using standard probit model. I want to find out what kind of potential problems probit model has and solutions to each issue in this post

The models has the outcome variable is a binary variable to identify if a farmer used PPE or not with a set of independent variables associated with individual characteristics(age, education, size of land etc), village attributes(infrastructure, facilities in a village), and the binary variable to identify if a village chief used PPE or not, whose marginal effect is a main interest in my thesis.

As far as I know, there are potential problems such as
(i) Endogeneity of independent variables
(ii) Heteroskedasticity and Normality in the latent variable model

The questions are below:
(1) How can you test heteroskedasticity besides hetprobit and the suggestion by Wooldridge(2007) at Section 15.5.3?
(2) How would you justify the approach by Wooldridge(2007) to test heteroskedasticity? (This is unrelated with Stata topic, though)

Thanks in advance,

Reference:
Jeffrey M Wooldridge, 2010. "Econometric Analysis of Cross Section and Panel Data," MIT Press Books, The MIT Press, edition 2, volume 1

Interaction effect between two non-dichotomous categorical variables

$
0
0
Dear all,

I would like to view the interaction effect between education level and age while trying to predict their health status (continuous variable) with the Oaxaca-Blinder decomposition approach (linear model).
Education level is measured by 3 dummy variables for lower than high school degree, high school degree and university degree. Age is measured by 8 age groups: 25-29, 30-34, 35-39, 40-44, 45-49, 50-54, 55-59 and 60-64.

I am unsure how to measure this interaction. Options I see are:
1) 3x8 interaction, but this seems over-complicated.
2) Interacting the two categorical variables directly as follows: educationlevel##age, but this is not allowed in the oaxaca command
3) Treating the age variable as a continuous variable and writing the code as follows: normalize(lessthanhighschool highschool university) normalize(lessthanhighschoolxage highschoolxage universityxage # age), but this does not seem technically correct.

What do you think?

combine variable names

$
0
0

Hello statalisters, I have a question regarding stata operation. I have 2 lists of variable names as follows: x = (a, b, c) y = (c, d, f) I want to perform a compound operation to get the variable list as follows (a, b, c, d, f). Please help me solve this problem. Thank you everyone

multi level ordinal regression ?crossed effect

$
0
0
Hi,

Hi,


I want to run a multi-level ordinal logistic regression in which people have completed an assessment ('assessoutcome') at different stages of their career. The outcome is 1-3 on an ordinal scale. They do the assessment at careerlevel1 through to careerlevel8

I have done the following, nesting assessment outcome by id:

meglm assessoutcome 'variable' || id:, family(ordinal) link(logit) or

One of the problems is that people enter the cohort at different times and so have different numbers of assessment outcomes, e.g. one person will enter the cohort at the point they are completing the last assessment (careerlevel8) so we do not have any data of assessment outcomes prior to this.

In order to account for this, will a crossed effect model like the one below work?


meglm assessoutcome 'variable' || _all:R.careerlevel || id:, family(ordinal) link(logit) cov(unstructured) or


I hope that makes sense and as always grateful for your help,
Carla






Piecewise regression

$
0
0
Dear Statalist. I was wondering how to know what intial value to enter when doing a piecewise regression? After a lot of testing i find that the c value that minimise the MSE is 28. However, this required a lot of effort. When entering a low value for example 5 I get a relativly high MS value, the MS value jumps up an down until I tested a c value of 28 which gave the optimal result. When I put a c value of more than 28 the MS increases again. Any suggestion on how to find the optimal value that minimse the MS more effectivly?

My command is: nl (KOSTBHG = SIZE*{b1} + (SIZE>{c})*( SIZE-{c})*{b2}), variables(SIZE) initial(b1 0 c 28 b2 0) noconstant

Possible issue with diff in diff regression?

$
0
0
Hello,

I am trying to do a diff in diff approach where my regression code looks like this

Code:
mi estimate, esampvaryok: reg job_hours treatment time i.time#i.treatment, robust
Treatment is defined as

Code:
gen treatment=0 if (expectation==2 & f.gift_received==2 & gift_total < 50000000) | (l.expectation==2 & gift_received==2 & gift_total < 50000000) 

replace treatment=1 if (expectation==2 & f.gift_received==1 & gift_total < 50000000) | (l.expectation==2 & gift_received==1 & gift_total < 50000000)
and time is a binary variable for the two time points.

My output looks as follows

Code:
Multiple-imputation estimates                     Imputations     =          5
Linear regression                                 Number of obs   =         55
                                                  Average RVI     =     0.1495
                                                  Largest FMI     =     0.3396
                                                  Complete DF     =         51
DF adjustment:   Small sample                     DF:     min     =      19.29
                                                          avg     =      37.33
                                                          max     =      47.65
Model F test:       Equal FMI                     F(   3,   38.8) =       1.62
Within VCE type:       Robust                     Prob > F        =     0.1996

--------------------------------------------------------------------------------
     job_hours |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
---------------+----------------------------------------------------------------
     treatment |  -7.653846   7.472867    -1.02   0.318    -23.27896    7.971272
          time |   -5.29398   3.226253    -1.64   0.108    -11.78518    1.197221
               |
time#treatment |
          0 1  |   3.972687   12.99843     0.31   0.762     -22.3997    30.34508
          1 0  |          0  (omitted)
          1 1  |          0  (omitted)
               |
         _cons |   42.74783   2.208462    19.36   0.000     38.30658    47.18907
--------------------------------------------------------------------------------
However, I want the regression to look like this

job_hours = b0 + b1 * (treated = 1) + b2 * (Time=1) + b3 * interaction+ e_it, where in the interaction both treated and time are = 1

I am unsure how to continue, how would I change the regression to make this happen? mi estimate doesn't seem to allow for "if"

Result in binary logistic regression significant but not in multilevel model

$
0
0
Dear all,

I have run a binary logistic regression analysis (good versus poor health) and my results are statistically signifiant. When I run a (two-level) multilevel model, because I actually have clustered data (participants from different countries), my result are not longer significant (p>0.05).

Would someone be so kind to explain why this happens?

Thank you.

How to get 1, 3, 6 month future returns

$
0
0
Hello.
I'm currently doing a finance dissertation on the U.S. stock market.
I have firm prices, daily returns in the entire market. There are thousands of firms in the entire market. I calculated past 1months, 3months and 6months past returns and standard deviation from daily returns.
My question is that I have to get 1month 3month 6month future returns of each firms from daily returns. In other words, as I calculated past returns, I try to get the future returns on each month.
My code and dataex look like below.
Please help me if you can. Thank you.


gen int mdate = mofd(date)

format mdate %tm

foreach lag of numlist 1 3 6 {
sort permno mdate date
rangestat (first) prc (sd) volatility_`lag' = prc, by(permno) interval(mdate
> -`lag' -1)
by permno mdate (date): gen ret_`lag' = prc[1]/prc_first - 1
drop prc_first
}


And dataex looks like this.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double permno long date double(shrcd exchcd siccd prc shrout retx) int mdate double volatility_1 float ret_1 double volatility_3 float ret_3 double volatility_6 float ret_6
10026 21186 11 3 2052 149.17999267578125 18668   -.017453791573643684 696                  .            .                  .          .                  .          .
10026 21187 11 3 2052 147.69000244140625 18668   -.009987869299948215 696                  .            .                  .          .                  .          .
10026 21188 11 3 2052 149.72999572753906 18668    .013812670484185219 696                  .            .                  .          .                  .          .
10026 21189 11 3 2052  148.3000030517578 18668   -.009550475515425205 696                  .            .                  .          .                  .          .
10026 21192 11 3 2052 148.41000366210938 18668   .0007417438318952918 696                  .            .                  .          .                  .          .
10026 21193 11 3 2052 147.33999633789063 18668  -.0072098057717084885 696                  .            .                  .          .                  .          .
10026 21194 11 3 2052  145.4600067138672 18668    -.01275953371077776 696                  .            .                  .          .                  .          .
10026 21195 11 3 2052 146.58999633789063 18668    .007768386974930763 696                  .            .                  .          .                  .          .
10026 21196 11 3 2052              146.5 18668  -.0006139323231764138 696                  .            .                  .          .                  .          .
10026 21200 11 3 2052 146.66000366210938 18668    .001092175138182938 696                  .            .                  .          .                  .          .
10026 21201 11 3 2052  152.0500030517578 18668     .03675166517496109 696                  .            .                  .          .                  .          .
10026 21202 11 3 2052 150.49000549316406 18668   -.010259767062962055 696                  .            .                  .          .                  .          .
10026 21203 11 3 2052  153.8000030517578 18668    .021994799375534058 696                  .            .                  .          .                  .          .
10026 21206 11 3 2052             149.75 18668    -.02633291855454445 696                  .            .                  .          .                  .          .
10026 21207 11 3 2052 150.22000122070313 18668   .0031385724432766438 696                  .            .                  .          .                  .          .
10026 21208 11 3 2052 148.36000061035156 18668   -.012381844222545624 696                  .            .                  .          .                  .          .
10026 21209 11 3 2052  150.9199981689453 18678    .017255308106541634 696                  .            .                  .          .                  .          .
10026 21210 11 3 2052 148.72999572753906 18678   -.014511015266180038 696                  .            .                  .          .                  .          .
10026 21213 11 3 2052  149.5500030517578 18678    .005513395648449659 696                  .            .                  .          .                  .          .
10026 21214 11 3 2052 138.99000549316406 18678    -.07061181962490082 696                  .            .                  .          .                  .          .
10026 21215 11 3 2052 138.44000244140625 18678   -.003957141190767288 696                  .            .                  .          .                  .          .
10026 21216 11 3 2052  139.5399932861328 18678     .00794561393558979 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21217 11 3 2052 136.97999572753906 18678    -.01834597811102867 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21220 11 3 2052 133.24000549316406 18678   -.027303185313940048 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21221 11 3 2052 135.91000366210938 18678    .020039012655615807 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21222 11 3 2052 134.74000549316406 18678   -.008608624339103699 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21223 11 3 2052  132.1699981689453 18678    -.01907382532954216 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21224 11 3 2052 133.88999938964844 18678    .013013552874326706 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21227 11 3 2052 134.24000549316406 18678    .002614131895825267 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21228 11 3 2052 134.61000061035156 18678   .0027562209870666265 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21229 11 3 2052 138.36000061035156 18678    .027858257293701172 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21230 11 3 2052 138.77999877929688 18678   .0030355460476130247 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21231 11 3 2052 139.10000610351563 18678   .0023058606311678886 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21235 11 3 2052 138.60000610351563 18678  -.0035945361014455557 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21236 11 3 2052  135.9499969482422 18678   -.019119834527373314 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21237 11 3 2052  134.6300048828125 18678   -.009709393605589867 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21238 11 3 2052  135.4199981689453 18678    .005867884028702974 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21241 11 3 2052  137.1199951171875 18678    .012553514912724495 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21242 11 3 2052 136.16000366210938 18678   -.007001104764640331 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21243 11 3 2052  134.3300018310547 18678   -.013440083712339401 697 3.6470898275500985   -.06461992 3.6470898275500985 -.06461992 3.6470898275500985 -.06461992
10026 21244 11 3 2052              134.5 18678   .0012655263999477029 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21245 11 3 2052 137.22000122070313 18678     .02022305689752102 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21248 11 3 2052 138.69000244140625 18678    .010712732560932636 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21249 11 3 2052 140.94000244140625 18678    .016223231330513954 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21250 11 3 2052  141.3300018310547 18678   .0027671304997056723 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21251 11 3 2052                141 18678   -.002334973542019725 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21252 11 3 2052  141.8000030517578 18678     .00567378057166934 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21255 11 3 2052 141.11000061035156 18678   -.004866025410592556 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21256 11 3 2052 141.00999450683594 18678  -.0007087102276273072 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21257 11 3 2052 138.92999267578125 18678   -.014750740490853786 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21258 11 3 2052  135.3800048828125 18678   -.025552349165081978 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21259 11 3 2052 136.69000244140625 18678    .009676448069512844 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21262 11 3 2052 136.11000061035156 18678   -.004243191331624985 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21263 11 3 2052 135.66000366210938 18678   -.003306126920506358 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21264 11 3 2052 133.82000732421875 18678   -.013563293032348156 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21265 11 3 2052  133.6999969482422 18678  -.0008968044421635568 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21266 11 3 2052 132.00999450683594 18678    -.01264025829732418 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21269 11 3 2052 135.17999267578125 18678    .024013319984078407 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21270 11 3 2052  135.0800018310547 18678   -.000739686714950949 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21271 11 3 2052  134.6199951171875 18678   -.003405438968911767 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21272 11 3 2052 136.55999755859375 18697    .014410953037440777 698 2.1448368228769437   -.03611863   6.75308261146184 -.09840456   6.75308261146184 -.09840456
10026 21276 11 3 2052 134.27000427246094 18697   -.016769137233495712 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21277 11 3 2052 137.44000244140625 18697    .023609131574630737 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21278 11 3 2052 139.22999572753906 18697    .013023816049098969 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21279 11 3 2052 140.52999877929688 18697    .009337089955806732 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21280 11 3 2052 138.47999572753906 18697    -.01458765473216772 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21283 11 3 2052  138.7899932861328 18697    .002238572807982564 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21284 11 3 2052 140.10000610351563 18697    .009438812732696533 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21285 11 3 2052 140.10000610351563 18697                      0 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21286 11 3 2052  140.1199951171875 18697  .00014267675578594208 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21287 11 3 2052  139.5399932861328 18697   -.004139322321861982 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21290 11 3 2052 142.41000366210938 18697    .020567653700709343 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21291 11 3 2052 143.97000122070313 18697    .010954269208014011 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21292 11 3 2052 143.99000549316406 18697  .00013894750736653805 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21293 11 3 2052 142.07000732421875 18697   -.013334246352314949 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21294 11 3 2052  140.6699981689453 18697   -.009854361414909363 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21297 11 3 2052 140.66000366210938 18697 -.00007104931137291715 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21298 11 3 2052 140.27000427246094 18697  -.0027726388070732355 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21299 11 3 2052  140.4499969482422 18697    .001283187186345458 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21300 11 3 2052 140.47000122070313 18702  .00014242985344026238 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21301 11 3 2052  139.0800018310547 18702    -.00989534705877304 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21304 11 3 2052 137.41000366210938 18702   -.012007464654743671 699   3.01939331007298 -.0017100055  6.210727198484631  -.0999463  6.210727198484631  -.0999463
10026 21305 11 3 2052 132.07000732421875 18702   -.038861773908138275 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21306 11 3 2052 129.66000366210938 18702   -.018247924745082855 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21307 11 3 2052 128.82000732421875 18702   -.006478453986346722 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21308 11 3 2052  132.6999969482422 18702    .030119463801383972 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21311 11 3 2052  135.0500030517578 18702    .017709163948893547 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21312 11 3 2052              135.5 18702    .003332076594233513 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21313 11 3 2052 135.74000549316406 18702   .0017712583066895604 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21314 11 3 2052  135.8000030517578 18702  .00044200351112522185 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21315 11 3 2052  137.0800018310547 18702    .009425616823136806 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21318 11 3 2052 135.97000122070313 18702   -.008097466081380844 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21319 11 3 2052  136.7100067138672 18702    .005442417226731777 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21320 11 3 2052 138.63999938964844 18702     .01411742065101862 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21321 11 3 2052  140.3000030517578 18702    .011973482556641102 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21322 11 3 2052  140.6999969482422 18702    .002850990043953061 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21325 11 3 2052 140.85000610351563 18702    .001066163182258606 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21326 11 3 2052             137.25 18702    -.02555914781987667 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21327 11 3 2052  138.0500030517578 18702     .00582880200818181 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
10026 21328 11 3 2052 138.83999633789063 18702   .0057225157506763935 700  2.179335261288767  -.016384874 2.9770448142147945 -.05353294 5.4588365863643675 -.11469357
end
format %d date
format %tm mdate
------------------ copy up to and including the previous line ------------------

Listed 100 out of 1861397 observations
Use the count() option to list more




Thank you for help again.

Change letter spacing

$
0
0
Dear all,

When plotting a graph, is there an option to change the distance between characters (letter spacing)?

If so, is there a parameter that can be changed in the scheme file or do I need to do it on graph level?


Thank you very much for your help!

How to measure firm's industry stock beta?

$
0
0
Hi everyone,

I am trying to measure firm's industry stock beta following the methodology used in the JFE paper "The influence of product market dynamics on a firm’s cash holdings and hedging behavior" by
David Haushalter, Sandy Klasa and William F. Maxwell (2007). I am quoting their methodology here,

"To measure how firms’ growth opportunities co-vary with those of their industry rivals, we calculate the correlation of firm stock returns with industry stock returns. The methodology used to calculate our correlation measure is similar to that in Parrino (1997). Using monthly stock return data from 1993 to 2001, we regress a firm’s monthly stock return on the monthly Center for Research in Security Prices (CRSP) equally weighted market return and the monthly equally weighted return for the index of firms sharing the same Compustat two-digit Standard Industrial Classification (SIC) code as the firm. The regression coefficient on the industry return index is then used as the proxy for the correlation between the firm’s stock returns with industry stock returns. To calculate these correlation measures we require that CRSP has at least 24 months of returns data for a firm."

I have collected the CRSP data on stock price, SIC code and equally weighted market return. I know it's a long process but will really appreciate it if someone can guide me towards the proper coding to get this beta!

Thanks in advance!

Generating a new variable (0/1) based on multiple variables and excluding missing values

$
0
0
Hi I am having some trouble. What I want to do is create a variable lets call it Var_1. I want this variable to have either a 1, 0 or a missing value depending on whether someone is over or under a certain threshold in multiple other variables.

I have tried the following code but it does not work:

Code:
gen Var_1 = Var_66<=2 & Var_66<. & Var_67 >=1 & Vat_67 <. & Var_68 >=1 & Var_68 <. & Var_69 >=1 & Var_69<. & Var_70<=3 & Var_70 <.
.

So I want it so if someone gets 2 or less for Var_66 they get a 1 for Var_1 regardless of how they score on the other variables. I want it to ignore missing values and if someone has a missing value for all variables then they will have a missing value in Var_1. Otherwise I want it to be a 0 if all values don't meet the thresholds specified.

Coefplot merging two graphs into one

$
0
0
Dear Statalist,

I am trying to merge two graphs (as shown in the attached graph file) into one using the user written coefplot command as follows but it is not working:

reg employed i.agecat i.agecat#i.dis i.married i.redu i.chb5 i.ch514 i.urban i.wave if male==1 margins r.dis, at(agecat=(16(5)61)) post
estimates store Male

reg employed i.agecat i.agecat#i.dis i.married i.redu i.chb5 i.ch514 i.urban i.wave if male==0 margins r.dis, at(agecat=(16(5)56)) post
estimates store Female

coefplot Male Female, at

Can anyone help, many thanks in advance!

Michael

Reformatting Data Conducive to Panel Data Analysis

$
0
0
Hello,

I am trying to use the reshape command to restructure my data into panel format. I've attached a picture of the current format where each country has 11 variables measured from 1990 - 2018. Does anyone have suggestions to convert the Indicators as column heads (variable names) and the time to be vertically listed? Thank you for your time.



Array



Marginal effects in GLM

$
0
0
Hi all,

I am having difficulties in obtaining marginal effects of a GLM estimation that I am running. When I run the following, I obtain all coefficients of all covariates specified:

Code:
svy, subpop(if group ==1): glm exportintensity bimodal990##(c.foreign c.govt c.age c.age2 c.size_num c.capacity i.email_d i.tech_d) i.countryyear i.industry, fam(bin) link(logit)
However, as far as I am aware, in GLM since these are not marginal effects, so I run the following:
Code:
margins, dydx(*)
, or
Code:
margins, dydx(*) atmeans
I get marginal effects for all but i.countryyear, and i.bimodal990 and its interactions with the other covariates. For these, Stata tells me they are "not estimable." This is a bit strange because I was obtaining all GLM coefficients perfectly. I am not sure if I am using the wrong command for marginal effects, since there's a bunch of interactions that I am estimating. Is there something I am overlooking here?

If you think the commands are correct and still I am getting problems, I'd be happy to share a part of my data. Thank you!

In panel data regression do respondents in only 1 wave still contribute to the analysis?

$
0
0
I've been asked to conduct a linear probability fixed effects analysis of children in panel data. There are three waves of data and it was suggested that the sample of children to be analysed are those who appear in the first wave and at least one other wave (wave two or three or two and three).

I understand technically how to do this, as below:

Code:
xtreg child_hours_slept_y control_var1 control_var2 if wave1==1 &  wave2==1 | wave1==1 & wave3==1 | wave1==1 & wave2==1 & wave3==1, cluster (child_location) fe robust
So I've created a sample of children who appear in at least 2 waves and analyse this sample in several regressions; for waves 1, 2 and 3, waves 1 and 2, waves 2 and 3 and waves 1 and 3 by dropping the below as necessary.

Code:
drop if year == 3

drop if year == 2

drop if year == 1

Here the sample is children in wave 1 and at least one other wave and no-one new joins the data after recruitment into wave 1. But, what I want to know is, in a linear probability fixed effects model, are children still contributing to the analysis even when they appear in only one wave?

So if I have a child who appears in wave 1 and 3 and I analyse wave 1 and 2 (by dropping wave 3 as above before running my regression), according to the sample inclusion rules this child will still be included in the analysis:

- as above

Code:
if wave1==1 &  wave2==1 | wave1==1 & wave3==1 | wave1==1 & wave2==1 & wave3==1
but will they be dropped from the regression? Or will their wave 1 data still be included in the analysis and in what way?

i.e. in a random effects model even if people drop out they provide a cohort effect, is the linear probability model doing likewise here?

I am very confused,

Thank you

Jack

DID Results Interpretation

$
0
0
Hi,

Can someone please recommend me where to look to interpret my DID results on stata please?

Unfortunately "help difference-in-difference" and Google hasnt been helpful.

Thanks,

N

Heckman and IV with weights

$
0
0
Hello,

I am doing a 2SLS regression model however I want to restrict my sample to a subset and will need to incorporate a Heckman IMR. I am bit confused on how to incorporate weights. My original sample has weights, is this problematic to use these in the iv model w/heckman?

Here's an example of the code:

keep if condition==1

gen lambda (code omitted)

ivregress 2sls depvar lambda $controls ($endog= $iv) [iweight=weight]

thank you,
Donovan

Handling Multiple Response Variable

$
0
0
Hello,

I am trying to create a summary of responses to a multiple response variable. My dataset looks like this:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int id byte(Bad_ReduceSexualityLibido Bad_AgainstGodWill Bad_PhysicalPain Bad_HandicapDisability Bad_Abusive Bad_HealthInfections Bad_MentalHealth Bad_NonSpecificGenerally Bad_PatriarchyGender Bad_CulturalPractice)
 1 1 0 1 0 0 0 0 0 0 0
 2 0 0 0 0 0 1 0 0 0 0
 3 0 0 1 0 0 1 0 0 0 0
 4 0 1 1 0 0 0 0 1 1 0
 5 0 0 0 0 0 0 0 1 0 0
 6 0 0 0 0 0 1 0 0 0 0
 7 1 0 0 0 0 1 0 0 0 0
 8 0 0 0 0 0 0 0 1 0 0
 9 0 1 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 1 0 0
end
label values Bad_ReduceSexualityLibido labels29
label def labels29 0 "No", modify
label def labels29 1 "Yes", modify
label values Bad_AgainstGodWill labels30
label def labels30 0 "No", modify
label def labels30 1 "Yes", modify
label values Bad_PhysicalPain labels31
label def labels31 0 "No", modify
label def labels31 1 "Yes", modify
label values Bad_HandicapDisability labels32
label def labels32 0 "No", modify
label values Bad_Abusive labels33
label def labels33 0 "No", modify
label values Bad_HealthInfections labels34
label def labels34 0 "No", modify
label def labels34 1 "Yes", modify
label values Bad_MentalHealth labels35
label def labels35 0 "No", modify
label values Bad_NonSpecificGenerally labels36
label def labels36 0 "No", modify
label def labels36 1 "Yes", modify
label values Bad_PatriarchyGender labels37
label values Bad_CulturalPractice labels37
label def labels37 0 "No", modify
label def labels37 1 "Yes", modify
I have reviewed the FAQ on Multiple Responses posted here: https://www.stata.com/support/faqs/d...ple-responses/ and understand the several approaches offered.

I am interested in creating two variables from the dataset:

Variable1: captures the number of times a specific bad reason is given. For example, the number of times "Bad_ReduceSexualityLibido" is given as a reason, regardless of whether it is the sole reason or not. I think the following code produces what I want:
Code:
 
/* Number of times a Bad Reason is Given - regardless of multiple indicators */
.
. tabstat Bad_*, s(sum) c(s)

    variable |       sum
-------------+----------
Bad_Reduce~o |        77
Bad_Agains~l |        24
Bad_Physic~n |        95
Bad_Handic~y |        57
 Bad_Abusive |        18
Bad_Health~s |       154
Bad_Mental~h |        22
Bad_NonSpe~y |       128
Bad_Patria~r |        45
Bad_Cultur~e |        15
------------------------
But how do I save the result in a single variable so I can use it for further analysis.


Variable 2: The second type of variable I want to create should capture the any combination of responses given, i.e., those who give one reason (e/g. Bad_PhysicalPain) or mutlple reasons (Bad_PhysicalPain and Bad_Abusive and Bad_PatriarchyGender).

How do I create this second one?

Thanks again for every assistance given.

best wishes, cY


Imputing values by group for a HHI index

$
0
0
Hi,
I am in the process of creating a Herfindafl index (HI) for newspaper media markets, where I use the number of subscribers to compute the market share of each outlet and pair this measure with the number of outlets in a market to create the index. The subscribers values are missing for many outlets, and as a result, the markets where subscribers values are not available for any outlet in the market have missing values for the HI. Only 94 out of 350 media markets have non-missing HI values. I am trying to impute missing values for the HI using the following commands,

Code:
mi set mlong
mi register imputed hhi
mi impute pmm hhi, by(media_market) add(10)
but this does not lead to imputed values (still have missing values). Is there another way to approach this?

Thank you.

Delaying the execution of a command till the end of do-file

$
0
0
Is there a way to delay the complete execution of a command till the end of do-file? So wherever this command is typed in the do-file -even at the top of the do-file- it would wait till the end of do-file, and provide output just before the do-file ends. Something like "collect information and run this command now, but show the output only when the do-file ends." Note that this is a single line of command that would not require writing additional lines of code at the bottom of the do-file.

A simple example is below (but what I actually want to do is more complicated than this example).
Code:
use https://www.stata-press.com/data/r16/auto, clear

replace price=1000 if mpg>30
cap summ price

// Below is the -doend- command that would collect information at this
// position in the do-file but delay its execution till the end of do-file

doend: display r(mean)

drop if mpg>20

// So without any additional lines of command, when the do-file ends,
// it provides the output of "display r(mean)" but the output would reflect
// the status of data before "drop if mpg>20" command line.

Viewing all 65449 articles
Browse latest View live


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