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

From |
"Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Re: -mkspline- reference |

Date |
Wed, 6 May 2009 11:09:24 -0700 |

Because of the shape of this function, it is sometimes referred to as "hockey stick" regression. Tony Peter A. Lachenbruch Department of Public Health Oregon State University Corvallis, OR 97330 Phone: 541-737-3832 FAX: 541-737-4001 -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Kit Baum Sent: Wednesday, May 06, 2009 7:56 AM To: statalist@hsphsun2.harvard.edu Subject: st: Re: -mkspline- reference <> Section 7.4.1 of IMEUS (below) contains some of that material. It does not work from first principles, but the algebra involved with linear splines is very straightforward in terms of restricted least squares. For a linear spline, the function must equal the same value to the left and right of each knot point, as discussed in 7.4.1. Thus if we did not have -mkspline-, we could easily do what it is doing: ----------------------------- webuse lutkepohl,clear g t1 = 0 g t2 = 0 g a1 = tin(1960q1,1974q4) g a2 = tin(1975q1,1982q4) replace t1 = qtr if tin(1960q1,1974q4) replace t2 = qtr if tin(1975q1,1982q4) reg income a1 a2 t1 t2, nocons hascons predict double ihat, xb tsline ihat if tin(1960q1,1974q4) || tsline ihat if tin(1975q1,1982q4) // 1982q4 is t = 60; apply continuity constraint def 1 a1 + t1*60 = a2 + t2*60 cnsreg income a1 a2 t1 t2, nocons c(1) predict double ihat2, xb tsline ihat2 if tin(1960q1,1974q4) || tsline ihat2 if tin(1975q1,1982q4) -------------------------------- Compare the two graphs. Notice that the constrained function is continuous (but not differenttiable) at the single knot point. (We could easily add additional knot points to this function). If we imposed that the derivative of the function was equal to the left and right, we'd have a quadratic spline. If we imposed that both first and second derivatives were equal to the left and right, we'd have a cubic spline. But linear splines are just predicted values that obey continuity over the variable at each knot point. Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html On May 6, 2009, at 02:33 , statalist-digest wrote: > Thanks. Actually, -mkspline- computes *linear* splines. For instance, > the following code: > > . mkspline Age1 44 Age2 = Age > > . regress Y Age1 Age2 > > fits a continuous, piecewise linear model of E(Y|Age) for which the > slope is permitted to change abruptly at Age=44. > > Thus I am looking for a reference that specifically explains what > algorithm and formulas are implemented in -mkspline-, and perhaps also > discusses uses of linear splines and gives examples where they are > used to good effect. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/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/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Re: -mkspline- reference***From:*Kit Baum <baum@bc.edu>

- Prev by Date:
**st: prediction after fitting a multi level model with xtmixed** - Next by Date:
**st: AW: prediction after fitting a multi level model with xtmixed** - Previous by thread:
**st: Re: -mkspline- reference** - Next by thread:
**st: Question_Heckman-Test_Mills-ratio** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |