FAMoS (version 0.1.0)

return.results: Return Final Results

Description

Returns the results of one FAMoS run. Includes the best parameter sets and corresponding information criterion.

Usage

return.results(homedir, mrun, ic = "AICc")

Arguments

homedir

A string giving the directory in which the result folders are found. This is the same directory in which famos was run.

mrun

The number of the FAMoS run that is to be evaluated. Must be a three digit string in the form of '001'. Alternatively, supplying 'best' will return the best result that is found over several FAMoS runs.

ic

The information criterion used. Default is 'AICc". Other options are 'AIC' and 'BIC'.

Value

A list containing the following elements:

IC

The value of the information criterion of the best model.

par

The values of the fitted parameter vector corresponding to the best model.

IC.type

The type of information criterion used.

binary

The binary information of the best model.

vector

Vector indicating which parameters were fitted in the best model.

total.models.tested

The total number of different models that were analysed. May include repeats.

mrun

The number of the current FAMoS run

initial.mode

The first model evaluated by the FAMoS run

Examples

Run this code
# NOT RUN {
future::plan(future::sequential)

#setting data
x.values <- 1:7
y.values <-  3^2 * x.values^2 - exp(2 * x.values)

#define initial conditions and corresponding test function
inits <- c(p1 = 3, p2 = 4, p3 = -2, p4 = 2, p5 = 0)

cost_function <- function(parms, x.vals, y.vals){
 if(max(abs(parms)) > 5){
   return(NA)
 }
 with(as.list(c(parms)), {
   res <- p1*4 + p2^2*x.vals^2 + p3*sin(x.vals) + p4*x.vals - exp(p5*x.vals)
   diff <- sum((res - y.vals)^2)
 })
}


#perform model selection
res <- famos(init.par = inits,
           fit.fn = cost_function,
           nr.of.data = length(y.values),
           homedir = getwd(),
           method = "forward",
           init.model.type = c("p2", "p3"),
           optim.runs = 1,
           x.vals = x.values,
           y.vals = y.values)

#get results
return.results(homedir = getwd(), mrun = res$mrun)
# }

Run the code above in your browser using DataLab