Each named argument is one attrition rule — a Group built with withAll, withAny, withAtLeast, or withAtMost. Rules are applied in order after the index event is selected.

attrition(..., expressionLimit = c("First", "All", "Last"))

Arguments

...

Named Group objects, each representing one inclusion or exclusion rule.

expressionLimit

Which qualifying events per person survive attrition — "First" (default), "All", or "Last". Should align with primaryCriteriaLimit in entry.

Value

A CohortAttrition object.

See also

Examples

t2dm <- cs(descendants(201826L), name = "T2DM")
attrition(
  noT2DM = withAll(exactly(0, conditionOccurrence(t2dm),
                           duringInterval(eventStarts(-Inf, 0)))),
  expressionLimit = "First"
)
#> An object of class "CohortAttrition"
#> Slot "rules":
#> $noT2DM
#> An object of class "Group"
#> Slot "occurrence":
#> An object of class "Occurrence"
#> Slot "type":
#> [1] "all"
#> 
#> Slot "count":
#> [1] NA
#> 
#> Slot "isDistinct":
#> [1] NA
#> 
#> Slot "countColumn":
#> [1] NA
#> 
#> 
#> Slot "criteria":
#> [[1]]
#> An object of class "Criteria"
#> Slot "occurrence":
#> An object of class "Occurrence"
#> Slot "type":
#> [1] "exactly"
#> 
#> Slot "count":
#> [1] 0
#> 
#> Slot "isDistinct":
#> [1] NA
#> 
#> Slot "countColumn":
#> [1] NA
#> 
#> 
#> Slot "query":
#> <Capr ConditionOccurrence Query> T2DM 
#> 
#> Slot "aperture":
#> An object of class "EventAperture"
#> Slot "startWindow":
#> An object of class "EventWindow"
#> Slot "event":
#> [1] "start"
#> 
#> Slot "start":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] Inf
#> 
#> Slot "coeff":
#> [1] -1
#> 
#> 
#> Slot "end":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] 0
#> 
#> Slot "coeff":
#> [1] -1
#> 
#> 
#> Slot "index":
#> [1] "startDate"
#> 
#> 
#> Slot "endWindow":
#> An object of class "EventWindow"
#> Slot "event":
#> [1] NA
#> 
#> Slot "start":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] NA
#> 
#> Slot "coeff":
#> [1] NA
#> 
#> 
#> Slot "end":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] NA
#> 
#> Slot "coeff":
#> [1] NA
#> 
#> 
#> Slot "index":
#> [1] NA
#> 
#> 
#> Slot "restrictVisit":
#> [1] FALSE
#> 
#> Slot "ignoreObservationPeriod":
#> [1] FALSE
#> 
#> 
#> 
#> 
#> Slot "group":
#> list()
#> 
#> 
#> 
#> Slot "expressionLimit":
#> [1] "First"
#>