An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20110623/1e15d625/attachment.pl>
revised link function of logistic regression model?
3 messages · Jian Zhang, David Duffy, Douglas Bates
On Thu, 23 Jun 2011, Jian Zhang wrote:
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?
I shall hazard a guess and say that you can't, exactly as you have specified it. You could fit such a model by ML, but you would have to hand code it using nlme (?) or directly maximizing the likelihood using optim() etc. But I suspect there are many similar models that might be better behaved. Are you trying to fit a parametric survival model in a roundabout fashion? Cheers, David Duffy.
| David Duffy (MBBS PhD) ,-_|\ | email: davidD at qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / * | Epidemiology Unit, Queensland Institute of Medical Research \_,-._/ | 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
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