Movatterモバイル変換


[0]ホーム

URL:


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 classDate.

convert_type

Default:"months". String value indicating thedate type. Possible values are"days","months".

convert_to_n

Default:1. Numeric value indicating the number ofconvert_types to convert to.

Example:convert_type="months" andconvert_to_n=3 indicates aquarterly conversion.

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 classmds_de, created bya call todeviceevent().

device_level

String value indicating the source device variable nameto analyze by. Ifexposure is specified,exposure data will bematched bydevice_level. If a hierarchy of 2 or more are present,see Details for important information.

Example: If thedeviceevents variable column isdevice_1 wherethe source variable name fordevice_1 is'Device Code', specifydevice_level='Device Code'.

event_level

String value indicating the source event variable name toanalyze by. Note thatevent_level is not matched toexposure.If a hierarchy of 2 or more are present, see Details for importantinformation.

Example: If thedeviceevents variable column isevent_1 wherethe source variable name forevent_1 is'Event Code', specifyevent_level='Event Code'.

Default:NULL will not analyze by event.

exposure

Optional exposure object of classmds_e. See detailsfor how exposure analyses definitions are handled.

Default:NULL will not consider inclusion of exposure.

date_level

String value for the primary date unit to analyze by. Canbe either'months' or'days'.

Default:'months'

date_level_n

Numeric value indicating the number ofdate_levelsto analyze by.

Example:date_level='months' anddate_level_n=3 indicatesanalysis on a quarterly level.

Default:1

covariates

Character vector specifying names of covariates to alsodefine analyses for. Acceptable names are covariate variables specifiedindeviceevents. If the covariate is a factor, additional subgroupanalyses will be defined at each level of the factor."_none_"specifies no covariates, while"_all_" are all covariates specified indeviceevents. See details for more.

Example:c("Country", "Region")

Default:"_none_" specifies no covariates.

times_to_calc

Integer value indicating the number of date unitscounting backwards from the latest date to define analyses for. Ifprior is specified,times_to_calc will be ignored.

Example 1:times_to_calc=12 withdate_level="months" anddate_level_n=1 defines analyses for the last year by month.

Example 2:times_to_calc=8 withdate_level="months" anddate_level_n=3 defines analyses for the 2 years by quarter.

Default:NULL will define analyses across all available time.

invivo

Logical value indicating whether to includetime_invivofromdeviceevents in the analysis definition. See details for more.

Default:FALSE will not includetime_invivo in the analysisdefinition.

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 fordate_level

date_level_n

Defined value fordate_level_n

device_level

Defined value fordevice_level

event_level

Defined value forevent_level

times_to_calc

Defined value fortimes_to_calc

prior_used

Boolean for whetherprior was 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 classmds_das

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 indata_framecorresponding to the event. Class must be Date, POSIXt, or character.

Example:"event_date"

device_hierarchy

Vector of character variable names representing thedevice hierarchy indata_frame. Vector ordering is lowest level first,most general level last. If more than 2 variables, see important note inDetails.

Example:c("Version", "Device", "ProductLine")

event_hierarchy

Vector of character variable names representing theevent hierarchy indata_frame. Vector ordering is most specific eventcategory first, most broad event category last. If more than 2 variables,see important note in Details.

Example:c("Event Code", "Event Group")

key

Character name of (uniquely identifying) primary key variable indata_frame. Class must be character or numeric.

Example:"key_ID"

Default:NULL will create a key variable.

covariates

Vector of character variable names representing thedesired covariates to retain, all of which must be of classnumericorfactor."_all_" includes all covariates, assumedto be remaining variables indata_frame not already specified inkey,time,device_hierarchy, orevent_hierarchy.Covariates must be numeric, categorical, or binary in nature.

Example:c("Reporter", "Operation Time", "Country")

Default:NULL includes no covariates.

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."_all_" includes all remaining variables indata_frame notalready specified inkey,time,device_hierarchy,event_hierarchy, orcovariates. Typical descriptors arefree text or high-dimensional categoricals.

Example:c("Description", "Unique Device Identifier")

Default:NULL includes no descriptors.

time_invivo

Character name of numeric variable indata_framerepresenting the time in vivo of the device at the time of the eventtime. See details for more.

IMPORTANT: If a call todefine_analyses() is planned,time_invivo must be in the time units specified collectively by itsparametersdate_level anddate_level_n.

Example:"Implanted Months". A value of45 in thevariabledata_frame$'Implanted Months' would indicate 45 units of timeelapsed since the device was first in vivo. Ifdate_level="months" anddate_level_n=1, this will be interpreted bydefine_analyses()as 45 months.

Default:NULL indicates this variable will not be used.

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 forkey

time

Original variable name fortime

device_hierarchy

Vector of original variable names fordevice_hierarchy with converted variable names correspondinglynamed.

event_hierarchy

Vector of original variable names forevent_hierarchy with converted variable names correspondinglynamed.

covariates

Vector of original variable names forcovariates with converted variable names correspondinglynamed.

descriptors

Vector of original variable names fordescriptors with 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 indata_frame. Class mustbe Date, POSIXt, or character.

Example:"event_date"

device_hierarchy

Vector of character variable names representing thedevice hierarchy indata_frame. Vector ordering is lowest level first,most general level last.

Example:c("Version", "Device", "ProductLine")

event_hierarchy

Vector of character variable names representing theevent hierarchy indata_frame. Vector ordering is most specific eventcategory first, most broad event category last.

Example:c("Family", "Device", "ProductCode")

Default:NULL will not include any event hierarchy.

key

Character name of (uniquely identifying) primary key variable indata_frame. Class must be character or numeric.

Example:"key_ID"

Default:NULL will create a key variable.

match_levels

Vector of character variable names indata_framerepresenting additional grouping factors for exposure. Specified variableswill be implicitly matched to equivalently named variables contained in themds_de object class.

Example:c("Country", "Region")

Default:NULL will not include any additional grouping factors.

count

Character name of exposure count variable indata_frame.Class must be numeric.

Example:"Units Sold"

Default:NULL will assume each row represents one exposure.

Value

A standardized MD-PMS data frame of classmds_e.Rows are deduplicated. Attributes are as follows:

key

Original variable name forkey

time

Original variable name fortime

device_hierarchy

Vector of original variable names fordevice_hierarchy with converted variable names correspondinglynamed.

event_hierarchy

Vector of original variable names forevent_hierarchy with converted variable names correspondinglynamed.

match_levels

Vector of variable names for grouping factors

count

Original variable name forcount

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

Eithermin ormax

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 oftest.

no

return values for false elements oftest.

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. Optional data frame to check ifx exists in the data frame.

null_ok

Default:T. Allowx to beNULL. Ifx isNULL, bypass checking.

exclusions

Default:NULL. Optional values that are excludedfrom checking incheck_names (if it is notNULL).

max_length

Default:NULL. Optional maximum length ofx.IfNULL, no max length check will occur.

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

maude

Format

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_ts

Format

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"device_1","device_2", etc.

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"event_1","event_2", etc.

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 classmds_ts.

mode

Series to plot. Valid values are:'nA','nB','nC','nD','exposure','rate'.'rate' issimply'nA' / 'exposure'. See details for more.

Default:'nA'

xlab

x-axis label

#' Default:'Time'

ylab

y-axis label

Default:'Count'

main

Plot title

Default:NULL infers the title fromx andmode.

...

Further arguments to pass ontoplot() generic.

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

sales

Format

A data frame with 360 rows and 4 variables:

device_name

Name of the device mapped from themaude dataset.

region

Geographical region mapped from themaude dataset.

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 classmds_das

...

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 classmds_da, list ofclassmds_das, or a list of objects each of classmds_da,usually created bydefine_analyses().

...

Further arguments for future work.

deviceevents

A device-event data frame of classmds_de, usuallycreated bydeviceevent(). This should be the same data frame used togenerateanalysis.

exposure

Optional exposure data frame of classmds_e, usuallycreated byexposure(). This should be the same data frame used togenerateanalysis, if exposure data was used.

Default:NULL will not consider exposure data.

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.nB will be missing if this is an'All' level analysis.

nC

Optional. Count of the non-device & event, or if covariate analysis,non-covariate & device.nC will 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.nD will be missing if this is an'All' level analysis.

ids

List of allkeys fromdeviceevents constitutingnA.

exposure

Optional. Count of exposures applicable tonA. This counts atthe device and covariate levels but not at the event level. If a matchingdevice and/or covariate level is not found, thenexposure will beNA. The exception is an'All' level analysis, which countsexposures across all levels.

ids_exposure

Optional. List of all exposure keys fromexposureapplicable tonA.

Themds_ts class attributes are as follows:

title

Short description of the analysis.

analysis

The analysis definition of classmds_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. Ifdpa isTRUE,listobject containing labels for the DPA contingency table.

covar_data

Optional. If analysis definition includes covariate levelor time in-vivo,data.frame object containing the relevant data.

Methods (by class)

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)

[8]ページ先頭

©2009-2025 Movatter.jp