plotOR: Plot Model

Description Usage Arguments Value Examples

View source: R/plotModels.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
plotOR(
  model,
  a,
  N1,
  c,
  N0,
  se = 1,
  sp = 1,
  x.min = 0,
  x.max = NULL,
  y.max = NULL,
  binwidth = 0.25,
  fill = "gray",
  ...
)

Arguments

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.min. Default to 0.

x.max

shows only samples with corrected odds ratio smaller or equal to x.max. Default to the largest OR in the posterior samples.

y.max

shows only samples or density line within the range of (0, y.max).

binwidth

default to 0.25

fill

default to "gray"

...

optional additional arguments passed to geom_histogram

Value

It returns a ggplot that can be further customized using the ggplot2 package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 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)

formidify/BayesSenMC documentation built on Sept. 2, 2021, 6:36 a.m.