0

I've calculated the following model:

a.Pfad<-lmer(FlowZ~MTsqZ+(1|VP04_01), data=MT)

with MTsqZ being a quadratic term.

I am looking for a way to plot this model: I want to see if there is an inverted u-shaped relationship between the variables. What is the best way to do this? As I am really unexperienced with any kinds of graphs in R, I am really looking forward to your help.

tifu
  • 1,352
  • 6
  • 17
Gina W.
  • 11
  • 2

1 Answers1

1

You can check out the sjPlot package to plot effect sizes from lmer models. The function you want is sjp.lmer and if you want to plot the fixed effect slope of MTsqZ, you could type:

library(sjPlot)
sjp.lmer(a.Pfad, type = "fe.slope", vars = "MTsqZ")

Additional comment: From the looks of it, you have not modeled the relationship between MT and FlowZ as quadratic, since you only included the squared version of the variable.

Edit: This is how you can model the relationship as quadratic:

a.Pfad<-lmer(FlowZ~MT+I(MT^2)+(1|VP04_01), data=MT)

It is then possible to plot the relationship using type = "poly":

sjp.lmer(a.Pfad, type = "poly", poly.term = "MT")
tifu
  • 1,352
  • 6
  • 17
  • thank you! Hmmm...by using this function I really get a linear regression line. What should I have included to have the quadratic relationship? (Flow~MTZ+MTsqZ)? And what would the sjp-code look like then? – Gina W. Jan 26 '18 at 11:19
  • See above. Your solution would yield the same estimates, but it wouldn't be possible to pass results to `sjp.lmer` – tifu Jan 26 '18 at 12:51
  • By the way, it is entirely possible that the quadratic relationship doesn't look much different from a straight line, especially when you are zooming in on the range your observations lie in. – tifu Jan 26 '18 at 12:58
  • thank you! It's working now and the graph looks quadratic :) – Gina W. Jan 26 '18 at 13:22
  • 1
    For the latest _sjPlot_ version, you can also use the new `plot_model()` function: `plot_model(a.Pfad, type = "pred", terms = "MT")`. – Daniel Feb 07 '18 at 13:05