compute.slices2: Compute the objective function on a grid of params and show...

Description Usage Arguments Value Examples

Description

Essentially the same as compute.slices, but does not report simulated moments but other model output. Useful for model output that is multidimensional. It's a simplified version of compute.slices in that it does not further process the model output: it return a list with nests "parameter name", "value of parameter", "model output". For example instead of reporting the mean of a certain statistic, this function can return a matrix or a higher dimensional array. Say you want to return the life-cycle profile of a certain model variable x. This will be a vector of length N, where N is the number of periods in the model. The user has to design the MOPT_OBJ_FUN in such a way that it returns the required output. There are 2 requirements for what MOPT_OBJ_FUN has to return. First it has to be a list, second, the list needs components "status" (indicating whether a particular evaluation is valid in some sense) and "output", which contains your custom model output.

Usage

1
compute.slices2(mcf, ns = 30, pad = 0.1, file = "est.slices.RData")

Arguments

mcf

object of class mopt

ns

number of points in each dimension to evaluate

pad

from bounds of parameter ranges. e.g. p in [0,1], avoid 0 and 1 with pad>0.

file

/path/to/your/file.RData

Value

list by paramter name, parameter value index, containing the value of the parameter vector and a list data containing your custom model output.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# generate custom output for a model
require(mopt)

# let's take a dummy objective function
MOPT_OBJ_FUNC <- objfc.norm2.custom(c(0,0),ns=2000)

# starting parameters
p <- list(x1=0.5,x2=0.5)
MOPT_OBJ_FUNC(p)

# then we want to setup the mopt
mcf                  = mopt_config(p)
mcf$wd               = getwd()
mcf$params_to_sample = c('x1','x2')
mcf$mode             = 'multicore'
mcf$algo             = algo.bgp


# set the parameter bounds
mcf <- mcf + 
  samplep('x1',-1,1) +
  samplep('x2',-1,1)


# prepare to run with OpenMP
require(parallel)
options(mc.cores = detectCores())

# finalize the preparation
mcf <- prepare.mopt_config(mcf)

# compute slices and generate plots
res <- compute.slices2(mcf,ns=30,pad=0.1)

tlamadon/mopt documentation built on May 31, 2019, 3:48 p.m.