Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

Re: st: Twoway quadratic prediction plots with CIs in a multivariate regression setting

 From Scott Merryman To statalist@hsphsun2.harvard.edu Subject Re: st: Twoway quadratic prediction plots with CIs in a multivariate regression setting Date Thu, 26 Jul 2012 06:56:57 -0500

```The -margins- command has a post option to save the results.  The
example below using Roger Newson's -xsvmat- (ssc desc xsvmat)

webuse nhanes2.dta,clear
qui reg iron c.age##c.age i.race zinc
qui margins , at(age = (10(10)80)  (base) race (zero) zinc)  post
mat a= r(table)
mat A = a'

qui reg iron c.age##c.age i.race zinc
qui margins , at(age = (10(10)80)  ) post
mat b = r(table)
mat B = b'
mat c = r(at)
mat atage = c[1..8,1]

xsvmat A,  name(col) saving(cond.dta,replace)
xsvmat B,  name(col)  saving(uncond.dta,replace)
xsvmat atage,  name(col) saving(age.dta,replace)
use b ll ul using cond,clear
rename * =_cond
merge 1:1 _n  using uncond, nogenerate noreport keepusing(b ll ul)
keep b* ll* ul*
merge 1:1 _n  using  age, nogenerate noreport

line b* age, lc(red blue) ///
|| rcap ul_cond ll_cond age, lc(red) ///
|| rcap ul ll age , lc(blue) ///
||, legend(order(1 "Conditional" 2 "Unconditional"))

Scott

On Thu, Jul 26, 2012 at 3:51 AM, Michael Ingenhaag
<Michael.Ingenhaag@unil.ch> wrote:
> Thank you Scott.
>
>
> The problem with the marginsplot command is, that I cannot combine other
> graphs as I would like to put graphs of two different models in one plot,
> i.e. for an unconditional and a conditional model. Hence, I was thinking