apci {APCI} R Documentation

## Run apci model

run APC-I model

### Arguments

 outcome An object of class character containing the name of the outcome variable. The outcome variable can be continuous, categorical, or count. age An object of class character representing the age group index taking on a small number of distinct values in the data. Usually, the vector should be converted to a factor (or the terms of "category" and "enumerated type"). period An object of class character, similar to the argument of age, representing the time period index in the data. cohort An optional object of class character representing cohort membership index in the data. Usually, the cohort index can be generated from the age group index and time period index in the data because of the intrinsic relationship among these three time-related indices. weight An optional vector of sample weights to be used in the model fitting process. If non-NULL, the weights will be used in the first step to estimate the model. Observations with negative weights will be automatically dropped in modeling. covariate An optional vector of characters, representing the name(s) of the user-specified covariate(s) to be used in the model. If the variable(s) are not found in data, there will be an error message reminding the users to check the data again. data A data frame containing the outcome variable, age group indicator, period group indicator, and covariates to be used in the model. If the variable(s) are not found in data, there will be an error message reminding the users to check the input data again. family Used to specify the statistical distribution of the error term and link function to be used in the model. Usually, it is a character string naming a family function. For example, family can be "binomial", "multinomial"", or "gaussian". Users could also check R package glm for more details of family functions. dev.test Logical, specifying if the global F test (step 1) should be implemented before running the APC-I model. If TRUE, apci will first run the global F test and report the test results; otherwise, apci will skip this step and return NULL. The default setting is TRUE. But users should be careful that the algorithm will not automatically stop even if there is no significant cohort average deviation. print Logical, specifying if the intermediate results should be displayed on the screen in running the model. The default setting is TRUE in order to show the results explicitly although it can be too clumpy when the intermediate results are shown on the screen. gee logical, indicating if the data is cross-sectional data or longitudinal/panel data. If TRUE, the generalized estimating equation will be used to correct the standard error estimates. The default is FALSE, indicating that the data are cross-sectional. id A vector of character, specifying the cluster index in longitudinal data. It is required when gee is TRUE. The length of the vector should be the same as the number of observations. corstr a character string, specifying a possible correlation structure in the error terms when gee is TRUE. The following are allowed: independence, fixed, stat\_M\_dep, non\_stat\_M\_dep, exchangeable, AR-M and unstructured. The default value is exchangeable. unequal_interval Logical, indicating if age and period groups are of the same width. The default is set as TRUE. age_range, period_range Numeric vector indicating the actual age and period range (e.g., 10 to 59 years old from 2000 to 2019). age_interval, period_interval, age_group, period_group Numeric values or character vectors indicating how age and period are grouped. age_interval and period_interval are numbers indicating the width of age and period groups respectively. age_group and period_group are character vectors explicitly listing all potential age and period groups. Either age_interval(period_interval) or age_group (period_group) have to be defined when unequal_interval is TRUE. ...

### Value

 model A summary of the fitted generalized linear regression. It displays the coefficients, standard errors, etc. dev_global The results of the global F test. It shows that if the interaction terms are significant as a component of the generalized linear regression model. intercept The overall intercept. age_effect A vector, representing the estimated age effect for each age group. period_effect A vector, representing the estimated period effect for each time period. cohort_average A vector, representing the cohort average effects for comparing inter-cohort differences. cohort_slope A vector, representing intra-cohort life-course changes.

### Examples

library("APCI")
test_data <- APCI::women9017
test_data$acc <- as.factor(test_data$acc)
test_data$pcc <- as.factor(test_data$pcc)
## run APCI model
APC_I <- apci(outcome = "inlfc",
age = "acc",
period = "pcc",
cohort = "ccc",
weight = "wt",
data = test_data,dev.test=FALSE,
family = "gaussian")

## check model results
summary(APC_I)

APC_I$model APC_I$dev_global
APC_I$dev_local APC_I$intercept
APC_I$age_effect APC_I$period_effect
APC_I$cohort_average APC_I$cohort_slope

[Package APCI version 1.0.6 Index]