# Defining scenarios: -----
# (a) minimal information:
hustosis <- riskyr(scen_lbl = "Screening for hustosis",
N = 1000, prev = .04, sens = .80, spec = .95)
# (2) detailed information:
scen_reoffend <- riskyr(scen_lbl = "Identify reoffenders",
cond_lbl = "being a reoffender",
popu_lbl = "Prisoners",
cond_true_lbl = "has reoffended",
cond_false_lbl = "has not reoffended",
dec_lbl = "test result",
dec_pos_lbl = "will reoffend",
dec_neg_lbl = "will not reoffend",
sdt_lbl = "combination",
hi_lbl = "reoffender found", mi_lbl = "reoffender missed",
fa_lbl = "false accusation", cr_lbl = "correct release",
prev = .45, # prevalence of being a reoffender.
sens = .98,
spec = .46, fart = NA, # (provide 1 of 2)
N = 753,
scen_src = "Example scenario")
# Using scenarios: -----
summary(hustosis)
plot(hustosis)
summary(scen_reoffend)
plot(scen_reoffend)
# 2 ways of defining the same scenario:
s1 <- riskyr(prev = .5, sens = .5, spec = .5, N = 100) # s1: define by 3 prob & N
s2 <- riskyr(hi = 25, mi = 25, fa = 25, cr = 25) # s2: same scenario by 4 freq
all.equal(s1, s2) # should be TRUE
# Rounding and sampling:
s3 <- riskyr(prev = 1/3, sens = 2/3, spec = 6/7, N = 100, round = FALSE) # s3: w/o rounding
s4 <- riskyr(prev = 1/3, sens = 2/3, spec = 6/7, N = 100, sample = TRUE) # s4: with sampling
# Note:
riskyr(prev = .5, sens = .5, spec = .5, hi = 25, mi = 25, fa = 25, cr = 25) # works (consistent)
riskyr(prev = .5, sens = .5, spec = .5, hi = 25, mi = 25, fa = 25) # works (ignores freq)
## Watch out for:
# riskyr(hi = 25, mi = 25, fa = 25, cr = 25, N = 101) # warns, uses actual sum of freq
# riskyr(prev = .4, sens = .5, spec = .5, hi = 25, mi = 25, fa = 25, cr = 25) # warns, uses freq
Run the code above in your browser using DataLab