spicer_soft: Soft spices

Description Usage Arguments Value Examples

View source: R/spice.R

Description

If you use Rstudio, the masher and spicer functions can help remind you which parameters go along with which ipa_brew flavor. The basic idea is to write spice(brew, with = spicer_<flavor>()) and mash(brew, with = masher_<flavor>()). Hitting the tab key with your curser inside the parentheses of masher_flavor()will create a drop-down menu that shows a list of the arguments that go along with your brew's flavor.

If you have no trouble remembering the parameters that go along with your brew's flavor, or if you just want your code to be more concise, you don't have to use the with argument. Instead, you can just specify parameter values directly using the ... argument in the mash and spice functions. In the examples below, both approaches are shown.

Usage

1
2
3
4
5
6
7
spicer_soft(
  rank_max_init = 2L,
  rank_max_ovrl = NULL,
  rank_stp_size = 1L,
  lambda = NULL,
  grid = FALSE
)

Arguments

rank_max_init

an integer value that restricts the rank of the solution for the first softImpute fit. Sequential fits may have higher rank depending upon rank_max_ovrl, rank_stp_size, and grid.

rank_max_ovrl

an integer value that restricts the rank of the solution for all softImpute fits.

rank_stp_size

an integer value that indicates how much the maximum rank of softImpute fits should increase between iterations.

lambda

nuclear-norm regularization parameter. If lambda = 0, the algorithm reverts to "hardImpute", for which convergence is typically slower, and to local minimum. Ideally lambda should be chosen so that the solution reached has rank slightly less than rank.max. See also lambda0() for computing the smallest lambda with a zero solution.

grid

a logical value. If TRUE, all combinations of rank and lambda are used to fit softImpute models. If FALSE, then one fit is supplied for each value of lambda, and increasing maximum ranks are paired with decreasing values of lambda.

Value

a list with input values that can be passed directly into spice, e.g spice(brew, with = spicer_nbrs()) for a neighbors brew or spice(brew, with = spicer_soft()) for a soft brew.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data <- data.frame(
  x1 = 1:10,
  x2 = 10:1,
  x3 = rnorm(10),
  outcome = 11 + runif(10)
)

data[1:2, 1:2] = NA

knn_brew <- brew(data, outcome = outcome, flavor = 'kneighbors')
sft_brew <- brew(data, outcome = outcome, flavor = 'softImpute')

# these two calls are equivalent
spicy_knn <- spice(knn_brew, with = spicer_nbrs(k_neighbors = c(3, 5)))
spicy_knn <- spice(knn_brew, k_neighbors = c(3, 5))

# these two calls are equivalent
spicy_sft <- spice(sft_brew, with = spicer_soft(grid = TRUE))
spicy_sft <- spice(sft_brew, grid = TRUE)

bcjaeger/ipa documentation built on May 7, 2020, 9:45 a.m.