Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
haziqj committed Apr 1, 2024
1 parent cc35541 commit f6b31ea
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 158 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ vignettes/cache
*.texpadtmp
/doc/
/Meta/
.DS_Store
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ LazyData: yes
VignetteBuilder:
knitr,
R.rsp
RoxygenNote: 7.3.1
RoxygenNote: 7.2.3
37 changes: 0 additions & 37 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/Kernel_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 0 additions & 54 deletions R/Kernel_loader_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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
Expand Down Expand Up @@ -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.
#
Expand All @@ -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
Expand Down Expand Up @@ -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().
Expand All @@ -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.
#
Expand All @@ -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,
Expand Down Expand Up @@ -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().
#
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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().
Expand All @@ -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.
#
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
27 changes: 0 additions & 27 deletions R/Utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
#
Expand All @@ -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.
#
Expand Down Expand Up @@ -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.
#
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions R/iprior-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit f6b31ea

Please sign in to comment.