
Obtains predictions from an R object inheriting class ‘cglasso
’.
# S3 method for cglasso
predict(object, type = c("B", "mu", "Sigma", "Theta"), X.new, lambda.new, rho.new,
…)
# S3 method for cggm
predict(object, X.new, …)
an R object inheriting class ‘cglasso
’, that is, the output of the model-fitting function ‘cglasso
’ or ‘cggm
’.
a description of prediction required.
matrix of new values for X
at which predictions are to be made. This argument is used only if ‘type = "mu"
’.
value of the tuning parameter
value of the tuning parameter
further arguments passed to or from other methods.
The matrix of predicted values.
If object
has S3 class ‘cglasso
’, then for a new pair of the tuning parameters 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
If the object
has S3 class ‘cggm
’, then the predict
function returns only the predicted fitted values using the argument X.new
.
Model-fitting function cglasso
and the other accessor functions coef.cglasso
, fitted.cglasso
, residuals.cglasso
and impute
.
# NOT RUN {
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(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(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
# }
Run the code above in your browser using DataLab