Hello everyone,
I am trying to regress 15 separate dependent variables (Country Index returns) with their corresponding (10) indepepent variables (Industrial Benchmark returns excluding the country)
on an annual basis (17years, weekly interval, 52 observations / year).
My aim is to extract the r squared from those regressions in a separate collumn for each regression.
Additionally I want to impose two restrictions on my coefficients, specifically that all β's are non-negative and Σβ=1.
I think that the most convenient way to do it is to align all my variables vertically, define an index value for each Year/variable and loop my regression through each index value
(i.e. Index value 18 will be the 1st year of the 2nd country).
I also understand that the constraint command does not work for innequalities, but I don't really understand the previous discussions and solutions that have been provided throughout the years. I am hoping that someone could clarify for me a bit the solution to this issue.
Bellow is the code I have understood so far that I should use, using the grunfeld dataset as an example.
clear
webuse grunfeld
constraint define 1 invest + mvalue=1
constraint define 2 invest > 0 mvalue > 0 // My main question
forvalues i=1(1)10{
quietly cnsreg company invest mvalue if company == i, c(1,2) //"No observations" message from Stata
generate Rsq_`i' = e(r2) // I think this part is also incorrect
}
End of code.
Stata version 15.1
I would appreciate some help on my inquiries and I hope this post satisfies the forum guidelines.
Regards,
Georgios
Related Posts with Constraint Regressions with a loop and saving the parameters for every year.
Create same variable across groups in panel dataHello Statalists, Hope you can advise on this. Lets say I have data N=20 and T=100, and I want to …
Loop RegressionDear all, I'm having a problem running a loop regression. Basically, I have to run a regression for …
Using foreach syntax to create new variableGreetings, I am having a challenge of creating a new variable that reflects the cases and controls f…
Modify color outside valuesGood morning I am using stata 14 and the following code to graph three boxplots. I have changed the…
How to get p-value from z statisticGood Morning, I am a novice STATA user hence kindly bare with me if my question is basic. I execute…
Subscribe to:
Post Comments (Atom)
0 Response to Constraint Regressions with a loop and saving the parameters for every year.
Post a Comment