resume: Resume HMC using a previous fit

Description Usage Arguments Value References See Also Examples

View source: R/resume_hmc.R

Description

Perform HMC using a previously compiled Stan model. This is specifically useful in cases when a previous fit failed to converged (i.e., Rhat > 1.1 for a portion of parameter estimates), thus requiring more iterations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
resume(object, ...)

## S3 method for class 'effects'
resume(
  object,
  init_type = c("last", "orig"),
  inits,
  iters,
  warmup = iters/2,
  chains = 1,
  cores = 1,
  seed = object$seeds$next_seed,
  return_summary = TRUE,
  verbose = FALSE,
  ...
)

Arguments

object

(required) Ouput of est.functions.

...

Additional arguments for methods.

init_type

Type of initial parameters, either the original set that was passed to est.functions or the last parameter sample from the reused fit. Defaults to last.

inits

List of values for parameter initialization. Overrides init_type.

iters

Number of iterations for for fitting. Defaults to 300 and 100 for HMC and ML, respectively.

warmup

For HMC, proportion of iterations devoted to warmup. Defaults to iters/2.

chains

For HMC, number of parallel chains. Defaults to 1.

cores

For HMC, number of cores to parallelize chains. Defaults to 1.

seed

Seed for the random number generator to reproduce previous results.

return_summary

Logical flag to return results summary. Defaults to TRUE.

verbose

Logical flag to print progress information. Defaults to FALSE.

Value

An object of class effects containing

model

List containing the parameters, fit, and summary.

gene_table

Dataframe containing the formatted predicted gene information from predict.topics.

References

Stan Development Team. 2016. RStan: the R interface to Stan. http://mc-stan.org

See Also

stan est.functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
formula <- ~DIAGNOSIS
refs <- 'Not IBD'

dat <- prepare_data(otu_table=GEVERS$OTU,rows_are_taxa=FALSE,tax_table=GEVERS$TAX,
                    metadata=GEVERS$META,formula=formula,refs=refs,
                    cn_normalize=TRUE,drop=TRUE)

## Not run: 
topics <- find_topics(dat,K=15)

functions <- predict(topics,reference_path='/references/ko_13_5_precalculated.tab.gz')

function_effects_init <- est(functions,level=3,iters=150,
                             prior=c('laplace','t','laplace'))
function_effects <- resume(function_effects_init,init_type='last',
                           iters=300,chains=4)

## End(Not run)

EESI/themetagenomics documentation built on May 10, 2020, 1:40 a.m.