Skip to main content
added 26 characters in body
Source Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
x <- c(1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0)
y <- c(1, 1, 1, 1, 1, 0.98, 0.99, 0.9, 0.8, 0.66, 0.58, 0.34, 0.33, 0.22, 0.08, 0.19, 0.09, 0.09, 0.18, 0.08, 0.13)
x <- c(1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45,
       0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0)
y <- c(1, 1, 1, 1, 1, 0.98, 0.99, 0.9, 0.8, 0.66, 0.58, 0.34, 0.33, 
       0.22, 0.08, 0.19, 0.09, 0.09, 0.18, 0.08, 0.13)
plot(x, y, ylim = c(0, 1), col = 'red')
abline(h = 0.1, lty = 2)
m <- glm(y ~ x, family = 'binomial')
p <- predict(m, newdata = data.frame(x = x), type = 'response')
lines(x, p, col = 'green')
plot(x, y, ylim = c(0, 1), col = 'red')
abline(h = 0.1, lty = 2)
m <- glm(y ~ x, family = 'binomial')
p <- predict(m, newdata = data.frame(x = x), type = 'response')
lines(x, p, col = 'green')

The line-of-best-fit should be more like the dotted black line, but I don't know how to estimate that.   

enter image description here

x <- c(1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0)
y <- c(1, 1, 1, 1, 1, 0.98, 0.99, 0.9, 0.8, 0.66, 0.58, 0.34, 0.33, 0.22, 0.08, 0.19, 0.09, 0.09, 0.18, 0.08, 0.13)
plot(x, y, ylim = c(0, 1), col = 'red')
abline(h = 0.1, lty = 2)
m <- glm(y ~ x, family = 'binomial')
p <- predict(m, newdata = data.frame(x = x), type = 'response')
lines(x, p, col = 'green')

The line-of-best-fit should be more like the dotted black line, but I don't know how to estimate that.  enter image description here

x <- c(1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45,
       0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0)
y <- c(1, 1, 1, 1, 1, 0.98, 0.99, 0.9, 0.8, 0.66, 0.58, 0.34, 0.33, 
       0.22, 0.08, 0.19, 0.09, 0.09, 0.18, 0.08, 0.13)
plot(x, y, ylim = c(0, 1), col = 'red')
abline(h = 0.1, lty = 2)
m <- glm(y ~ x, family = 'binomial')
p <- predict(m, newdata = data.frame(x = x), type = 'response')
lines(x, p, col = 'green')

The line-of-best-fit should be more like the dotted black line, but I don't know how to estimate that. 

enter image description here

Source Link
Dan
  • 605
  • 5
  • 12

Estimate a GLM where the intercept is known

I have some x and y values. The y values have some random error.

x <- c(1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0)
y <- c(1, 1, 1, 1, 1, 0.98, 0.99, 0.9, 0.8, 0.66, 0.58, 0.34, 0.33, 0.22, 0.08, 0.19, 0.09, 0.09, 0.18, 0.08, 0.13)

I know for certain that the minimum value of y is 0.1 and the intercept is 0.1. Some observed y values are smaller than 0.1 simply due to random error in measurement. How do I fit a binomial line-of-best fit to this data, accounting for the fact that I know the intercept is 0.1? If I don't account for this, then I could draw the green line, which is clearly wrong.

plot(x, y, ylim = c(0, 1), col = 'red')
abline(h = 0.1, lty = 2)
m <- glm(y ~ x, family = 'binomial')
p <- predict(m, newdata = data.frame(x = x), type = 'response')
lines(x, p, col = 'green')

The line-of-best-fit should be more like the dotted black line, but I don't know how to estimate that. enter image description here