getBootCICSC: Title Function designed for use in dplyr (tidyverse) piping...

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

View source: R/getBootCICSC.R

Description

Title Function designed for use in dplyr (tidyverse) piping to return CSC and bootstrap CI around that

Usage

1
getBootCICSC(formula1, data, bootReps = 1000, conf = 0.95, bootCImethod = "pe")

Arguments

formula1

formula defining the two variables to be correlated as scores ~ group

data

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

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, minimum two letters 'pe', 'no', 'ba' or 'bc' for percentile, normal, basic or bca

Value

list of named values obsCSC, LCLCSC and UCLCSC

Background

For general information about the CSC (Clinically Significant Change criterion), see getCSC

History/development log

Started before 5.iv.21

Author(s)

Chris Evans

See Also

getCSC provides just the CSC if you don't need the CI around it. Much faster of course!

Other RCSC functions: classifyScoresVectorByRCI(), getCSC(), getRCIfromSDandAlpha()

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

Examples

 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
29
30
31
32
33
34
35
36
## Not run: 
### will need tidyverse to run
library(tidyverse)
### create some data
n <- 120
list(scores = rnorm(n), # Gaussian random base for scores
  ### now add a grouping variable: help-seeking or not
  grp = sample(c("HS", "not"), n, replace = TRUE),
  ### now add gender
  gender = sample(c("F", "M"), n, replace = TRUE)) %>%
  as_tibble() %>%
  ### next add a gender effect nudging women's scores up by .4
  mutate(scores = if_else(gender == "F", scores + .4, scores),
  ### next add the crucial help-seeking effect of 1.1
        scores = if_else(grp == "HS", scores + 1.1, scores)) -> tmpDat

### have a look at that
tmpDat

set.seed(12345) # to get replicable results from the bootstrap
tmpDat %>%
  ### don't forget to prefix the call with "list(" to tell dplyr
  ### you are creating list output
  summarise(CSC = list(getBootCICSC(scores ~ grp, cur_data()))) %>%
  ### now unnest the list to columns
  unnest_wider(CSC)

### now an example of how this becomes useful: same but by gender
tmpDat %>%
  group_by(gender) %>%
  ### remember the list output again!
  summarise(CSC = list(getBootCICSC(scores ~ grp, cur_data()))) %>%
  ### remember to unnnest again!
  unnest_wider(CSC)

## End(Not run)

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