R/graphicalLm.R

Defines functions graphicalLm coef.fastVAR.graphicalLm

graphicalLm = function(X, Y, weights, rho) {
  if (is.null(weights)) weights = rep(1, nrow(Y))
  X = scale(scale.rows(X, sqrt(weights)), center = T, scale = F)
  Y = scale(scale.rows(Y, sqrt(weights)), center = T, scale = F)
  X.glasso = glasso(var(X) * (nrow(X) - 1), rho)
  coefficients = X.glasso$wi %*% crossprod(X, Y)
  return (structure(list(coefficients = coefficients),
                    class = "fastVAR.graphicalLm"))
}

coef.fastVAR.graphicalLm = function(graphicalLm, ...) {
  return (graphicalLm$coefficients)
}
jeffwong/fastVAR documentation built on May 19, 2019, 4:02 a.m.