get_vcov: Get the variance-covariance matrix of a gamlss object in any...

Description Usage Arguments Details Value Examples

View source: R/vcov_env.R

Description

The vcov.gamlss method relies on the object passed to the data parameter of the call to gamlss::gamlss to be found in the global environment. However, this may well not be the case, especially if the object were fit inside a function. The object may also exist but have changed its value.

It would be ideal to simply pass the dataframe to vcov.gamlss directly, but that would need to adjust the gamlss package (as I don't know how to create the same package but with a different name and this slight adjustment), which I would rather avoid.

So, this function assigns the dataframe to the global environment with the name that was passed to mod.

Usage

1
get_vcov(mod, data, data_name)

Arguments

mod

gamlss object. Object of class gamlss.

data

dataframe. Dataframe originally passed to data parameter in gamlss function used to fit mod.

data_name

character. Name of object passed to data parameter in gamlss function used to fit mod.

Details

It's unclear what would happen under parallel processing or if the user were altering this object in the global environment as well.

Value

Variance-covariance matrix as output by vcov.gamlss.

Examples

1
2
3
data_test <- data.frame(x = runif(10))
data_test[['y']] <- 3 * data_test[['x']] + rnorm(10, sd = 1)
mod_gam <- gamlss::gamlss(y ~ x, data = data_test)

MiguelRodo/gamlssutils documentation built on July 9, 2020, 12:48 a.m.