guess_decisionSupport_estimates: guessing decisionSupport's estimates from imperfect...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/guess_decisionSupport_estimates.R

Description

Take some data along with other tuning parameters to return the formated estimates as returned by estimate to be used in the mcSimulation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
guess_decisionSupport_estimates(
  data,
  fun = NULL,
  distr = "norm",
  method = "mge",
  estimate_method = NULL,
  percentiles = c(0.025, 0.975),
  plot = FALSE,
  show.output = FALSE
)

Arguments

data

The base data or list of base data such that fun (data), or do.call (fun, data) will either return a data.frame or a numeric vector coercible to data.frame. see example.

fun

Thefunction to be applied to data.

distr

charater vector. The expected probability distribution function.

method

Distribution fitting method (see method argument in fitdist). default to "mge" (maximum goodness-of-fit estimation).

estimate_method

character vector. Method to be used for estimating the marginal distribution parameters as in estimate. If null, the default, method is set to "fit" (see estimate).

percentiles

numeric vector of percentiles based on which to define a quantile function to be used for fitting distr with rriskDistributions package.

plot

logical. Should the quantile function be ploted? default to FALSE

show.output

Should the computation be verbose? default to FALSE

Details

In decisonSupport package, estimate assumes the case where hard data are not available and expert can agree on a set of estimated benchmarking (i.e. minimum, mediam, maximun) values and distributions based on which data can generated to support decision making under uncertainity. guess_decisionSupport_estimates () function provide additional ways to derive such estimates from the persepectives where some sort of hard data are available. The function is more useful when intermediate computations are needed to generate the desired the data. For example it can use the data generating function (fun argument) to construct intermediate outputs upon which it derives the recipies required by estimate. This could be useful for variables that difficult to be directly estimated by experts.

Value

estimate object as returned by estimate or a list of thereof depending on the data provided.

Author(s)

Issoufou Liman

See Also

estimate.

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## - Suppose we have data on yield potential of different crops grown in a given area
## distributed following a gamma distribution function.
## - Suppose also we can estimates the proportion of biomass accumulation following the
## crop development stages
## - Suppose we also have an idea of the proportion of grains relative to the biomass
## towards the harvest period.
## Now we want to construct the decisionSupport estimates of the actual grain yield
## from these.
## generate some hypothetical data reporting yield potential of different crops varietie
potential_grain_yield <- rgamma(100, shape=1, rate = 1)
## checking the distribution shape
hist(potential_grain_yield)
## proportion of grain yield relative to biomass yield
harvest_index = c(0.2, 0.6)
## relative biomass accumulation accross over time.
stage_ratio = c(initial_stage = 0.27, mid_stage = 0.68, development_stage = 1, late_stage = 0.86)
## A function for making an informed guess of biomass yield at each stage
guess_biomass_yield <-  function(observed_grain_yield, harvest_index = c(0.2, 0.6), stage_ratio){
  harvest_index <- runif(1000, harvest_index[1], harvest_index[2])
  actu_bomass <- sapply(harvest_index, function(i){
    observed_grain_yield/i
  })
  actu_bomass <- sapply(stage_ratio, function (i){
    i * actu_bomass
  }, simplify = TRUE, USE.NAMES = TRUE)
  as.data.frame(na.omit(actu_bomass))
}

## Try it with gamma distribution and fit method
library (rriskDistributions)
fit_gamma <- guess_decisionSupport_estimates (data = list(potential_grain_yield,
  harvest_index = harvest_index, stage_ratio = stage_ratio),
  fun = guess_biomass_yield, distr = 'gamma', percentiles = c(0.025, 0.5, 0.975),
  plot = FALSE, show.output = FALSE)

 ## Try it with gamma distribution and calculate method
calc_gamma <- guess_decisionSupport_estimates (data = list(potential_grain_yield,
  harvest_index = harvest_index, stage_ratio = stage_ratio), estimate_method = 'calculate',
  fun = guess_biomass_yield, distr = 'gamma', percentiles = c(0.025, 0.5, 0.975),
  plot = FALSE, show.output = FALSE)

 ## Try it with normal distribution and calculate method
calc_norm <- guess_decisionSupport_estimates (data = list(potential_grain_yield,
  harvest_index = harvest_index, stage_ratio = stage_ratio), estimate_method = 'calculate',
  fun = guess_biomass_yield, distr = 'norm', percentiles = c(0.025, 0.5, 0.975),
  plot = FALSE, show.output = FALSE)

 ## Try with a constant with a function
 calc_const_with_fun <- guess_decisionSupport_estimates(data = 1, fun = "sum")

 ## Try with a constant without function
 calc_const_without_fun <- guess_decisionSupport_estimates(data = 100)

## Check the difference
calc_gamma; fit_gamma; calc_norm; calc_const_with_fun; calc_const_without_fun

Issoufou-Liman/decisionSupportExtra documentation built on Dec. 21, 2020, 6:28 p.m.