Estimates number of samples and prior parameters of the Bayesian Sampler using the Mean/Variance relationship as shown by (Sundh et al. 2023) . For consistency with the Bayesian Sampler function we call beta the prior parameter, and b0 and b1 slope and intercept respectively.

Mean_Variance(rawData, idCol)

Arguments

rawData

Dataframe with the following column variables for N repetitions of each unique query: participant ID ('id'), response query 1, response query 2, ... , response query N

idCol

Name of the 'ID' column.

Value

A dataframe with values for the intercept (b0) and slope (b1) of the estimated regression, as well as estimates for N, d, and beta (termed b in the paper) for each participant.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
library(tidyr)
library(magrittr)
#> 
#> Attaching package: ‘magrittr’
#> The following object is masked from ‘package:tidyr’:
#> 
#>     extract
library(samplrData)
data <- sundh2023.meanvariance.e3 %>%
  group_by(ID, querydetail) %>% 
  mutate(iteration = LETTERS[1:n()]) %>% 
  pivot_wider(id_cols = c(ID, querydetail), 
      values_from = estimate, names_from = iteration) %>% 
  mutate(across(where(is.numeric), \(x){x/100})) %>% 
  ungroup %>% 
  select(-querydetail)
head(data)
#> # A tibble: 6 × 4
#>      ID     A     B     C
#>   <dbl> <dbl> <dbl> <dbl>
#> 1   101  0.9    0.3   0.2
#> 2   101  0.5    0.7   0.3
#> 3   101  0.9    0.1   0.1
#> 4   101  0.05   0.2   0.2
#> 5   101  0.8    0.8   0.7
#> 6   101  0.2    0.1   0.2
head(Mean_Variance(data, "ID"))
#>    ID          b0        b1        N          d      beta
#> 1 101 -0.04111800 0.5202392 1.922193 0.08652294 0.2011161
#> 2 101 -0.05357651 0.7175646 1.393603 0.08126903 0.1352381
#> 3 101 -0.01880811 0.2170622 4.606975 0.09583234 0.5461807
#> 4 101 -0.02522666 0.3277590 3.051022 0.08402777 0.3081583
#> 5 101 -0.02727728 0.4445454 2.249489 0.06567286 0.1700681
#> 6 101 -0.03305531 0.4535753 2.204705 0.07914042 0.2072916