Learn R Programming

GGMncv (version 2.1.2)

coef.ggmncv: Regression Coefficients from ggmncv Objects

Description

There is a direct correspondence between the inverse covariance matrix and multiple regression stephens1998,kwan2014regressionGGMncv. This readily allows for converting the off diagonal elements to regression coefficients, resulting in noncovex penalization for multiple regression modeling.

Usage

# S3 method for ggmncv
coef(object, ...)

Value

A matrix of regression coefficients.

Arguments

object

An Object of class ggmncv.

...

Currently ignored.

References

Examples

Run this code

# \donttest{

# data
Y <- GGMncv::ptsd[,1:5]

# correlations
S <- cor(Y)

# fit model
fit <- ggmncv(R = S, n = nrow(Y), progress = FALSE)

# regression
coefs <- coef(fit)

coefs


# no regularization, resulting in OLS

# data
# note: scaled for lm()
Y <- scale(GGMncv::ptsd[,1:5])

# correlations
S <- cor(Y)

# fit model
# note: non reg
fit <- ggmncv(R = S, n = nrow(Y), progress = FALSE, lambda = 0)

# regression
coefs <- coef(fit)

# fit lm
fit_lm <- lm(Y[,1] ~ 0 + Y[,-1])

# ggmncv
coefs[1,]

# lm
as.numeric(coef(fit_lm))

# }

Run the code above in your browser using DataLab