Description Usage Arguments Details Examples
Plots the blm object along with the MAP fit line and quantiles for the fit.
1 2 3 4 5 6 | ## S3 method for class 'blm'
plot(x, explanatory = NULL, show_blm_interval = TRUE,
blm_interval_level = 0.95, expand_fit = TRUE, blm_col = "blue",
blm_map_lty = 1, blm_interval_lty = 2, show_lm = TRUE, lm_col = "red",
lm_lty = 2, caption = "Bayesian lm fit", add_formula = TRUE,
show_legend = TRUE, legend_parm = NULL, xlab, ylab, ...)
|
x |
a blm object. |
explanatory |
name of the explanatory variable to be plotted on the x axis. |
show_blm_interval |
display interval of the blm fitted values? |
blm_interval_level |
level for the interval of the distribution of response to be shown. |
expand_fit |
expand fit lines to the limits of the plot? |
blm_col |
color for the blm fit lines. |
blm_map_lty |
linetype for the blm MAP estimate line. |
blm_interval_lty |
linetype for the blm quantiles line. |
show_lm |
display the regular lm fit on the plot? |
lm_col |
color for the lm fit line. |
lm_lty |
linetype for the lm fit line. |
caption |
title to be added to the plot. |
add_formula |
append formula to the caption. |
show_legend |
add a legend for the fit lines to the plot? |
legend_parm |
list of additional arguments for the legend. |
xlab |
label for the x axis. |
ylab |
label for the y axis. |
... |
other arguments passed to plot. |
Plots the data points used to create the blm
object,
together with the blm fit, 95
(frequentist) lm fit.
explanatory
can be used to specify what parameter is to be
plotted on the x axis. This can be useful ie when plotting models
without a 'pure' explanatory ie y~sin(x); where untransformed 'x'
itself is not part of the model. Providing explanatory = 'x'
will produce the correct output for such models.
expand_fit
shows fit lines and extend to plot limits,
otherwise the fit is only shown for the range covered by the data.
fit_legend_param
a list (of lists) of parameters to
customize the legend. The first item in each slot targets the lm fit
line (if present), the second paramter the blm fit line and the third
paramter the interval lines for the blm fit.
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 | x <- rnorm(100)
b <- 1.3
w0 <- 0.2 ; w1 <- 3 ; w2 <- 10
y <- rnorm(100, mean = w0 + w1 * x + w2 *sin(x), sd = sqrt(1/b))
model <- blm(y ~ x + sin(x), prior = NULL, beta = b,
data = data.frame(x=x, y=y))
##need to do more in case of complex model that does not contain a term 'x'
y <- rnorm(100, mean = w0 + w1 * cos(x), sd = sqrt(1/b))
model <- blm(y ~ cos(x), prior = NULL, beta = b,
data = data.frame(x=x, y=y))
## Not run:
#plots y~cos(x) on the x-axis and this does probably not produce the plot we
want.
plot(model, xlim=c(-10,10))
## End(Not run)
#one can specify that we want 'x' and not 'cos(x)' on the x axis by providing
#the name of the explanatory and we get the correct results
plot(model, explanatory='x', xlim=c(-10,10))
#response and explanatory names do not matter
z_not_x <- rnorm(100)
b <- 1.3
w0 <- 0.2 ; w1 <- 3 ; w2 <- 10
means = w0 + w1 * z_not_x + w2 *sin(z_not_x)
v_not_y <- rnorm(100, means, sd = sqrt(1/b))
formula <- v_not_y ~ z_not_x + sin(z_not_x)
model <- blm(formula, prior = NULL, beta = b,
data = data.frame(z_not_x=z_not_x, v_not_y=v_not_y))
plot(model)
#customizing the plot, almost anything is possible
plot(model, col='purple', pch=19, cex=.3, type='p')
plot(model, col='purple', pch=19, cex=.3, xlim=c(-10,10), ylim=c(-50,50))
plot(model, col='purple', pch=19, cex=.3, xlim=c(-10,10), ylim=c(-50,50),
expand_fit=FALSE)
#customizing the plot lines
plot(model, show_lm=FALSE)
plot(model, show_lm=FALSE, blm_interval_lty=3, blm_col='red')
plot(model, lm_col='blue', lm_lty=4, blm_interval_lty=3, blm_col='red')
plot(model, show_legend=FALSE)
plot(model, legend_parm=list(x='bottomright', cex=.5))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.