Dear all,
I want to estimate betas of the Fama French Model for every year. I have got weekly returns and I am using the following loop:
foreach variable of varlist r_share* {
sum `variable' if year == 1991
if r(N) >= 52 {
scalar lagged = floor(4*(r(N)/100)^(2/9))
newey `variable' r_sp500 smb hml if year == 1991, lag(`= lagged')
}
else {
display "Not enough observations"
}
matrix matrix_1991 = nullmat(matrix_1991) \ e(b)
}
Variables:
r_share = return share
smb = Fama French factor
hml = Fama French factor
r_sp500 = return s&p500
The loop is working fine there is just one problem and I am not able to solve this. As I need all the estimated betas in a matrix afterwards (matrix_1991) and I have got missing observations (for the Y-values) how can I tell stata to save "." in the matrix when there are "Not enough observations"?
So if I have got enought observations Stata should do the newey west regression and if not it should just store . for all coefficients.
Hopefully somebody can help me out!
BR
Ikn
Related Posts with Loop with missing values
merging survey data files - duplicate data problemDear All, I am working on two survey datasets and have encountered the same problem in the small da…
Combine roc curvesI have two ROC curves each one is derived from a totally different model and interested in combining…
Generate new variable without duplicatesHello I have one problem, I need to create a new variable: One extrait of my dataset is the followi…
xttrans2 - calculating transitional probabilities for multiple years.Hi, I'm a little confused with regards to the xttrans2 command and obtaining transitional probabilit…
graph that shows the evolution over 10 yearsHi guys, We have drawn 10 individual histograms for working hours from 2004 to 2013 in Belgium. No…
Subscribe to:
Post Comments (Atom)
0 Response to Loop with missing values
Post a Comment