View source: R/sd_from_min_max.R
| sd_from_min_max | R Documentation | 
Bayesian estimate of underlying distribution.
The distribution of extrema is expected to be a Gaussian distribution; we could do better using
generalized extreme value (GEV) distribution.
Weisstein, Eric W. "Extreme value distribution". mathworld.wolfram.com
sd_from_min_max(
  n,
  observedMean = NULL,
  observedMinimum,
  observedMaximum,
  priors = NULL,
  fittedparameters = c("mean-sd"),
  n.iter = 10000,
  n.chains = 1,
  n.adapt = 100,
  thin = 30,
  adaptive = FALSE,
  trace = 100
)
n | 
 Number of observations used to estimate observedMinimum and observedMaximum  | 
observedMean | 
 The observed mean (can be omited)  | 
observedMinimum | 
 The observed minimum  | 
observedMaximum | 
 The observed maximum  | 
priors | 
 The priors (can be omited)  | 
fittedparameters | 
 Can be "sd" or "mean-sd"  | 
n.iter | 
 Number of iterations for each chain  | 
n.chains | 
 Number of chains  | 
n.adapt | 
 Number of iteration to stabilize likelihood  | 
thin | 
 Interval for thinning likelihoods  | 
adaptive | 
 Should an adaptive process for SDProp be used  | 
trace | 
 Or FALSE or period to show progress  | 
sd_from_min_max returns standard deviation and/or mean from minimum and maximum
sd_from_min_max returns a mcmcComposite object
Marc Girondot marc.girondot@gmail.com
## Not run: 
minobs <- 45
maxobs <- 53
n <- 4
# To estimate only the sd of the distribution
out_sd_mcmc <- sd_from_min_max(n=n, observedMinimum=minobs, 
                           observedMaximum=maxobs, 
                           fittedparameters="sd")
plot(out_sd_mcmc, what="MarkovChain", parameters="sd")
plot(out_sd_mcmc, what="posterior", parameters="sd")
as.parameters(out_sd_mcmc, index="quantile")
# To be compared with the rule of thumb:
print(paste0("sd = ", as.character((maxobs - minobs) / 4))) # SD Clearly biased
# To estimate both the sd and mean of the distribution
out_sd_mean_mcmc <- sd_from_min_max(n=n, observedMinimum=minobs, 
                           observedMaximum=maxobs, 
                           fittedparameters="mean-sd")
plot(out_sd_mean_mcmc, what="MarkovChain", parameters="sd")
plot(out_sd_mean_mcmc, what="MarkovChain", parameters="mean")
plot(out_sd_mean_mcmc, what="posterior", parameters="mean", xlim=c(0, 100), 
     breaks=seq(from=0, to=100, by=5))
as.parameters(out_sd_mean_mcmc, index="quantile")
# To be compared with the rule of thumb:
print(paste0("mean = ", as.character((maxobs + minobs) / 2))) # Mean Not so bad
print(paste0("sd = ", as.character((maxobs - minobs) / 4))) # SD Clearly biased
# Covariation of sd and mean is nearly NULL
cor(x=as.parameters(out_sd_mean_mcmc, index="all")[, "mean"], 
    y=as.parameters(out_sd_mean_mcmc, index="all")[, "sd"])^2
plot(x=as.parameters(out_sd_mean_mcmc, index="all")[, "mean"], 
     y=as.parameters(out_sd_mean_mcmc, index="all")[, "sd"], 
     xlab="mean", ylab="sd")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.