[R-sig-ME] revised link function of logistic regression model?

Douglas Bates bates at stat.wisc.edu
Fri Jun 24 12:53:15 CEST 2011


On Thu, Jun 23, 2011 at 1:31 PM, Jian Zhang <jzhang1982 at gmail.com> wrote:
> Hey, I have a problem using the glm function for the logistic regression model.
>
> For the logistic model, the survival probability is: P(y=1|x) = exp(b0+b1*x) / (1+exp(b0+b1*x))
> The link function is: b0+b1*x

Your terminology is a bit off:  b0+b1*x is the linear predictor, g(p)
= log(p/(1-p)) is the link function and g^1(eta) =
exp(eta)/(1+exp(eta)) is the inverse link.

> My question is: If I changed the function of the survival probability to the following: P(y=1|x) = (exp(b0+b1*x) / (1+exp(b0+b1*x)) ) ^t, how should I do the regression using the glm? How can I add the "t" into the function as a predictor variable? Or should I revise the link function?

The glm function allows for a user-written family but, unfortunately,
doesn't allow for additional covariates or even constants.  It is
possible to "smuggle" them  in at the time that the family is
instantiated.  See the glm.nb function in the MASS package for an
example.

> Give an example here:
>
>> y=c(0,1,1,0,1,1,1,1,0,0,1,0,1,0,0)
>> x1=rnorm(length(y))
>> t=sample(1:30,length(y),replace=TRUE)
>> (dat1=data.frame(y,x1,t))
>   y         x1  t
> 1  0  0.6486104 23
> 2 1 0.6989650  9
> 3  1 -1.6542582  9
> 4  0 -0.2465761 30
> 5  1  1.7133463 17
> 6 1 -0.3536826 20
> 7 1 0.4766255  3
> 8 1 -0.3549167  2
> 9 0 0.3203217 22
> 10 0  0.6136343  3
> 11 1 -0.3993963 29
> 12 0  0.8339387  3
> 13 1 0.5359685 17
> 14 0  0.2322983  4
> 15 0 0.7317251 21
>> rm(y,x1,t)
>> res1=glm(y~x1,family=binomial(link ="logit"), data=dat1)  ### How can I add the "t" into the function as a predictor variable
>> summary(res1)
> Call:
> glm(formula = y ~ x1, family = binomial(link = "logit"), data = dat1)
> Deviance Residuals:
>    Min       1Q   Median       3Q      Max
> -1.3999  -1.1258   0.6282   1.0614   1.5764
> Coefficients:
>            Estimate Std. Error z value Pr(>|z|)
> (Intercept)   0.3317     0.5853   0.567    0.571
> x1           -0.7200     0.7948  -0.906    0.365
> (Dispersion parameter for binomial family taken to be 1)
>    Null deviance: 20.728  on 14  degrees of freedom
> Residual deviance: 19.792  on 13  degrees of freedom
> AIC: 23.792
> Number of Fisher Scoring iterations: 4
>
>
> Jian
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




More information about the R-sig-mixed-models mailing list