# Re: [R] complex contrasts and logistic regression

From: Frank E Harrell Jr <f.harrell_at_vanderbilt.edu>
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

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.

Frank

>
> Nicholas
>
>
>

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

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help