Re: [R] A Contrast Question

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Thu, 10 Jan 2008 23:13:15 +0100

(Ted Harding) wrote:
> Hi Folks,
> This should have been simple to answer,
> but despite much chasing I don't seem able
> to catch this particular mouse!
>
> Basically (somewhat simplified): I have a
> binary response variable Y (0/1) and a
> 2-level factor A (0/1).
>
> I want to assign a contrast to A such that,
> when I run
>
> summary(glm(Y~A, family=binomial))\$coef
>
> the Intercept coefficient is the result that
> I would get from running glm(Y ~ 1), and
> the "A" coefficient is the log(odds ratio)
> of the "A=1" results relative to all the data.
>
> Explicitly: if p = sum(Y==1)/length(Y),
> and p1 = sum(Y[A==1]==1)/length(Y[A==1])
> then:
>
> Intercept: log(p/(1-p))
>
> Coeff of A: log((p1/(1-p1))/(p/(1-p)))
>
> (The objective is to assess whether a covariate
> that may result in only observing a subset of
> the data would produce a significant selection
> bias in the result).
>
> I know I could derive the result from manipulation
> of the output from a standard contrast function,
> but I would prefer to delegate it all (including
> calculation of SE and P-value) to a run of glm()
I don't think that is possible. The contrasts would have to depend on p, p0, and p1, and if they do, then you can't base SE calculations on the usual formulas. Can't you just use the delta method and begone with it?

--

```  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
```
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 Thu 10 Jan 2008 - 22:17:54 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 Thu 10 Jan 2008 - 22:30:06 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.