Question

Various functions in the truncdist package require a parameter "spec". What are the distributions supported by the functions?

I mean for a normal distributin we can type spec = "norm" (given in the example). But, what about other distributions ?

What I have to type in spec for other distributions/what are the list of distributions supported?

Was it helpful?

Solution 2

It looks to support all distribution in the R stats package: http://stat.ethz.ch/R-manual/R-patched/library/stats/html/Distributions.html since the functions in the truncdist package prepend "d" and "p" for calls:

g <- get(paste("d", spec, sep = ""), mode = "function")
G <- get(paste("p", spec, sep = ""), mode = "function")

and their paper doesn't specify any restrictions.

OTHER TIPS

Actually, it looks like truncdist does no checking at all for an actual "distribution". It merely prepends d and p to whatever you pass as spec=.... So you can use any distribution from any package as long as it's loaded. For example, the VGAM package has a very large number of distributions that are not in base R. All of these can be used with truncdist if VGAM is loaded.

library(truncdist)  # for dtrunc(....)
library(VGAM)       # for slash(...)

x <- seq(-5,5,0.01)
Y <- dslash(x)      # slash is dist of Z=Y/X where Y~N[0,1] and X~U[0,1]
Z <- dtrunc(x,spec="slash", a=-2, b=2)
plot(x,Y,xlim=c(-5,5),ylim=c(0,.4), type="l",col="blue")
lines(x,Z,xlim=c(-5,5),col="red")

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top