Re: [R] complex contrasts and logistic regression

From: Frank E Harrell Jr <>
Date: Sat, 16 Jun 2007 11:14:12 -0500

Nicholas Lewin-Koh wrote:
> Hi,
> I am doing a retrospective analysis on a cohort from a designed trial,
> and I am fitting
> the model
> fit<-glmD(survived ~ Covariate*Therapy + confounder,myDat,X=TRUE,
> Y=TRUE, family=binomial())

For logistic regression you can also use Design's lrm function which gives you more options.

> My covariate has three levels ("A","B" and "C") and therapy has two
> (treated and control), confounder is a continuous variable.
> Also patients were randomized to treatment in the trial, but Covariate
> is something that is measured
> posthoc and can vary in the population.

If by posthoc you mean that the covariate is measured after baseline, it is difficult to get an interpretable analysis.

> I am trying to wrap my head around how to calculate a few quantities
> from the model
> and get reasonable confidence intervals for them, namely I would like to
> test
> H0: gamma=0, where gamma is the regression coefficient of the odds
> ratios of surviving
> under treatment vs control at each level of Covariate
> (adjusted for the confounder)

You mean regression coefficient on the log odds ratio scale. This is easy to do with the contrast( ) function in Design. Do ?contrast.Design for details and examples.

> and I would like to get the odds of surviving at each level of Covariate
> under treatment and control
> for each level of covariate adjusted for the confounder. I have looked
> at contrast in the Design
> library but I don't think it gives me the right quantity, for instance
> contrast(fit,list(covariate="A", Therapy="Treated",
> confounder=median(myDat$confounder), X=TRUE)
> ( "A" is the baseline level of Covariate)
> gives me beta0 + beta_Treated + beta_confounder*68
> Is this correctly interpreted as the conditional odds of dying?
> As to the 1st contrast I am not sure how to get it, would it be using
> type = 'average' with some weights
> in contrast? The answers are probably staring me in the face, i am just
> not seeing them today.

contrast( ) is for contrasts (differences). Sounds like you want predicted values. Do ?predict ?predict.lrm ?predict.Design. Also do ?gendata which will generate a data frame for getting predictors, with unspecified predictors set to reference values such as medians.


> Nicholas

Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 16 Jun 2007 - 16:21:40 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 25 Jun 2007 - 19:32:16 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.