From f6b31eacf58e79d5f3c18d8b490208c1d4f034e1 Mon Sep 17 00:00:00 2001 From: Haziq Jamil Date: Mon, 1 Apr 2024 23:58:13 +0800 Subject: [PATCH] Fix documentation --- .gitignore | 1 + DESCRIPTION | 2 +- NAMESPACE | 37 --------------------------- R/Kernel_functions.R | 2 +- R/Kernel_loader_helper.R | 54 ---------------------------------------- R/Utilities.R | 27 -------------------- R/iprior-package.R | 8 ++++-- R/iprior_helper.R | 30 ---------------------- README.md | 6 ++--- man/iprior-package.Rd | 3 ++- man/kernel.Rd | 2 +- vignettes/tecator.Rmd | 2 +- 12 files changed, 16 insertions(+), 158 deletions(-) diff --git a/.gitignore b/.gitignore index bf7affa..9e34124 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ vignettes/cache *.texpadtmp /doc/ /Meta/ +.DS_Store diff --git a/DESCRIPTION b/DESCRIPTION index 01f3e96..7c29d20 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,4 +35,4 @@ LazyData: yes VignetteBuilder: knitr, R.rsp -RoxygenNote: 7.3.1 +RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index f8201f5..6a6582c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,45 +24,8 @@ S3method(print,time) S3method(sigma,ipriorMod) S3method(summary,ipriorMod) S3method(update,ipriorMod) -export(.A_times_a) -export(.calc_Hlam) -export(.checkLevels) -export(.collapse_param) -export(.convert_se) -export(.correct_pearson_kernel) -export(.deal_with_one.lam) -export(.eigen_Hlam) -export(.eigen_Hlam_nys) -export(.em_loop_logical) -export(.expand_Hl_and_lambda) -export(.expand_theta) -export(.fix_call_default) -export(.fix_call_formula) -export(.formula_to_xy) -export(.get_Hl) -export(.get_Hlam) -export(.get_Htildelam) -export(.get_Xl.nys) -export(.get_hyperparam) -export(.get_kernels_from_Hl) -export(.get_polydegree) -export(.get_y_and_levels) -export(.iprior_method_checker) -export(.is.categorical) -export(.is.ipriorKernel_cv) export(.kernel_summary_translator) -export(.kernel_to_param) -export(.kernel_translator) export(.kernels_for_summary) -export(.param_to_kernel) -export(.param_to_theta) -export(.param_translator) -export(.reduce_theta) -export(.terms_to_xy) -export(.theta_to_collapsed_param) -export(.theta_to_kernel) -export(.theta_to_param) -export(.update_control) export(as.time) export(check_theta) export(dec_plac) diff --git a/R/Kernel_functions.R b/R/Kernel_functions.R index 730c158..788f32b 100644 --- a/R/Kernel_functions.R +++ b/R/Kernel_functions.R @@ -62,7 +62,7 @@ #' kern_linear(1:3) #' kern_fbm(1:5, 1:3, gamma = 0.7) #' -#' @references \url{http://phd.haziqj.ml/intro/} +#' @references \url{https://phd.haziqj.ml/intro/} #' #' @name kernel #' @aliases kernels diff --git a/R/Kernel_loader_helper.R b/R/Kernel_loader_helper.R index c39c1f9..03dd10e 100644 --- a/R/Kernel_loader_helper.R +++ b/R/Kernel_loader_helper.R @@ -41,9 +41,6 @@ param_to_kernel <- function(param) { as.character(param$kernels) } -#' @export -.param_to_kernel <- param_to_kernel - theta_to_kernel <- function(theta, object) { # Convert theta to vector of kernels. # @@ -54,9 +51,6 @@ theta_to_kernel <- function(theta, object) { param_to_kernel(param) } -#' @export -.theta_to_kernel <- theta_to_kernel - param_to_theta <- function(param, est.list, logpsi = 0) { # Convert param table to the theta vector. Note that theta is designed so that # the values are unbounded, i.e. hurst is Phi^{-1}(hurst), lengthscale is @@ -86,9 +80,6 @@ param_to_theta <- function(param, est.list, logpsi = 0) { theta.omitted = theta.omitted) } -#' @export -.param_to_theta <- param_to_theta - kernel_to_param <- function(kernels, lambda) { # Convert vector of kernels to a param table. # @@ -115,9 +106,6 @@ kernel_to_param <- function(kernels, lambda) { res } -#' @export -.kernel_to_param <- kernel_to_param - reduce_theta <- function(theta.full, est.list) { # The user may specify for some of the hyperparameters to not be estimated, # therefore theta vector should be smaller than the full set of @@ -163,9 +151,6 @@ reduce_theta <- function(theta.full, est.list) { theta.drop = theta.drop) } -#' @export -.reduce_theta <- reduce_theta - expand_theta <- function(theta.reduced, theta.drop, theta.omitted) { # This convertes the reduced theta vector back to the full theta vector. # Useful in other functions such as theta_to_param(). @@ -182,9 +167,6 @@ expand_theta <- function(theta.reduced, theta.drop, theta.omitted) { theta.full } -#' @export -.expand_theta <- expand_theta - collapse_param <- function(param) { # Args: A param table. # @@ -208,9 +190,6 @@ collapse_param <- function(param) { list(param = res, na = na) } -#' @export -.collapse_param <- collapse_param - theta_to_param <- function(theta, object) { # Args: A vector of parameters to be optimised, including logpsi. object must # be either a ipriorKernel type object, or a list containing param.na, @@ -249,9 +228,6 @@ theta_to_param <- function(theta, object) { param } -#' @export -.theta_to_param <- theta_to_param - param_translator <- function(x) { # Helper function in theta_to_param(). # @@ -268,9 +244,6 @@ param_translator <- function(x) { "linear" } -#' @export -.param_translator <- param_translator - correct_pearson_kernel <- function(x, which.pearson) { # When using theta_to_param(), unable to identify which data x uses the # Pearson kernel. This helper function corrects it by reading from the logical @@ -284,9 +257,6 @@ correct_pearson_kernel <- function(x, which.pearson) { x } -#' @export -.correct_pearson_kernel <- correct_pearson_kernel - kernel_translator <- function(x, y = NULL, kernel, lam.poly = 1) { # Used as a helper function in get_Hl() to output list of kernel # matrices in kernL2() and predict(). For future expansion, add new kernels @@ -329,9 +299,6 @@ kernel_translator <- function(x, y = NULL, kernel, lam.poly = 1) { call. = FALSE) } -#' @export -.kernel_translator <- kernel_translator - theta_to_collapsed_param <- function(theta, object) { # This is a wrapper function for theta_to_param(). It is useful to get # the vector of parameters directly from theta. @@ -343,9 +310,6 @@ theta_to_collapsed_param <- function(theta, object) { c(collapse_param(param)$param, theta_to_psi(theta, object)) } -#' @export -.theta_to_collapsed_param <- theta_to_collapsed_param - theta_to_psi <- function(theta, object) { # Obtains psi from the theta vector, or if not estimated, from the # ipriorKernel object. @@ -373,9 +337,6 @@ get_hyperparam <- function(x) { as.numeric(unlist(strsplit(x, ","))[2]) } -#' @export -.get_hyperparam <- get_hyperparam - get_polydegree <- function(x) { # Obtain the degree of the polynomial kernel. Note: the exported version is # get_degree(). @@ -392,9 +353,6 @@ get_polydegree <- function(x) { degree } -#' @export -.get_polydegree <- get_polydegree - get_kernels_from_Hl <- function(x) { # Obtain the kernels used to generate the list of kernel matrices. # @@ -404,9 +362,6 @@ get_kernels_from_Hl <- function(x) { sapply(x, function(x) attributes(x)$kernel) } -#' @export -.get_kernels_from_Hl <- get_kernels_from_Hl - get_Xl.nys <- function(object) { # When using the Nystrom method, we calculate the kernel matrix using # get_Hl(Xl, Xl.nys) which produces a smaller m x n matrix. This is the helper @@ -427,9 +382,6 @@ get_Xl.nys <- function(object) { } } -#' @export -.get_Xl.nys <- get_Xl.nys - get_Hl <- function(Xl, yl = list(NULL), kernels, lambda) { # Obtain the list of kernel matrices. Except for polynomial kernels, these are # not scaled, i.e. not Hlam matrices. @@ -442,9 +394,6 @@ get_Hl <- function(Xl, yl = list(NULL), kernels, lambda) { mapply(kernel_translator, Xl, yl, kernels, lambda, SIMPLIFY = FALSE) } -#' @export -.get_Hl <- get_Hl - expand_Hl_and_lambda <- function(Hl, lambda, intr, intr.3plus, env = NULL) { # Helper function to expand Hl (list of kernel matrices) and lambda (scale # parameters) according to any interactions specification. @@ -485,9 +434,6 @@ expand_Hl_and_lambda <- function(Hl, lambda, intr, intr.3plus, env = NULL) { } } -#' @export -.expand_Hl_and_lambda <- expand_Hl_and_lambda - BlockB_fn <- function(Hl, intr, n, p) { # This is the function which returns the BlockBStuff required for closed-form # EM algorithm. diff --git a/R/Utilities.R b/R/Utilities.R index d1dae8e..4db2aba 100644 --- a/R/Utilities.R +++ b/R/Utilities.R @@ -170,9 +170,6 @@ is.ipriorKernel_cv <- function(x) { } } -#' @export -.is.ipriorKernel_cv <- is.ipriorKernel_cv - #' @rdname is.iprior_x #' @export is.nystrom <- is.ipriorKernel_nys @@ -189,9 +186,6 @@ is.categorical <- function(x) { !is.null(x$y.levels) } -#' @export -.is.categorical <- is.categorical - #' Test kernel attributes #' #' Test whether an object uses a specific type of kernel. @@ -323,12 +317,6 @@ get_y_and_levels <- function(y) { list(y = as.numeric(y), levels = levels(y)) } -#' @export -.checkLevels <- get_y_and_levels - -#' @export -.get_y_and_levels <- get_y_and_levels - fix_call_default <- function(cl = match.call(), new.name = "iprior") { # Replace the default call name with a new name. When using the default call, # it is possible that some of the X names are blank. This fixes that too. @@ -343,9 +331,6 @@ fix_call_default <- function(cl = match.call(), new.name = "iprior") { cl } -#' @export -.fix_call_default <- fix_call_default - fix_call_formula <- function(cl = match.call(), new.name = "iprior") { # Replace the formula call name with a new name. # @@ -356,9 +341,6 @@ fix_call_formula <- function(cl = match.call(), new.name = "iprior") { cl } -#' @export -.fix_call_formula <- fix_call_formula - formula_to_xy <- function(formula, data, one.lam) { # Convert formula entry to y, X entry. # @@ -400,9 +382,6 @@ formula_to_xy <- function(formula, data, one.lam) { tt = tt) } -#' @export -.formula_to_xy <- formula_to_xy - deal_with_one.lam <- function(x, interactions) { # Helper function to convert list of X according to one.lam option. # @@ -430,9 +409,6 @@ deal_with_one.lam <- function(x, interactions) { list(x = x, xname = xname) } -#' @export -.deal_with_one.lam <- deal_with_one.lam - terms_to_xy <- function(object, newdata) { # Args: An ipriorKernel object. tt <- object$terms @@ -452,9 +428,6 @@ terms_to_xy <- function(object, newdata) { list(Xl = x, y = y) } -#' @export -.terms_to_xy <- terms_to_xy - fastSquareRoot2 <- function(x) { # Function to quickly find a square root of a matrix from its # eigendecomposition. diff --git a/R/iprior-package.R b/R/iprior-package.R index 06a89e4..d81bb7c 100644 --- a/R/iprior-package.R +++ b/R/iprior-package.R @@ -31,7 +31,11 @@ #' #' Contributors: \itemize{\item{Wicher Bergsma}} #' -#' @seealso \url{http://phd.haziqj.ml/} -#' +#' @seealso \url{https://phd.haziqj.ml/} #' @keywords internal +#' @aliases iprior-package "_PACKAGE" + +## usethis namespace: start +## usethis namespace: end +NULL diff --git a/R/iprior_helper.R b/R/iprior_helper.R index 2511c86..3d1933b 100644 --- a/R/iprior_helper.R +++ b/R/iprior_helper.R @@ -67,9 +67,6 @@ iprior_method_checker <- function(object, method) { res } -#' @export -.iprior_method_checker <- iprior_method_checker - update_control <- function(arg.list, default.list) { # In most of the iprior_x functions, a list of control options is required. # This helper function checks whether the list supplied contains the allowed @@ -88,9 +85,6 @@ update_control <- function(arg.list, default.list) { default.list } -#' @export -.update_control <- update_control - convert_se <- function(se, theta, object) { # Converts the standard errors for theta into the standard errors for param # using the delta method. These are then used in the summary() method for @@ -117,9 +111,6 @@ convert_se <- function(se, theta, object) { res } -#' @export -.convert_se <- convert_se - get_Hlam <- function(object, theta, theta.is.lambda = FALSE) { # Obtain the scaled kernel matrix Hlam. # @@ -204,15 +195,6 @@ calc_Hlam <- function(Hl, lambda, object) { res } -#' @export -.get_Hlam <- get_Hlam - -#' @export -.get_Htildelam <- get_Htildelam - -#' @export -.calc_Hlam <- calc_Hlam - eigen_Hlam <- function(Hlam, env = NULL) { # The routine for the eigendecomposition of the scaled kernel matrix. # @@ -227,9 +209,6 @@ eigen_Hlam <- function(Hlam, env = NULL) { else list2env(res, env) } -#' @export -.eigen_Hlam <- eigen_Hlam - eigen_Hlam_nys <- function(Hlam, env = NULL) { # The routine for the eigendecomposition of the scaled kernel matrix using # Nystrom approximation. @@ -261,9 +240,6 @@ eigen_Hlam_nys <- function(Hlam, env = NULL) { else list2env(res, env) } -#' @export -.eigen_Hlam_nys <- eigen_Hlam_nys - A_times_a <- function(u, V, a) { # Calculate A %*% a from the eigendecomposition of A. Mostly used to calculate # Vy^{-1} %*% a without having to invert Vy, because the eigendecompostion of @@ -275,9 +251,6 @@ A_times_a <- function(u, V, a) { (V * rep(u, each = nrow(V))) %*% crossprod(V, a) } -#' @export -.A_times_a <- A_times_a - em_loop_logical <- function() { # Helper function to determine when to stop the while loop for the EM # algorithm. @@ -304,9 +277,6 @@ em_loop_logical <- function() { } } -#' @export -.em_loop_logical <- em_loop_logical - get_w <- function(u, V, Vy.inv.y, psi) { # Helper function to obtain posterior mean of I-prior random effects. It is # calculated as psi * Hlam %*% Vy.inv %*% y. diff --git a/README.md b/README.md index fa72760..c40385e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![R-CMD-check](https://github.com/haziqj/iprior/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/haziqj/iprior/actions/workflows/R-CMD-check.yaml) -[![codecov](https://codecov.io/gh/haziqj/iprior/graph/badge.svg?token=W4xTtuyt6r)](https://codecov.io/gh/haziqj/iprior) +[![codecov](https://codecov.io/gh/haziqj/iprior/graph/badge.svg?token=W4xTtuyt6r)](https://app.codecov.io/gh/haziqj/iprior) [![CRAN_Status_Badge_version_ago](http://www.r-pkg.org/badges/version-ago/iprior)](https://cran.r-project.org/package=iprior) [![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/iprior)](https://cran.r-project.org/package=iprior) @@ -21,7 +21,7 @@ The package estimates these parameters using direct log-likelihood maximisation, While the main interest of I-prior modelling is prediction, inference is also possible, e.g. via log-likelihood ratio tests. For installation instructions and some examples of I-prior modelling, continue reading below. -The package is documented with help files, and the [vignette](http://phd.haziqj.ml/iprior_paper.pdf) provides an introduction to the concept of I-priors and also to using the package. +The package is documented with help files, and the [vignette](https://phd.haziqj.ml/iprior_paper.pdf) provides an introduction to the concept of I-priors and also to using the package. ## Installation @@ -38,7 +38,7 @@ or the developmental version from this GitHub repository. R/iprior makes use of - On Mac, install Xcode from the app store. - On Linux, `sudo apt-get install r-base-dev` or similar. -The easiest way to then install from this repo is by using the [devtools](https://github.com/hadley/devtools) package. +The easiest way to then install from this repo is by using the [devtools](https://github.com/r-lib/devtools) package. Install this first. ``` r diff --git a/man/iprior-package.Rd b/man/iprior-package.Rd index 3aeec3e..d2c3183 100644 --- a/man/iprior-package.Rd +++ b/man/iprior-package.Rd @@ -3,6 +3,7 @@ \docType{package} \name{iprior-package} \alias{iprior-package} +\alias{_PACKAGE} \title{\code{iprior}: Regression using priors with Fisher information covariance kernels.} \description{ @@ -19,7 +20,7 @@ log-likelihood or an EM algorithm. } \seealso{ -\url{http://phd.haziqj.ml/} +\url{https://phd.haziqj.ml/} } \author{ \strong{Maintainer}: Haziq Jamil \email{haziq.jamil@gmail.com} diff --git a/man/kernel.Rd b/man/kernel.Rd index 7f9ddb1..f554cc5 100644 --- a/man/kernel.Rd +++ b/man/kernel.Rd @@ -78,5 +78,5 @@ kern_fbm(1:5, 1:3, gamma = 0.7) } \references{ -\url{http://phd.haziqj.ml/intro/} +\url{https://phd.haziqj.ml/intro/} } diff --git a/vignettes/tecator.Rmd b/vignettes/tecator.Rmd index 17966be..42375e8 100644 --- a/vignettes/tecator.Rmd +++ b/vignettes/tecator.Rmd @@ -14,7 +14,7 @@ vignette: > library(iprior) ``` -Continuing on Section 3.4 of the [vignette](http://phd.haziqj.ml/iprior_paper.pdf), we revisit the code used to obtain out-of-sample test error rates, and extend the analysis to a leave-one-out cross-validation (LOOCV) scheme. +Continuing on Section 3.4 of the [vignette](https://phd.haziqj.ml/iprior_paper.pdf), we revisit the code used to obtain out-of-sample test error rates, and extend the analysis to a leave-one-out cross-validation (LOOCV) scheme. # Easy train/test split