[R] explaining a model with rcs() terms

Dylan Beaudette dylan.beaudette at gmail.com
Mon Dec 1 17:10:56 CET 2008


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.

Cheers,

Dylan



>
>>> <complex_equation.png>______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
> --
> Frank E Harrell Jr   Professor and Chair           School of Medicine
>                     Department of Biostatistics   Vanderbilt University
>



More information about the R-help mailing list