as.APC.NA.df {MAPCtools}R Documentation

Create NA structure across age, period and cohort groups based on strata

Description

Creates a data frame where age, period, and cohort values are placed into columns specific to their stratum (defined by stratify_var), with other strata combinations marked as NA. This structure is often useful for specific modeling approaches, like certain Age-Period-Cohort (APC) models. Optionally includes unique indices for random effects.

Usage

as.APC.NA.df(data, stratify_by, age, period, cohort, include.random = FALSE)

Arguments

data

Data frame with age, period, cohort, and stratification columns.

stratify_by

Stratification variable column. This column will be used to create the stratum-specific NA structure. It should ideally be a factor or character vector.

age

Age column in data (must be a numeric/integer column).

period

Name of the period column (must be a numeric/integer column).

cohort

Name of the cohort column (must be a numeric/integer column).

include.random

Logical. Whether to include a unique index ('random') for each combination of age, period, and stratum, potentially for use as random effect identifiers in models. Defaults to FALSE.

Value

A data frame containing the original age, period, cohort, and stratify_by columns, plus:


[Package MAPCtools version 0.1.0 Index]