Description Usage Arguments Value Examples
View source: R/return_results_function.R
Returns the results of one FAMoS run. Includes the best parameter sets and corresponding selection criterion.
1 | return.results(homedir, mrun)
|
homedir |
A string giving the directory in which the result folders are found. This is the same directory in which |
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. |
A list containing the following elements:
The value of the selection criterion of the best model.
The values of the fitted parameter vector corresponding to the best model.
The binary information of the best model.
Vector indicating which parameters were fitted in the best model.
The total number of different models that were analysed. May include repeats.
The number of the current FAMoS run.
The first model evaluated by the FAMoS run.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.