make_vt_data | R Documentation |
Makes custom visual testing objects that can be used as input to the viztest()
function. This is useful in the case
where coef()
and vcov()
do not function as expected on objects of interest, where the user wants to intervene with some
modification to the usual estimates or (more likely) variance-covariance matrix or where normal theory tests may not be
as useful (e.g., in the case of simulations of non-normal values). The examples section below shows how this could be leveraged
to use a heteroskedasticity-consistent covariance matrix in the test rather than the one returned by lm()
.
make_vt_data(estimates, variances = NULL, type = c("est_var", "sim"), ...)
estimates |
A vector of estimates if type is |
variances |
In the case of independent estimates, a vector of variances of the same length
as |
type |
Indicates the type of input data either estimates with variances or a variance-covariance matrix or data from a simulation. |
... |
Other arguments passed down, currently not implemented. |
An object of class "vtcustom" that takes one of two forms:
A list with estimates and a variance-covariance matrix. In this case, the functionms coef.vtcustom()
and vcov.vtcustom()
are
used to extract the coefficients and variance-covariance matrix in a way that will work with viztest.default()
.
An object of class "vtsim" that has a single element - the data giving the draws from the simulation.
data(mtcars)
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$hp <- scale(mtcars$hp)
mtcars$wt <- scale(mtcars$wt)
mod <- lm(qsec ~ hp + wt + cyl, data=mtcars)
V <- sandwich::vcovHC(mod, "HC3")
vtdat <- make_vt_data(coef(mod), V)
viztest(vtdat,
test_level = .025,
include_intercept = FALSE,
include_zero = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.