I have a simple positive/negative test result as a function of a protein concentration, and I am trying to plot the logit regression curve. However, I am consistently getting a error that I cannot fix.
This is my data:
sp <- structure(list(Cry = c(32, 32, 32, 32, 32, 32, 16, 16, 16, 8,
8, 8, 4, 4, 4, 2, 2, 2, 1, 1, 1, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25,
0.12, 0.12, 0.06, 0, 0, 0, 0, 0, 0), Positive = c(1L, 1L, 1L,
1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L)), class = "data.frame", row.names = c(NA, -36L))
This is my glm:
test.glm <- glm(Positive ~ Cry, family = binomial, data = sp)
summary(test.glm)
I am trying to make predicted values to plot
x_test <- seq(0,32, 0.01)
y_test <- predict(test.glm, newdata = list(x_test) ,type = "response")
So, when I try to plot it:
plot(sp$Positive ~ log(Cry))
lines(x_test, y_test)
I get this error:
Error in xy.coords(x, y) : 'x' and 'y' lengths differ
because
length(x_test)
3201
length(y_test)
36
The length of y_test ends up being 36 instead of the same length as x_test
Why is my predict function ignoring the length of my newdata and only predicting as many values as I have in my original dataframe?

dput(head(x))ordata.frame(...)) directly. - r2evans