Using predict()
one can obtain the predicted value of the dependent variable (y
) for a certain value of the independent variable (x
) for a given model. Is there any function that predicts x
for a given y
?
For example:
kalythos <- data.frame(x = c(20,35,45,55,70),
n = rep(50,5), y = c(6,17,26,37,44))
kalythos$Ymat <- cbind(kalythos$y, kalythos$n - kalythos$y)
model <- glm(Ymat ~ x, family = binomial, data = kalythos)
If we want to know the predicted value of the model for x=50
:
predict(model, data.frame(x=50), type = "response")
I want to know which x
makes y=30
, for example.
invM1 <- lm(x ~ y, data)
and then usepredict
on your new predictory
. Now, before you jump in and do so, I recommend taking into account what @vitoshKa commented above.x
variable).