Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: margins, marginsplot and piecewise regression


From   Chris <chris.stata@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: margins, marginsplot and piecewise regression
Date   Fri, 14 Jun 2013 11:02:42 +0200

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index