# generate ten multiple imputations for 2x2 table, compute
# log-odds ratios and standard errors, and combine
fitML <- cvam( ~ V1 * V2, data=crime, freq=n ) # run EM first
set.seed(54981)
result <- cvam( fitML, method="MCMC",
control=list( iterMCMC=5000, imputeEvery=500 ) )
impData <- get.imputedFreq(result)[-(1:2)] # just the frequencies
est.list <- std.err.list <- as.list(1:10) # to hold the estimates and SEs
for( m in 1:10 ) {
f <- impData[,m]
est.list[[m]] <- log( (f[1] * f[4]) / (f[2] * f[3]) )
std.err.list[[m]] <- sqrt( sum(1/f) )
}
miInference( est.list, std.err.list )
Run the code above in your browser using DataLab