Skip to content

Commit

Permalink
adding check for nan before testing if R(max anom) is greater then la…
Browse files Browse the repository at this point in the history
…m(critical value) in detect_anoms. Fix suggested in issue twitter#36
  • Loading branch information
owen vallis committed Apr 15, 2015
1 parent 1039cfd commit b092103
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/detect_anoms.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ detect_anoms <- function(data, k = 0.49, alpha = 0.05, num_obs_per_period = NULL
t <- qt(p,(n-i-1L))
lam <- t*(n-i) / sqrt((n-i-1+t**2)*(n-i+1))

if(R > lam)
if(!is.nan(R) && R > lam)
num_anoms <- i
}

Expand Down

0 comments on commit b092103

Please sign in to comment.