pBayes  R Documentation 
Estimation of cells counts in contingency tables by means of the pseudoBayes estimator.
pBayes(x, method="m.ind", const=NULL)
x 
A contingency table with observed cell counts. Typically the output of 
method 
The method for estimating the final cell frequencies. The following options are available:

const 
Numeric value, a user defined constant a (a>0) to be added to each cell before estimation of the relative frequencies when 
This function estimates the frequencies in a contingency table by using the pseudoBayes approach. In practice the estimator being considered is a weighted average of the input (observed) cells counts n_h and a suitable prior guess, gamma_h, for cells probabilities :
ep_h = n/(n+K)*p_h + K/(n+K)*gamma_h
K depends on the parameters of Dirichlet prior distribution being considered (for major details see Chapter 12 in Bishop et al., 1974).
It is worth noting that with a constant prior guess gamma_h=1/c (h=1,2,...,c), then K=1 and in practice corresponds to adding 1/c to each cell before estimation of the relative frequencies (method = "invcat"
); K=c/2 when the constant 0.5 is added to each cell (method = "Jeffreys"
); finally sqrt(n) when the quantity sqrt(n)/c is added to each cell (method = "minimax"
). All these cases corresponds to adding a flattening constant; the higher is the value of K the more the estimates will be shrinked towards gamma_h=1/c (flattening).
When method = "m.ind"
the prior guess gamma_h is estimated under the hypothesis of mutual independence between the variables crossed in the initial contingency table x
, supposed to be at least a twoway table. In this case the value of K is estimated via a datadriven approach by considering
eK = (1  sum(p_h^2))/(sum(gamma_h  p_h)^2)
On the contrary, when method = "h.assoc"
the prior guess gamma_h is estimated under the hypothesis of homogeneous association between the variables crossed in the initial contingency table x
.
Please note that when the input table is estimated from sample data where a weight is assigned to each unit, the weights should be used in estimating the input table, but it is suggested to rescale them so that their sum is equal to n, the sample size.
A list
object with three components.
info 
A vector with the sample size 
prior 
A table having the same dimension as 
pseudoB 
A table with having the same dimension as 
Marcello D'Orazio mdo.statmatch@gmail.com
Bishop Y.M.M., Fienberg, S.E., Holland, P.W. (1974) Discrete Multivariate Analysis: Theory and Practice. The Massachusetts Institute of Technology
data(samp.A, package="StatMatch") tab < xtabs(~ area5 + urb + c.age + sex + edu7, data = samp.A) out.pb < pBayes(x=tab, method="m.ind") out.pb$info out.pb < pBayes(x=tab, method="h.assoc") out.pb$info out.pb < pBayes(x=tab, method="Jeffreys") out.pb$info # usage of weights in estimating the input table n < nrow(samp.A) r.w < samp.A$ww / sum(samp.A$ww) * n # rescale weights to sum up to n tab.w < xtabs(r.w ~ area5 + urb + c.age + sex + edu7, data = samp.A) out.pbw < pBayes(x=tab.w, method="m.ind") out.pbw$info
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.