Learn R Programming

RSA (version 0.5.1)

demoRSA: Plots a response surface of a polynomial equation of second degree with interactive controls

Description

Plots an RSA object, or a response surface with specified parameters, with interactive controls for coefficients.

Usage

demoRSA(x = NULL, y = 0, x2 = 0, y2 = 0, xy = 0, w = 0,
    wx = 0, wy = 0, b0 = 0, type = "3d", zlim = c(-2, 2),
    xlim = c(-2, 2), ylim = c(-2, 2), points = FALSE,
    model = "full", extended = FALSE, ...)

Arguments

x
Either an RSA object (returned by the RSA function), or the coefficient for the X predictor
y
Y coefficient
x2
X^2 coefficient
y2
Y^2 coefficient
xy
XY interaction coefficient
w
W coefficient (for (un)constrained absolute difference model)
wx
WX coefficient (for (un)constrained absolute difference model)
wy
WY coefficient (for (un)constrained absolute difference model)
b0
Intercept
xlim
Limits of the x axis
ylim
Limits of the y axis
zlim
Limits of the z axis
type
3d for 3d surface plot, contour for 2d contour plot. Shortcuts (i.e., first letter of string) are sufficient; be careful: "contour" is very slow at the moment
points
Should the original data points be overplotted?
model
If x is an RSA object: from which model should the response surface be computed?
extended
Show additional controls (not implemented yet)
...
Other parameters passed through to plot.RSA (e.g., xlab, ylab, zlab, cex, legend)

Details

No details so far. Just play around with the interface!

See Also

plotRSA, RSA

Examples

Run this code
# Plot response surfaces from known parameters
# example of Edwards (2002), Figure 3
demoRSA(x=.314, y=-.118, x2=-.145, y2=-.102, xy=.299, b0=5.628, type="3d")
demoRSA(x=.314, y=-.118, x2=-.145, y2=-.102, xy=.299, b0=5.628, legend=FALSE, type="c")

# Plot response surface from an RSA object
set.seed(0xBEEF)
n <- 300
err <- 2
x <- rnorm(n, 0, 5)
y <- rnorm(n, 0, 5)
df <- data.frame(x, y)
df <- within(df, {
	diff <- x-y
	absdiff <- abs(x-y)
	sqdiff <- (x-y)^2
	z.diff <- diff + rnorm(n, 0, err)
	z.abs <- absdiff + rnorm(n, 0, err)
	z.sq <- sqdiff + rnorm(n, 0, err)
	z.add <- diff + 0.4*x + rnorm(n, 0, err)
	z.complex <- 0.4*x + - 0.2*x*y + + 0.1*x^2 - 0.03*y^2 + rnorm(n, 0, err)
})

r1 <- RSA(z.sq~x*y, df)
demoRSA(r1)
demoRSA(r1, points=TRUE, model="sqdiff")

Run the code above in your browser using DataLab