[R] ols function in rms package

From: Mark Seeto <mark.seeto_at_nal.gov.au>
Date: Mon, 07 Jun 2010 13:49:24 +1000


Hello,

I have a couple of questions about the ols function in Frank Harrell's rms package.

Is there any way to specify variables by their column number in the data frame rather than by the variable name?

For example,

library(rms)

x1 <- rnorm(100, 0, 1)
x2 <- rnorm(100, 0, 1)
x3 <- rnorm(100, 0, 1)

y <- x2 + x3 + rnorm(100, 0, 5)
d <- data.frame(x1, x2, x3, y)
rm(x1, x2, x3, y)
lm(y ~ d[,2] + d[,3], data = d) # This works ols(y ~ d[,2] + d[,3], data = d) # Gives error Error in if (!length(fname) || !any(fname == zname)) { :   missing value where TRUE/FALSE needed

However, this works:
ols(y ~ x2 + d[,3], data = d)

The reason I want to do this is to program variable selection for bootstrap model validation.

A related question: does ols allow "y ~ ." notation?

lm(y ~ ., data = d[, 2:4]) # This works ols(y ~ ., data = d[, 2:4]) # Gives error Error in terms.formula(formula) : '.' in formula and no 'data' argument

Thanks for any help you can give.

Regards,
Mark

-- 
Mark Seeto
Statistician

National Acoustic Laboratories <http://www.nal.gov.au/>
A Division of Australian Hearing

126 Greville Street
Chatswood NSW 2067 Australia
P +61 2 9412 6800
F +61 2 9411 8273

______________________________________________
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.
Received on Mon 07 Jun 2010 - 08:32:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jun 2010 - 13:50:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive