getNormFromCI: Find the best-fit normal / Gaussian distribution for a given...

Description Usage Arguments Value See Also Examples

View source: R/fitDistributionsToCIs.R

Description

Finds the best-fit normal distribution for a given confidence interval; returns the corresponding density, distribution, quantile and sampling functions.

Usage

1
getNormFromCI(qLow, qUpp, alpha = 0.05, initPars = c(0, 1), maxiter = 1000)

Arguments

qLow

The observed lower quantile.

qUpp

The observed upper quantile.

alpha

The confidence level; i.e. the desired coverage is 1-alpha. Defaults to 0.05.

initPars

A vector of length 2 giving the initial parameter values (mean & sd) to start the optimisation; defaults to c(0,1).

maxiter

Maximum number of iterations for optim. Defaults to 1e3. Set to higher values if convergence problems are reported.

Value

A list with 5 elements:

r

The sampling function.

d

The density function.

p

The distribution function.

q

The quantile function.

pars

A vector of length 2 giving the mean and standard deviation for the best-fit normal distribution (mean and sd as in rnorm, dnorm, pnorm, qnorm).

See Also

identifyNormPars, optim, dnorm

Examples

1
2
3
4
5
6
7
8
9
n<-getNormFromCI(qLow=1.08,qUpp=8.92)
print(n$pars) # the fitted parameter values (mean & sd)
n$r(10) # 10 random values from the fitted normal distribution
n$d(6) # the probability density at x=6 for the normal distribution
n$p(4.25) # the cumulative density at x=4.25 for the fitted normal distribution
n$q(c(0.25,0.5,0.75)) # the 25th, 50th (median) and 75th percentiles of the fitted distribution
x<-seq(0,10,length=1e3)
y<-n$d(x)
plot(x,y,type="l",xlab="",ylab="density") # density plot for the fitted normal distribution

bootComb documentation built on Nov. 19, 2020, 1:07 a.m.