Learn R Programming

ezsim (version 0.5.5)

setBanker.parameterDef: Set a parameterDef Object.

Description

setBanker sets the scalar parameters of a parameterDef object. setBanker are "call by reference", so assignment is not needed to update the parameterDef object. In other words, they will overwrite the value of its argument(parameterDef object). parameterDef is a short hand of "parameter definition". It defines parameters used by the dgp which is the most important part of a simulation. For each simulation,There is a particular set of parameter. parameterDef allow us to define several parameters for different simulation at once. There are two types of parameter in parameterDef, scalar parameters and other parameters. Scalar parameters must be a scalar. Any vectors or matrix is regarded as a sequence of scalar parameters. For example, n=seq(10,50,10), first simulation takes n=10, second simulation takes n=20 and so on. Other parameters can be anything and it is banker over the scalar parameters. For example, we would like to know how would the sample size affect the variance of the sample mean of normally distributed variable. We can set n=seq(10,50,10), mean=1 and sd=2. (see example)

Usage

"setBanker"(x,...)

Arguments

x
A parameterDef object
...
Variables to be added to a parameterDef object

Value

A parameterDef object

See Also

setSelection.parameterDef,createParDef,evalFunctionOnParameterDef,generate.parameterDef

Examples

Run this code
par_def1<-createParDef(selection=list(mean=1,sd=2,n=seq(10,50,10)))

par_def2<-createParDef()
setSelection(par_def2,mean=1,sd=2,n=seq(10,50,10))

identical(par_def1,par_def2)

evalFunctionOnParameterDef(par_def1, function() rnorm(n,mean,sd) )  # 10 random number
evalFunctionOnParameterDef(par_def1, function() rnorm(n,mean,sd), index=3)  # 30 random number

generate(par_def1)

# More than 1 selection parameters
par_def3<-createParDef(selection=list(sd=2,mean=1:3,n=seq(10,50,10)))

generate(par_def3)

#
par_def4<-createParDef(selection=list(mean=1,sd=2,n=seq(10,50,10)))
setBanker(par_def4,some_matrix=matrix(1:4,nrow=2),some_vector=1:6)
par_def4
generate(par_def4)

Run the code above in your browser using DataLab