Description Usage Arguments Value Examples
View source: R/post_stratified_ITS.R
Reweight the components of a series to match target weights for several categories. This is a good preprocessing step to adjust for time-varying covariates such as changing mix of case types.
1 2 3 4 5 6 7 8 9 10 | adjust_data(
dat,
outcomename,
groupname,
Nname,
pi_star,
is_count = FALSE,
include_aggregate = FALSE,
covariates = NULL
)
|
dat |
Dataframe of data. Requires an N column of total cases represented in each row. |
outcomename |
Name of column that has the outcome to calculated adjusted values for. |
groupname |
Name of categorical covariate that determines the groups. |
Nname |
Name of column in dat that contains total cases (this is the name of the variable used to generate the weights in pi_star). |
pi_star |
The target weights. Each month will have its groups re-weighted to match these target weights. |
is_count |
Indicator of whether outcome is count data or a continuous measure (this impacts how aggregation is done). |
include_aggregate |
Include aggregated (unadjusted) totals in the output as well. |
covariates |
Covariates to be passed to aggregation (list of string variable names). |
Dataframe of adjusted data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | data( "meck_subgroup" )
head( meck_subgroup )
pis = calculate_group_weights( "category", Nname="n.cases",
meck_subgroup, t_min=0, t_max= max( meck_subgroup$month ) )
pis
agg = aggregate_data( meck_subgroup,
outcomename="pbail", groupname="category", Nname="n.cases",
is_count=FALSE,
rich = TRUE, covariates = NULL )
head( agg )
adjdat = adjust_data( meck_subgroup, "pbail", "category", "n.cases", pis, include_aggregate=TRUE )
head( adjdat )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.