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
biprobit with two endogenous variableDear Statalist users, I am trying to estimate a model where both dependent (y) and two endogenous v…
Looping a regression command sequentially by observation and storing each model.Hi all, Apologies if this is very simple or has been asked before. I have searched through many top…
Importing csvHi, I have an easy problem, but unfortunately I could not solve it. When I want to import data fro…
Confidence interval for graphsHi all, I am plotted a connected graph using this code: Code: twoway (connected weekmeanifference …
no observations error for regressing two IVs that are mutually exclusiveDear Statalist, I have a dataset with European and non-European countries. I define "europe" as: C…
Subscribe to:
Post Comments (Atom)
0 Response to Correct use of constraint in foreach cycle
Post a Comment