hello
maybe this post is more mathematic than R
i have created (with R) a sample :
with a function plusrunif
which 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…
i can't find where the problem is…