Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitejohnson committed Sep 26, 2024
2 parents 72afa13 + 73c0438 commit 8524d91
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 124 deletions.
4 changes: 3 additions & 1 deletion R/get_mae.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
######################################################
## FUNCTION TO CALCULATE THE MAE FOR VECTOR OF RT ##
######################################################
get_mae(pd,rt_sim){

get_mae <- function(pd,rt_sim){

# pd is summarize.rtestimate object
# rt_sim is true values of rt

Expand Down
9 changes: 6 additions & 3 deletions R/this_plot.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#####################################
## FUNCTION TO PLOT RESULTS ##
#####################################
this_plot <- function(pd, title,rt_sim) {
this_plot <- function(pd, title,rt_sim = NULL) {
# pd is from summarize.rtestimate()
# title is package/method name
# rt_sim is data.frame with Day and true rt values, Rt_calc
Expand All @@ -14,14 +14,17 @@ this_plot <- function(pd, title,rt_sim) {
show.legend = F) +
coord_cartesian(ylim = c(0, 2.5)) +
xlab("Days") +
ylab(expression(R(t))) +
ylab(expression(R(t)))

if (length(rt_sim)) {
# *******
# this is the true r(t), back-calculated
geom_line(aes(x = Day, y = Rt_calc), data = rt_sim,
plot.res <- plot.res + geom_line(aes(x = Day, y = Rt_calc), data = rt_sim,
linewidth= 0.5,
linetype = '11',
color="blue") +
ggtitle(title)
}

return(plot.res)
}
38 changes: 0 additions & 38 deletions R/utils.R

This file was deleted.

8 changes: 4 additions & 4 deletions vignettes/EpiNow2_vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ output: html_document
date: "2024-09-25"
---

```{r,include=F}
```{r}
# load packages
library(tidyverse)
require(EpiNow2)
Expand All @@ -13,7 +13,7 @@ require(EpiNow2)
# Load in the data
We first load in the sample dataset that we have generated using Simulate.RMD. This list contains the incubation period (incubation), generation interval (generation), transmission interval (transmission), serial interval (serial), reporting delay distribution (reporting_delay), true values of $R_t$ (rt), and number of cases by infection, onset and report day (cases).

```{r setup, include=FALSE}
```{r setup}
url <- "https://raw.githubusercontent.com/cmilando/RtEval/main/all_data.RDS"
all_data <- readRDS(url(url))
Expand All @@ -22,7 +22,7 @@ all_data <- readRDS(url(url))
# Prepare the data for analysis data
We will evaluate the package using the daily report data. We set up the data to be a data frame with two columns. The first column has the date and the second column has the case counts. The data starts with a row with no cases.

```{r, include=FALSE}
```{r}
# ********************************
case_choice <- 'daily_reports'
# Options: 'Daily Infections', 'Daily Onsets', 'Daily Reports'
Expand Down Expand Up @@ -63,7 +63,7 @@ incubation_pmf <- NonParametric(pmf = all_data$incubation$Px)
EpiNow2 takes in the reporting delay distribution. EpiNow2 uses rstan and we specify the option to have 4 chains. Finally, we print the total run time for the model.


```{r, include=FALSE}
```{r}
start.time <- Sys.time()
#
res_epinow <- epinow(
Expand Down
33 changes: 17 additions & 16 deletions vignettes/epiestim_vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ sapply(list.files("../R", full.names = TRUE), source)
# Install/load packages

```{r load_packages}
if (!require('devtools')) install.packages('devtools'); library(devtools)
if (!require('summrt')) devtools::install_github("EpiForeSITE/summrt"); library(summrt)
if (!require('tidyverse')) install.packages('tidyverse'); library(tidyverse)
if (!require('EpiEstim')) install.packages('EpiEstim', repos = c('https://mrc-ide.r-universe.dev', 'https://cloud.r-project.org')); library('EpiEstim')
if (!require('ggplot2')) install.packages('ggplot2'); library(ggplot2)
if (!require('lemon')) install.packages('lemon'); library(lemon)
if (!require('ggtext')) install.packages('ggtext'); library(ggtext)
library(devtools)
library(summrt)
library(tidyverse)
library('EpiEstim')
library(ggplot2)
library(lemon)
library(ggtext)
```

# Load in the data
Expand Down Expand Up @@ -95,13 +95,14 @@ reportingdelay_shift <- round(weighted.mean(
Plot data:

```{r plot_data}
plot_data <- data.frame(
package = "EpiEstim",
date = all_data$cases$day[getR$R$t_end] - incubation_shift - reportingdelay_shift,
Rt_median = getR$R$`Median(R)`,
Rt_lb = getR$R$`Quantile.0.025(R)`,
Rt_ub = getR$R$`Quantile.0.975(R)`
)
# plot_data <- data.frame(
# package = "EpiEstim",
# date = all_data$cases$day[getR$R$t_end] - incubation_shift - reportingdelay_shift,
# Rt_median = getR$R$`Median(R)`,
# Rt_lb = getR$R$`Quantile.0.025(R)`,
# Rt_ub = getR$R$`Quantile.0.975(R)`
# )
plot_data <- summarize_rtestimate(getR)
this_plot(plot_data, "EpiEstim")
```
```
Loading

0 comments on commit 8524d91

Please sign in to comment.