lcDmc {lazy.stat} | R Documentation |
Estimates the Density of the Weighed Linear Combination of a Dirichlet Variables by Simulation.
lcDmc( class, f, table = NULL, alpha0 = 0.5, omitmiss = 1, nsample = 1000, smooth = 0, bandwid = 3, maxiter = 2, density = 2, ndensity = 201, epsz = 1e-09, ..., hdr_prob = 0.95, print = 0, plot = 0, outmcmc = 0, simple = 0 ) stat_lcDmc(class, f, alpha0, hdr_prob = 0, pdf_info)
class |
A vector containing the numeric values of scored multinomial |
f |
A vector containing the frequency associated with class |
table |
The output of native table function. |
alpha0 |
prior constant for Dirichlet |
omitmiss |
= 1 to remove the classes with f=0 from (class,f) |
nsample |
# of Dirichlet random numbers to simulate distribution of mu. |
smooth |
= 1 to smooth the density by mative smooth |
bandwid |
= length of the running average smooth |
maxiter |
= # of repetition for smooth |
density |
= 1 to use simple tabulation = 2 to use native density function |
ndensity |
# of points to be used to density estimation
by native density. |
epsz |
= the value which defines almost zero. |
... |
additional parameters to native density function. |
hdr_prob |
= probability value for hdr: 0 <= hdr_prob < 1 |
print |
= 1 to print the result |
plot |
= 1 to plot the density |
outmcmc |
= 1 to output mcmc result of mu |
simple |
= 1 to produce simple output |
Let (class, f) be the observed frequency distribution of the scored
multinomial R.V.
The likelihood of the multinomial parameter vector p is:
sum_{k=1}^{ncat} f[k]*log(p[k])
Given the Dirichlet prior of p with parameter vector alpha0,
the posterior distribution of p is the Dirichlet with alpha=f+alpha0
.
The posterior mean of the scored multinomial distribution is defined as:
mu = sum_{k=1}^{ncat} class[k]*p[k]
and this function simulates the distribution of mu by sampling from
the posterior Dirichlet distribution.
When hpd_prob is given or plot=1,
"hpd" function of "TeachingDemos" package is used.
When simple = 1:
A list of sample, param, dom
where
param is the alpha parameter of the post means (freq+prior),
class is the categorie values
nobs is the # of observations: sum(f)
nsample # of mcmc samples
pdf_info a list consisting of:
dtable a matrix consisting of the estimated density (ndensity x 3)
where the density in column 2 is normalized to unit sum.
locz1, locnz, locz2, minval, maxval
When simple = 0:
A list consisting of above and more.
When outmcmc = 1:
A list consisting of above and
sample is the vector of length nsample consisting of mu's,
# Increase nsample when in real use. class=1:3 f=c(1,2,1) alpha0=0.5 res=lcDmc( class, f, alpha0=alpha0, nsample=1000, density=2, ndensity=201 , smooth=0, print=1, plot=0, simple=1, hdr_prob=0 ) res2=stat_lcDmc( class, f, alpha0, pdf_info=res$pdf_info, hdr_prob=0 )