Learn R Programming

DISTRIB (version 1.0)

DISTRIB-package: \Sexpr[results=rd,stage=build]{tools:::Rd_package_title("#1")}DISTRIBFour Essential Functions for Statistical Distributions Analysis: A New Functional Approach

Description

Previously, four useful functions dnorm, pnorm, qnorm and rnorm are introduced for any univariate distribution in package stats. But the name of these functions are different for any distribution, for example compare the names of dcauchy and dchisq which are for Cauchy and Chi-square distributions, respectively. Now suppose that you have a fixed formula which you want to work with any distribution. To this matter, the author of this package try to define four functions pdf, cdf, rd and q in package DISTRIB, in which the user is able to consider the name of distribution as a argument of them, and therefore these functions can work with any arbitrary distribution.

Arguments

Examples

Run this code
# An applied example for computing p-value in testing H0: mu>=0, vs, H1: mu<0 with two 
# different test statistic distribution: 

# (a) where the statistics test is T~N(0,1) and its observed value is t = -1.5
p_value = cdf(T.dist="norm", T.dist.par=c(0,1), t=-1.5)
print(p_value)

# (b) where the statistics test T has t-student dist. with 10 degree of freedom 
#     and its observed value is t = -1.5
p_value = cdf(T.dist="t", T.dist.par=10, t=-1.5) 
print(p_value)

Run the code above in your browser using DataLab