[R] rms::ols & I(.) in formulas
Otto Kässi
otto.kassi at gmail.com
Thu Jul 1 15:28:23 CEST 2010
Dear R-helpers,
To start I would like to thank Prof. Harrell for package rms. It is
one of the most useful packages for R that I have encountered.
Turning to my problem, I encountered a surprising problem when working
with rms::ols. It seems that insulating terms in a formula by using
I() to insulate terms in a formula seems to occasionally create a bug.
See the example below:
library(rms)
x <- rnorm(100)
y <- rnorm(100)
dd <- data.frame(cbind(x,y))
ols(y ~ x + I(x^2), data=dd)
ols() function gives the error:
Error in if (!length(fname) || !any(fname == zname)) { :
missing value where TRUE/FALSE needed
Has anyone else encountered something similar? Is this a bug or does
this behavior have a reason?
There are of course trivial workarounds: one can either use poly(x, 2)
or save x^2 as a new column to dd, but trying to debug this was a
pain.
With kind regards,
Otto Kassi
More information about the R-help
mailing list