fit_Schelegle: Fit the model from Schelegle et al.

Description Usage Arguments Value Author(s) Examples

Description

This function 'fits' the model from Schelegle et al papers. Since the number of parameters is relatively small and the response surface has many local optimum, this function conducts a grid search.

Usage

1
fit_Schelegle(data, bounds = list(dos = c(5, 2500), a = c(-0.2, -1e-5), k = c(1e-6, 0.2), sigma = c(1e-5, 5)), n_interval = 50L, model = OzoneExposure::stanmodels$schelegle, cores = 1L, ...)

Arguments

data

list, result of mungeSAS

bounds

list, with the upper and lower bounds for each parameter ("dos", "a", "k", and "sigma"). There must only two numbers for each parameter, and each parameter must be named.

n_interval

integer, the number of intervals to create between each parameter's upper and lower bound.

model

a compiled Stan model

cores

the number of CPU cores to use. On OSX and Linux, any value > 1 will result in parallel computations. Currently, parallel ops are not available under Windows.

...

Additional arguments passed to rstan::sampling

Value

A data.frame with

dos
k
a
sigma
aic

the associated AIC value for each parameter combination

Author(s)

Matt Espe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (data, bounds = list(dos = c(5, 2500), a = c(-0.2, 0), 
    k = c(0, 0.2), sigma = c(0.01, 5)), n_interval = 50L, model = OzoneExposure::stanmodels$schelegle, 
    cores = 1L) 
{
    grid = expand_bounds(bounds, n_interval)
    if (cores > 1) {
        cl = makeCluster(cores, "FORK")
        on.exit(stopCluster(cl))
        ans = parApply(cl, grid, 1, function(x) fit_eds(model, 
            data, x))
    }
    else ans = apply(grid, 1, function(x) fit_eds(model, data, 
        x))
    return(cbind(grid, aic = ans))
  }

dsidavis/Ozone2 documentation built on June 26, 2019, 7:35 a.m.