visualizers: Internal Functions for Plot Method

visualizersR Documentation

Internal Functions for Plot Method

Description

Internal functions used by the plot.gammi function to visualize main effects and two-way interaction effects in fit gammi objects.

Usage

visualizer1(x, y, bars = FALSE, bw = 0.02, lty = 1, lwd = 2, col = "black", 
            lwr = NULL, upr = NULL, ci.lty = 2, ci.lwd = 1.25, ci.col = "black",
            zero = TRUE, zero.lty = 3, xlim = NULL, ylim = NULL, 
            xlab = NULL, ylab = NULL, main = NULL, add = FALSE, ...)
            
visualizer2(x, y, z, col = NULL, ncolor = 21,
            xlim = NULL, ylim = NULL, zlim = NULL, zline = 1.5,
            xlab = NULL, ylab = NULL, zlab = NULL, main = NULL, 
            xticks = NULL, xlabels = NULL, yticks = NULL, ylabels = NULL, ...)

Arguments

x, y, z

For 1D plots: x and y are the primary inputs to the plot function. For 2D plots: these are the primary inputs to the image function.

bars

For 1D plots: logical indicating whether to create a line plot (default) or a bar plot (bars = TRUE).

bw

For 1D plots: width of the bars relative to range of x (ignored if bars = FALSE).

lty, lwd

For 1D plots: line type and width for 1D plots.

col

For 1D plots: single color for line/bar plot. For 2D plots: vector of colors for image plot.

ncolor

For 2D plots: number of colors used for image plot and color legend, see Note.

lwr, upr

For 1D plots: number vectors defining the lower and upper bounds to plot for a confidence interval. Must be the same length as x and y.

ci.lty, ci.lwd, ci.col

For 1D plots: the type, width, and color for the confidence interval lines drawn from the lwr and upr arguments.

zero, zero.lty

For 1D plots: zero is a logicical indicating whether a horizontal line at y = 0 should be included, and zero.lty controls the line type

xlim, ylim, zlim

For 1D plots: xlim and ylim are the axis limits input to the plot function. For 2D plots: these are the axis limits input to the image function (note: zlim controls range for color legend).

xlab, ylab, zlab

For 1D plots: xlab and ylab are the axis labels input to the plot function. For 2D plots: these are the axis labels input to the image function (note: zlab controls label for color legend).

main

Title of the plot.

add

Should lines/bars be added to current plot?

zline

For 2D plots: margin line for the z-axis label.

xticks, yticks

For 2D plots: tick marks for x-axis and y-axis grid lines.

xlabels, ylabels

For 2D plots: labels corresponding to the input tick marks that define the grid lines.

...

Additional arguments passed to the plot and image functions.

Details

The visualizer1 function is used to plot 1D (line/bar) plots, and the visaulizer2 function is used to plot 2D (image) plots. These functions are not intended to be called by the user, but they may be useful for producing customized visualizations that are beyond the scope of the plot.gammi function.

Value

A plot is produced and nothing is returned.

Note

The vector of colors used to construct the plots is defined as colorRampPalette(col)(ncolor), which interpolates a color palette of length ncolor from the input colors in the vector col.

Author(s)

Nathaniel E. Helwig <helwig@umn.edu>

References

Helwig, N. E. (2024). Precise tensor product smoothing via spectral splines. Stats, 7(1), 34-53, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3390/stats7010003")}

See Also

plot.gammi for plotting effects from gammi objects

Examples

# load 'gammi' package
library(gammi)

# load 'exam' help file
?exam

# load data
data(exam)

# header of data
head(exam)

# fit model
mod <- gammi(Exam.score ~ VRQ.score, data = exam,
             random = ~ (1 | Primary.school) + (1 | Secondary.school))
             
# plot results (using S3 method)
plot(mod, include.random = FALSE)

# plot results (using visualizer)
xnew <- seq(min(exam$VRQ.score), max(exam$VRQ.score), length.out = 400)
pred <- predict(mod, newdata = data.frame(VRQ.score = xnew), 
                type = "terms", conf.int = TRUE)
visualizer1(x = xnew, y = pred$fit, lwr = pred$lwr, upr = pred$upr,
            xlab = "VRQ.score", ylab = "Exam.score", main = "VRQ.score effect")

gammi documentation built on April 4, 2025, 4:48 a.m.

Related to visualizers in gammi...