Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: quick question about spline


From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: quick question about spline
Date   Wed, 07 Apr 2004 10:58:15 +0100

At 01:02 07/04/04 -0700, Shige wrote:
Dear All,

For example, in a regression model where age is one of the independent
variables. I am not sure the functional form of age so I want to use
age spline in the model. I choose cubic spline using "frencurv, power(3)".
Now I want to test whether there is gender difference in age effect, can I
simplely generate a set of interaction terms between gender and the set of
spline variables or there are something else I need to do? Thanks!
One possibility is to define separate splines for males and females. For instance, if you have a basis of reference splines sp_1,
sp_2 etc. and a variable -sex- which is one for males and two for females, then you can type

foreach X of var sp_* {
gene m`X'=`X'*(sex==1)
gene f`X'=`X'*(sex==2)
}

and create a list of variables msp_1, msp_2 etc. which are equal to the spline for males and to zero for females, and a list of variables fsp_1, fsp_2 etc. which are equal to zero for males and to the spline for females. If you then type

regress y msp_* fsp_*

then you will have the combined set of parameters for 2 spline models, 1 for males and 1 for females. And you can measure "interactions" (ie differences between differences) using -lincom-. For instance, if sp_3 is the reference spline at age 30 and sp_5 is the reference spline at age 50, then you can type

lincom msp_5-msp_3-fsp_5+fsp_3

and calculate a confidence interval for the difference between the male change between ages 30 and 50 and the female change between ages 30 and 50.

I hope this helps.

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.

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