I want to truncate beta distribution that is the value of the beta distribution in [0,0.2] is zero. I used "dtrunc" as follows:
I encountered the following error message:
"Error in g(x, ...) : argument "shape1" is missing, with no default"
Could yo please let me know what is happening?
p <-seq(0,1,length=1000)
pdf <- dtrunc(p, spec="beta", a = 0, b = 0.2,log=FALSE)
Assuming you're using the truncdist
package (you should always specify when you're using non-base resources, as there could be a dtrunc()
function in more than one non-base package): you need to use shape1
and shape2
as the names of the shape parameters, not a
and b
pdf <- dtrunc(p, spec="beta", shape1 = 0, shape2 = 0.2,log=FALSE)
This is line with the base R function dbeta
(which does use a
and b
in the Details section, but it's explicit:
The Beta distribution with parameters ‘shape1’ = a and ‘shape2’ = b has density
Gamma(a+b)/(Gamma(a)Gamma(b))x^(a-1)(1-x)^(b-1)