CMA_per_episode {AdhereR} | R Documentation |
CMA_per_episode constructor.
Description
Applies a given CMA to each treatment episode and constructs a CMA_per_episode object.
Usage
CMA_per_episode(
CMA.to.apply,
data,
treat.epi = NULL,
ID.colname = NA,
event.date.colname = NA,
event.duration.colname = NA,
event.daily.dose.colname = NA,
medication.class.colname = NA,
medication.groups = NULL,
flatten.medication.groups = FALSE,
medication.groups.colname = ".MED_GROUP_ID",
carry.only.for.same.medication = NA,
consider.dosage.change = NA,
medication.change.means.new.treatment.episode = TRUE,
dosage.change.means.new.treatment.episode = FALSE,
maximum.permissible.gap = 180,
maximum.permissible.gap.unit = c("days", "weeks", "months", "years", "percent")[1],
maximum.permissible.gap.append.to.episode = FALSE,
followup.window.start = 0,
followup.window.start.unit = c("days", "weeks", "months", "years")[1],
followup.window.start.per.medication.group = FALSE,
followup.window.duration = 365 * 2,
followup.window.duration.unit = c("days", "weeks", "months", "years")[1],
observation.window.start = 0,
observation.window.start.unit = c("days", "weeks", "months", "years")[1],
observation.window.duration = 365 * 2,
observation.window.duration.unit = c("days", "weeks", "months", "years")[1],
return.inner.event.info = FALSE,
date.format = "%m/%d/%Y",
summary = "CMA per treatment episode",
event.interval.colname = "event.interval",
gap.days.colname = "gap.days",
force.NA.CMA.for.failed.patients = TRUE,
return.mapping.events.episodes = FALSE,
parallel.backend = c("none", "multicore", "snow", "snow(SOCK)", "snow(MPI)",
"snow(NWS)")[1],
parallel.threads = "auto",
suppress.warnings = FALSE,
suppress.special.argument.checks = TRUE,
...
)
Arguments
CMA.to.apply |
A string giving the name of the CMA function (1 to 9) that will be computed for each treatment episode. |
data |
A |
treat.epi |
A |
ID.colname |
A string, the name of the column in |
event.date.colname |
A string, the name of the column in
|
event.duration.colname |
A string, the name of the column in
|
event.daily.dose.colname |
A string, the name of the column in
|
medication.class.colname |
A string, the name of the column in
|
medication.groups |
A vector of characters defining medication
groups or the name of a column in |
flatten.medication.groups |
Logical, if |
medication.groups.colname |
a string (defaults to ".MED_GROUP_ID")
giving the name of the column storing the group name when
|
carry.only.for.same.medication |
Logical, if |
consider.dosage.change |
Logical, if |
medication.change.means.new.treatment.episode |
Logical, should a change in medication automatically start a new treatment episode? |
dosage.change.means.new.treatment.episode |
Logical, should a change in dosage automatically start a new treatment episode? |
maximum.permissible.gap |
The number of units given by
|
maximum.permissible.gap.unit |
can be either "days",
"weeks", "months", "years" or "percent", and
represents the time units that |
maximum.permissible.gap.append.to.episode |
a logical value
specifying of the |
followup.window.start |
If a |
followup.window.start.unit |
can be either "days",
"weeks", "months" or "years", and represents the time
units that |
followup.window.start.per.medication.group |
a logical: if there are
medication groups defined and this is |
followup.window.duration |
either a number representing the
duration of the follow-up window in the time units given in
|
followup.window.duration.unit |
can be either "days",
"weeks", "months" or "years", and represents the time
units that |
observation.window.start , observation.window.start.unit , observation.window.duration , observation.window.duration.unit |
the definition of the observation window (see the follow-up window parameters above for details). |
return.inner.event.info |
Logical specifying if the function
should also return the event.info for all the individual events in each
sliding window; by default it is |
date.format |
A string giving the format of the dates used in the
|
summary |
Metadata as a string, briefly describing this CMA. |
event.interval.colname |
A string, the name of a newly-created
column storing the number of days between the start of the current event and
the start of the next one; the default value "event.interval" should be
changed only if there is a naming conflict with a pre-existing
"event.interval" column in |
gap.days.colname |
A string, the name of a newly-created column
storing the number of days when medication was not available (i.e., the
"gap days"); the default value "gap.days" should be changed only if there is
a naming conflict with a pre-existing "gap.days" column in |
force.NA.CMA.for.failed.patients |
Logical describing how the
patients for which the CMA estimation fails are treated: if |
return.mapping.events.episodes |
A Logical, if |
parallel.backend |
Can be "none" (the default) for single-threaded
execution, "multicore" (using |
parallel.threads |
Can be "auto" (for |
suppress.warnings |
Logical, if |
suppress.special.argument.checks |
Logical parameter for internal
use; if |
... |
other possible parameters |
Details
CMA_per_episode
first identifies the treatment episodes for the whole
follo-up window (using the compute.treatment.episodes
function),
and then computes the given "simple" CMA for each treatment episode that
intersects with the observation window. NB: the CMA is computed for the
period of the episode that is part of the observations window; thus, if an
episode starts earlier or ends later than the observation window, CMA will
be computed for a section of that episode.
Thus, as opposed to the "simple" CMAs 1 to 9, it returns a set of CMAs, with
possibly more than one element.
It is highly similar to CMA_sliding_window
which computes a CMA
for a set of sliding windows.
Value
An S3
object of class CMA_per_episode
with the
following fields:
-
data
The actual event data, as given by thedata
parameter. -
ID.colname
the name of the column indata
containing the unique patient ID, as given by theID.colname
parameter. -
event.date.colname
the name of the column indata
containing the start date of the event (in the format given in thedate.format
parameter), as given by theevent.date.colname
parameter. -
event.duration.colname
the name of the column indata
containing the event duration (in days), as given by theevent.duration.colname
parameter. -
event.daily.dose.colname
the name of the column indata
containing the prescribed daily dose, as given by theevent.daily.dose.colname
parameter. -
medication.class.colname
the name of the column indata
containing the classes/types/groups of medication, as given by themedication.class.colname
parameter. -
carry.only.for.same.medication
whether the carry-over applies only across medication of the same type, as given by thecarry.only.for.same.medication
parameter. -
consider.dosage.change
whether the carry-over is adjusted to reflect changes in dosage, as given by theconsider.dosage.change
parameter. -
followup.window.start
the beginning of the follow-up window, as given by thefollowup.window.start
parameter. -
followup.window.start.unit
the time unit of thefollowup.window.start
, as given by thefollowup.window.start.unit
parameter. -
followup.window.duration
the duration of the follow-up window, as given by thefollowup.window.duration
parameter. -
followup.window.duration.unit
the time unit of thefollowup.window.duration
, as given by thefollowup.window.duration.unit
parameter. -
observation.window.start
the beginning of the observation window, as given by theobservation.window.start
parameter. -
observation.window.start.unit
the time unit of theobservation.window.start
, as given by theobservation.window.start.unit
parameter. -
observation.window.duration
the duration of the observation window, as given by theobservation.window.duration
parameter. -
observation.window.duration.unit
the time unit of theobservation.window.duration
, as given by theobservation.window.duration.unit
parameter. -
date.format
the format of the dates, as given by thedate.format
parameter. -
summary
the metadata, as given by thesummary
parameter. -
event.info
thedata.frame
containing the event info (irrelevant for most users; seecompute.event.int.gaps
for details). -
computed.CMA
the class name of the computed CMA. -
CMA
thedata.frame
containing the actualCMA
estimates for each participant (theID.colname
column) and treatment episode, with columns:-
ID.colname
the patient ID as given by theID.colname
parameter. -
episode.ID
the unique treatment episode ID (within patients). -
episode.start
the treatment episode's start date (as aDate
object). -
end.episode.gap.days
the corresponding gap days of the last event in this episode. -
episode.duration
the treatment episode's duration in days. -
episode.end
the treatment episode's end date (as aDate
object). -
CMA
the treatment episode's estimated CMA.
-
Please note that if medication.groups
are defined, then the CMA
and event.info
are named lists, each element containing the CMA and
event.info corresponding to a single medication group (the element's name).
See Also
CMA_sliding_window
is very similar, computing a
"simple" CMA for each of a set of same-size sliding windows.
The "simple" CMAs that can be computed comprise CMA1
,
CMA2
, CMA3
, CMA4
,
CMA5
, CMA6
, CMA7
,
CMA8
, CMA9
, as well as user-defined classes
derived from CMA0
that have a CMA
component giving the
estimated CMA per patient as a data.frame
.
If return.mapping.events.episodes
is TRUE
, then this also has a
component mapping.episodes.to.events
that gives the mapping between
episodes and events as a data.table
with the following columns:
-
patid
the patient ID. -
episode.ID
the episode unique ID (increasing sequentially). -
event.index.in.data
the event given by its row number in thedata
.
Examples
## Not run:
cmaE <- CMA_per_episode(CMA="CMA1",
data=med.events,
ID.colname="PATIENT_ID",
event.date.colname="DATE",
event.duration.colname="DURATION",
event.daily.dose.colname="PERDAY",
medication.class.colname="CATEGORY",
carry.only.for.same.medication=FALSE,
consider.dosage.change=FALSE,
followup.window.start=0,
observation.window.start=0,
observation.window.duration=365,
date.format="%m/%d/%Y"
);
## End(Not run)