| predict | R Documentation |
Obtains predictions from an R object inheriting class ‘cglasso’.
## S3 method for class 'cglasso'
predict(object, type = c("B", "mu", "Sigma", "Theta"), X.new, lambda.new, rho.new,
...)
## S3 method for class 'cggm'
predict(object, X.new, ...)
object |
an R object inheriting class ‘ |
type |
a description of prediction required. |
X.new |
matrix of new values for |
lambda.new |
value of the tuning parameter lambda at which predictions are required. |
rho.new |
value of the tuning parameter rho at which predictions are required. |
... |
further arguments passed to or from other methods. |
If object has S3 class ‘cglasso’, then for a new pair of the tuning parameters lambda and rho, the predict function can be used to predict the estimate of the regression coefficient matrix (‘type = "B"’), the estimate of the covariance matrix (‘type = "Sigma"’) or the estimate of the precision matrix (‘type = "Theta"’). If X.new is missing and ‘type = "mu"’, then the predict function returns the predicted values using the matrix of predictors X, otherwise the predicted fitted values are computed using the matrix X.new.
For a new pair of the tuning parameters lambda and rho, the predicted values are computed using a bilinear interpolation.
If the object has S3 class ‘cggm’, then the predict function returns only the predicted fitted values using the argument X.new.
The matrix of predicted values.
Luigi Augugliaro (luigi.augugliaro@unipa.it)
Model-fitting function cglasso and the other accessor functions coef.cglasso, fitted.cglasso, residuals.cglasso and impute.
set.seed(123) # Y ~ N(0, Sigma) and probability of left/right censored values equal to 0.05 n <- 100L p <- 3L rho <- 0.3 Sigma <- outer(1L:p, 1L:p, function(i, j) rho^abs(i - j)) Z <- rcggm(n = n, Sigma = Sigma, probl = 0.05, probr = 0.05) out <- cglasso(. ~ ., data = Z) rho.new <- mean(out$rho) Theta.pred <- predict(out, rho.new = rho.new, type = "Theta") Theta.pred # Y ~ N(b0 + XB, Sigma) and probability of left/right censored values equal to 0.05 n <- 100L p <- 3L q <- 2 b0 <- runif(p) B <- matrix(runif(q * p), nrow = q, ncol = p) X <- matrix(rnorm(n * q), nrow = n, ncol = q) rho <- 0.3 Sigma <- outer(1L:p, 1L:p, function(i, j) rho^abs(i - j)) Z <- rcggm(n = n, b0 = b0, X = X, B = B, Sigma = Sigma, probl = 0.05, probr = 0.05) out <- cglasso(. ~ ., data = Z) rho.new <- mean(out$rho) lambda.new <- mean(out$lambda) Theta.pred <- predict(out, lambda.new = lambda.new, rho.new = rho.new, type = "Theta") Theta.pred