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: RE: margins, marginsplot and piecewise regression
From
"Knee, Alexander" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: RE: margins, marginsplot and piecewise regression
Date
Fri, 14 Jun 2013 09:01:25 -0400
If you haven't already looked at it, there is an excellent tutorial on piecewise regression using Stata from the UCLA Statistical Consulting Group
http://www.ats.ucla.edu/stat/stata/faq/piecewise.htm
In addition, Michael Mitchell's book on Interpreting and Visualizing Regression Models Using Stata is excellent and goes into great detail in regards to piecewise models and margins. In particular he has a variety of coding schemes that you can apply to your piecewise model as well as how to pull out the appropriate results using margins and then creating two-way graphs (either automated or via brute force) to represent the results in a piecewise fashion. I strongly recommend this one!
Mitchell, M. N. (2012) Interpreting and Visualizing Regression Models Using Stata. College Station, TX: Stata Press.
For a review of his book see :http://www.stata-journal.com/article.html?article=gn0053
Acock, A.C. (2012) Review of Interpreting and Visualizing Regression Models Using Stata by Michael N. Mitchell. The Stata Journal: 12(3) 562-564.
Alex Knee, Biostatistician
Baystate Medical Center
Springfield, MA
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hoffman, George
Sent: Friday, June 14, 2013 8:39 AM
To: [email protected]
Subject: st: RE: margins, marginsplot and piecewise regression
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/
----------------------------------------------------------------------
Please view our annual report at http://baystatehealth.org/annualreport
CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information for the use of the designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited. If you have received this communication in error, please reply to the sender immediately or by telephone at 413-794-0000 and destroy all copies of this communication and any attachments. For further information regarding Baystate Health's privacy policy, please visit our Internet site at http://baystatehealth.org.
*
* 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/