Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: linear and cubic spine regression


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: linear and cubic spine regression
Date   Sun, 23 Mar 2008 10:22:54 +0000 (GMT)

--- Mohammed El Faramawi <[email protected]> wrote:
> I have a question about cubic spline regression and
> linear spline regressionv. I would like to know what
> are the differences between them? I will be very
> grateful if someone explains the difference between
> them particularly when I should use linear spline
> regression and when should i use cubic spline
> regression? If someone has online materials about this
> subject, this will be great.

In Stata 10 -mkspline- has the ability of creating a restricted cubic
spline. This is not the same as a cubic spline: it restricts the line
to be linear before the first knot and after the last knot, between the
first and the last knot, the curve is a cubic spline. This has the
advantage of being more stable. 

The difference between the restricted cubic spline and the linear
spline is best explained using a graph:

*--------------- begin example -------------------
sysuse auto, clear

mkspline lin1 18 lin2 =mpg
reg price lin1 lin2 
predict yhatlin

mkspline cub=mpg, cubic knots(15 18 30)
reg price cub1 cub2
predict yhatcub
twoway scatter price mpg ||             ///
       line yhatlin yhatcub mpg, sort   ///
       legend(order( 1                  /// 
                     2 "linear spline"  ///
                     3 "restricted"     /// 
                       "cubic spline")) 
*------------- end example -------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

The cubic spline is more smooth, while the linear spline changes very
abrubtly at the knot (mpg=18). The linear spline looks a bit awkward,
but it has the advantage of being able to easily read the effect of
price in the regression table: before mpg=18 a unit change in mpg led
to a decrease in price approx. 1200 dollars, while after mpg=18 a unit
increase in mpg led to a decrease in price of approx. 60 dollars.

I am working on a program that shows the effect of mpg in a restricted
cubic spline. If you are interested I am willing to sent a pre-release
to you privately.

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________ 
Rise to the challenge for Sport Relief with Yahoo! For Good  

http://uk.promotions.yahoo.com/forgood/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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