Try this Lm(y~X + I(X^2)), data=dd) # this runs OLS regression and it worked for me
Hope it helps Lexi -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Otto Kässi Sent: Thursday, July 01, 2010 3:28 PM To: r-help@r-project.org Subject: [R] rms::ols & I(.) in formulas 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 ______________________________________________ R-help@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. DISCLAIMER:\ Sample Disclaimer added in a VBScript.\ ...{{dropped:3}} ______________________________________________ R-help@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.