This function computes Monte Carlo estimates of conditional Pvalues for goodness of fit tests for general loglinear models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  mcexact(formula,
data,
stat = gof,
dens = hyper,
nosim = 10 ^ 3,
method = "bab",
savechain = FALSE,
tdf = 3,
maxiter = nosim,
p = NULL,
batchsize = NULL)
build.mcx.obj(formula,
data,
stat = gof,
dens = hyper,
nosim = 10 ^ 3,
method = "bab",
savechain = FALSE,
tdf = 3,
maxiter = nosim,
p = NULL,
batchsize = NULL)

formula 
Null model formula specified as in 
data 
Data frame 
stat 
The test statistic, a function of the form 
dens 
The target density on the log scale up to a constant of
proportionallity. A function of the form

nosim 
Desired number of simulations. 
method 
Possibly two values, the importance sampling method of
Booth and Butler, 
savechain 
If 
tdf 
A tuning parameter 
maxiter 
For 
p 
A tuning parameter for 
batchsize 
Required batchsizes for 
Returns a list of class either "bab"
or "cab"
depending
on method
. The list contains all of the inputs plus all
required information to resume the simulation. Generic functions
print
and summary
format the output while update
can be used to resume simulations. mcexact
is the front end while
build.mcx.obj
simply builds the basic object that mcexact
applies to.
simulate.conditional
generates a matrix of simulated tables.
Brian Caffo
Booth and Butler (1999), "An importance sampling algorithm for exact conditional tests in loglinear models", Biometrika 86: 321332.
Caffo and Booth (2001). "A Markov Chain Monte Carlo Algorithm for Approximating Exact Conditional Probabilities", The Journal of Computational and Graphical Statistics 10: 73045.
http://www.biostat.jhsph.edu/~bcaffo/downloads.htm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  #library(mcexact)
set.seed(1)
#importance sampling
data(residence.dat)
mcx < mcexact(y ~ res.1985 + res.1980 + factor(sym.pair), data = residence.dat)
summary(mcx)
#mcmc
data(pathologist.dat)
mcx < mcexact(y ~ factor(A) + factor(B) + I(A * B),
data = pathologist.dat,
method = "cab",
p = .5,
nosim = 10 ^ 4,
batchsize = 100)
summary(mcx)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.