Skip to content

Commit

Permalink
Update functionfupcompleteness.R
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmveen authored Sep 21, 2023
1 parent 0390297 commit 082c7ef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/functionfupcompleteness.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ fup.completeness = function(date.inclusion,
death.date = NULL,
death = NULL,
deathcode = 1,
method = "clarkc"){
method = "clarkc",
r.pre = NULL){

dat = cbind.data.frame("date.inclusion" = date.inclusion,
"end.date" = end.date,
Expand Down Expand Up @@ -55,13 +56,16 @@ fup.completeness = function(date.inclusion,
dat$death.fup = as.numeric(dat$death.date - dat$date.inclusion)

x = table(dat$death)
if(dim(x)==1){stop("There are no deaths; hence caculation of death rate is not possible")}
if(!is.null(r.pre)){
if(dim(x)==1){stop("There are no deaths; hence caculation of death rate is not possible. Please pre-specify a daily death rate (r)")}
r = sum(table(dat$death)[!rownames(x) == deathcode]) / sum(dat$death.fup)

print(paste0("Daily rate is ", r))

if(r > 0.05){warning("Death rate is very high you sure death rate is correct?")}

} esle{r = r.pre}

dat$obs.fup = as.numeric(dat$last.fup.date - dat$date.inclusion)
dat$missed.fup = as.numeric(dat$end.date - dat$last.fup.date)
dat$missed.fup = replace(dat$missed.fup, dat$missed.fup<0,0)
Expand Down

0 comments on commit 082c7ef

Please sign in to comment.