var_th: Theoretical variance

Description Usage Arguments Details See Also Examples

View source: R/var_th.R

Description

Use Calculate the theoretical variance of base probability distributions

Usage

1
2
3
4
var_th(p, distribution = c("uniform", "exponential", "gamma", "t",
  "students-t", "bates", "binomial", "nbinom", "negative binomial", "beta",
  "f", "geometric", "hypergeometric", "lognormal", "log-normal", "weibull",
  "signed-rank", "rank-sum", "logistic"))

Arguments

p

a named vector of parameter values, or a single unnamed numeric if only one parameter. Use a data.frame with appropriately named columns to calculate several variances of the same distribution.

distribution

the name of the distribution to calculate the variance of

Details

The parameters and their names are the same as used in their respective density function. In some cases, like gamma, (negative) binomial etc. more than one convention is followed.

See Also

Distributions

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
var_th(p=data.frame(min=1:2, max=5:6), dist="unif")
var(runif(1e5, 1, 5))

var_th(p=2:3, dist="exp")
var(rexp(1e5, 2))

var_th(p=data.frame(shape=3:2, scale=c(0.8, 1)), dist="gamma")
var(rgamma(1e5, shape=3, scale=0.8))

var_th(p=c(shape=3, rate=1.25), dist="gamma")
var(rgamma(1e5, shape=3, rate=1.25))

var_th(p=18:20, dist="t")
var(rt(1e5, 18))

var_th(p=c(a=1, b=2, n=3), dist="bates")
var(rbates(1e5, a=1, b=2, nr=3))

var_th(p=c(size=10, prob=0.8), dist="binom")
var(rbinom(1e5, 10, 0.8))

var_th(p=c(size=10, prob=0.8), dist="nbinom")
var(rnbinom(1e5, size=10, prob=0.8))

var_th(p=c(size=10, mu=2), dist="nbinom")
var(rnbinom(1e5, size=10, mu=2))

var_th(p=data.frame(shape1=c(1, 2), shape2=c(1.5, 1)), dist="beta")
var(rbeta(1e5, shape1=1, shape2=1.5))
var(rbeta(1e5, shape1=2, shape2=1))

var_th(p=c(df1=6, df2=11), dist="f")
var(rf(1e5, 6, 11))

var_th(p=c(m=3, n=3, k=2), dist="hypergeom")
var(rhyper(1e5, m=3, n=3, k=2))

var_th(p=c(meanlog=0, sdlog=1), dist="log-normal")
var(rlnorm(1e5, meanlog=0, sdlog=1))

var_th(p=c(shape=2, scale=1), dist="weibull")
var(rweibull(1e5, shape=2, scale=1))

var_th(p=20, dist="signed-rank")
var(rsignrank(1e5, n=20))

var_th(p=c(m=13, n=10), dist="rank-sum")
var(rwilcox(1e5, m=13, n=10))

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.