R: Compute the probability density function of the special definition of the Skew-T distribution
I am currently working with a mixture model package EMMIXskew
and I have set the layout to my data (some number vector). The package has some density function ddmst
, but I have not seen the probability density function in this package and I need a little!
What I thought I could do is
- use some other packages that provide a pdf to unwind like package
sn
cpst
, but the problem is that this distribution has a different definition of skew distribution, OR - I could use
integrate
inddmst
, but it doesn't work yet.
I have tried something like
library(EMMIXskew) dat <- rdmst(n=1000,p=1,mean=0,cov=1,del=1) mu=0.01 sigma=0.9 nu=1.1 del=3 pdmst <- function(x){ ddmst(x,n=length(dat),p=1,mean=mu,cov=sigma,nu=nu,del=del) } x=0.6 F_x <- integrate(pdmst,lower=-Inf,upper=x)
and also if I assume 3-modality of my data with parameters
mu=c(0.01,2,-0.4) sigma=c(0.9,2,2.3) nu=c(1.1,1,0.8) del=c(3,2,1.2) pdmst <- function(x){ ddmst(x,n=length(dat),p=1,mean=mu,cov=sigma,nu=nu,del=del)
I am getting this error
Error in ddmix(dat, n, p, 1, "mst", mean, cov, nu, del) : dat does not match n and p.
I really don't know what I did wrong!
source to share
Try the following:
pdmst <- function(x){
ddmst(x,n=length(x),p=1,mean=mu,cov=sigma,nu=nu,del=del)
}
n
should be length x
instead of dat
. Then pdmst(x)
should give you the density in x
.
For the three-way case, please refer to the documentation ddmix
on how to specify the arguments to this function. For your second example, it can be entered like this:
mu = cbind(0.01, 2, -0.4)
sigma = cbind(0.9,2,2.3)
del = cbind(3,2,1.2)
nu=c(1.1,1,0.8)
ddmix(x,1,1,3,"mst",mu, sigma, nu, del)
The last command should give you the log density in x
for each of the three components.
source to share