Skip to content

Commit

Permalink
Merge pull request #339 from cmu-delphi/missing-rlang-imports
Browse files Browse the repository at this point in the history
Missing rlang imports
  • Loading branch information
dajmcdon authored Jun 14, 2024
2 parents de6e1db + 12fafa6 commit abe8805
Show file tree
Hide file tree
Showing 9 changed files with 749 additions and 199 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ importFrom(magrittr,"%>%")
importFrom(quantreg,rq)
importFrom(recipes,bake)
importFrom(recipes,prep)
importFrom(rlang,"!!!")
importFrom(rlang,"!!")
importFrom(rlang,"%@%")
importFrom(rlang,"%||%")
Expand All @@ -243,7 +244,10 @@ importFrom(rlang,abort)
importFrom(rlang,as_function)
importFrom(rlang,caller_env)
importFrom(rlang,global_env)
importFrom(rlang,inject)
importFrom(rlang,is_logical)
importFrom(rlang,is_null)
importFrom(rlang,is_true)
importFrom(rlang,set_names)
importFrom(smoothqr,smooth_qr)
importFrom(stats,as.formula)
Expand Down
3 changes: 2 additions & 1 deletion R/epipredict-package.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## usethis namespace: start
#' @importFrom tibble tibble
#' @importFrom rlang := !! %||% as_function global_env set_names
#' @importFrom rlang := !! %||% as_function global_env set_names !!!
#' @importFrom rlang is_logical is_true inject
#' @importFrom stats poly predict lm residuals quantile
#' @importFrom cli cli_abort
#' @importFrom checkmate assert assert_character assert_int assert_scalar
Expand Down
15 changes: 9 additions & 6 deletions vignettes/articles/sliding.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ library(purrr)
A key function from the epiprocess package is `epi_slide()`, which allows the
user to apply a function or formula-based computation over variables in an
`epi_df` over a running window of `n` time steps (see the following `epiprocess`
vignette to go over the basics of the function: ["Slide a computation over
signal values"](https://cmu-delphi.github.io/epiprocess/articles/slide.html)).
vignette to go over the basics of the function:
["Slide a computation over signal values"](https://cmu-delphi.github.io/epiprocess/articles/slide.html)).
The equivalent sliding method for an `epi_archive` object can be called by using
the wrapper function `epix_slide()` (refer to the following vignette for the
basics of the function: ["Work with archive objects and data
revisions"](https://cmu-delphi.github.io/epiprocess/articles/archive.html)). The
basics of the function:
["Work with archive objects and data revisions"](https://cmu-delphi.github.io/epiprocess/articles/archive.html)). The
key difference from `epi_slide()` is that it performs version-aware
computations. That is, the function only uses data that would have been
available as of time t for that reference time.
Expand Down Expand Up @@ -171,7 +171,9 @@ in such forecasting. Including such factors as well as making enhancements such
as correcting for outliers are some improvements one could make to this simple
model.[^1]

[^1]: Note that, despite the above caveats, simple models like this tend to out-perform many far more complicated models in the online Covid forecasting due to those models high variance predictions.
[^1]: Note that, despite the above caveats, simple models like this tend to
out-perform many far more complicated models in the online Covid forecasting due
to those models high variance predictions.

### Example using case data from Canada

Expand Down Expand Up @@ -327,7 +329,8 @@ fc <- bind_rows(
) %>% pivot_quantiles_wider(fc_.pred_distn)
```

Now we can plot the results on top of the latest case rates. As before, we will only display and focus on the results for FL and CA for simplicity.
Now we can plot the results on top of the latest case rates. As before, we will
only display and focus on the results for FL and CA for simplicity.

```{r plot-ar-asof, message = FALSE, warning = FALSE, fig.width = 9, fig.height = 6}
fc_cafl <- fc %>% filter(geo_value %in% c("ca", "fl"))
Expand Down
262 changes: 202 additions & 60 deletions vignettes/articles/smooth-qr.Rmd

Large diffs are not rendered by default.

302 changes: 246 additions & 56 deletions vignettes/articles/symptom-surveys.Rmd

Large diffs are not rendered by default.

180 changes: 151 additions & 29 deletions vignettes/arx-classifier.Rmd

Large diffs are not rendered by default.

145 changes: 110 additions & 35 deletions vignettes/epipredict.Rmd

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions vignettes/panel-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ summary(extract_fit_engine(wf_linreg))
```

This output tells us the coefficients of the fitted model; for instance,
the estimated intercept is $\widehat{\alpha}_0 =$ `r round(coef(extract_fit_engine(wf_linreg))[1], 3)` and the coefficient for $y_{tijk}$ is
the estimated intercept is $\widehat{\alpha}_0 =$
`r round(coef(extract_fit_engine(wf_linreg))[1], 3)` and the coefficient for
$y_{tijk}$ is
$\widehat\alpha_1 =$ `r round(coef(extract_fit_engine(wf_linreg))[2], 3)`.
The summary also tells us that all estimated coefficients are significantly
different from zero. Extracting the 95% confidence intervals for the
Expand Down Expand Up @@ -315,7 +317,8 @@ defined as follows:
\end{aligned}
\]

where $y_{tijk}$ is the 5-year median income (proportion) at time $t$ (in location $i$, age group $j$ with education quality $k$),
where $y_{tijk}$ is the 5-year median income (proportion) at time $t$ (in
location $i$, age group $j$ with education quality $k$),
$x_{tijk}$ is the 2-year median income (proportion) at time $t$, and
$z_{tijk}$ is the number of graduates (proportion) at time $t$.

Expand Down
30 changes: 20 additions & 10 deletions vignettes/preprocessing-and-models.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ and forecasts to characterize the state of an outbreak and its course. They use
it to inform public health decision makers on potential consequences of
deploying control measures.

One of the outcomes that the CDC forecasts is [death counts from COVID-19](https://www.cdc.gov/coronavirus/2019-ncov/science/forecasting/forecasting-us.html).
One of the outcomes that the CDC forecasts is
[death counts from COVID-19](https://www.cdc.gov/coronavirus/2019-ncov/science/forecasting/forecasting-us.html).
Although there are many state-of-the-art models, we choose to use Poisson
regression, the textbook example for modeling count data, as an illustration
for using the `epipredict` package with other existing tidymodels packages.
Expand Down Expand Up @@ -109,7 +110,8 @@ Poisson distribution with mean $\mu_{t+7}$; $s_{\text{state}}$ are dummy
variables for each state and take values of either 0 or 1.

Preprocessing steps will be performed to prepare the
data for model fitting. But before diving into them, it will be helpful to understand what `roles` are in the `recipes` framework.
data for model fitting. But before diving into them, it will be helpful to
understand what `roles` are in the `recipes` framework.

---

Expand Down Expand Up @@ -235,9 +237,10 @@ using
`layer_residual_quantiles()` should be used before population scaling or else
the transformation will make the results uninterpretable.

We wish, now, to predict the 7-day ahead death counts with lagged case rates and death
rates, along with some extra behaviourial predictors. Namely, we will use survey data
from [COVID-19 Trends and Impact Survey](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/fb-survey.html#behavior-indicators).
We wish, now, to predict the 7-day ahead death counts with lagged case rates and
death rates, along with some extra behaviourial predictors. Namely, we will use
survey data from
[COVID-19 Trends and Impact Survey](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/fb-survey.html#behavior-indicators).

The survey data provides the estimated percentage of people who wore a mask for
most or all of the time while in public in the past 7 days and the estimated
Expand Down Expand Up @@ -413,7 +416,8 @@ We say location $\ell$ is a hotspot at time $t$ when $Z_{\ell,t}$ is
`up`, meaning the number of newly reported cases over the past 7 days has
increased by at least 25% compared to the preceding week. When $Z_{\ell,t}$
is categorized as `down`, it suggests that there has been at least a 20%
decrease in newly reported cases over the past 7 days (a 20% decrease is the inverse of a 25% increase). Otherwise, we will
decrease in newly reported cases over the past 7 days (a 20% decrease is the
inverse of a 25% increase). Otherwise, we will
consider the trend to be `flat`.

The expression of the multinomial regression we will use is as follows:
Expand All @@ -439,7 +443,8 @@ g_{\text{up}}(x) &= \log\left(\frac{Pr(Z_{\ell,t}=\text{up}\mid x)}{Pr(Z_{\ell,t
\end{aligned}

Preprocessing steps are similar to the previous models with an additional step
of categorizing the response variables. Again, we will use a subset of death rate and case rate data from our built-in dataset
of categorizing the response variables. Again, we will use a subset of death
rate and case rate data from our built-in dataset
`case_death_rate_subset`.

```{r}
Expand Down Expand Up @@ -585,7 +590,12 @@ Sciences 118.51 (2021): e2111453118. [doi:10.1073/pnas.2111453118](https://doi.o

## Attribution

This object contains a modified part of the [COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University](https://github.com/CSSEGISandData/COVID-19) as [republished in the COVIDcast Epidata API.](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html)
This object contains a modified part of the
[COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University](https://github.com/CSSEGISandData/COVID-19)
as [republished in the COVIDcast Epidata API.](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/jhu-csse.html)

This data set is licensed under the terms of the [Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/) by the Johns Hopkins University
on behalf of its Center for Systems Science in Engineering. Copyright Johns Hopkins University 2020.
This data set is licensed under the terms of the
[Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/)
by the Johns Hopkins
University on behalf of its Center for Systems Science in Engineering. Copyright
Johns Hopkins University 2020.

0 comments on commit abe8805

Please sign in to comment.