[R] A Contrast Question
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Jan 10 23:13:15 CET 2008
(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
More information about the R-help
mailing list