[R] explaining a model with rcs() terms

Frank E Harrell Jr f.harrell at vanderbilt.edu
Mon Dec 1 17:54:13 CET 2008


Dylan Beaudette wrote:
> On Mon, Dec 1, 2008 at 5:48 AM, Frank E Harrell Jr
> <f.harrell at vanderbilt.edu> wrote:
>> David Winsemius wrote:
>>> On Nov 30, 2008, at 10:23 PM, Dylan Beaudette wrote:
>>>
>>>> Hi, I am using the rcs() function in the Design library to model
>>>> non-linearity that is not well characterized by an otherwise
>>>> mechanistic function. I am able to make the model 'available' to
>>>> others through the excellent nomogram() function and the set of tables
>>>> that it can create. However, I would like to present the model in an
>>>> 'expanded' format-- probably what rcspline.restate() or latex.Design()
>>>> produce on a model fit object.
>>>>
>>>> Here is how the model was fit:
>>>>
>>>> fit.ols <- ols( log(k) ~ (rcs(activity) * (log(conc) + sar)) +
>>>> (rcs(sand) * (log(conc) + sar)), data=sm.clean, x=TRUE, y=TRUE)
>>>>
>>>> Here is how I am accessing the 'expanded' format of the model structure:
>>>>
>>>> options(digits=3)
>>>> latex(fit.ols, file='fit_rcs.tex')
>>>>
>>>> The output contains several notation elements that I am not familiar
>>>> with:
>>>>
>>>> 1. x_{+}  --> it seems that this represent a term that should be set
>>>> to 0, when x is 0?
>>> It is set to zero when the term inside the cubic is less than zero. See
>>> pages 20-21 of Harrell's book where the basis functions are described
>>> and illustrated.
>>>> i.e.  the entire expression   −453(activity − 0.842)_{+}^{3}  = 0 when
>>>> 'activity' = 0 ??
>>> .... whenever (activity − 0.842) < 0
>>>
>>>
>>>
>>>> 2. the '!x' found in :
>>>>
>>>> +log(conc) [ −0.0118sand + 9.58
>>>> ! ×
>>>> !10−6 (sand − 11.6)
>>> My guess is that this is 9.58 x 10^-6
>>>> − 0.000128(sand − 37.5)
>>>> +0.00045(sand − 47.2)
>>>> − 0.000350(sand − 51)
>>>> + 1.86
>>>> ! ×
>>>> !10−5 (sand − 69.8) ]
>>> I don't see anything like that in Harrell's text and I am wondering if a
>>> different character is getting rendering incorrectly. The only time you
>>> see it is when the exponent is below -4.
>>>
>>>
>>>>
>>>>
>>>> .... what exactly does that mean?
>>>>
>>>>
>>>> An image version of the equation in question is attached.
>>>>
>>>> Any input would be greatly appreciated!
>>>>
>>>> Cheers,
>>>>
>>>> Dylan
>> Thanks for the good reply David.
>>
>> There is a bug in one of the Hmisc functions regarding the ! spacing
>> command.  If you get any LaTeX syntax errors I can send you
>> the correction.
>>
>> Frank
> 
> I didn't get any show-stopping errors when compiling the latex code
> used to generate the previously attached equation. Looking through the
> LATEX log file I don't see anything related to the equation and odd
> '!x' stuff.
> 
> HOWEVER: I think that this is where the error is occuring:
> 
> \\!\times\\!10^{-6}
> 
> * should be *
> 
> \! \times \! 10^{-6}
> 
> What do you think Frank? Altering the above syntax results in a
> normal-looking presentation.

Yes you can remove the extra \ or source( ) in the attached new version
of one of the functions that will be in an upcoming release of Hmisc.

Frank

> 
> Cheers,
> 
> Dylan
> 
> 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rcspline.restate.s
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081201/c8c394b3/attachment.pl>


More information about the R-help mailing list