I have a little dataframe with two columns: fp (False Positive) and fn (false negative), like so:
falsepos <- c(.05, .25, .5)
falseneg <- c(.01, .05, .1)
x_name <- "fp"
y_name <- "fn"
df <- data.frame(falsepos,falseneg)
names(df) <- c(x_name, y_name)
I've also written a little adaptation of Bayes's Rule as a function, like so:
bayesrule <- function(baserate = .03,
fp,
fn) {
output <- (baserate * (1 - fn)) / ((baserate * (1 - fn)) + ((1 - baserate) * (fp)))
return(output)
}
fp and fn stand for the same thing they did in df. In this function, bayesrule, I've left a default value for the baserate of .03. My question is: how can I write some R code - likely using the apply family of functions, I'm guessing, but maybe something else - to pass each each row in df's value for fp and fn into their corresponding place in the bayesrule function, yielding me three Bayes's Rule calculations (each with the same default baserate of .03)?
I've looked at similar posts in SX and have gotten quite close, but I'm just shy of the mark on this. I've gotten as close as this:
sapply(df,FUN = bayesrule,fn=df$fn, fp=df$fp)
But no closer.