{Compack}R Documentation

Extract estiamted coefficients from a "cv.FuncompCGL" object.


This function gets the coefficients from a cross-validated FuncompCGL model, using the stored "" object, and the optimal grid values of the penalty parameter lam and the degrees of freedom k.


## S3 method for class 'cv.FuncompCGL'
coef(object, trim = FALSE, s = c("lam.min", "lam.1se"), k = NULL, ...)



fitted cv.FuncompCGL object.


logical; whether to use the trimmed result. Default is FALSE.


value(s) of the penalty parameter lam at which coefficients are requested.

  • s="lam.min"(default), grid value of lam and k stored in the "cv.FuncompCGL" object such that the minimum cross-validation error is achieved.

  • s="lam.1se", grid value of lam and k stored on the "cv.FuncompCGL" object such that the 1 standard error above the miminum cross-validation error is achieved.

  • If s is numeric, it is taken as the value(s) of lam to be used. In this case, k must be provided.

  • If s = NULL, the whole sequence of lam stored in the cv.FuncompCGL object is used.


value(s) of the degrees of freedom of the basis function at which coefficents are requested. k can be NULL (default) or integer(s).

  • k = NULL, s must be either "lam.min" or "lam.1se".

  • if k is an integer(s), it is taken as the value of k to be used and it must be one(s) of these in the "cv.FuncompCGL" object.


not used.


s is a vector of lambda values at which the coefficients are requested. If s is not in the lam sequence used for fitting the model, the coef function will use linear interpolation, so the function should be used with caution.


The coefficients at the requested values of s and k. If k is a vector, a list of coefficient matrices is returned.


Zhe Sun and Kun Chen


Sun, Z., Xu, W., Cong, X., Li G. and Chen K. (2020) Log-contrast regression with functional compositional predictors: linking preterm infant's gut microbiome trajectories to neurobehavioral outcome, Annals of Applied Statistics

See Also

cv.FuncompCGL and FuncompCGL, and predict and plot methods for "cv.FuncompCGL" object.


df_beta = 5
p = 30
beta_C_true = matrix(0, nrow = p, ncol = df_beta)
beta_C_true[1, ] <- c(-0.5, -0.5, -0.5 , -1, -1)
beta_C_true[2, ] <- c(0.8, 0.8,  0.7,  0.6,  0.6)
beta_C_true[3, ] <- c(-0.8, -0.8 , 0.4 , 1 , 1)
beta_C_true[4, ] <- c(0.5, 0.5, -0.6  ,-0.6, -0.6)
Data <- Fcomp_Model(n = 50, p = p, m = 0, intercept = TRUE,
                    SNR = 4, sigma = 3, rho_X = 0, rho_T = 0.6, df_beta = df_beta,
                    n_T = 20, obs_spar = 1, theta.add = FALSE,
                    beta_C = as.vector(t(beta_C_true)))

cv_m1 <-  cv.FuncompCGL(y = Data$data$y, X = Data$data$Comp,
                        Zc = Data$data$Zc, intercept = Data$data$intercept,
                        k = c(4,5), nfolds = 5, nlam = 50,
                        keep = TRUE)
coef(cv_m1, s = "lam.1se")
coef(cv_m1, s = c(0.5, 0.1, 0.05), k = c(4,5))
coef(cv_m1, s = NULL, k = c(4,5))

[Package Compack version 0.1.0 Index]