This function simulates volume-time tracing data produced by breathing of a hypothetical subject as recorded by the Harvard spirometer. A number of parameters can be specified to adjust the tracing data. The output of this function is a data frame to be plotted by the user.

sim_Harvard_tracing(
  f = "cos",
  t_start = 0,
  t_end = 1,
  paper_speed = 25,
  TV = 500,
  RR = 20,
  oxycons = 0,
  oxycons_unit = c("L/hr", "ml/min"),
  y_int_O2_line = 0,
  seq_x_by = 0.05,
  epsilon_sd = NULL,
  seed = 1
)

Arguments

f

(Character or Symbol) A function to generate 1 respiratory cycle (i.e., inspiration and expiration). The default, currently, is a cosine function. Any function can be specified such that the amplitude is 1 (peak at 1, trough at -1) and the wavelength is 2*pi.

t_start

(Numeric) Time point (minute) when the experiment start

t_end

(Numeric) Time point (minute) when the experiment end

paper_speed

(Numeric) Paper speed (mm/minute) of the tracing

TV

(Numeric) Tidal volume (mL) that subject breath

RR

(Numeric) Respiratory Rate (/min) of subject

oxycons

(Numeric) Oxygen consumption of subject

oxycons_unit

(Character) Units of the oxycons must be one of: "L/hr" or "ml/min".

y_int_O2_line

(Numeric) Y-intercept of an oxygen-line, i.e., the baseline that passed through the trough of each respiratory cycle waves.

seq_x_by

(Numeric) Difference between consecutive x values to generate. (similar to by argument of seq())

epsilon_sd

If provided as numeric, it is a standard deviation of an error term sampled from Gaussian distribution with mean = 0

seed

(Numeric) If provided epsilon_sd, It is a seed to generated random error variation.

Value

A data.frame with "HarvardTracing" subclass which has 3 columns:

  • x: x-axis data of the respiratory wave tracing (in milimeter)

  • y: y-axis data of the respiratory wave tracing (in milimeter)

  • y_O2_line: y-axis data of the oxygen-line (in milimeter)