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

returndata, based on fiscalyear instead of calender year.

$
0
0
Hello,

The past few days I've been struggling with computing annual returns (CRSP). This is the code i used:

Code:
gen lnret= ln(1+ret)
bys permno year: egen sumlnret= sum(lnret)
bys permno year: gen return= exp(sumlnret)-1
bys permno year: gen count=_N
However, the firms in my sample have different fiscal year ends.. Although it seems like a common problem when creating annual returns, i cant seem to find any proper solution to take the difference between the calender and fiscalyear into account. I was hoping you could help me out here!

Thanks in advance.














saving regression outputs for many regressions by group

$
0
0
Hi all,

I have stock data, so stock permno and date identifies an observation.

There are multiple events, and for each event, there is a dummy variable for pre-event and post-event windows (i.e., pre_e1, post_e1, pre_e2, post_e2,..., pre_e5, post_e5).

I am interested in estimating betas for each stock and for each window. For example, pseudo,

for permno = 1 to 5 {
reg stock_excess_return market_excess_return if permno==i&pre_e1
reg stock_excess_return market_excess_return if permno==i&post_e1
reg stock_excess_return market_excess_return if permno==i&pre_e2
reg stock_excess_return market_excess_return if permno==i&post_e2
...
reg stock_excess_return market_excess_return if permno==i&pre_e5
reg stock_excess_return market_excess_return if permno==i&post_e5
}

and I am interested in storing regression coefficients for all the regressions.

I did find,

statsby, by(permno): reg stock_excess_return market_excess_return if pre_e1

But statsby runs regressions under only one if condition. Is there a way I can run multiple regressions by permno and save regression coefficients for all of these at the same time? It feels like it ought to be much faster that way.

I'd much appreciate any and all helps.

Thanks so much!

Best,


John

Robustness test

$
0
0
Hi
I am using panel data for 130 developing countries for 18 years. I used fixed effect model with clustering at country level to see the impact of parental leave policy on Gender employment gap.Now I want to do some robustness checks but do not have idea how to do that as this is my first paper.
Can any one suggest me including coding?
Best
Nuzaba

POLS-FE range for GMM estimates

$
0
0
Hi! I'm using the Arellano Bond estimator for my model and firstly I tried my dynamic model with POLS and FE to obtain the range of the estimates as described in Roodman 2006. When I run the AB model the estimates of the lagged variable are significative and the tests (AR and Hansen) give me good answers about the instruments. The problem is that the estimates from the AB are not in the range but are lower than the FE regressions so it seems that are underestimated. I tried different AB, limiting the lags, collapsing the lags, twostep etc. but the estimates are always lower than the FE. So my questions are

- I need to observe the POLS-FE bounds for all my variables or just for the dependent lagged variable?
- Following my first question, If the estimates are not in the range, the estimates are biased?

Thank you!

teffects ra and ipwra --iterations not concave

$
0
0
Dear Statalist:
I have encountered a convergence problem when running both teffects ra and teffects ipwra (only when using atet). Even when imposing limits on the number of iterations, I still get these errors.
I have also allowed the programs to run--but they run for a long time.

I have a multivalued treatment and ordinal outcome.
For the ipwra analyses, the treatment and outcome models are similar in that they share similar covariates (factors and continuous variables).

I have been able to successfully run both teffects aipw as well as regular regression (ologit as well as mlogit) models for my outcome and the treatment, with no problems (i.e., estimates and standard errors look fine).

I am happy to provide more details and the code if someone has any initial thoughts or suggestions.

Thank you!
Saul

Display variable label in bar chart

$
0
0
Hello.

Using the sample data set, I ran the following commands:

. sysuse auto.dta
. graph hbar (mean) mpg rep78, ascategory blabel(bar)

The Y-axis displays ,,mean of varname’’ for mpg and rep78. I however would like to display ,,varlabel’’, so Mileage (mpg) and Repair Record 1978 (possibly without the term ,,mean of").

Does someone has an answer to that?

Many thanks,
Aline

marginal effects vs. odds ratios

$
0
0
Hello,

I am currently trying to understand the pros and cons of using odds ratios vs. marginal effects for the interpretation of a multinomial logit. If anyone could enlighten me, or point me to a resource that could help with this decision, it would be greatly appreciated.

J

Unknown error message when doing multiple imputation

$
0
0
Hello,

I am conducting multiple imputation using the mi chained command with predictive mean matching (pmm). It appears that the imputation is completed, but I am receiving an error message and I am unable to figure out what it means. Here is the error message:

"Median of S12 invalid name
stata(): 3598 Stata returned error
_Imp_chained::destroy(): - function returned error

S12 is a variable name. Can anyone tell me what the error message means?

Here is all of my code:

mi register imputed CBI7re CBI8re CBI9re CBI10re CBI11re CBI12re CBI13rre CBI14re CBI15re CBI16re CBI17re CBI18re CBI19re JS1 JS2 JS3 JS4 JS5 JS6 ST1 ST2 ST4 ST5
TP1 TP2 TP3 TP4 TP5 PS1 PS2 PS3 PS4 PS5 PS6 PS7 S12_Comb S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16 S17 S18 CR1 CR2a CR2b CR2c CR2d CR2e CR2f CR2g;

mi register regular SanFran Missouri Indiana YrsPosDum0 YrsPosDum1 YrsPosDum2 YrsPosDum3 YrsPosDum4 YrsPosDum5 JobFunAssess JobFunPerm JobFunOther EduBachelors EduMasters EduOther Race3 Gender1;

mi impute chained (pmm, knn(10)) CBI7re CBI8re CBI9re CBI10re CBI11re CBI12re CBI13rre CBI14re CBI15re CBI16re CBI17re CBI18re CBI19re JS1 JS2 JS3 JS4 JS5 JS6 ST1 ST2 ST4 ST5 TP1 TP2 TP3 TP4 TP5 PS1 PS2 PS3 PS4 PS5 PS6 PS7 S12_Comb S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16 S17 S18 CR1 CR2a CR2b CR2c CR2d CR2e CR2f CR2g
=Missouri Indiana YrsPosDum1 YrsPosDum2 YrsPosDum3 YrsPosDum4 YrsPosDum5 JobFunPerm JobFunOther EduMasters EduOther Race3 Gender1, add(3) burnin(100) rseed(9995) dots force savetrace(T:\JDR_COHA\convergence\chainedTRACE_Sca leItems_5pmm10_pmmONLY, replace);

Thank you in advance for any guidance you can offer,

Jon Phillips


Granger causality test on a VECM-model.

$
0
0
Hi,

I have used a VECM model and wonder if it is possible to do a Granger causality test after the VECM-test in stata? And if yes, what is the commandos to do this?

Thanks!

Sincerly
// Gregg

Interpreting marginal effects from probit when independent variable of interest also has quadratic

$
0
0
Hello,

I am having difficulty interpreting marginal effects from a probit model and ordered probit model

. My dependent variables are whether an individual voted in the 2016 election (probit) and how they self-identify politically on a likert-type scale. My independent variables of interest are years of private schooling and years of private schooling squared. Simply:

Vote2016=privyears+privyears^2+controls
Political selfID=privyears+privyears^2+controls

My instinct was to run the model as follows:
probit votedin2012 privateyears privyearssq
margins, dydx (*) at (privateyears==0 3 6 9) 12) post

That gives me this result:
Array

Have I coded this correctly? Also, what would be the interpretation of these?

I am pretty new to STATA, so the simpler the better. Thanks!

Accessing the Census API via. Stata

$
0
0
Dear all,

I am currently attempting to access data from the U.S. Census Bureau's API using Stata. According to the Census Bureau's documentation, the API outputs data in a "nonstandard version of JSON that is streamlined". Raw output from the API looks like this:

[["STNAME","POP","DATE","state"],
["Alabama","4849377","7","01"],
["Alaska","736732","7","02"],
["Arizona","6731484","7","04"],
["Arkansas","2966369","7","05"],
["California","38802500","7","06"],

I am currently trying to import this data using insheetjson, but it appears that insheetjson is having difficulty parsing the output above. Any help on this issue would be greatly appreciated.

Thanks,
Zhao

Are there any ways to test the robustness of propensity score matched regressions?

$
0
0
Hi,

I am testing whether a policy led to an increase in returns using a matched diff-in-diff framework. In this test, we match on collapsed baseline data on a nearest neighbour basis. We then hold the matching fixed throughout the experiment and incorporate the frequency weights in diff-in-diff regression. Since there is a lot of criticism to this measure, can you perform any robustness test on it?

We have already examined the balance of covariates and common support.

Many thanks!

Margins after GSEM with Binary Outcome & Mediation

$
0
0
I'm using GSEM to estimate a mediated model with a binary outcome influenced by a continuous mediating variable. Margins won't work saying "prediction is a function of possibly stochastic quantities other than e(b)". I'd like to calculate the influence of a change in a rhs variable on the dv.

Code:
clear
set obs 200
g x1=rnormal()
g x2=rnormal()
g x3=rnormal()
g y1=x1 +x2+ rnormal()
g y2=(x1 + x3 - y1 + rnormal())>.5

sem(y2<- x1 x3 y1) (y1<-x1 x3),
estat teffects,compact

gsem(y2<- x1 x3 y1, probit) (y1<-x1 x2)
I can easily treat these as a regression and a probit, calculate the predicted change in y1 for a change in x1. I could use this predicted change along with the change in x1 to give me a predicted change in probability in the y2 equation.

Code:
reg y1 x1 x3
margins , at(x1=(0 1)) post
local lowy2=_b[1bn._at]
local highy2=_b[2._at]
probit y2 x1 x3 y1
margins , at(x1=(0 1)  y1=(`lowy2' `highy2') ) post
local change=_b[1bn._at] - _b[4._at]
di "change in prob for y2 for 1 unit chg in x1=`change'"
I suspect there is something wrong with this procedure.

What is wrong with the procedure? Is there a better solution?

Phil

z-score

$
0
0
Good afternoon,
A reviewer is asking in Table 1 for z-scores of 3 different continuous variables from my study.
I calculated the z-score for each indiviuals but don't know what he means by the z-score from the variables.
Can someone help me?
Thanks

Creating Clusters

$
0
0
How can I create a cluster of zipcodes for the below definition?

Cluster -- A set of zip codes where 80% of sales reps cover 80% of zip codes.

Sales reps cover many zipcodes and many zipcodes have many sales reps associated to them. A many-to-many relationship. I am trying to create a cluster where 80% of sales reps cover 80% of zipcodes.

Appreciate any help.

Sample size calculations for mixed effect (repeated measures)

$
0
0
I have tried to use the "power repeated meanspec, corrspec [power(numlist) options]" command, but cannot fathom the instructions for the "corrspec" There is just not enough detail to know what the command needs, even using the menu instead of the command line. Anyone use this before?


New to Stata. Question regarding M&amp;A deals merging

$
0
0
Hello everybody,

I am new to stata so I have still to figure alot of things out. I have a question regarding M&A deals. I am focusing on 1 m&A deal per acquiror and I calculated the CAR for the announcement date. Now I need to merge these M&A deals with their CAR to compustat data about the acquiror/target and also data of corporate governance. How should I merge 1 deal of M&A with several years of data with compustat / ISS RISK metrics. I already merged the M&A deals with the CAR. Further I merged acq compustat with acq corporate governance.

I hope that anyone can help me with this question.

Thanks alot,

Gordof

Rolling regression by omitting observations

$
0
0
Dear All,

I come across a complicated time series regression approach which requires to drop observations {t+1, t+2, t+3} for regression at time t. For time t+1, we need to drop observations {t+2, t+3,t+4} and so on until we exhaust all of our time series observations. I was looking for some similar rolling module for this, however couldn't find anything what could help so far. Maybe someone had similar situation and figured out how to proceed? Would really appreciate any help!

Best Regards,
Marijus

How to make sub samples

$
0
0
Hey, I have a panel data set comprising of 85 countries on different variables. I want to run a regression by selecting different countries from the panel data.Is there any command through which it can be possible? For example i have Bangladesh (2000-2014) all coded as 1 1 1 1... 1 1, Nepal (2000-2014) all coded as 2 2 2 2... 2 2,Bhutan (2000-2014) all coded as 3 3 3 3... 3 3, India (2000-2014) all coded as 4 4 4 4... 4 4, Now i want to run a regression by including only 1. 3 and 4 and dropping 2?

ivprobit margins

$
0
0
Dear Stata users,

I ran ivprobit on a balanced panel data (N=2250;T=2) with Stata 14.2. I instrument one endogenous variable with four instruments. To give you an idea, when I run regress with my endogenous variable as left hand side variable and the instruments as right hand side variables the R² is 17% (which might seem a little low but it is actually above what is found in the literature when rainfall data are used as instrument, which is my case) and the F-stat is 186.

I run ivprobit of the form :

Code:
ivprobit inorganique organique i.formal rain education i.advice i.supplier Stayers (Movers=ln_Barycentre i.border Traditional woman i.agent_elevage) market distance size, vce(cluster hid)
margins, dydx(Stayers Movers)
As you can see in the two following Stata output the coefficient associated with the variable Movers is outside the bound [0;1] on both outputs. Thus I am wondering if there is anything wrong with my code, or if there is something special with ivprobit that I am not aware of.


HTML Code:
Probit model with endogenous regressors         Number of obs     =      4,448
                                                Wald chi2(9)      =      68.47
Log pseudolikelihood =  1889.9723               Prob > chi2       =     0.0000

                                                (Std. Err. adjusted for 1,141 clusters in hid)
----------------------------------------------------------------------------------------------
                             |               Robust
                             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-----------------------------+----------------------------------------------------------------
                      Movers |   4.099236    1.33403     3.07   0.002     1.484585    6.713888
                   organique |   .3488198   .0659298     5.29   0.000     .2195998    .4780398
                    1.formal |  -.0849123   .1459579    -0.58   0.561    -.3709846      .20116
                        rain |   .0008964   .0010072     0.89   0.373    -.0010777    .0028705
                   education |   .0224099   .0352133     0.64   0.525    -.0466068    .0914266
                     Stayers |  -.6379742   .2083458    -3.06   0.002    -1.046324   -.2296241
                      market |   .0001818   .0011555     0.16   0.875    -.0020829    .0024465
                    distance |   .1356513   .0451289     3.01   0.003     .0472003    .2241022
                        size |  -.0042543   .0239482    -0.18   0.859    -.0511918    .0426832
                       _cons |  -1.113372    .282005    -3.95   0.000    -1.666092   -.5606528
-----------------------------+----------------------------------------------------------------
 corr(e.Movers,e.inorganique)|  -.4298723   .1499165                     -.6751657   -.0989789
                 sd(e.Movers)|   .1033371    .005832                      .0925161    .1154237
----------------------------------------------------------------------------------------------
Instrumented:  Movers
Instruments:   organique 1.formal rain education Stayers market distance size ln_Barycentre
               1.border Traditional woman 1.agent_elevage
----------------------------------------------------------------------------------------------


HTML Code:
margins, dydx(Stayers Movers)

Average marginal effects        Number    of    obs     =    4,448
Model VCE    : Robust

Expression   : Fitted values, predict()
dy/dx w.r.t. : Movers Stayers

                    
Delta-method
dy/dx   Std. Err.    z    P>z        [95% Conf.    Interval]
                    
Movers    4.099236    1.33403    3.07    0.002        1.484585    6.713888
Stayers   -.6379742   .2083458    -3.06    0.002        1.046324    -.2296241
                    
I have tried some other codes such as the predict(pr) but haven't found anything interesting yet.
Any suggestion is very welcome
Kind regards,
Marcel
Viewing all 65420 articles
Browse latest View live