return.results: Return Final Results

Description Usage Arguments Value Examples

View source: R/return_results_function.R

Description

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

Usage

1
return.results(homedir, mrun)

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.

Value

A list containing the following elements:

SCV

The value of the selection criterion of the best model.

par

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

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

 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
#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 = tempdir(),
           init.model.type = c("p2", "p3"),
           optim.runs = 1,
           x.vals = x.values,
           y.vals = y.values)

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

#delete tempdir
unlink(paste0(tempdir(),"/FAMoS-Results"), recursive = TRUE)

FAMoS documentation built on May 26, 2019, 5 p.m.