plot_objective {flimo}R Documentation

Plot the objective to be minimized using flimo

Description

Plot of the objective function with one parameter moving (objective = f(theta_index)). You need either to provide data, dsumstats AND simulatorQ OR obj.

Usage

plot_objective(
  ndraw,
  data = NULL,
  dsumstats = NULL,
  simulatorQ = NULL,
  obj = NULL,
  quantiles = NULL,
  index = NULL,
  other_param = NULL,
  nsim = 10,
  lower = 0,
  upper = 1,
  dim2 = TRUE,
  visualize_min = TRUE,
  plot_legend = TRUE,
  npoints = 300,
  add_to_plot = NULL
)

Arguments

ndraw

Integer.Number of random variables to draw for one simulation of the model.

data

1D array containing the observations.

dsumstats

Function computing the distance between simulations and data of form dsumstats(simulations, data) where simulations : 2D array and data : 1D array. ncol(simulations) = length(data) mandatory.

simulatorQ

Function of type simulatorQ(Theta, quantiles) where Theta is the parameter set for the simulations and quantiles are drawn in U(0,1).

obj

objective function of type objective(Theta, quantiles). Default : directly computed with "dsumstats" and "simulatorQ".

quantiles

2D array containing values drawn in U(0,1). Row number = number of simulations. Default: simulated within the function. Column number = number of random variables to draw in one simulation.

index

Integer. Index of the moving parameter.

other_param

Other parameters of the model. If NULL : assume 1D-model. If numeric : 2D-model, one curve. If 1D-array and dim2 is True (default) : 2D-model, one curve by value in other_param. If 1D-array and dim2 is False or 2D-array : (n>2)D-model, one curve by row in other_param. If your model has n>2 dimensions, you should define other_param as a matrix even if you have only one parameter set to test (with as.matrix(t(vect_param)) where vect_param is a 1D-array).

nsim

Integer. Number of simulations to run for each step of the optimization algorithm. Computation time grows linearly with this number. Default to 10.

lower

Numeric. Lower value of the plot.

upper

Numeric. Upper value of the plot.

dim2

Boolean. True if model is 2-dimensional.

visualize_min

Boolean. If True, show explicitly the minimum point.

plot_legend

Boolean. If True (default), plots the legend.

npoints

Integer. Number of points evaluated. Default = 300.

add_to_plot

ggplot object. If not NULL, will add all curves/points on previous plot instead of creating a new one. Does not change title/labels/limits defined in previous plot.

Value

ggplot object representing the objective function to be minimized.

Examples

data <- rep(100, 5)

dsumstats <- function(simulations, data){
mean_simu <- mean(rowMeans(simulations))
mean_data <- mean(data)
(mean_simu-mean_data)^2
}

simulatorQ <- function(Theta, quantiles){
qpois(quantiles, lambda = Theta)
}

plot_objective(5, data, dsumstats, simulatorQ,
lower = 0, upper = 200)


[Package flimo version 0.1.5 Index]