TDPdensity(y,support=3,transform=1,ngrid=1000,prior,mcmc,state,status,
data=sys.frame(sys.parent()),na.action=na.fail)y
is lower or equal than 2. The default value is 1000.aa0 and ab0 giving the hyperparameters for
prior distribution of the precision parameter of the Dirichletnburn giving the number of burn-in
scans, nskip giving the thinning interval, nsave givingTRUE) or the
continuation of a previous analysis (FALSE). In the latter case
the current value of the parameters must be specifieNAs. The default action (na.fail) causes
TDPdensity to print an error message and terminate if there areTDPdensity representing the Triangular-Dirichlet
model fit. Generic functions such as print, summary, and plot have methods to
show the results of the fit. The results include the degree of the polynomial k, alpha, and the
number of clusters.
The MCMC samples of the parameters and the errors in the model are stored in the object
thetasave and randsave, respectively. Both objects are included in the
list save.state and are matrices which can be analyzed directly by functions
provided by the coda package.
The list state in the output object contains the current value of the parameters
necessary to restart the analysis. If you want to specify different starting values
to run multiple chains set status=TRUE and create the list state based on
this starting values. In this case the list state must include the following objects:y latent variables of the clusters (only the first ncluster are
considered to start the chain).ncluster clusters each observation belongs.kmax is the upper limit of the discrete uniform prior
for the number of components in the Mixture of Triangular
distributions, $\alpha$ is the total mass parameter of the Dirichlet process component,
and $G_0$ is the centering distribution of the DP. The centering distribution corresponds
to a $G_0=Beta(a_0,b_0)$ distribution.
Note that our representation is different to the Mixture of Triangular
distributions proposed by Perron and Mengersen (2001). In this function
we consider random weights following a Dirichlet prior and we exploit the
underlying DP structure. By so doing, we avoid using Reversible-Jumps algorithms.
The precision or total mass parameter, $\alpha$, of the DP prior
can be considered as random, having a gamma distribution, $Gamma(a_0,b_0)$,
or fixed at some particular value. When $\alpha$ is random the method described by
Escobar and West (1995) is used. To let $\alpha$ to be fixed at a particular
value, set $a_0$ to NULL in the prior specification.DPdensity, PTdensity, BDPdensity# Data
data(galaxy)
galaxy<-data.frame(galaxy,speeds=galaxy$speed/1000)
attach(galaxy)
# Initial state
state <- NULL
# MCMC parameters
nburn<-1000
nsave<-10000
nskip<-10
ndisplay<-100
mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay)
# Prior
prior<-list(aa0=2.01,
ab0=0.01,
kmax=50,
a0=1,
b0=1)
# Fitting the model
fit<-TDPdensity(y=speeds,prior=prior,mcmc=mcmc,state=state,status=TRUE)
plot(fit)Run the code above in your browser using DataLab