hello
maybe this post is more mathematic than R
i have created (with R) a sample :
with a function plusrunifwhich is the one of my other post of this morning :

now i make the reverse job, reading the datas and trying to guess the correlation :
but it doesn't fit…

n <- 200
plusrunif <- function(unvecteur,unautre) {
#il faut unvecteur < unautre
retour <- c()
for (i in 1:n){
retour <- append(retour,runif(1,unvecteur[i],unautre[i]))
}
return(retour)
}
a3 <- 10
b3 <- -2
x3 <- runif(n,0,1)
e3 <- exp(a3*x3+b3)
y3bas <- e3/(1+e3)*0.8
y3haut<- e3/(1+e3)*1
y3 <- plusrunif(y3bas,y3haut)
z3 <- log(y3/(1-y3))
t3 <- (x3)
reg <- lm(z3~t3)
ab <- reg$coefficients
a <- ab[2]
b <- ab[1]
#a=10.5
#b=-2.36
plot(x3,y3)
curve((exp(a*x+b)/(exp(a*x+b)+1)), xmin, xmax, n = 200,col="green",add=TRUE)

the calculus are not very complicated indeed… i have made them again and mys students obtain the same bad fit…

but why are the a,b calculated by R
worse
than 10.5 and -2.36

how is it that R gives a,b that do not produce the best Pearson

you see if you manually give to a,b the values canceled by # in my code, the pearson is better and the curve fits visually much better that with the a,b calculated by R