lcDmc {lazy.stat}R Documentation

Estimates the Density of the Weighed Linear Combination of a Dirichlet Variables by Simulation.

Description

Estimates the Density of the Weighed Linear Combination of a Dirichlet Variables by Simulation.

Usage

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)

Arguments

class

A vector containing the numeric values of scored multinomial

f

A vector containing the frequency associated with class
The set (class,f) consists of the frequency distribution: (midpoints,freq)

table

The output of native table function.
This has the priority over (class, f).

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
= 2 to smooth the density by smoothra

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.
or 0 to skip.

epsz

= the value which defines almost zero.

...

additional parameters to native density function.

hdr_prob

= probability value for hdr: 0 <= hdr_prob < 1
When hpd_prob is given "hpd" function of "TeachingDemos" package is used.

print

= 1 to print the result

plot

= 1 to plot the density
When plot=1, "hpd" function of "TeachingDemos" package is used.

outmcmc

= 1 to output mcmc result of mu

simple

= 1 to produce simple output

Details

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.

Value


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,

Examples

# 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 )
res2=stat_lcDmc( class, f, alpha0, pdf_info=res$pdf_info )


[Package lazy.stat version 0.1.3 Index]