hetplot | R Documentation |
This function creates various two-dimensional scatter plots that can aid in detecting heteroskedasticity in a linear regression model.
hetplot(
mainlm,
horzvar = "index",
vertvar = "res",
vertfun = "identity",
filetype = NA,
values = FALSE,
...
)
mainlm |
Either an object of |
horzvar |
A character vector describing the variable(s) to plot on
horizontal axes ( |
vertvar |
A character vector describing the variable to plot on the
vertical axis ( |
vertfun |
A character vector giving the name of a function to apply to
the |
filetype |
A character giving the type of image file to which the
plot(s) should be written. Values can be |
values |
A logical. Should the sequences corresponding to the
horizontal and vertical variable(s) be returned in a |
... |
Arguments to be passed to methods, such as graphical parameters
(see |
The variable plotted on the horizontal axis could be the original
data indices, one of the explanatory variables, the OLS predicted
(fitted) values, or any other numeric vector specified by the user. The
variable plotted on the vertical axis is some function of the OLS
residuals or transformed version thereof such as the BLUS residuals
\insertCiteTheil68;textualskedastic or standardised or studentised
residuals as discussed in \insertCiteCook83;textualskedastic. A
separate plot is created for each (horzvar
, vertvar
,
vertfun
) combination.
A list containing two data frames
, one
for vectors plotted on horizontal axes and one for vectors plotted
on vertical axes.
plot.lm
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
# Generates 2 x 2 matrix of plots in console
hetplot(mtcars_lm, horzvar = c("index", "fitted.values"),
vertvar = c("res_blus"), vertfun = c("2", "abs"), filetype = NA)
# Generates 84 png files in tempdir() folder
## Not run: hetplot(mainlm = mtcars_lm, horzvar = c("explanatory", "log_explanatory",
"fitted.values2"), vertvar = c("res", "res_stand", "res_stud",
"res_constvar"), vertfun = c("identity", "abs", "2"), filetype = "png")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.