My sjPlot package for data visualization has just been updated on CRAN. I’ve added some features to existing function, which I want to introduce here.

## Plotting linear models

So far, plotting model assumptions of linear models or plotting slopes for each estimate of linear models were spread over several functions. Now, these plot types have been integrated into the `sjp.lm`

function, where you can select the plot type with the `type`

parameter. Furthermore, plotting standardized coefficients now also plot the related confidence intervals.

Detailed examples can be found here:

www.strengejacke.de/sjPlot/sjp.lm

## Plotting generalized linear models

Beside odds ratios, you now can also plot the predicted probabilities of the outcome for each predictor of generalized linear models. In case you have continuous variables, these kind of plots may be more intuitive than an odds ratio value.

Detailed examples can be found here:

www.strengejacke.de/sjPlot/sjp.glm

## Plotting (generalized) linear mixed effects models

The plotting function for creating plots of (generalized) linear mixed effects models (`sjp.lmer`

and `sjp.glmer`

) also got new plot types over the course of the last weeks.

For `sjp.lmer`

, we have

`re`

(default) for estimates of random effects`fe`

for estimates of fixed effects`fe.std`

for standardized estimates of fixed effects`fe.cor`

for correlation matrix of fixed effects`re.qq`

for a QQ-plot of random effects (random effects quantiles against standard normal quantiles)`fe.ri`

for fixed effects slopes depending on the random intercept.

and for `sjp.glmer`

, we have

`re`

(default) for odds ratios of random effects`fe`

for odds ratios of fixed effects`fe.cor`

for correlation matrix of fixed effects`re.qq`

for a QQ-plot of random effects (random effects quantiles against standard normal quantiles)`fe.pc`

or`fe.prob`

to plot probability curves (predicted probabilities) of all fixed effects coefficients. Use facet.grid to decide whether to plot each coefficient as separate plot or as integrated faceted plot.`ri.pc`

or`ri.prob`

to plot probability curves (predicted probabilities) of random intercept variances for all fixed effects coefficients. Use facet.grid to decide whether to plot each coefficient as separate plot or as integrated faceted plot.

Detailed examples can be found here:

www.strengejacke.de/sjPlot/sjp.lmer and www.strengejacke.de/sjPlot/sjp.glmer

## Plotting interaction terms of (generalized) linear (mixed effects) models

Another function, where new features were added, is `sjp.int`

(formerly known as sjp.lm.int). This function is now kind of generic and can plot interactions of

- linar models (lm)
- generalized linar models (glm)
- linar mixed effects models (lme4::lmer)
- generalized linar mixed effects models (lme4::glmer)

For linear models (both normal and mixed effects), slopes of interaction terms are plotted. For generalized linear models, the predicted probabilities of the outcome towards the interaction terms is plotted.

Detailed examples can be found here:

www.strengejacke.de/sjPlot/sjp.int

## Plotting Likert scales

Finally, a comprehensive documentation for the `sjp.likert`

function is finsihed, which can be found here:

www.strengejacke.de/sjPlot/sjp.likert

Looks good! Can you comment on how this compares to or complements the visreg package?

I haven’t used the visreg package yet, so I refer to this PDF.

As far as I can see, only figure 1, page 4 can be exactly reproduced by sjPlot with

`sjp.lm(fit, type = "pred")`

. Fig. 6 on p. 8 is similar, but not identical to`sjp.lm(fit, type = "pred")`

again (cave! needs development version 1.6.9 to plot interaction terms and factor levels as well!). sjPlot has a different approach to plot interaction terms like shown in fig. 6, via`sjp.int(fit)`

, see here for details.Generally, sjPlot also focuses on plotting estimates and CI as „forest plots“, while visreg seems to focus on plotting single predictors against the outcome (what can be achieved with the

`type = "pred"`

parameter in`sjp.lm`

).I would suggest you compare the above mentioned PDF with following sjPlot-tutorials:

http://www.strengejacke.de/sjPlot/sjp.lm/

http://www.strengejacke.de/sjPlot/sjp.glm/

http://www.strengejacke.de/sjPlot/sjp.int/

and, if you’re interested in mixed models:

http://www.strengejacke.de/sjPlot/sjp.lmer/

http://www.strengejacke.de/sjPlot/sjp.glmer/

Hi, thanks a lot for this helpful tool. I encounter the following error when using interaction plots for glmes with sjp.int : “ not possible to find the function „sji.getValueLabels“.

do you have an idea about this problem? I use sjPlot 1.7

Are you using

`sji.getValueLabels`

outside the function? Since version 1.7 of the package, the „tool“ functions have been renamed, see here. And with the next version, these functions are even moved into a new package, see CRAN, GitHub sjmisc and GitHub sjPlot.I’m totally new with R. I use Rstudio. I have install the package through Rstudio and write the syntax directly in it. this is not correct?

I guess I knew what you made wrong. I guess you have copied the example from http://www.strengejacke.de/sjPlot/sjp.int

`sjp.int(fit, legendLabels = sji.getValueLabels(efc$c161sex), plevel = 0.1)`

The

sji.getValueLabelsis wrong, see last example from`?sjp.int`

. It has to be`sjp.int(fit, legendLabels = get_val_labels(efc$c161sex), plevel = 0.1)`

thanks a lot. I now have the following Error in loadNamespace(name) : there is no package called ‘labeling’. I will try your suggestion by using axistitle.x…

I fear, I need more information to help, probably also the

`sessionInfo()`

. Could you send me example data via email? E.g., the object from the environment (saved with`save(objectName, file = "filename.RData")`

?It’s hard to give an advice because I don’t know your syntax nor your data. Perhaps it’ll help you reading this manual on sjp.int and this manual on data initialization.

Or provide labels via parameters, like

`axisTitle.x`

,`legendLabels`

etc., see`?sjp.int`

.Hi there,

Nice package, thanks for this. I’m trying to assign colors to each point+errorbar in a forest plot (sjp.lm). It seems that I can only color all of the geoms, and not per level. Any thoughts?

my_df = data.frame(a = rnorm(100), b = factor(rep(c(„W“,“X“,“Y“,“Z“),25)), c = runif(100))

sjp.lm(lm(a ~ c:b, data = my_df), coord.flip=F, sort.est = F, geom.colors = c(„green“, „red“))

my_plot = sjp.lm(lm(a ~ c:b, data = my_df), coord.flip=F, sort.est = F, printPlot = F)$plot

my_plot + scale_color_manual(values = c(„red“, „green“, „blue“, „yellow“))

Thanks,

Alex

You can only set colors for estimates > 0 or 1 or <= 1 (for glm). As you have the predictor names on the y axis, a color for each level would just double the annotation – or did I misunderstand you?

Thanks Daniel. I wish to assign colors to groups of predictors. For example, assign „green“ to geoms associated with „X“ and „Y“, and „red“ to „Y“ and „Z“. Does that make sense? This adds information to the plot in terms of how one might group the predictors. In my case, for example, I fit separate predictors by plots (e.g. pred:plot). I want to color the geoms according to the ecotype of my plots (e.g. forests, savannas, etc). Hope this makes sense.