plot.MFx: Plotting method for 'MFx' objects

View source: R/plot.MFx.R

plot.MFxR Documentation

Plotting method for MFx objects

Description

This is the generic plot S3 method for the MFx class. It plots the survival probability as a function of the multiplication factor applied or as a function of time.

Usage

## S3 method for class 'MFx'
plot(
  x,
  x_variable = "MFx",
  xlab = NULL,
  ylab = "Survival probability \n median and 95 CI",
  main = NULL,
  log_scale = FALSE,
  ncol = 3,
  ...
)

Arguments

x

An object of class MFx.

x_variable

A character to define the variable for the X-axis, either "MFx" or "Time". The default is "MFx".

xlab

A label for the X-axis, by default NULL and depend on the argument x_variable.

ylab

A label for the Y-axis, by default Survival probability median and 95 CI.

main

A main title for the plot.

log_scale

If TRUE, the x-axis is log-scaled. Default is FALSE.

ncol

An interger for the number of columns when several panels are plotted.

...

Further arguments to be passed to generic methods.

Value

a plot of class ggplot

Examples


# (1) Load the data
data("propiconazole")

# (2) Create an object of class 'survData'
dataset <- survData(propiconazole)


# (3) Run the survFit function with model_type SD (or IT)
out_SD <- survFit(dataset, model_type = "SD")

# (4) data to predict
data_4prediction <- data.frame(time = 1:10, conc = c(0,0.5,3,3,0,0,0.5,3,1.5,0))

# (5) estimate MF for 30% reduction of survival at time 4
MFx_SD_30.4 <- MFx(out_SD, data_predict = data_4prediction , X = 30, time_MFx = 4)

# (6) plot the object of class 'MFx'
plot(MFx_SD_30.4)

# (6bis) plot with log-scale of x-axis
plot(MFx_SD_30.4, log_scale = TRUE)

# (6ter) plot with "Time" as the x-axis
plot(MFx_SD_30.4, x_variable = "Time") 

# (7) plot when X = NULL and along a MFx_range from 5 to 10:
MFx_SD_range <- MFx(out_SD, data_predict = data_4prediction ,
                    X = NULL, time_MFx = 4, MFx_range = seq(5, 10, length.out = 50))
plot(MFx_SD_range)
plot(MFx_SD_range, x_variable = "Time", ncol = 10)



morse documentation built on Oct. 29, 2022, 1:14 a.m.