calculate_group_weights: Calculate proportion of subgroups across time

Description Usage Arguments Value Examples

View source: R/post_stratified_ITS.R

Description

Calculate overall proportion of cases in each group that lie within a given interval of time defined by t_min and t_max.

Usage

1
2
3
4
5
6
7
calculate_group_weights(
  groupname,
  dat,
  t_min,
  t_max = max(dat$month),
  Nname = "N"
)

Arguments

groupname

Name of the column that has the grouping categorical variable

dat

Dataframe with one row for each time point and group that we are going to post stratify on. This dataframe should also have an column with passed name "Nname" indicating the number of cases that make up each given row. It should have a 'month' column for the time.

t_min

The start month to aggregate cases over.

t_max

The final month (default is last month).

Nname

Name of variable holding the counts (weight) in each group.

Value

Dataframe of each group along with overall average group weight in the specified timespan.

Examples

 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 )

simITS documentation built on July 2, 2020, 4:10 a.m.