Bookmark and Share

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

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

st: margins, marginsplot and piecewise regression

From   Chris <>
To   statalist <>
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:

When I plot a polynomial for the last period manually using the
estimated coefficients, it seems reasonable and very unlike the

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:

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