From 1bb0131cc9bb175fe40b7feb1d1d7a0422bf6142 Mon Sep 17 00:00:00 2001 From: Nima Hejazi Date: Mon, 15 Apr 2024 01:59:49 -0400 Subject: [PATCH] reduce defaults for knot points --- DESCRIPTION | 2 +- NEWS.md | 12 ++++++++---- R/formula_hal9001.R | 1 + R/hal.R | 7 ++++--- man/fit_hal.Rd | 2 +- man/formula_helpers.Rd | 22 ++++++++++++++++++++++ 6 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 man/formula_helpers.Rd diff --git a/DESCRIPTION b/DESCRIPTION index a57654b8..eb67a18f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -68,5 +68,5 @@ LinkingTo: Rcpp, RcppEigen VignetteBuilder: knitr -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Roxygen: list(markdown = TRUE) diff --git a/NEWS.md b/NEWS.md index c04ae0c2..db88bf16 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,19 +1,23 @@ # hal9001 0.4.6 * Fixed predict method to address changes required by Matrix 1.6.2 +* Reduced default number of knots used for zero-order and first-order basis + expansions as follows: + * `base_num_knots_0` set to 20, used to be 200 + * `base_num_knots_1` set to 10, used to be 50 # hal9001 0.4.5 * Added multivariate outcome prediction # hal9001 0.4.4 -* Fixed bug with `prediction_bounds` (a `fit_hal` argument in `fit_control` - list), which would error when it was specified as a numeric vector. Also, +* Fixed bug with `prediction_bounds` (a `fit_hal` argument in `fit_control` + list), which would error when it was specified as a numeric vector. Also, added a check to assert this argument is correctly specified, and tests to ensure a numeric vector of bounds is provided. * Simplified `fit_control` list arguments in `fit_hal`. Users can still specify additional arguments to `cv.glmnet` and `glmnet` in this list. * Defined `weights` as a formal argument in `fit_hal`, opposed to an optional - argument in `fit_control`, to facilitate specification and avoid confusion. - This increases flexibility with SuperLearner wrapper `SL.hal9001` as well; + argument in `fit_control`, to facilitate specification and avoid confusion. + This increases flexibility with SuperLearner wrapper `SL.hal9001` as well; `fit_control` can now be customized with `SL.hal9001`. # hal9001 0.4.3 diff --git a/R/formula_hal9001.R b/R/formula_hal9001.R index fe3b85a2..973c226c 100644 --- a/R/formula_hal9001.R +++ b/R/formula_hal9001.R @@ -251,6 +251,7 @@ print.formula_hal9001 <- function(x, ...) { cat(paste0("A hal9001 formula object of the form: ~ ", x$formula_term)) } +#' Formula Helpers #' #' @param var_names A \code{character} vector of variable names representing a single type of interaction # " (e.g. var_names = c("W1", "W2", "W3") encodes three way interactions between W1, W2 and W3. diff --git a/R/hal.R b/R/hal.R index 864263c2..31ecf795 100644 --- a/R/hal.R +++ b/R/hal.R @@ -179,11 +179,12 @@ fit_hal <- function(X, num_knots = num_knots_generator( max_degree = max_degree, smoothness_orders = smoothness_orders, - base_num_knots_0 = 200, - base_num_knots_1 = 50 + base_num_knots_0 = 20, + base_num_knots_1 = 10 ), reduce_basis = NULL, - family = c("gaussian", "binomial", "poisson", "cox", "mgaussian"), + family = c("gaussian", "binomial", "poisson", "cox", + "mgaussian"), lambda = NULL, id = NULL, weights = NULL, diff --git a/man/fit_hal.Rd b/man/fit_hal.Rd index 8f67fdf1..1809f2e0 100644 --- a/man/fit_hal.Rd +++ b/man/fit_hal.Rd @@ -12,7 +12,7 @@ fit_hal( max_degree = ifelse(ncol(X) >= 20, 2, 3), smoothness_orders = 1, num_knots = num_knots_generator(max_degree = max_degree, smoothness_orders = - smoothness_orders, base_num_knots_0 = 200, base_num_knots_1 = 50), + smoothness_orders, base_num_knots_0 = 20, base_num_knots_1 = 10), reduce_basis = NULL, family = c("gaussian", "binomial", "poisson", "cox", "mgaussian"), lambda = NULL, diff --git a/man/formula_helpers.Rd b/man/formula_helpers.Rd new file mode 100644 index 00000000..6e0b0706 --- /dev/null +++ b/man/formula_helpers.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/formula_hal9001.R +\name{fill_dots} +\alias{fill_dots} +\title{Formula Helpers} +\usage{ +fill_dots(var_names, .) +} +\arguments{ +\item{var_names}{A \code{character} vector of variable names representing a single type of interaction +var_names may include the wildcard variable "." in which case the argument \code{.} must be specified +so that all interactions matching the form of var_names are generated.} + +\item{.}{Specification of variables for use in the formula. +This function takes a character vector \code{var_names} of the form c(name1, name2, ".", name3, ".") +with any number of name{int} variables and any number of wild card variables ".". +It returns a list of character vectors of the form c(name1, name2, wildcard1, name3, wildcard2) +where wildcard1 and wildcard2 are iterated over all possible character names given in the argument \code{.}.} +} +\description{ +Formula Helpers +}