Hi Statalist users,
I need advice on the following problem.
Suppose I have two macros
local b "b1 b2"
local var "var1 var2"
What would be an elegant way to create macro that contains a string "b1*var1+b2*var2"?
Just to place it into context -- I want to compute fitted value that is based on a regression prediction, but not for all Xs. Something along these lines (but it needs to be general solution for any subset of independent variables):
reg y X1 X2 X3
gen yhat=_b[X1]*X1+_b[X2]*X2
Thanks, Oleksandr
Related Posts with Form a text string of scalar product of two macros
Two-Step System GMM with xtabond2 commandDear Stata Experts, I am dealing with a dynamic panel model in which the sample size is 100 firms a…
list if conditionsI used the following code to list the observations in a variable if the binary "check" is 0. But in …
Determining numeric "rule" used for a categorical variableHi, I'm trying to figure out what "rule" has been used for assigning letter grades in my data. I ha…
Why many commands do not work?Hello dear stata community I am kind of new to stata but I have been facing issues with many command…
How to shorten multiple line of codes relevant?In my data, I have a numeric number called year which have value from 2 to 22, I want to replace thi…
Subscribe to:
Post Comments (Atom)
0 Response to Form a text string of scalar product of two macros
Post a Comment