5.3.plot.addXYFit.functions {loa}R Documentation

Plot addXYFit... functions

Description

Functions for adding XY fit model layers to existing plots.

Usage


#main functions

addXYLMFit(lattice.plot = trellis.last.object(),
           preprocess = addXYFit_prep,
           panel=panel.loaXYFit, ...)

addXYLOESSFit(lattice.plot = trellis.last.object(),
           preprocess = addXYFit_prep, model.method = loaXYFit_loess,
           panel = panel.loaXYFit, ...)

#others

addXYFit_prep(lattice.plot = trellis.last.object(),
           model.method = loaXYFit_lm, ...)

loaXYFit_lm(x, y, output.len = 25, formula.signif = 2, 
           r2.digits = 3, group.id = NULL, ...)

loaXYFit_loess(x, y, output.len = 25, r2.digits = 3, 
           group.id = NULL, ...)

panel.loaXYFit(...)

Arguments

lattice.plot

The plot to add an extra layer or layers to. This defaults to last lattice plot produced if not set in call.

preprocess

If set, a function to apply to lattice.plot before adding new panel.

panel

If set, a new panel... function to add to lattice.plot after the current lattice.plot panel.

...

Additional arguments, passed on to daughter functions.

model.method

Function to use on XY data to generate fit reports.

x, y

XY data from plot, typically filtered by both panel and group.

output.len

Number of XY pairs to use when making fit line standard error bands.

formula.signif, r2.digits

When number of significant numbers and digits to use when reporting the fit formula and r.squared, respectively.

group.id

When XY data is grouped, the group identity.

Details

addXYLMFit and addXYLMFit add linear and loess model fit surfaces to exiting lattice plot.

Both functions are intended to be used in form:

[make plot, e.g. loaPlot(...) then] addXYLMFit(...)

loaXYFit_lm and loaXYFit_lm generate fit and report information for linear and loess fit surfaces.

Other functions contain code structure common to all addXYFit functions.

Value

addXYLMFit returns the supply (or last) lattice plot with an added linear fit surface layer, generated using lm().

addXYLMFit returns the supply (or last) lattice plot with an added linear fit surface layer, generated using loess().

The elements of the XYFit layers are fit the fit line, se the standard error bands, and report the fit report panels. These track properties, e.g. col, etc, of the plot they add to unless these terms are reset in the addXYFit call. They can also be removed by setting to FALSE, e.g. fit=FALSE, or updated individually using e.g. fit.col=2 to change just the fit line color to red.

The report position within the plot panel can be set using report.position which uses a relative (x=0-1, y=0-1) scale to position the report.

Note

These functions are in-development aand may change significantly in future pacakge versions.

Author(s)

Karl Ropkins

References

This function makes extensive use of code developed by others.

lattice: Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R. Springer, New York. ISBN 978-0-387-75968-5

lm() and loess() in stats (part of base R): R Core Team (2017). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.

Examples


# add lm fit a loaPlot
addXYLMFit(loaPlot(cadmium~copper*zinc, data=lat.lon.meuse))

## Not run: 

loaPlot(cadmium~copper*zinc, data=lat.lon.meuse)
addXYLOESSFit(col="red")

p <- loaPlot(cadmium~copper*zinc, data=lat.lon.meuse)
addXYLMFit(p, se.col="grey", report.position=c(0.95, 0.22))


## End(Not run)


[Package loa version 0.2.45.4 Index]