trun.r {gamlss.tr}R Documentation

Generates Random Values from a Truncated Density Function of a gamlss.family Distribution

Description

Creates a function to generate randon values from a truncated probability density function created from a current GAMLSS family distribution

Usage

trun.r(par, family = "NO", type = c("left", "right", "both"), ...)

Arguments

par a vector with one (for left or right truncation) or two elements for both
family a gamlss.family object, which is used to define the distribution and the link functions of the various parameters. The distribution families supported by gamlss() can be found in gamlss.family. Functions such as BI() (binomial) produce a family object.
type whether left, right or in both sides truncation is required, (left is the default)
... for extra arguments

Value

Returns a r family function

Author(s)

Mikis Stasinopoulos d.stasinopoulos@londonmet.ac.uk and Bob Rigby r.rigby@londonmet.ac.uk

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2003) Instructions on how to use the GAMLSS package in R. Accompanying documentation in the current GAMLSS help files, (see also http://www.gamlss.com/).

See Also

trun.p, trun.q, trun.d, gen.trun

Examples

# trucated r function
# continuous
#----------------------------------------------------------------------------------------
# left
test1<-trun.r(par=c(0), family="TF", type="left")
rr<-test1(1000)
hist(rr)
#----------------------------------------------------------------------------------------
# right
test2 <- trun.r(par=c(10), family="BCT", type="right")
rr<-test2(1000)
hist(rr)
#----------------------------------------------------------------------------------------
# both
test3<-trun.r(par=c(-3,3), family="TF", type="both")
rr<-test3(1000)
hist(rr)
#----------------------------------------------------------------------------------------
# discrete 
# trucated r function
# left
test1<-trun.r(par=c(0), family="PO", type="left")
tN <- table(Ni <- test1(1000))
 r <- barplot(tN, col='lightblue')
#----------------------------------------------------------------------------------------
# right
test2 <- trun.r(par=c(10), family="NBI", type="right")
tN <- table(Ni <- test2(1000))
 r <- barplot(tN, col='lightblue')
tN <- table(Ni <- test2(1000,mu=5))
  r <- barplot(tN, col='lightblue')
tN <- table(Ni <- test2(1000,mu=10, sigma=.1))
  r <- barplot(tN, col='lightblue')
#----------------------------------------------------------------------------------------
# both 
test3<-trun.r(par=c(0,10), family="NBI", type="both")
 tN <- table(Ni <- test3(1000,mu=5))
 r <- barplot(tN, col='lightblue')

[Package gamlss.tr version 1.9-0 Index]