R/estimate_eta.R

#' Group-level estimation of eta
#'
#' @param xz_svd,xz_svd_list A compact singular vector decomposition objects or
#' a list of compact singular vector decomposition objects.
#' @param y,y_list A numeric vector or list of numeric vectors  representing the
#' response.
#' @param family A description of the error distribution and link function to be
#' used in the model. See \code{\link{glm}}
#' @return a numeric vector or list of numeric vectors.
estimate_eta <- function(xz_svd, y, family, precision) {
	# PRECISION_COEF <- c(gaussian = 0.0, binomial = 0.2)

	U <- xz_svd$U
	D <- xz_svd$D

	UD <- U %*% D
	# precision <- PRECISION_COEF[family$family] * diag(ncol(UD))
	precision <- precision * diag(ncol(UD))

	fit <- fit_lbfgs(UD, y, precision, family)
	fit$par
}

#' @describeIn estimate_eta Calls \code{estimate_eta} for multiple inputs.
estimate_eta_list <- function(xz_svd_list, y_list, family, precision) {
    Map(estimate_eta, xz_svd_list, y_list, list(family), list(precision))
}
kschmaus/gammmbest documentation built on May 7, 2019, 9 p.m.