dgamma3: The gamma Distribution (3 Parameter)

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

Description

Density function, distribution function and quantile function for the gamma distribution.

Usage

1
2
3
dgamma3(x, shape, scale, threshold)
pgamma3(q, shape, scale, threshold)
qgamma3(p, shape, scale, threshold, ...)

Arguments

x, q

vector of quantiles

p

vector of probabilities

shape

shape parameter by default 1

scale

scale parameter by default 1

threshold

threshold parameter by default 0

...

Arguments that can be passed into uniroot.

Details

The gamma distribution with ‘scale’ parameter alpha, ‘shape’ parameter c and ‘threshold’ parameter zeta has density given by

f(x) = (c/alpha) (((x-zeta)/alpha)^(c-1)) exp(-((x-zeta)/alpha)^c)

The cumulative distribution function is given by

F(x) = 1 - exp(-((x-zeta)/alpha)^c)

Value

dgamma3 gives the density, pgamma3 gives the distribution function and qgamma3 gives the quantile function.

Note

qgamma3 calls uniroot for each value of the argument ‘p’. The solution is consequently not exact; the ... can be used to obtain a more accurate solution if necessary.

Author(s)

Thomas Roth thomas.roth@tu-berlin.de
Etienne Stockhausen stocdarf@mailbox.tu-berlin.de

References

Johnson, L., Kotz, S., Balakrishnan, N. (1995) Continuous Univariate Distributions-Volume 1, 2nd ed. New York: John Wiley & Sons.

See Also

uniroot

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
##Simple Example
dgamma3(x=1,scale=1,shape=5,threshold=0)
temp=pgamma3(q=1,scale=1,shape=5,threshold=0)
temp
qgamma3(p=temp,scale=1,shape=5,threshold=0)
#
##Visualized Example
##prepare screen
#dev.new()
#split.screen(matrix(c(0,0.5,0,1, 0.5,1,0,1),byrow=TRUE,ncol=4))
##generate values
#x=seq(0,3,length=1000)
##plot different density functions
#screen(1)
#plot(x,y=dgamma3(x,threshold=0,shape=0.5,scale=1),col="green",
#     xlim=c(0,2.5),ylim=c(0,2.5),type="l",lwd=2,xlab="x",
#     ylab="f(x)",main="Density Function of gamma-Distribution")
#lines(x,y=dgamma3(x,threshold=0,shape=1,scale=1),lwd=2,col="red")
#lines(x,y=dgamma3(x,threshold=0,shape=1.5,scale=2),lwd=2,col="blue")
#lines(x,y=dgamma3(x,threshold=0,shape=5,scale=1),lwd=2,col="orange")
##add legend
#legend("topright",legend=c(expression(paste(alpha, " = 1 ")*
#       paste(c, " = 0.5 ")*paste(zeta," = 0")),
#       expression(paste(alpha, " = 1 ")*paste(c, " = 1 ")*
#       paste(zeta," = 0")),expression(paste(alpha, " = 2 ")*
#       paste(c, " = 1.5 ")*paste(zeta," = 0")),
#       expression(paste(alpha, " = 1 ")*paste(c, " = 5 ")*
#       paste(zeta," = 0"))),col=c("green","red","blue","orange"),
#       text.col="black",lwd=2,bty="0",inset=0.04)
#abline(v=0,lty=2,col="grey")
#abline(h=0,lty=2,col="grey")
##plot different distribution functions
#screen(2)
#plot(x,y=pgamma3(x,threshold=0,shape=0.5,scale=1),col="green",
#     xlim=c(0,2.5),ylim=c(0,1),type="l",lwd=2,xlab="x",ylab="F(x)",
#     main="Cumulative Distribution Function of gamma-Distribution")
#lines(x,y=pgamma3(x,threshold=0,shape=1,scale=1),lwd=2,col="red")
#lines(x,y=pgamma3(x,threshold=0,shape=1.5,scale=2),lwd=2,col="blue")
#lines(x,y=pgamma3(x,threshold=0,shape=5,scale=1),lwd=2,col="orange")
##add legend
#legend("bottomright",legend=c(expression(paste(alpha, " = 1 ")*
#       paste(c, " = 0.5 ")*paste(zeta," = 0")),
#       expression(paste(alpha, " = 1 ")*paste(c, " = 1 ")*
#       paste(zeta," = 0")),expression(paste(alpha, " = 2 ")*
#       paste(c, " = 1.5 ")*paste(zeta," = 0")),
#       expression(paste(alpha, " = 1 ")*paste(c, " = 5 ")*
#       paste(zeta," = 0"))),col=c("green","red","blue","orange"),
#       text.col="black",lwd=2,bty="0",inset=0.04)
#abline(v=0,lty=2,col="grey")
#abline(h=0,lty=2,col="grey")
#close.screen(all=TRUE)

Example output

Loading required package: Rsolnp
Loading required package: MASS

Attaching package:qualityToolsThe following object is masked frompackage:stats:

    sigma

[1] 0.01532831
[1] 0.003659847
[1] 0.9999981

qualityTools documentation built on May 2, 2019, 10:21 a.m.