View source: R/getBootCICorr.R

getBootCICorr | R Documentation |

Function to return observed correlation between two variables with bootstrap CI

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

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

`data` |
data.frame or tibble with the data, often subset of the data created with group_by() and pick() |

`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 |

list of named values: obsCorr, LCLCorr and UCLCorr

Started before 5.iv.21

Chris Evans

Other bootstrap CI functions:
`getBootCICSC()`

,
`getBootCIalpha()`

,
`getBootCIgrpMeanDiff()`

,
`getBootCImean()`

```
## Not run:
library(tidyverse)
### create some data
set.seed(12345) # make this replicable
n <- 150
tibble(x = rnorm(n), y = rnorm(y)) %>%
### that's got us sample x and y from population in which they're uncorrelated
### make them correlated:
mutate(y = y + .2 * x) -> data
data %>%
### don't forget to prefix the call with "list(" to tell dplyr
### you are creating list output
summarise(corr = list(getBootCICorr(x ~ y,
pick(everything()),
### pick(everything()) is, to my mind, a rather verbose replacement for 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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.