Bookmark and Share

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]

Re: st: Why does mkspline only have "restricted" cubic splines and what does it mean in practice?


From   Jen Zhen <[email protected]>
To   [email protected]
Subject   Re: st: Why does mkspline only have "restricted" cubic splines and what does it mean in practice?
Date   Tue, 8 Mar 2011 15:06:28 +0100

Dear Nick, Maarten and Roger,

thanks a lot for your comments and suggestions!

@ Nick:
> I am really surprised that you feel you need so many knots, even if
> you have ages that aren't integers in your data. I'd experiment with
> far fewer, even for something variable like people retiring, or going
> through the menopause, at different ages, or whatever your application
> is.
I wanted to use all these knots (the original variable age is measured
to the day), because I know that in each interval between these knot
points individuals receive a different treatment. My main interest is
in the effect of that treatment, i.e. in the constants of the
different intervals, and I would like to make sure to fully control
for the effects of any factors also correlated with age, hence my
decision to allow each interval to have a different slope. I hope that
you will find the choice to make more sense then.

@ Maarten:
I had actually not looked at this part of the manual, but the
suggestion is of course a very useful one to fully understand the
command I'm using here!

@ Roger:
Thanks also for suggesting -bspline- which I will look at shortly, to
see which of the two is more suitable for my purposes.

Best regards,
JZ



On Tue, Mar 8, 2011 at 2:48 PM, Roger Newson <[email protected]> wrote:
> If you want to fit unrestricted cubic splines, with parameters that you can
> understand, then you might like to use the -flexcurv- module of the
> -bspline- package. The -bspline- package is usually downloaded from SSC.
> However, because of Kit Baum's absence from Boston, the very latest version
> can currently be downloaded only from my website. In Stata, type
>
> net from "http://www.imperial.ac.uk/nhli/r.newson/stata10/";
>
> and select and install -bspline-, and also get the manual -bspline.pdf-,
> distributed with the package as an ancillary file.
>
> The -frencurv- module is usually the one to use, although another 2 modules
> also exist. If you type
>
>
>        . sysuse auto, clear
>        . describe
>        . flexcurv, xvar(weight) refpts(1760(770)4840) gen(cs) power(3)
>        . describe cs*
>        . regress mpg cs*, robust noconst
>
>
> then you will fit an unrestricted cubic spline model for -mpg- as a function
> of -weight-, with parameters named -cs1-, -cs2-, -cs3-, -cs4- and -cs5-,
> whose values (with confidence limits) are values of the spline at weights of
> 1750, 2530, 3300, 4070 and 4840 US (or Imperial) pounds, respectively. And,
> if you type
>
>        . flexcurv, xvar(weight) refpts(1760(770)4840) omit(1760) gen(ics)
> power(3)
>        . describe ics*
>        . regress mpg ics*, robust
>
> yhen you will fit the same unrestricted cubic spline model, with parameters
> -ics2-, -ics3-, -ics4-, -ics5-, and -_cons-. The parameter -_cons- is then
> the value of the spline at the base value of 1760 pounds, and the parameters
> -ics2-, -ics3-, -ics4- and -ics5- ate differences between the values of the
> spline at 2530, 3300, 4070 and 4840 pounds (respectively) and the value of
> the spline at 1760 pounds.
>
> You can choose more reference points if you like. The knots will be
> generated automatically, and (in default) will be regularly spaced.
>
> I hope this helps.
>
> Best wishes
>
> Roger
>
>
> Roger B Newson BSc MSc DPhil
> Lecturer in Medical Statistics
> Respiratory Epidemiology and Public Health Group
> National Heart and Lung Institute
> Imperial College London
> Royal Brompton Campus
> Room 33, Emmanuel Kaye Building
> 1B Manresa Road
> London SW3 6LR
> UNITED KINGDOM
> Tel: +44 (0)20 7352 8121 ext 3381
> Fax: +44 (0)20 7351 8322
> Email: [email protected]
> Web page: http://www.imperial.ac.uk/nhli/r.newson/
> Departmental Web page:
> http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/
>
> Opinions expressed are those of the author, not of the institution.
>
> On 08/03/2011 12:33, Jen Zhen wrote:
>>
>> Dear all,
>>
>> I've used Stata's -mkspline- to create the 2 kinds of spline it
>> offers, a linear one:
>> - mkspline Age_1 50 Age_2 52 Age_3 54 Age_4 56 Age_5 58 Age_6 59 Age_7
>> 60 Age_8 61 Age_9 62 Age_10 63 Age_11 64 Age_12 65 Age_13 66 Age_14 =
>> Age -
>> and a restricted cubic one:
>> - mkspline rcs = Age, cubic knots(50 52 54 56 58 59 60 61 62 63 64 65 66)
>> -
>> The knot points are given by my context.
>>
>> What the linear spline maker does is very clear and transparent when I
>> browse it: For instance, for someone aged 55.04, it will make
>> Age_1=50, Age_2=2, Age_3=2, Age_4=1.04, Age_5=0, etc.
>> But I have trouble understanding what the "cubic" one does, where I
>> get the following:
>> Age     rcs1    rcs2    rcs3    rcs4    rcs5    …
>> 55.04383        55.04383        0.5012364       0.1101598       0.0044428
>>       0       …
>> Obviously rcs1 is just Age linearly for all elements thrown together,
>> but I have no idea how rcs2 and higher are computed, and indeed why
>> -mkspline- allows only for "restricted" and not "unrestricted" cubic
>> splines.
>>
>> Searching for answers and literature led me to some great introduction
>> slides on this by Maarten
>> (http://www.maartenbuis.nl/presentations/bonn09.pdf). However I am
>> still puzzled by the commands for cubic spline on page 17, which seems
>> to make only the cubic term different for each knot interval, wheras
>> in terms of linear and quadratic terms there is just one each for the
>> full range. Is that because they would otherwise be collinear?
>>
>> Thanks a lot for any wisdom you might be able to share on this.
>> JZ
>>
>> *
>> *   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/
>

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index