1
#' Estimation of Sigma2 for Linear Mixed Model with Lasso Penalty
2
#'
3
#' @description \code{sigma2lasso} estimates the value of the sigma2 for the
4
#'   linear mixed model with lasso penalty
5
#'
6
#' @seealso \code{\link{ggmix}}
7
#' @param ggmix_object A ggmix_object object of class \code{lowrank} or
8
#'   \code{fullrank}
9
#' @param beta current estimate of the beta parameter including the intercept.
10
#'   this should be of length p+1, where p is the number of variables.
11
#' @param eta current estimate of the eta parameter
12
#' @param n number of observations
13
#' @param ... Extra parameters. Currently ignored.
14
#' @return A decreasing sequence of tuning parameters
15
#' @note There is a closed form solution for sigma^2, given beta and eta. This
16
#'   function isn't meant to be called directly by the user.
17 4
sigma2lasso <- function(ggmix_object, ...) UseMethod("sigma2lasso")
18

19
#' @rdname sigma2lasso
20
sigma2lasso.default <- function(ggmix_object, ...) {
21 0
  stop(strwrap("This function should be used with a ggmix object of class
22 0
               lowrank or fullrank"))
23
}
24

25
#' @rdname sigma2lasso
26
sigma2lasso.fullrank <- function(ggmix_object,
27
                                 ...,
28
                                 n, beta, eta) {
29 4
  x <- ggmix_object[["x"]]
30 4
  y <- ggmix_object[["y"]]
31 4
  eigenvalues <- ggmix_object[["D"]]
32

33 4
  (1 / n) * sum(((y - x %*% beta)^2) / (1 + eta * (eigenvalues - 1)))
34
}
35

36

37
# still need to create sigma2lasso.lowrank, sigma2gglasso.fullrank, sigma2gglasso.lowrank

Read our documentation on viewing source code .

Loading