cell_defn: Allocate Observations to Cells

View source: R/cell_defn.R

cell_defnR Documentation

Allocate Observations to Cells

Description

Take a dataset of hospital discharges, and assigns them to cells that meet a minimum threshold cell size.

Usage

cell_defn(data, min_size, layers, count = "count", expandLayers = FALSE)

Arguments

data

Dataset of discharges.

min_size

Minimize cell size.

layers

A list of lists. Each layer is a list of the variables on which observations will be allocated to cells. The layers should be ordered in decreasing refinement, so that observations not assigned to a cell meeting the minimum size threshold can be assigned by a more coarse layer.

count

Name of variable which indicates the number of admissions represented by an observation. Default variable name is count.

expandLayers

logical; if only a single layer is given, setting this to TRUE will expand the layer to a set of layers where each layer drops the last variable in the list of the previous layer.

Details

If the variable count is not available, the function will assume that each observation represents one admission, and a variable count will be created in the output data frame to indicate this.

When assigning observations to cells in a given layer, this function only assigns observations that have not been previously assigned in a finer layer. That is, the function assigns observations without replacement. Assignment with replacement is currently not supported.

For more details see the example vignette by typing: vignette("semipar_example", package = "healthcare.antitrust")

Value

A list of data frames. The first component in the list, assigned, is the original data frame, with observations assigned to cells, and excluding observations that were not assigned. The assigned cells are designated by the variable cell, and the layer number in which the observation is assigned to the cell is given by the variable cell_type. The second component of the list, unassigned, is a data frame with the unassigned observations.

Examples

data(discharge_data, package = "healthcare.antitrust")

list1 <- c("drg","age","zip5")
layers <- list(list1)
th <- 15
discharge_data$count <- 1

outList <- cell_defn(discharge_data,th,layers)


healthcare.antitrust documentation built on May 29, 2024, 6:29 a.m.