# [R] How can we get a predicted value that are used to plot the figure using a plot_model function of sjPlot?

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sat Sep 19 20:29:34 CEST 2020

```As no one has responded. Typically,
> ?predict
so
> predict(fit)
should give you fitted values for the class of fit, whatever it is.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, Sep 19, 2020 at 1:29 AM Peter Wagey <peter.wagley09 using gmail.com>
wrote:

> Hi R users,
> I was trying to create a figure of three-way-interactions. There is a
> function "plot-model" but I was wondering whether we can extract the
> predicted value before we run the "plot-model" function.
> For example:
> in this example,
> plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]",
> "c161sex"))
> How can we see the predicted values that are used to plot the figure? If we
> can see the data (predicted values), we could use other functions to create
> another type of figures.
> Thank you very much for your suggestions.
>
> Thanks,
>
> Peter
> #############
> library(sjPlot)
> library(sjmisc)
> library(ggplot2)
> data(efc)
> theme_set(theme_sjplot())
>
> # make categorical
> efc\$c161sex <- to_factor(efc\$c161sex)
>
> # fit model with 3-way-interaction
> fit <- lm(neg_c_7 ~ c12hour * barthtot * c161sex, data = efc)
>
> # select only levels 30, 50 and 70 from continuous variable Barthel-Index
> plot_model(fit, type = "pred", terms = c("c12hour", "barthtot [30,50,70]",
> "c161sex"))
>
> How can we get the predicted value that is used to plot the graph? we would
> like to see the predicted value using three groups of barthtot
> [30,50,70].Is there any way we can extract the data (predicted value) so
> that we can use other graphic functions to create figures?
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help