Description Usage Arguments Examples
This function allows you to calculate A from from a vector hits and a vector a false alarms.
1 |
data |
A data frame. |
h |
A vector of hits (0 = miss, 1 = hit). |
f |
A vector of false alarms (0 = correct rejection, 1 = false alarm). |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # Create some data
set.seed(1); library(dplyr)
axb <- data.frame(subj = sort(rep(1:10, each = 20, times = 10)),
group = gl(2, 1000, labels = c("g1", "g2")),
hit = c(rbinom(1000, size = c(0, 1), prob = .8),
rbinom(1000, size = c(0, 1), prob = .6)),
fa = c(rbinom(1000, size = c(0, 1), prob = .3),
rbinom(1000, size = c(0, 1), prob = .4))
)
# Calculate A on entire data frame
A(axb, hit, fa)
# Calculate A for each subject
# by group, plot it, and run a
# linear model
axb %>%
group_by(subj, group) %>%
summarize(A = A(., hit, fa)) %T>%
{
plot(A ~ as.numeric(group), data = .,
main = "A as a function of group", xaxt = "n",
xlab = "Group", ylab = "A")
axis(1, at = 1:2, labels = c("g1", "g2"))
abline(lm(A ~ as.numeric(group), data = .), col = "red")
} %>%
lm(A ~ group, data = .) %>%
summary()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.