Re: questions on how to create linear spline terms
- From: "Ray Koopman" <koopman@xxxxxx>
- Date: 31 Jan 2007 10:33:46 -0800
Ming wrote:
I need to do some linear spline term test for age. If I use 1 knot
(i.e. a cutpoint) of 65, then the SAS code I got from colleagues is:
if . < age < 65 then do;
agelt65 = age;
agege65 = 0;
end;
if age >= 65 then do;
agelt65 = 65;
agege65 = age - 65;
end;
That way, two new spline terms were created: agelt65 and agege65.
However, the way I learned from a stat book regarding regression
splines when there are 2 knots (say 65 and 74 for age in this case)
is:
if . < age < 65 then do;
agege65 = 0;
end;
if age >= 65 then do;
agege65 = age - 65;
end;
if . < age < 74 then do;
agege74 = 0;
if age >= 74 then do;
agege74 = age - 74;
end;
Despite the difference in knot number, I think the above two ways of
presenting spline terms are different. My question is: what way to use
if I want to create linear spline terms when there are 2 knots?
Thanks very much for your input!
Ming
I think the second way of defining the spline terms is better,
but the code is too convoluted. Why not use something like
age65 = max(age-65,0)
age74 = max(age-74,0)
.
- References:
- Prev by Date: Re: Measure of representativeness
- Next by Date: Re: How to solve this random integer generation problem?
- Previous by thread: questions on how to create linear spline terms
- Index(es):