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

From: Göran Broström <goran.brostrom_at_gmail.com>
Date: Fri 06 Apr 2007 - 07:47:50 GMT

On 4/6/07, Kaspar Rufibach <kaspar.rufibach@stanford.edu> wrote:
> 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?

See 'coxreg.fit' in package 'eha'. Or 'glm.fit' for logistic regression.

hth,

Göran
>
> 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 */
>
> return(r)}
>
> 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
>
> mailto:kaspar.rufibach@stanford.edu
> skype:kasparrufibach
> http://www.stanford.edu/~kasparr
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

-- 
Göran Broström

______________________________________________
R-help@stat.math.ethz.ch 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 Fri Apr 06 17:59:39 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.