retrieve.results: Retrieve Model Results

Description Usage Arguments Value Examples

View source: R/retrieve_results_function.R

Description

Returns the results of a specified model that was tested by famos.

Usage

1
retrieve.results(model, homedir = getwd(), all.names = NULL)

Arguments

model

Either the binary number of the model as a string (e.g. "011001"), a named vector containing the names the names of the fitted parameters or a vector containing ones and zeroes to indicate which model parameter were fitted. If the names of the fitted parameters are supplied, all.names must be specified as well.

homedir

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

all.names

A vector containing the names of all parameters.

Value

A vector containing the calculated selection criteria and estimated parameters of the specified model.

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
34
35
36
#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
retrieve.results(model = "01110", homedir = tempdir())
retrieve.results(model = c("p2", "p3", "p4"), homedir = tempdir(),
                 all.names = c("p1","p2", "p3", "p4", "p5"))
retrieve.results(model = c(0,1,1,1,0), homedir = tempdir())

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

FAMoS documentation built on April 14, 2020, 5:43 p.m.