#' A master function for total effect estimation
#' @param y A numeric vector
#' @param x A matrix for covariates
#' @param target A character for estimation target
#' @export
total.effect.master <- function(x, y, inter = FALSE,
decorrelation.method = c("none", "historical", "glasso")[1],
rho = NA,
thr = NA,
emp.sigma = NA,
total.effect.method,
total.effect.args.list){
# 1. standardized the x
x <- std.fn(x)
n <- nrow(x)
p <- ncol(x)
# 1.1 add inter terms
if(inter == TRUE){
x <- std.fn((add.inter(x)))
}
# 2 decorrelation
if(decorrelation.method == "historical"){
if(!is.na(emp.sigma)){
x <- empirical.cov.method(x = x, emp.sigma = emp.sigma)$uncorr.data
} else if(is.na(emp.sigma) & (n < p)){
stop("decorrelation with an empirical covariance matrix requires use provide an emperical sigma or the x is n > p")
} else if(is.na(emp.sigma) & (n >= p)){
x <- empirical.cov.method(x = x)$uncorr.data
}
} else if (decorrelation.method == "glasso") {
x <- GLASSO.method(x = x, rho = rho)$uncorr.data
} else if (decorrelation.method == "none") {
x <- x
}
# 3 total.effect calculation
args <- append(list(x = x, y = y), total.effect.args.list)
total.effect.res <- do.call(total.effect.method, args)
# 4 return the final result
res <- list(total.effect.res = total.effect.res,
decorrelation.method = decorrelation.method)
res
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.