I would like to build the results of multivariate logistic regression analysis (GLM) for certain independent variables, adjusted (i.e., regardless of the relationship included in the model), with the result (binary).
I saw posts that recommend the following method using the command predictthat follows curve, here is an example;
x <- data.frame(binary.outcome, cont.exposure)
model <- glm(binary.outcome ~ cont.exposure, family=binomial, data=x)
plot(cont.exposure, binary.outcome, xlab="Temperature",ylab="Probability of Response")
curve(predict(model, data.frame(cont.exposure=x), type="resp"), add=TRUE, col="red")
However, this does not work for multivariate regression models. I get the following error when I add "age" (arbitrary - can be any variable of the same length) as a mixing variable;
> x <- data.frame(binary.outcome, cont.exposure, age)
> model <- glm(binary.outcome ~ cont.exposure + age, family=binomial, data=x)
> plot(cont.exposure, binary.outcome, xlab="Temperature",ylab="Probability of Response")
> curve(predict(model, data.frame(cont.exposure=x), type="resp"), add=TRUE, col="red")
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) :
variable lengths differ (found for 'age')
In addition: Warning message:
'newdata' had 101 rows but variable(s) found have 698 rows
, , ; , ..
, , . .