Hi all,
I have a rather simple question. I'm trying to generate predicted outcomes for two variables in a panel
This is the full code of what I am doing
xtregar D.gdp cpi u Output dummy1 dummy2 c.indicator1##c.indicator1, fe
// get the x where the minimum occurs
local x = -_b[indicator1]/(2*_b[indicator1#indicator1])
// get the y for that minimim
qui margins, at(indicator1 = `x' cpi=0 u=2 Output= 7.54e+16 dummy1=0 dummy2=0 indicator1=-4)
// the predictions are stored in the matrix r(b)
// el(r(b),1,1) extracts the cell 1,1 from the matrix r(b)
local y = el(r(b),1,1)
// prepare for our plot
nlcom -_b[indicator1]/(2*_b[indicator1#indicator1])
qui margins, at(indicator1=(-16(4)29) cpi=0 u=2 Output= 7.54e+16 dummy1=0 dummy2=0 indicator1=-4)
// with scatteri we can add a point and a label to our graph
marginsplot, noci plotopts(msymbol(i)) legend(off) ///
addplot(scatteri `y' `x' (12) "(`xlab'; `ylab')") ///
ylab(,format(%9.3fc) angle(0)) ytitle("predicted gdp ") title("Predicted Marings pair")
My variables of interest are gdp and indicator1.
What I can't figure out is how to then store those results for the two variables gdp and indicator1, as the -predict- command does, in the same dataset.
Is this doable? What am I not getting here??
Thanks in advance.
Giorgio
I have a rather simple question. I'm trying to generate predicted outcomes for two variables in a panel
This is the full code of what I am doing
xtregar D.gdp cpi u Output dummy1 dummy2 c.indicator1##c.indicator1, fe
// get the x where the minimum occurs
local x = -_b[indicator1]/(2*_b[indicator1#indicator1])
// get the y for that minimim
qui margins, at(indicator1 = `x' cpi=0 u=2 Output= 7.54e+16 dummy1=0 dummy2=0 indicator1=-4)
// the predictions are stored in the matrix r(b)
// el(r(b),1,1) extracts the cell 1,1 from the matrix r(b)
local y = el(r(b),1,1)
// prepare for our plot
nlcom -_b[indicator1]/(2*_b[indicator1#indicator1])
qui margins, at(indicator1=(-16(4)29) cpi=0 u=2 Output= 7.54e+16 dummy1=0 dummy2=0 indicator1=-4)
// with scatteri we can add a point and a label to our graph
marginsplot, noci plotopts(msymbol(i)) legend(off) ///
addplot(scatteri `y' `x' (12) "(`xlab'; `ylab')") ///
ylab(,format(%9.3fc) angle(0)) ytitle("predicted gdp ") title("Predicted Marings pair")
My variables of interest are gdp and indicator1.
What I can't figure out is how to then store those results for the two variables gdp and indicator1, as the -predict- command does, in the same dataset.
Is this doable? What am I not getting here??
Thanks in advance.
Giorgio
Comment