I currently work with the mixture model package EMMIXskew
and I have fitted a skew-t Distribution on my data (some numerical vector).
The package has some density function ddmst
but I haven't seen a probability density function in this package and I need some!
What I thought I could do is
sn
with pst
, but the problem is that this distribution
has a different definition of skew-t distribution,
OR integrate
on ddmst
, but it doesn't work so far.I 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 get 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!
Try this:
pdmst <- function(x){
ddmst(x,n=length(x),p=1,mean=mu,cov=sigma,nu=nu,del=del)
}
n
should be the length of x
instead of dat
.
Then pdmst(x)
should give you the density at x
.
For the 3-component case, please refer to the documentation of ddmix
on how to specify the arguments of this function.
For your second example, it can be entered as follows:
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 final command should give you the logarithm of the density at x
for each of the three components.