I have the following model :
model_ <- glm( response ~ var_1 + var_2, family = "binomial" )
which gives me the following results :
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.07418 0.05484 -56.053 <2e-16 ***
var_1 0.19238 0.13547 1.420 0.156
var_2 2.07090 0.23579 8.783 <2e-16 ***
---
The only way I figured out how to plot with the base graphic functions the two probability curves was by running two different models :
model_1 <- glm( response ~ var_1, family = "binomial" )
model_2 <- glm( response ~ var_2, family = "binomial" )
and create two predicted curves :
curve( predict( mod_1, data.frame( var_1=x ), type="resp" ))
curve( predict( mod_2, data.frame( var_2=x ), type="resp" ))
Which once plotted look like the following graphs :
But of course the coefficients are then not the same than with my initial model_
.
coef(model_) coef(model_1) coef(model_2)
var_1 0.192 0.165 ---
var_2 2.071*** --- 2.065***
I would like to plot the two probability curves corresponding to each variable from the multivariate model model_
and not from the two submodels model_1
and model_2
.
- Is there a more or less simple way to show those two curves directly from
model_
without having to run other submodels which give slightly different coefficients ? - How would it work with 4 probability curves corresponding to the variables
var_1
,var_2
,var_3
andvar_4
with a formula such asresponse ~ var_1 + var_2 + var_3 + var_4
?
There are some examples on the net, but either using automatic functions from ggplot (which i don't want to use) or running univariate models.