is_trx_df() will return TRUE if x is a trx_df object.
as_trx_df() will coerce a data frame to a trx_df object if that
data frame has the required columns for transaction studies listed below.
as_trx_df() is most useful for working with aggregate summaries of
experience that were not created by actxps where individual policy
information is not available. After converting the data to the trx_df
class, summary() can be used to summarize data by any grouping variables,
and autoplot() and autotable() are available for reporting.
At a minimum, the following columns are required:
Transaction amounts (trx_amt)
Transaction counts (trx_n)
The number of exposure records with transactions (trx_flag). This number
is not necessarily equal to transaction counts. If multiple transactions
are allowed per exposure period, trx_flag will be less than trx_n.
Exposures (exposure)
If transaction amounts should be expressed as a percentage of another
variable (i.e. to calculate utilization rates or actual-to-expected ratios),
additional columns are required:
A denominator "percent of" column. For example, the sum of account values.
A denominator "percent of" column for exposure records with transactions.
For example, the sum of account values across all records with non-zero
transaction amounts.
If confidence intervals are desired and "percent of" columns are passed, an
additional column for the sum of squared transaction amounts (trx_amt_sq)
is also required.
The names in parentheses above are expected column names. If the data
frame passed to as_trx_df() uses different column names, these can be
specified using the col_* arguments.
start_date, and end_date are optional arguments that are
only used for printing the resulting trx_df object.
Unlike trx_stats(), as_trx_df() only permits a single transaction type and
a single percent_of column.