Skip to content

Commit

Permalink
Refining examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nsjohnsen committed Apr 18, 2024
1 parent bd78c5f commit f0193c0
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions vignettes/ep_spec_strata_w_events.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ knitr::opts_chunk$set(

# Overview

The `only_strata_with_events` endpoint parameter specifies whether the endpoint upon completion in the {chef} framework
will include all strata levels or only those levels that contain events. By default, all levels will be included in the endpoint
The `only_strata_with_events` endpoint parameter specifies whether the output data will include all strata levels or only those levels that contain events.
By default, all levels will be included in the endpoint

If there is at least one event in one of the treatment arms for a given strata level, then that strata level with be included in the
endpoint for both treatment arms regardsless of whether one of the treatment arms has no events in that stratum.
Expand Down Expand Up @@ -74,13 +74,13 @@ In this setup we note:
* `stratify_by`: `RACE` has 4 levels
* `stat_by_strata_by_trt`: 2 statistics per combination of group level and strata level

For each strata this implies:
For each SOC this implies:

* `TOTAL`: 2 treatment arms x 2 statistics = 4 combinations
* `RACE`: 2 treatment arms x 3 races x 2 statistics = 12 combinations
* Strata = `TOTAL`: 2 treatment arms x 2 statistics = 4 combinations
* Strata = `RACE`: 2 treatment arms x 3 races x 2 statistics = 12 combinations

Thus we have 23 SOCs x (4 + 12) = 368 combinations, i.e. 368 rows in the output data.
Specifically, let us consider SOC "Eye Disorder" and print the the subset of the output data that covers that SOC (see below).
Specifically, let us consider the SOC "Eye Disorder" and print the the subset of the output data that covers that SOC (see below).
As expected 4 + 12 = 16 rows are provided. We also notice that two of the strata levels for `RACE` has no event (`n` = 0), which leads to the next example.

```{r, include=FALSE}
Expand Down Expand Up @@ -114,14 +114,14 @@ targets::tar_make()
targets::tar_load(ep_stat)
```

```{r, echo=FALSE}
ep_stat[endpoint_id == "1-0007", c("stat_filter", "fn_name", "stat_result_value")]
```{r}
ep_stat[endpoint_label == "AESOC: EYE DISORDERS", c("stat_filter", "fn_name", "stat_result_value")]
```


##### Ex 7.2

Now suppose that we are only interested in the combinations of group levels and strata levels in example 7.1 that have events.
Suppose that we are only interested in the combinations of group levels and strata levels in example 7.1 that have events.
To accomplish this we may specify `only_strata_with_events = TRUE`.

```{r}
Expand All @@ -144,10 +144,9 @@ ep_spec_ex7_2 <- chef::mk_endpoint_str(

Now the number of combination in the output has been reduced to 256.

Let us revisit the SOC "Eye Disorder" and
print all rows in the output that related to that SOC (see below).
Let us revisit the SOC "Eye Disorder" and print all rows in the output that relate to that SOC (see below).
We notice that 2 strata levels for `RACE` are not present anymore ("BLACK OR AFRICAN AMERICAN", "AMERICAN INDIAN OR ALASKA NATIVE")
since they have no events c.f. example 7.1., which effectively reduces the number of rows/combinations to 8.
since they have no events c.f. example 7.1., which effectively reduces the number of rows/combinations to 8 for this SOC.

```{r, include=FALSE}
Expand Down Expand Up @@ -180,8 +179,13 @@ targets::tar_make()
targets::tar_load(ep_stat)
```

```{r, echo=FALSE, out.width=10}
ep_stat[endpoint_id == "1-0007", c("stat_filter", "fn_name", "stat_result_value")]
```{r}
ep_stat[endpoint_label == "AESOC: EYE DISORDERS", c("stat_filter", "fn_name", "stat_result_value")]
```

Similarly, the number of combinations for many of the other 22 SOCs are also less than the full 16 combinations:

```{r}
table(ep_stat$endpoint_label)
```

0 comments on commit f0193c0

Please sign in to comment.