Learn R Programming

glamlasso (version 3.0.1)

objective: Compute objective values

Description

Computes the objective values of the penalized log-likelihood problem for the models implemented in the package glamlasso.

Usage

objective(Y, 
          Weights, 
          X, 
          Beta, 
          lambda,
          penalty.factor, 
          family,
          penalty)

Arguments

Y

The response values, an array of size \(n_1 \times \cdots \times n_d\).

Weights

Observation weights, an array of size \(n_1 \times \cdots \times n_d\).

X

A list containing the tensor components of the tensor design matrix, each of size \(n_i \times p_i\).

Beta

A coefficient matrix of size \(p_1\cdots p_d \times \)nlambda.

lambda

The sequence of penalty parameters for the regularization path.

penalty.factor

An array of size \(p_1 \times \cdots \times p_d\). Is multiplied with each element in lambda to allow differential shrinkage on the coefficients.

family

A string specifying the model family (essentially the response distribution).

penalty

A string specifying the penalty.

Value

A vector of length length(lambda) containing the objective values for each lambda value.

Examples

Run this code
# NOT RUN {
n1 <- 65; n2 <- 26; n3 <- 13; p1 <- 13; p2 <- 5; p3 <- 4
X1 <- matrix(rnorm(n1 * p1), n1, p1) 
X2 <- matrix(rnorm(n2 * p2), n2, p2) 
X3 <- matrix(rnorm(n3 * p3), n3, p3) 
Beta <- array(rnorm(p1 * p2 * p3) * rbinom(p1 * p2 * p3, 1, 0.1), c(p1 , p2, p3))
mu <- RH(X3, RH(X2, RH(X1, Beta)))
Y <- array(rnorm(n1 * n2 * n3, mu), dim = c(n1, n2, n3))
fit <- glamlasso(list(X1, X2, X3), Y, family = "gaussian", penalty = "lasso", iwls = "exact")
objfit <- objective(Y, NULL, list(X1, X2, X3), fit$coef, fit$lambda, NULL, fit$family)
plot(objfit, type = "l")
# }

Run the code above in your browser using DataLab