Statalist


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

Re: st: linear and cubic spine regression


From   Keith Dear <[email protected]>
To   [email protected]
Subject   Re: st: linear and cubic spine regression
Date   Mon, 24 Mar 2008 12:27:26 +1100

Like Mohammed Faramawi, I am using version 9 and needing cubic splines.
Could someone (Maarten?) please confirm that the following are equivalent:

* version 10
mkspline cub=mpg, cubic knots(15 18 30) // as per Maarten, 09:22 PM

* version 9
splinegen mpg 18, bknots(15 30) basis(cub)

Are they (a) different (b) functionally equivalent (c) numerically identical? I think they should be at least equivalent and perhaps identical, but of course I can't check.
Thanks,
Keith


At 09:57 PM 23/03/2008, you wrote:

Unfortunately, the program I am writing is for Stata 10
only. However, you can create restricted cubic splines
in Stata 9 using the -splinegen- program, which is part
of Patrick Royston's -mvrs- package, see: -findit mvrs-.

Hope this helps,
Maarten

--- Mohammed El Faramawi <[email protected]> wrote:

> Thank you very much Maartin,
> Yes why not, please send it. Unfortunately, I have
> stata version 9 I do not have version 10. Is there
> anyway to use  mkspline in version 9?
> --- Maarten buis <[email protected]> wrote:
>
> > --- 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/
> >
>
>
>
>
>
____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs
> *
> *   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/
>


-----------------------------------------
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/

Dr Keith B.G. Dear
Senior Fellow in Biostatistics
National Centre for Epidemiology and Population Health
Australian National University
Canberra, ACT 0200, Australia
Tel: 02 612 54865, Fax: 02 612 50740
http://nceph.anu.edu.au/Staff_Students/staff_pages/dear.php
CRICOS provider #00120C

http://canberragliding.org/

*
*   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