plot.gformula_continuous_eof: Plot method for objects of class "gformula_continuous_eof"

View source: R/s3methods.R

plot.gformula_continuous_eofR Documentation

Plot method for objects of class "gformula_continuous_eof"

Description

This function generates graphs of the mean simulated vs. observed values at each time point of the time-varying covariates under the natural course. For categorical covariates, the observed and simulated probability of each level are plotted at each time point.

Usage

## S3 method for class 'gformula_continuous_eof'
plot(
  x,
  covnames = NULL,
  ncol = NULL,
  nrow = NULL,
  common.legend = TRUE,
  legend = "bottom",
  xlab = NULL,
  ylab_cov = NULL,
  ...
)

Arguments

x

Object of class "gformula_continuous_eof".

covnames

Vector of character strings specifying the names of the time-varying covariates to be plotted. The ordering of covariates given here is used in the plot grid. Time-varying covariates of type "categorical time" cannot be included. By default, this argument is set equal to the covnames argument used in gformula_continuous_eof, where covariates of type "categorical time" are removed.

ncol

Number of columns in the plot grid. By default, two columns are used when there is at least two plots.

nrow

Number of rows in the plot grid. By default, a maximum of six rows is used and additional plots are included in subsequent pages.

common.legend

Logical scalar indicating whether to include a legend. The default is TRUE.

legend

Character string specifying the legend position. Valid values are "top", "bottom", "left", "right", and "none". The default is "bottom".

xlab

Character string for the x axes of all plots. By default, this argument is set to the time_name argument specified in gformula_continuous_eof.

ylab_cov

Vector of character strings for the y axes of the plots for the covariates. This argument must be the same length as covnames. The i-th element of this argument corresponds to the plot for the i-th element of covnames.

...

Other arguments, which are passed to ggarrange.

Value

An object of class "ggarrange". See documentation of ggarrange.

See Also

gformula_continuous_eof

Examples

## Estimating the effect of treatment strategies on the mean of a continuous
## end of follow-up outcome

library('Hmisc')
id <- 'id'
time_name <- 't0'
covnames <- c('L1', 'L2', 'A')
outcome_name <- 'Y'
covtypes <- c('categorical', 'normal', 'binary')
histories <- c(lagged)
histvars <- list(c('A', 'L1', 'L2'))
covparams <- list(covmodels = c(L1 ~ lag1_A + lag1_L1 + L3 + t0 +
                                  rcspline.eval(lag1_L2, knots = c(-1, 0, 1)),
                                L2 ~ lag1_A + L1 + lag1_L1 + lag1_L2 + L3 + t0,
                                A ~ lag1_A + L1 + L2 + lag1_L1 + lag1_L2 + L3 + t0))
ymodel <- Y ~ A + L1 + L2 + lag1_A + lag1_L1 + lag1_L2 + L3
intvars <- list('A', 'A')
interventions <- list(list(c(static, rep(0, 7))),
                      list(c(static, rep(1, 7))))
int_descript <- c('Never treat', 'Always treat')
nsimul <- 10000

gform_cont_eof <- gformula_continuous_eof(obs_data = continuous_eofdata,
                                          id = id,
                                          time_name = time_name,
                                          covnames = covnames,
                                          outcome_name = outcome_name,
                                          covtypes = covtypes,
                                          covparams = covparams, ymodel = ymodel,
                                          intvars = intvars,
                                          interventions = interventions,
                                          int_descript = int_descript,
                                          histories = histories, histvars = histvars,
                                          basecovs = c("L3"),
                                          nsimul = nsimul, seed = 1234)
plot(gform_cont_eof)



gfoRmula documentation built on May 31, 2023, 9:46 p.m.