| Type: | Package |
| Title: | Medical Devices Surveillance |
| Version: | 0.3.2 |
| Maintainer: | Gary Chung <gchung05@gmail.com> |
| Description: | A set of core functions for handling medical device event data in the context of post-market surveillance, pharmacovigilance, signal detection and trending, and regulatory reporting. Primary inputs are data on events by device and data on exposures by device. Outputs include: standardized device-event and exposure datasets, defined analyses, and time series. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.1.0 |
| Depends: | R (≥ 2.10) |
| Imports: | stats, parsedate, lubridate |
| Suggests: | testthat, knitr, rmarkdown |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2020-06-15 01:46:04 UTC; gchun |
| Author: | Gary Chung [aut, cre] |
| Repository: | CRAN |
| Date/Publication: | 2020-06-15 13:30:03 UTC |
Character Vector to Header of Empty Data Frame
Description
Converts a character vector into the column names of an empty data frame.Used in conjunction withcheck_names parameter ofinput_param_checker()
Usage
char_to_df(x)Arguments
x | Input character vector. |
Value
Empty data frame where columns are namedx.
Convert to Acceptable Date
Description
Converts aDate vector into its equivalent daily, monthly, yearly,etc...Date vector.
Usage
convert_date(x, convert_type = "months", convert_to_n = 1)Arguments
x | Input vector of class |
convert_type | Default: |
convert_to_n | Default: Example: |
Value
ConvertedDate vector of classmdpms.Date withattributesadder (function that adds units),convert_to_n, andconvert_type.
Assess Analyses Definitions
Description
Define analyses based on an MD-PMS device-event data frame and, optionally,an MD-PMS exposure data frame. See Details for how to use.
Usage
define_analyses( deviceevents, device_level, event_level = NULL, exposure = NULL, date_level = "months", date_level_n = 1, covariates = "_none_", times_to_calc = NULL, invivo = FALSE, prior = NULL)Arguments
deviceevents | A device-events object of class |
device_level | String value indicating the source device variable nameto analyze by. If Example: If the |
event_level | String value indicating the source event variable name toanalyze by. Note that Example: If the Default: |
exposure | Optional exposure object of class Default: |
date_level | String value for the primary date unit to analyze by. Canbe either Default: |
date_level_n | Numeric value indicating the number of Example: Default: |
covariates | Character vector specifying names of covariates to alsodefine analyses for. Acceptable names are covariate variables specifiedin Example: Default: |
times_to_calc | Integer value indicating the number of date unitscounting backwards from the latest date to define analyses for. If Example 1: Example 2: Default: |
invivo | Logical value indicating whether to include Default: |
prior | Future placeholder, currently not used. |
Details
define_analyses() is a prerequisite to callingtime_series(). This function enumerates all possible analyses basedon input device-event (deviceevent()) and, optionally,exposure (exposure()) data frames. An analysis is defined as a set ofinstructions specifying at minimum the device level, event level, the daterange of analysis, and the date unit. Additional instructions include thecovariate level, time in-vivo status, and exposure levels.
By separating the analysis enumeration (define_analyses()) from thegeneration of the time series (time_series()), the user may rerunthe analyses on different datasets and/or filter the analyses to only thoseof interest.
The analyses definitions will always include rollup levels for eachofdevice_level,event_level (if specified), andcovariates. Rollups are analyses at all device, event, and/orcovariate levels. These rollup analyses will be indicated by the keyword'All' in the analysis definition.
When a hierarchy of 2 or more variables for eitherdevice_level orevent_level are present indeviceevents,define_analyses() will enforce the 1-level-up parent level ONLY.Additional higher parent levels are not currently enforced, thus the user isadvised to uniquely name the 1-level-up parent level. The parent levelDOES NOT ROLLUP currently because the parent level is intended to separatedisparate data and devices. This may change in the future.
Ifexposure is specified, any availablematch_levels will beused to calculate the appropriate timeframe for analyses. The exception arethe special rollup analyses (see prior paragraph).
Whencovariates are specified, a special rollup analysis definitionwill always be defined that does not consider the covariates at all. Thisanalysis can be identified bycovariate='Data' andcovariate_level='All' in the outputmds_da object.
Whencovariates are specified and there is no variation in thedistribution of covariate values (e.g. all males, all 10, all missing) in thedevice- and event-specific dataset, these specific analyses will be dropped.
When factorcovariates are specified, covariate-level analyses may bedefined two ways: 1) detect an overall covariate level effect,also known as a 3-dimensional analysis, and 2) subset the data by eachlevel of the covariate, also known as a subgroup analysis. 1) will bedenoted ascovariate_level='All' in the outputmds_da object,while 2) will specify the factor level incovariate_level.
Ifinvivo=TRUE,define_analyses() will first verify if dataexists in thetime_invivo variable for the givendevice_level,event_level, and, if applicable,covariates level. If no dataexists,invivo will be implicitly assigned toFALSE.
Value
A list of defined analyses of classmds_das.Each list item, indexed by a numeric key, defines a set of analyses for aunique combination of device, event, and covariate level. Each list item isof the classmds_da.Attributes of classmds_das are as follows:
- date_level
Defined value for
date_level- date_level_n
Defined value for
date_level_n- device_level
Defined value for
device_level- event_level
Defined value for
event_level- times_to_calc
Defined value for
times_to_calc- prior_used
Boolean for whether
priorwas specified.- timestamp
System time when the analyses were defined.
Examples
# Device-Eventsde <- deviceevent( data_frame=maude, time="date_received", device_hierarchy=c("device_name", "device_class"), event_hierarchy=c("event_type", "medical_specialty_description"), key="report_number", covariates=c("region"), descriptors="_all_")# Exposuresex <- exposure( data_frame=sales, time="sales_month", device_hierarchy="device_name", match_levels="region", count="sales_volume")# Defined Analyses - Simple exampleda <- define_analyses(de, "device_name")# Defined Analyses - Simple example with a quarterly analysisda <- define_analyses(de, "device_name", date_level_n=3)# Defined Analyses - Example with event type, exposures, and covariatesda <- define_analyses(de, "device_name", "event_type", ex, covariates="region")Create Data Frame from Analyses Definitions
Description
Returns a data frame summarizing all defined analyses from themds_das object.
Usage
define_analyses_dataframe(inlist)Arguments
inlist | Object of class |
Value
A data frame with each row representing an analysis.
MD-PMS Device Event Data Frame
Description
Converts a data frame into a MD-PMS Device Event data frame.
Usage
deviceevent( data_frame, time, device_hierarchy, event_hierarchy, key = NULL, covariates = NULL, descriptors = NULL, time_invivo = NULL)Arguments
data_frame | The input data frame requiring components specified in theremaining arguments. |
time | Character name of date variable in Example: |
device_hierarchy | Vector of character variable names representing thedevice hierarchy in Example: |
event_hierarchy | Vector of character variable names representing theevent hierarchy in Example: |
key | Character name of (uniquely identifying) primary key variable in Example: Default: |
covariates | Vector of character variable names representing thedesired covariates to retain, all of which must be of class Example: Default: |
descriptors | Vector of character variable names representing additionaldescriptive variables that will not be used in any analyses but may berecalled or displayed later during individual device-event review. Example: Default: |
time_invivo | Character name of numeric variable in IMPORTANT: If a call to Example: Default: |
Details
When more than 2 variables are specified in eitherdevice_hierarchyorevent_hierarchy, it is important to note that a subsequent call todefine_analyses() currently only utilizes a maximum of 2 variables:the lowest level and the 1-level-up parent. The user may enforce fullhierarchy in >2 variable cases by ensuring that the parent values areuniquely named.
time_invivo can be thought of more generally as the time ofexposure of the device to the subject at the time of the event. The commonusage is duration of the implant in the patient at time of event, for animplantable medical device.
Value
A standardized MD-PMS data frame of classmds_de.Rows are deduplicated. Attributes are as follows:
- key
Original variable name for
key- time
Original variable name for
time- device_hierarchy
Vector of original variable names for
device_hierarchywith converted variable names correspondinglynamed.- event_hierarchy
Vector of original variable names for
event_hierarchywith converted variable names correspondinglynamed.- covariates
Vector of original variable names for
covariateswith converted variable names correspondinglynamed.- descriptors
Vector of original variable names for
descriptorswith converted variable names correspondinglynamed.
Examples
# A barebones datasetde <- deviceevent(maude, "date_received", "device_name", "event_type")# With more variables and variable typesde <- deviceevent( data_frame=maude, time="date_received", device_hierarchy=c("device_name", "device_class"), event_hierarchy=c("event_type", "medical_specialty_description"), key="report_number", covariates=c("region"), descriptors="_all_")MD-PMS Exposure Data Frame
Description
Converts a data frame into a MD-PMS Exposure data frame.
Usage
exposure( data_frame, time, device_hierarchy, event_hierarchy = NULL, key = NULL, match_levels = NULL, count = NULL)Arguments
data_frame | The input data frame requiring components specified in theremaining arguments. |
time | Character name of date variable in Example: |
device_hierarchy | Vector of character variable names representing thedevice hierarchy in Example: |
event_hierarchy | Vector of character variable names representing theevent hierarchy in Example: Default: |
key | Character name of (uniquely identifying) primary key variable in Example: Default: |
match_levels | Vector of character variable names in Example: Default: |
count | Character name of exposure count variable in Example: Default: |
Value
A standardized MD-PMS data frame of classmds_e.Rows are deduplicated. Attributes are as follows:
- key
Original variable name for
key- time
Original variable name for
time- device_hierarchy
Vector of original variable names for
device_hierarchywith converted variable names correspondinglynamed.- event_hierarchy
Vector of original variable names for
event_hierarchywith converted variable names correspondinglynamed.- match_levels
Vector of variable names for grouping factors
- count
Original variable name for
count
Examples
# A barebones datasetex <- exposure(sales, "sales_month", "device_name")# With more variables and variable typesex <- exposure( data_frame=sales, time="sales_month", device_hierarchy="device_name", match_levels="region", count="sales_volume")Min/Max With All NA's AllowedMin and Max functions that allows the vectorx to beNA, wheref ismin ormax
Description
Min/Max With All NA's AllowedMin and Max functions that allows the vectorx to beNA, wheref ismin ormax
Usage
fNA(x, f)Arguments
x | Numeric input vector |
f | Either |
Value
Numeric value corresponding tomin ormax, orNA
Class-Preserving If-ElseIf-Else function preservingT &F classes
Description
Class-Preserving If-ElseIf-Else function preservingT &F classes
Usage
ifelse_cp(test, yes, no)Arguments
test | an object which can be coerced to logical mode |
yes | return values for true elements of |
no | return values for false elements of |
Value
A vector of the same length and attributes astest.
Check Input Parameters
Description
Verifies correct class and, optionally, verifies existence in a data frame
Usage
input_param_checker( x, check_class = NULL, check_names = NULL, null_ok = T, exclusions = NULL, max_length = NULL)Arguments
x | Single object name, character, or vector of characters |
check_class | Vector of correct classes in character format |
check_names | Default: |
null_ok | Default: |
exclusions | Default: |
max_length | Default: |
Value
Stop error, if an error is found. Else nothing.
Bone Cement MAUDE Events in 2017
Description
A dataset containing 535 events reported into the FDA MAUDE database on bonecement in 2017. Data were obtained via the openFDA API(https://open.fda.gov).
Usage
maudeFormat
A data frame with 535 rows and 15 variables. Full variabledescriptions may be found on the FDA Device Reference Guide(https://open.fda.gov). Note thatregionis a simulated variable not present in MAUDE. Descriptions as follows:
- report_number
Identifying number for the adverse event report.
- event_type
Outcomes associated with the adverse event.
- date_received
Date the report was received by the FDA.
- product_problem_flag
Indicates whether or not a report was about thequality, performance or safety of a device.
- adverse_event_flag
Whether the report is about an incident where theuse of the device is suspected to have resulted in an adverse outcome in apatient.
- report_source_code
Source of the adverse event report.
- lot_number
The lot number found on the label or packaging material.
- model_number
The exact model number found on the device label oraccompanying packaging.
- manufacturer_d_name
Device manufacturer name.
- manufacturer_d_country
Device manufacturer country.
- brand_name
The trade or proprietary name of the suspect medicaldevice as used in product labeling or in the catalog.
- device_name
This is the proprietary name, or trade name, of thecleared device.
- medical_specialty_description
Regulation Medical Specialty isassigned based on the regulation (e.g. 21 CFR Part 888 is OrthopedicDevices).
- device_class
A risk based classification system for all medicaldevices ((Federal Food, Drug, and Cosmetic Act, section 513)
- region
A simulated, randomly assigned geographical region forpackage example purposes.
Source
https://open.fda.gov/data/maude/
Example List of mds_ts Time Series Objects
Description
An example list of time series objects (classmds_ts) generated usingthemds package.
Usage
mds_tsFormat
A list of 3 elements each of classmds_ts
Source
See?maude and?sales for source device-event andexposure data. See?mds::time_series for how to generatemds_tstime series.
Return next level up device
Description
Returns the variable name of the next level in the device hierarchy
Usage
next_dev(x)Arguments
x | String input of device name, such as |
Value
String representation of the next device level variable
Return next level up event
Description
Returns the variable name of the next level in the event hierarchy
Usage
next_ev(x)Arguments
x | String input of event name, such as |
Value
String representation of the next event level variable
Plot MD-PMS Time Series
Description
Quickly visualizes an MD-PMS times series of classmds_ts.
Usage
## S3 method for class 'mds_ts'plot(x, mode = "nA", xlab = "Time", ylab = "Count", main = NULL, ...)Arguments
x | An object of class |
mode | Series to plot. Valid values are: Default: |
xlab | x-axis label #' Default: |
ylab | y-axis label Default: |
main | Plot title Default: |
... | Further arguments to pass onto |
Details
mode values defined as follows. Note: The followingdefinitions use a device-event pair as a working example, however it may alsobe a covariate-device pair.
- 'nA'
Counts of the device-event pair.
- 'nB'
Counts of the device for all other events.
- 'nC'
Counts of all other devices for the event.
- 'nD'
Counts of all other devices for all other events.
- 'exposure'
Counts of exposure for the device-event pair.
- 'rate'
A crude rate, calculated as the device-event counts pairdivided by the exposure counts.
Simulated Device Sales Data
Description
A dataset containing simulated monthly sales by device and country fordevices reported in themaude dataset. For package usage examples,this data serves as a proxy for exposures. Data were generated using arandom normal distribution weighted by the number of reported events bydevice and country.
Usage
salesFormat
A data frame with 360 rows and 4 variables:
- device_name
Name of the device mapped from the
maudedataset.- region
Geographical region mapped from the
maudedataset.- sales_month
The month of sales.
- sales_volume
The volume of sales.
Source
Random normal distribution usingrnorm().
Summarize a Collection of MD-PMS Defined AnalysesPrints basic counts and date ranges by various analysis factors as defined inthe originaldefine_analyses() call.
Description
Summarize a Collection of MD-PMS Defined AnalysesPrints basic counts and date ranges by various analysis factors as defined inthe originaldefine_analyses() call.
Usage
## S3 method for class 'mds_das'summary(object, ...)Arguments
object | A MD-PMS Defined Analyses object of class |
... | Additional arguments affecting the summary produced |
Value
List of analyses counts and date ranges.
Generate Time Series from Defined Analysis or Analyses
Description
Creates time series data frame(s) from defined analysis/analyses(define_analyses()), device-event data frame(deviceevent()), and optionally, exposure data frame(exposure()). If analysis includes covariates or time in-vivo, createsthe relevant supporting data frame.
Usage
time_series(analysis, ...)## S3 method for class 'list'time_series(analysis, ...)## S3 method for class 'mds_das'time_series(analysis, ...)## S3 method for class 'mds_da'time_series(analysis, deviceevents, exposure = NULL, use_hierarchy = T, ...)Arguments
analysis | A defined analysis object of class |
... | Further arguments for future work. |
deviceevents | A device-event data frame of class |
exposure | Optional exposure data frame of class Default: |
use_hierarchy | Deprecated - do not use. Logical value indicatingwhether device and event hierarchies should be used in counting contingencytables for disproportionality analysis. |
Value
A standardized MD-PMS time series data frame of classmds_ts.
The data frame contains, by defined date levels, the following columns:
- nA
Count of the device & event level of interest. If covariateanalysis is indicated, this will be at the covariate & device level ofinterest.
- nB
Optional. Count of the device & non-event, or if covariate analysis,covariate & non-device.
nBwill be missing if this is an'All'level analysis.- nC
Optional. Count of the non-device & event, or if covariate analysis,non-covariate & device.
nCwill be missing if this is an'All'level analysis.- nD
Optional. Count of the non-device & non-event, or if covariate analysis,non-covariate & non-device.
nDwill be missing if this is an'All'level analysis.- ids
List of all
keys fromdeviceeventsconstitutingnA.- exposure
Optional. Count of exposures applicable to
nA. This counts atthe device and covariate levels but not at the event level. If a matchingdevice and/or covariate level is not found, thenexposurewill beNA. The exception is an'All'level analysis, which countsexposures across all levels.- ids_exposure
Optional. List of all exposure keys from
exposureapplicable tonA.
Themds_ts class attributes are as follows:
- title
Short description of the analysis.
- analysis
The analysis definition of class
mds_da.- exposure
Boolean of whether exposure counts are present.
- dpa
Boolean of whether 2x2 contingency table counts are present(presumably for disproportionality analysis or 'DPA').
- dpa_detail
Optional. If
dpaisTRUE,listobject containing labels for the DPA contingency table.- covar_data
Optional. If analysis definition includes covariate levelor time in-vivo,
data.frameobject containing the relevant data.
Methods (by class)
list: Generate time series from a listmds_das: Generate time series from a list of defined analysesmds_da: Generate time series using defined analysis
Examples
de <- deviceevent(maude, "date_received", "device_name", "event_type")ex <- exposure(sales, "sales_month", "device_name", count="sales_volume")da <- define_analyses(de, "device_name", exposure=ex)# Time series on one analysistime_series(da, de, ex)# Time series on multiple analysestime_series(da[1:3], de, ex)