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, is already up and running.

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

st: RE: margins, marginsplot and piecewise regression

From   "Hoffman, George" <>
To   "" <>
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: [] 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:

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:

*   For searches and help try:

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