Function to return observed correlation between two variables with bootstrap CI

getBootCICorr(
  formula1,
  data,
  method = "p",
  bootReps = 1000,
  conf = 0.95,
  bootCImethod = "pe"
)

Arguments

formula1

formula defining the two variables to be correlated as var1 ~ var2

data

data.frame or tibble with the data, often cur_data() in dplyr

method

string giving correlation method, can be single letter 'p', 's' or 'k' for pearson, spearman or kendall (in cor())

bootReps

integer giving number of bootstrap replications

conf

numeric value giving width of confidence interval, e.g. .95 (default)

bootCImethod

string giving method to derive bootstrap CI, can be two letters 'pe', 'no', 'ba' or 'bc' for percentile, normal, basic or bca

Value

list of named values: obsCorr, LCLCorr and UCLCorr

History/development log

Started before 5.iv.21

See also

Other bootstrap CI functions: getBootCICSC(), getBootCIalpha(), getBootCImean()

Author

Chris Evans

Examples

if (FALSE) { library(tidyverse) data %>% ### don't forget to prefix the call with "list(" to tell dplyr ### you are creating list output summarise(corr = list(getBootCICorr(score1 ~ score2, cur_data(), method = "p", # gets the Pearson correlation bootReps = 1000, ### "pe" in next line gets the percentile bootstrap CI bootCImethod = "pe"))) %>% ### now unnest the list output to separate columns unnest_wider(corr) }