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
How to combine SDC Platinum/ThomsonOne with CRSP?I have a dataset from SDC containing 127 000 M&A bids, including announcement date, year, compan…
Error with Probit: outcome does not varyDear Statalists, I create a variable = 1 in case of treatment and = 0 in case of no treatment. Then…
convert time variable from; 'Jan 2018' to 'Jan'I want add a time variable that only shows the months in this format; 'Jan', 'Feb', .. So I have 2 t…
Lasso inference for cox regressionDear STATA team, I hope all is well. I was trying to do lasso inference for survival ,model. The va…
Exporting Mean/Median of Variable X by variables Y and ZI am using data from the IPUMS-CPS ASEC series. I am looking to calculate the median income for each…
Subscribe to:
Post Comments (Atom)
0 Response to Loop with missing values
Post a Comment