Learn R Programming

Infusion (version 2.3.0)

def_projectors: Wrapper to generate projection functions for all parameters

Description

Convenience function automating the initial project.character calls of a typical workflow.

Usage

def_projectors(reftable, pars, stats, npp = 1L, projNames = NULL, 
               npp_opt=Infusion.getOption("npp_opt"), ...)

Value

A list of projectors. Each of them is either an object returned by project.character, or a list inheriting from class "projector" which includes such a return object as one of its elements. The more detailed structure of a "projector" object is not part of the API.

Arguments

reftable

A reference table of simulation as produced by add_reftable.

pars

Fitted parameter names for which projection functions should be returned.

stats

Names of summary statistics to be used for predicting parameter values.

npp, npp_opt

For development purposes.

projNames

Character vector of names of the projections. By default, names are given as paste0("p", pars) (or a more elaborate default when npp > 1L), and these names are checked for possible name conflicts with pre-existing variables in the reftable. Non-default values should be given in case of conflict.

...

Other arguments passed to project.character.

.

Details

The npp > 1L feature is experimental and awaiting further documentation.

Examples

Run this code
## variation on example from help("example_reftable")

if (Infusion.getOption("example_maxtime")>2) {
  blurred <- function(mu,s2,sample.size) {
    s <- rnorm(n=sample.size,mean=mu,sd=sqrt(s2))
    s <- exp(s/4)
    return(c(mean=mean(s),var=var(s)))
  }
  
  set.seed(123)
  dSobs <- blurred(mu=4,s2=1,sample.size=40)
  
  parsp_j <- init_reftable(lower=c(mu=2.5, s2=0.25, sample.size=40), 
                           upper=c(mu=5.2, s2=2.4, sample.size=40))
  dsimuls <- add_reftable(,Simulate="blurred", parsTable=parsp_j,verbose=FALSE)

  ## Then instead of
  #
  # mufit <- project("mu",stats=c("mean","var"),data=dsimuls,verbose=FALSE)
  # s2fit <- project("s2",stats=c("mean","var"),data=dsimuls,verbose=FALSE)
  # dprojectors <- list(MEAN=mufit,VAR=s2fit)
  #
  ## one can use
  #
  dprojectors <- def_projectors(dsimuls, pars=c("mu","s2"), 
                   stats=c("mean","var"), npp = 1L, 
                   projNames = c("MEAN", "VAR"))
                   
  
  ## More speculatively, for non-default 'npp':                   
  dprojectors <- def_projectors(dsimuls, pars=c("mu","s2"), 
                   stats=c("mean","var"), npp = 2L)
}

Run the code above in your browser using DataLab