rp.lm: Graphical display of linear models with no more than two...

View source: R/rp_lm.R

rp.lmR Documentation

Graphical display of linear models with no more than two explanatory variables

Description

This function is primarily intended to provide graphical representations of linear models with no more than two explanatory variables. These can be covariates or factors or a mixture of the two. When there are more than two explanatory variables the model is passed on to the rp.coefficients or rp.drop1 functions.

Usage

rp.lm(x, ylab, xlab, zlab, panel = TRUE, panel.plot = TRUE,
      style = 'ggplot', plot.nodes = FALSE,
      uncertainty.display = 'density', inference = 'coefficients',
      ci = TRUE, cols, display.model, comparison.model,
      residuals.showing, linewidth = 1,
      hscale = 1, vscale = hscale, ...)

Arguments

x

a formula defining the linear model or a fitted linear model object.

ylab, xlab, zlab

character variables used for the axis labels.

panel

a logical value which determines whether a panel is created to allow interactive control of the fitted models.

panel.plot

a logical value which determines whether the plot is placed inside the panel (TRUE) or the standard graphics window (FALSE).

style

a character variable determining whether ggplot graphics are used. Any value other than 'ggplot' invokes an older form of the function with standard graphics. ggplot style is strongly recommended.

plot.nodes

a logical value, relevant only when the function is called in non-interactive mode (panel = FALSE), which determines whether the lattice of model nodes is plotted or the plot of the data and fitted model is returned. In the latter case, the returned object is a ggplot object.

uncertainty.display

a character value which determines whether the uncertainty display is in 'density' or 'shading' style.

inference

a character value which determines whether the inference display is based on 'coefficients' or 'terms'.

ci

a logical value which is passed to the rp.coefficients function when this is used to display model coefficients. When ci is set to FALSE uncertainty is placed around 0 in hypothesis test style.

cols

a named character vector of colours to be used in constructing the display. See help(rp.colours) for details.

display.model

a one sided formula which determines the specific model to be displayed. This can be a reduced model which omits some of the terms present in the model defined by x, or an expanded model which includes interaction terms.

comparison.model

a one sided formula which determines the specific model to be compared with the displayed model. This can be a reduced model which omits some of the terms present in the model defined by x or, when at least one factor is present, an expanded model which includes an interaction term.

residuals.showing

a logical value which determines whether residuals are displayed when there are two covariates.

linewidth

a numerical value which sets the linewidth parameter in the case of one covariate and one factor.

hscale, vscale

scaling parameters for the size of the plot when panel.plot is set to TRUE. The default values are 1.

...

other arguments passed on to lm when x is a formula rather than a fitted model.

Details

The display of the data is adapted to the form of the explanatory variables. When panel = TRUE a lattice of potential models is displayed in graphical form. When a node of the lattice is clicked the corresponding fitted model is displayed. When a connection between adjacent models is clicked, a comparison of the two adjacent models is displayed, either as model coefficients (display = 'coefficients') or model terms (display = 'coefficients').

When the model defined by x contains two explanatory variables, where at least one is a factor, the models which can be fitted include the interaction term, even where this is not explicitly included in x.

When there are exactly two covariates in x, the function will not consider an interaction between these, even when x includes this.

If display.model is not specified, its default setting is NULL when panel = TRUE and the model specified by x when panel = FALSE.

Missing data are removed before the linear models are fitted.

Value

Nothing is returned.

References

rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.

Examples

## Not run: 
  y <- rnorm(50, mean = 10, sd = 0.5)
  rp.normal(y)
  
## End(Not run)

rpanel documentation built on March 12, 2026, 9:07 a.m.

Related to rp.lm in rpanel...