plot_lm: Plotting several kinds of regression line

Description Usage Arguments Details Value See Also Examples

Description

Plot a regression line for linear, orthogonal, local-polynomial, kernel, cubic smoothing spline, or GAM regressions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
plot_lm(
  x,
  y,
  col = "#00000040",
  lcol = "#FF0000BF",
  ci.col = "#ffd800",
  cex = 0.8,
  pch = 16,
  xlab = NULL,
  ylab = NULL,
  args.func = list(),
  interval = c("none", "confidence", "prediction"),
  ...
)

plot_ortho(
  x,
  y,
  col = "#00000040",
  lcol = "#FF0000BF",
  cex = 0.8,
  pch = 16,
  xlab = NULL,
  ylab = NULL,
  args.func = list(),
  ...
)

plot_loess(
  x,
  y,
  col = "#00000040",
  lcol = "#FF0000BF",
  cex = 0.8,
  pch = 16,
  xlab = NULL,
  ylab = NULL,
  args.func = list(),
  ...
)

plot_kernel(
  x,
  y,
  col = "#00000040",
  lcol = "#FF0000BF",
  cex = 0.8,
  pch = 16,
  xlab = NULL,
  ylab = NULL,
  args.func = list(),
  ...
)

plot_spline(
  x,
  y,
  col = "#00000040",
  lcol = "#FF0000BF",
  cex = 0.8,
  pch = 16,
  xlab = NULL,
  ylab = NULL,
  args.func = list(),
  ...
)

plot_gam(
  x,
  y,
  col = "#00000040",
  lcol = "#FF0000BF",
  cex = 0.8,
  pch = 16,
  xlab = NULL,
  ylab = NULL,
  args.func = list(),
  ...
)

Arguments

x, y

vectors of x- and y-axis values.

col

vector of point colors.

lcol

vector of line colors.

ci.col

confidence interval color.

cex

numeric vector for scaling point size.

pch

a vector of plotting characters or symbols: see points.

xlab, ylab

character strings for axis labels.

args.func

further arguments passed to the regression function.

interval

type of interval calculation, for linear model only.

...

further arguments passed to plot.

Details

Plots a scatterplot with a regression line, useful for quick exploratory analysis.

Value

A plot object.

See Also

lm, prcomp, loess, ksmooth, smooth.spline, and gam for the underlying functions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set.seed(23)
n <- 55
x <- sin(1:n/pi)
y <- runif(n, 0, 0.75) + x
x[12] <- NA  # handles NA
set_par(6)
plot_lm(x, y, main='Linear', interval='confidence')
plot_ortho(x, y, main='Orthogonal') # not identical to linear!
plot_loess(x, y,  args.func=list(span=0.2), main='Loess')
plot_kernel(x, y, args.func=list(bandwidth=0.2), main='Kernel')
plot_spline(x, y, args.func=list(df=11), main='Spline')
plot_gam(x, y, args.func=list(gamma=0.5), main='GAM')

phytomosaic/ecole documentation built on Jan. 2, 2022, 11:24 p.m.