rp.regression: Graphical display of regression effects (interactive with one...

rp.regressionR Documentation

Graphical display of regression effects (interactive with one or two covariates)

Description

When there are one or two covariates, the function rp.regression creates a panel which controls the model which is fitted to the data and displayed on the plot. In the case of two covariates, a three-dimensional display is created. If a formula or a fitted linear model is passed, then a graphical display of the regression effects is created, irrespective of the number of covariates. The function rp.regression2 is retained simply for compatibility with earlier releases of the package.

Usage

  rp.regression(x, y, ylab = NA, x1lab = NA, x2lab = NA, xlab = NA, yrange,
                 panel = TRUE, panel.plot = TRUE, hscale = NA, vscale = hscale,
                 model = "None", line.showing = TRUE, residuals.showing = FALSE,
                 size = 3, col)
  rp.regression2(y, x1, x2, ylab  = NA, x1lab = NA, x2lab = NA, 
                 panel = TRUE, model = "None", residuals.showing = FALSE,
                 size = 3, col = "red")
  

Arguments

x

a vector or two column matrix of covariate values, or a formula, or a fitted linear model.

y

a vector of response values. This is not required if x is a formula or a fitted linear model.

x1, x2

vectors of covariate values.

ylab

a character variable used for the response axis label.

x1lab

a character variable used for the first covariate axis label.

x2lab

a character variable used for the second covariate axis label.

xlab

a character variable used for the first covariate axis label. This is provided for convenience as a more natural argument name when there is only one covariate.

yrange

a vector of length 2 giving the range of values for the change in the response when regression effects are plotted in a static display. This applies when x is a formula.

panel

a logical variable which determines whether a panel is created to allow interactive control of the fitted models. This is relevant only to the case of two covariates.

panel.plot

a logical variable which determines whether the plot is placed inside the control panel. This is relevant only to the case of one covariate.

hscale, vscale

scaling parameters for the size of the plot when there is one covariate and panel.plot is set to TRUE. The default values are 1 on Unix platforms and 1.4 on Windows platforms.

model

a character variable defining the model to be fitted when the function starts. The valid values are "None", the name of the first and second covariates and the combination of these names with an "&". This is relevant only to the case of two covariates.

line.showing

a logical value determining whether a regression line is shown on the plot when the function starts. This is relevant only to the case of one covariates.

residuals.showing

a logical value determining whether the residuals are shown on the plot when the function starts.

size

the size of the plotted points. This is relevant only to the case of two covariates.

col

the colour of the plotted points. This is relevant only to the case of two covariates.

Details

In the case of one covariate, the control panel allows a line to be drawn on the plot and its intercept and slope altered interactively. The residuals and the least squares fitted line can be displayed. When the fitted line is displayed, the effects of moving individual points can be viewed by clicking and dragging.

In the case of two covariates, the plot is constructed with the aid of the rgl package for three-dimensional display, through the rpanel function rp.plot3d. This display can be rotated and linear models involving one, two or none of the covariates can be displayed. Residuals can also be superimposed. Static plots, for printing or other purposes can be created by setting the panel argument to FALSE and specifying model and residuals.showing as required.

If x is a formula, then a static plot of the regression effects is created. Each coefficient is scaled by the length of the range of corresponding covariate values, in order to display the regression effects in a manner which allows these to be compared. Density plots are used to indicate the uncertainty involved.

Value

Nothing is returned.

References

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

See Also

rp.plot3d

Examples

## Not run: 
  with(CofE, {
    rp.regression(Employ, Giving)
    rp.regression(cbind(Employ, Attend), Giving)
    rp.regression(Giving ~ Employ + Elect + Attend)
  })

## End(Not run)

rpanel documentation built on Feb. 16, 2023, 10:37 p.m.

Related to rp.regression in rpanel...