Hi, I would like to set constraints later use them in a program. Here is a small example:
sysuse auto, clear
regress price weight mpg
local indep "weight mpg"
local ind=1
foreach var of varlist `indep' {
constraint `ind' `var'=_b[`var']
local ++ind
}
What I get is
. constraint list
1: weight=_b[weight]
2: mpg=_b[mpg]
So, my question is why my constraints do not have numbers, representing regression coefficients on the right hand sides?
I also tried modification:
sysuse auto, clear
regress price weight mpg
local indep "weight mpg"
local ind=1
foreach var of varlist `indep' {
local b`var'=_b[`var']
constraint `ind' `var'=`bvar'
local ++ind
}
but then I get
. constraint list
1: weight=
2: mpg=
Again no numbers, just blanks.
Related Posts with Correct use of constraint in foreach cycle
How to store formatted number in a noteStataMP 15.1 on macOS Sierra I'd like to display the number of observations in a note with formatti…
Keeping observations under many criteria (when they appear in more than one period)Hello there! I need to drop some observations of my dataset. I have aprox.115,000 observations of d…
Calculating Gini CoefficientHi Statalist, Here I have a dataset comprising company name, year, host country, host country econom…
Question about graph bar command and how to include a second y-axis for a second variableDear Stata forum, I have a question about the graph bar command. So far, I have been using the foll…
Compare elements of locals and return distingushing elementsDear all, I have the following three locals: Code: local house "1 2 3 4" local garden "1 2 3" loc…
Subscribe to:
Post Comments (Atom)
0 Response to Correct use of constraint in foreach cycle
Post a Comment