How to save constant terms (_cons) as a new variable in STATA.

Man

New Member
#1
Hello,

I have an unbalanced panel data. I examine 850 mutual funds during the period of 2000-2013.
I ran regressions to estimate performance by using Carhart 4 factor model. Specifically, I have used the Carhart alpha in the prior 12 months as a measure of risk-adjusted performance. Thus I ran regression every year for each company. After that I have obtained a number of outputs where I have coefficients and other stuff.

My question - how to save constants (i.e. alphas) as a new variable?
What command should I use to correctly get alphas for each fund based on prior 12 month observations? I need them in further analysis.

I would be very grateful for any advice on how to deal with this issue!
 

maartenbuis

TS Contributor
#2
Code:
tempfile foo
statsby _b[_cons], by(byvars) saving(`foo') : reg depvar indepvars
merge m:1 byvars using `foo'
You obviously need to change byvars, depvar, and indepvars with the appropriate variable names.
 

Man

New Member
#3
Hi all

I am using this code:

gen ffalph = .
forvalues i=1/100 {
quietly regress excret excmkt hml smb mom if fund == `i'
mat A = e(b)
quietly replace ffalph = A[1, 5] if fund== `i'
}

However, I have got some problem, namely, the loop stops doing regression when I have missing values (e.g. there is no exc_ret on some date). How can I overcome this issue and calculate further regressions despite having missing values?


Regards.
 

maartenbuis

TS Contributor
#4
The answer I gave you above would solve your problem. Did you try it? Did it work for your case? If not, how does the output differ from your expectation/what were the exact error messages/...? If it did work, then why did you not use it?