[R] Logistic/Cox regression: Parameter estimates directly from model matrix

From: Kaspar Rufibach <kaspar.rufibach_at_stanford.edu>
Date: Thu 05 Apr 2007 - 22:47:28 GMT

Hi out there

Is there a way to get the estimated coefficients in a logistic / Cox regression without having to specify a 'formula' but by only giving the model matrix?

Example for Cox regression:

## predictors

n <- 50
q1 <- rnorm(n)
q2 <- rgamma(n, 2, 2)
Z <- cbind(q1, q2)

## response

ttf <- rexp(n)
tf <- round(runif(n))

## compute estimates

res <- coxph(Surv(ttf, tf) ~ q1 + q2)
r <- res$coef

My goal is to have a function

estFromModelMatrix <- function(tf, ttf, Z){

      /* do something meaningful using built-in functions */


I have written such functions myself using LL - maximization from scratch, but these are slower than the built-in functions. Since I intend to do some simulations (where I specify the model matrix, but not want to give a 'formula' manually for each simulation scenario), it would be nice to have a function estFromModelMatrix().

I searched the help extensively, but did not find a way to do this.

Hope I was clear enough, any help is appreciated! Kaspar Rufibach

Kaspar Rufibach
Department of Statistics -- Sequoia Hall
390 Serra Mall
Stanford University
Stanford, CA 94305-4065


R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Apr 06 08:55:07 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 06 Apr 2007 - 08:31:01 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.