Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: margins, marginsplot and piecewise regression


From   "Hoffman, George" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: margins, marginsplot and piecewise regression
Date   Fri, 14 Jun 2013 12:38:35 +0000

Have you tried this:
margins i.control, at(time=(1(1)39))

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Chris
Sent: Friday, June 14, 2013 4:03 AM
To: statalist
Subject: st: margins, marginsplot and piecewise regression

Dear Statalist,

I am running a piecewise regression of the form

reg depvar i.period#control#(c.time1##c.time1##c.time1)

where period can take values 0,1,2; control is a dummy denoting the control group, and time1 gives the month (from 1 to 39). Hence, I want to estimate a third degree polynomial time trend for each of the 3 periods in each of the two groups (3*2 polynomials overall), and plot the time trend for both control and treatment group.

The regression runs fine, and when I plot the polynomial(s) using the coefficients I get reasonable results. However, when I want to plot it via marginsplot, using

margins, at(time1==(1(1)39)) over(control) marginsplot, name(piecewise, replace)

then what I get is something like a second degree polynomial; nothing piecewise; for the plot see here:
https://dl.dropboxusercontent.com/u/6071534/piecewise.pdf

When I plot a polynomial for the last period manually using the estimated coefficients, it seems reasonable and very unlike the
marginsplot: https://dl.dropboxusercontent.com/u/6071534/manualplot.pdf

In short, the problem seems to be that margins won't predict the piecewise model correctly. If I replace period with all 1, then marginsplot works fine (just one polynomial for the entire support, instead of three). Can margins not deal with this piecewise specification? Or do I have to specify the model differently?

Any help is very much appreciated
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index