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