r - inverse of 'predict' function -
using predict()
1 can obtain predicted value of dependent variable (y
) value of independent variable (x
) given model. there function predicts x
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 want know predicted value of model x=50
:
predict(model, data.frame(x=50), type = "response")
i want know x
makes y=30
, example.
saw previous answer deleted. in case, given n=50 , model binomial, calculate x given y using:
f <- function (y,m) { (logit(y/50) - coef(m)[["(intercept)"]]) / coef(m)[["x"]] } > f(30,model) [1] 48.59833
but when doing so, better consult statistician show how calculate inverse prediction interval. , please, take vitoshka's considerations account.
Comments
Post a Comment