umxPlot: Quickly plot y ~ x with a regression line and R^2, and nice...

View source: R/fit_and_reporting.R

umxPlotR Documentation

Quickly plot y ~ x with a regression line and R^2, and nice labels.

Description

Want a figure for your paper or presentation but not the work of combining ggplot2::ggplot(), ggplot2::geom_smooth() and method options, plus ggplot2::geom_point(). Organizing ggplot2::labs() and its x, y, and title components. Adding your preferred theme like ggplot2::theme_gray(), plus recalling for cowplot::draw_label(), and/or ggplot2::annotate() to draw math-enabled labels on the plot, as well as the required bquote(), and extracting the relevant fit statistics from lm() and the subsidiary tasks of reformulate() programmatic variables?

umxPlot just takes y ~ x (or "x" and "y" as strings), and gives you a nicely labelled plot, with a fitted line, the R2 so readers can see how well this fitted. It knows how to put Greek symbols like beta into axes.

Usage

umxPlot(
  x,
  y = NULL,
  data,
  xlab = x,
  ylab = y,
  title = paste0(y, " as a function of ", x),
  fitx = NA,
  fity = NA,
  geom_point = TRUE,
  method = c("lm", "auto", "loess", "glm", "gam"),
  family = c("gaussian", "binomial", "Gamma", "inverse", "poisson", "quasi",
    "quasibinomial", "quasipoisson")
)

Arguments

x

formula or (alternatively) x as string

y

variable as string.

data

The data for the graph.

xlab

X-axis label (default y).

ylab

Y-axis label (default y).

title

Graph title. Default = paste0(y, " as a function of ", x)

fitx

x location for the fit summary (default 1).

fity

y location for the fit summary (default 2).

geom_point

show points? (TRUE)

method

Method for fitting curve (default = lm)

family

for glm default = "gaussian"

Value

  • plot you can edit.

See Also

  • ggplot2::qplot()

Other Plotting functions: ggAddR(), plot.MxLISRELModel(), plot.MxModel(), plot.MxModelTwinMaker(), umx, umxPlotACE(), umxPlotACEcov(), umxPlotACEv(), umxPlotCP(), umxPlotDoC(), umxPlotFun(), umxPlotGxE(), umxPlotGxEbiv(), umxPlotIP(), umxPlotSexLim(), umxPlotSimplex()

Examples

data(mtcars)
umxPlot(mpg ~ wt, data = mtcars, fitx = 2, fity = 10)
umxPlot(x = "wt", y = "mpg", mtcars, fitx = 2, fity = 10)

tbates/umx documentation built on Dec. 14, 2024, 11:28 a.m.