plot_gdfa: Plot Log-OR vs. X for Gamma Discriminant Function Approach

Description Usage Arguments Value Examples

View source: R/plot_gdfa.R

Description

When p_gdfa is fit with constant_or = FALSE, the log-OR for X depends on the value of X (and covariates, if any). This function plots the log-OR vs. X for one or several sets of covariate values.

Usage

1
2
plot_gdfa(estimates, varcov = NULL, xrange, xname = "X",
  cvals = NULL, set_labels = NULL, set_panels = TRUE, ncol = 1)

Arguments

estimates

Numeric vector of point estimates for (gamma_0, gamma_y, gamma_c^T, b1, b0).

varcov

Numeric matrix with variance-covariance matrix for estimates. If NULL, 95% confidence bands are omitted.

xrange

Numeric vector specifying range of X values to plot.

xname

Character vector specifying name of X variable, for plot title and x-axis label.

cvals

Numeric vector or list of numeric vectors specifying covariate values to use in log-odds ratio calculations.

set_labels

Character vector of labels for the sets of covariate values. Only used if cvals is a list.

set_panels

Logical value for whether to use separate panels for each set of covariate values, as opposed to using different colors on a single plot.

ncol

Integer value specifying number of columns for multi-panel figure. Only used if there are multiple sets of covariate values (i.e. cvals is a list).

Value

Plot of log-OR vs. X generated by ggplot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Fit Gamma discriminant function model for poolwise X vs. (Y, C), without
# assuming a constant log-OR. Note that data were generated with a constant
# log-OR of 0.5.
data(dat_p_gdfa)
dat <- dat_p_gdfa$dat
c.list <- dat_p_gdfa$c.list
fit <- p_gdfa(
  g = dat$g,
  y = dat$y,
  xtilde = dat$x,
  c = c.list,
  errors = "neither",
  constant_or = FALSE
)

# Plot estimated log-OR vs. X, holding C fixed at the sample mean.
p <- plot_gdfa(
  estimates = fit$estimates,
  varcov = fit$theta.var,
  xrange = range(dat$x[dat$g == 1]),
  cvals = mean(unlist(c.list))
)
p

pooling documentation built on Feb. 13, 2020, 9:07 a.m.

Related to plot_gdfa in pooling...