Skip to content

Instantly share code, notes, and snippets.

@adamhsparks
Last active January 19, 2022 10:57
Show Gist options
  • Save adamhsparks/d6a5cbe62263422cabcdecb3eb6afdc0 to your computer and use it in GitHub Desktop.
Save adamhsparks/d6a5cbe62263422cabcdecb3eb6afdc0 to your computer and use it in GitHub Desktop.
A Julia function to calculate area under the disease progress curve (AUDPC)
function audpc(evaluation, dates)
n = length(evaluation) - 1
disvec = Base.zeros(n)
datevec = Base.zeros(n)
out = 0.0
for i in 1:n
disvec[i] = (evaluation[i] + evaluation[i + 1]) / 2
datevec[i] = dates[i + 1] - dates[i]
out = sum(disvec .* datevec)
end
return out
end
@adamhsparks
Copy link
Author

adamhsparks commented Jan 8, 2022

Example from the audpc() help from R's agricolae package.

dates = [14, 21, 28] # days
evaluation = [40, 80, 90]
audpc(evaluation, dates)
1015.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment