plotOR | R Documentation |
Plot the posterior distribution of adjusted odds ratio given the stanfit object. It also plots the density lines of crude/uncorrected odds ratio and corrected odds ratio with constant misclassification, assuming log-normality is true. If both Se and Sp are set to 1 (i.e., no misclassification), then only the density line of crude OR will be plotted.
plotOR( model, a, N1, c, N0, se = 1, sp = 1, x.min = 0, x.max = NULL, y.max = NULL, binwidth = 0.25, fill = "gray", ... )
model |
A stanfit object. |
a |
number of exposed subjects in the case group. Along with N1, c, N0, se and sp, they are used to plot probability density with no misclassification and constant misclassification as a comparison. |
N1 |
number of total subjects in the case group. |
c |
number of exposed subjects in the control group. |
N0 |
number of total subjects in the control group. |
se |
sensitivity. Default to 1. If no other values are specified for either se or sp, then only the density curve of corrected model will be drawn. |
sp |
specificity. Default to 1. |
x.min |
shows only samples with corrected odds ratio larger or equal to |
x.max |
shows only samples with corrected odds ratio smaller or equal to |
y.max |
shows only samples or density line within the range of (0, |
binwidth |
default to |
fill |
default to |
... |
optional additional arguments passed to |
It returns a ggplot that can be further customized using the ggplot2 package.
# Case-control study data of Bipolar Disorder with rheumatoid arthritis (Farhi et al. 2016) # Data from \url{https://www.sciencedirect.com/science/article/pii/S0165032715303864#bib13} library(ggplot2) my.mod <- randCorrOR(a = 66, N1 = 11782, c = 243, N0 = 57973, m.lg.se = 1.069, m.lg.sp = 1.126, s.lg.se = 0.893, s.lg.sp = 0.712, m.z = -0.399, s.z = 0.139, seed = 0) my.plot <- plotOR(my.mod, a = 66, N1 = 11782, c = 243, N0 = 57973, se = 0.744, sp = 0.755, x.max = 3, y.max = 5, binwidth = 0.1) + ggtitle("Model with random correlation") # the user can also directly extract the data from a stanfit object using the following my.data <- as.data.frame(my.mod)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.