Dear all,
For our master paper, we need to replicate the Fama and French three factor model. We started with the one factor model.
At the moment, we have 520 variables. We have one dependent variable: MktRF (Fama and French one factor model) and 519 independent variables (companies) with the daily excess returns over 20 years.
We were able to execute our loop regression (for our 519 firms: from the variable SOLVAY to ADECCOGROUP), by executing the following command:
foreach x of varlist SOLVAY-ADECCOGROUP{
regress `x' MktRF
}
Now, we have our 519 regressions results and we want to store the 519 residual values in a new variable and store the 519 R-squared values in another variable.
For the residual values, we tried to use this command:
predict residual, r
But unfortunately, with this command, Stata gives us the daily residuals and not the residuals per firm obtained from the loop regression.
For the R-squared values, we tried to use this command:
tempname results output
foreach x of varlist SOLVAY-ADECCOGROUP {
regress `x' MktRF
mat `results' = r(r2)
mat `output' = (nullmat(`output') \\`results'[1,1])
}
mat colnames `output' = R-squared
svmat `output', names(col)
With this command, Stata gives me an error code for the svmat `output', names(col) command:
invalid syntax
r(198);
Does anyone know how we can solve this?
For our master paper, we need to replicate the Fama and French three factor model. We started with the one factor model.
At the moment, we have 520 variables. We have one dependent variable: MktRF (Fama and French one factor model) and 519 independent variables (companies) with the daily excess returns over 20 years.
We were able to execute our loop regression (for our 519 firms: from the variable SOLVAY to ADECCOGROUP), by executing the following command:
foreach x of varlist SOLVAY-ADECCOGROUP{
regress `x' MktRF
}
Now, we have our 519 regressions results and we want to store the 519 residual values in a new variable and store the 519 R-squared values in another variable.
For the residual values, we tried to use this command:
predict residual, r
But unfortunately, with this command, Stata gives us the daily residuals and not the residuals per firm obtained from the loop regression.
For the R-squared values, we tried to use this command:
tempname results output
foreach x of varlist SOLVAY-ADECCOGROUP {
regress `x' MktRF
mat `results' = r(r2)
mat `output' = (nullmat(`output') \\`results'[1,1])
}
mat colnames `output' = R-squared
svmat `output', names(col)
With this command, Stata gives me an error code for the svmat `output', names(col) command:
invalid syntax
r(198);
Does anyone know how we can solve this?
Comment