Re: [R] Fitting a modified logistic with glm?

From: Ken Knoblauch <ken.knoblauch_at_inserm.fr>
Date: Sun, 09 Nov 2008 14:09:04 +0000 (UTC)

Mike Lawrence <mike <at> thatmike.com> writes:
> Where f(x) is a logistic function, I have data that follow:
> g(x) = f(x)*.5 + .5

> How would you suggest I modify the standard glm(..., family='binomial')
> function to fit this? Here's an example of a clearly ill-advised attempt to
> simply use the standard glm(..., family='binomial') approach:
> #define the scale and location of the modified logistic to be fit
> location = 20
> scale = 30
> x = runif(200,-200,200)
> x.noise = runif(length(x),-10,10)
> prob.success = plogis(x+x.noise,location,scale)*.5 + .5
> y = rep(NA,length(x))
> for(i in 1:length(x)){
> y[i] = sample(
> x = c(1,0)
> , size = 1
> , prob = c(prob.success[i], 1-prob.success[i])
> )
> }
> plot(x,y)
> curve(plogis(x,location,scale)*.5 + .5,add=T)
Hi,

You might try the link mafc.logit(m = 2) defined in the psyphy package. Continuing with your example, library(psyphy)
fit <- glm(y ~ x, binomial(mafc.logit(2)),   control = glm.control(maxit = 100)) # default didn't converge x.ord <- order(x)
lines(x[x.ord], fitted(fit)[x.ord], col = "red", lwd = 3)

HTH, Ken

-- 
Ken Knoblauch
Inserm U846
Institut Cellule Souche et Cerveau
Département Neurosciences Intégratives
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr

______________________________________________
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 Sun 09 Nov 2008 - 14:11:35 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 Sun 09 Nov 2008 - 16:30:23 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.

list of date sections of archive