getBootCICorr: Function to return observed correlation between two variables...

Description Usage Arguments Value History/development log Author(s) See Also Examples

View source: R/getBootCICorr.R

Description

Function to return observed correlation between two variables with bootstrap CI

Usage

1
2
3
4
5
6
7
8
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

Author(s)

Chris Evans

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
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)

## End(Not run)

cpsyctc/CECPfuns documentation built on April 15, 2021, 3:26 a.m.