Description Usage Arguments Details Value Author(s) See Also Examples
This function compares the posterior distributions on two frequency MAPs from two unmatched populations. Posterior summaries are calculated of the population frequency differences and log odds ratios.
1 | posterior.comparison.freqMAP(group1, group2)
|
group1 |
A |
group2 |
A |
Posterior summaries are calculated by simply comparing the posterior
samples inside the two freqMAP
objects. The probability that
group1 frequency is greater than group2 frequency is calculated, the
log odds ratio mean and 95% central posterior interval (CPI) is
also calculated for each pair of categories.
For any given category, the posterior distributions on the frequencies in the two populations are assumed independent. Namely the category data in the two populations is assumed to be unmatched.
The two frequency MAPs group1
and group2
must have the
same values in their elements
[["cat.names"]]
,[["hw"]]
, and
[["x.label"]]
. Further, the values of the continuous covariate in
...$cat.ma[,...$x.label]
must be the same in both groups.
Dataframe with the following columns:
x |
The values of the continuous covariate. |
n1 |
The number of observations in group 1 falling into the
bucket centered at |
n2 |
The number of observations in group 2 falling into the
bucket centered at |
*.gr1.gt.gr2 |
(One column for each category) The posterior probability that group 1 frequency for this category is greater than the frequency in group 2. |
*.*.lor.mean |
(One column for each possible pair of categories) The posterior mean on the log odds ratio for each pair of categories. |
*.*.lor.lpi & *.*.lor.cpi |
(One column for each possible pair of categories) The posterior lower (lpi) and upper bounds (upi) on the CPI on the log odds ratio for each pair of categories. |
Colin McCulloch <colin.mcculloch@themccullochgroup.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #Make two sets of 2-category frequency data, y1 & y2, which both vary as
#a function of a continuous variable x
x <- runif(2000,min=-2,max=2)
y1 <- c("a","b")[1+rbinom(n=length(x),size=rep(1,length(x)),prob=pnorm(x/2))]
y2 <- c("a","b")[1+rbinom(n=length(x),size=rep(1,length(x)),prob=pnorm(x/5))]
#Create the frequency MAP objects for y1 and y2
fp1 <- freqMAP(data.frame(x=x,y=y1,stringsAsFactors=FALSE),
x=seq(-2,2,by=.2),x.label="x",hw=.2)
fp2 <- freqMAP(data.frame(x=x,y=y2,stringsAsFactors=FALSE),
x=seq(-2,2,by=.2),x.label="x",hw=.2)
#Examine the frequency MAP objects
summary(fp1)
print(fp2)
#Compare the posterior distributions on the two frequency MAPs
pc <- posterior.comparison.freqMAP(group1=fp1,group2=fp2)
#Three example plots
plot(fp1,ylim=matrix(c(0,1),nrow=length(fp1$cat.names),ncol=2,byrow=TRUE))
plot(fp1,fp2,type="freq",legend=c("y1","y2"),show.p.value.legend=TRUE)
plot(fp1,fp2,type="or")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.