[R] interpretation of RCS 'coefs' and 'knots'

Frank E Harrell Jr f.harrell at vanderbilt.edu
Sat Oct 24 15:21:58 CEST 2009


Dylan Beaudette wrote:
> On Friday 23 October 2009, Frank E Harrell Jr wrote:
>> Dylan Beaudette wrote:
>>> Hi,
>>>
>>> I have fit a series of ols() models, by group, in this manner:
>>>
>>> l <- ols(y ~ rcs(x, 4))
>>>
>>> ... where the series of 'x' values in each group is the same, however
>>> knots are not always identical between groups. The result is a table of
>>> 'coefs' derived from the ols objects, by group:
>>>
>>> group	Intercept       top     top'    top''
>>> 1      	 6.864   0.01    2.241   -2.65
>>> 2      	 6.836   0.047   -0.556  0.606
>>> 3      	 5.877   -0.019  0.084   -0.175
>>> 4       	6.021   -0.003  0.121   -0.128
>>> 5       	7.164   0.014   0.031   -0.096
>>>
>>> I would like to describe groups of relationships, based on the
>>> coefficients, however I am not sure if they are directly comparable. In
>>> addition, I would like to regress these coefs on another set of
>>> variables, with the aim of predicting a series of RCS coefficients along
>>> external gradients. In essence, I am hoping to use RCS coefficients to
>>> summarize y ~ rcs(x), in a way that can then me modeled like this: [y ~
>>> rcs(x)] ~ z.
>>>
>>> Is this interpretation of RCS coefficients even possible? If not, would
>>> forcing knot locations make it a possibility? Or, would modeling both
>>> knots and RCS coefs with external variables lead to sensible predictions?
>>>
>>> Cheers,
>>> Dylan
>> Dylan,
>>
>> It is possible to interpret rcs coefficients.  But it is not possible to
>> equate coefficients across fits using different know locations.  My
>> suggestion is either to specify the same knots (e.g., rcs(x, c(2, 4, 6,
>> 8)) across fits or to compare the fitted relationships (predictions)
>> rather than the coefficients.
>>
>> Frank
> 
> Thanks Frank. That makes sense. Unfortunately the knot locations dot not 
> always occur in the same places. 

My point was that you can force them to be the same.

> 
> Perhaps I am approaching the problem from the wrong angle. This project 
> involves patterns that are well characterized by rcs(x). The shape of the 
> fitted rcs function seems to relate well to some other set of variables Z. 
> Ideally, I would like to be able to predict the minimal required parameters 
> needed to regenerate the continuous function rcs(x), based on matrix Z. This 
> all boils down to soil properties varying in space and depth, with strong 
> depth-trends that are interesting. Therefore, I am looking for an approach 
> that can be used to model the 'shape' of y ~ rcs(x).
> 
> Aside from all of this, is there some way to synthesize rcs(x) from the 
> returned coefs, and the knot locations?

It all depends on what you mean.  You can evaluate the function at a 
grid of equally spaced points and use those predicted values are your 
descriptors.

What I'm hearing more, though, is the need to have another variable that 
interacts with rcs(x).  This exampled model might formalize what you are 
doing.

Frank

> 
> Cheers,
> Dylan
> 
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list