gamma_to_crit: Transforms gamma posterior samples to midpoint centered...

Description Usage Arguments Details Value Examples

View source: R/gamma_to_crit.R

Description

gamma_to_crit transforms gamma posterior samples to midpoint centered criteria. This will work correctly only if the column of the gamma fixed effects parameter matrix specified by beta_index represents values of gamma for a given condition, not the regression slope or the difference in gamma values between conditions (see also 'Details'). WARNING: The same gamma link function as the one used when specifying the model has to be used.

Usage

1
gamma_to_crit(samples, beta_index = 1, gamma_link = "softmax", s = 2, K = NULL)

Arguments

samples

a data frame of posterior samples from stanfit object (e.g., samples = as.data.frame(stanfit)).

beta_index

a fixed effect index (a scalar) = an index of a gamma_fixed matrix column. If only the relevant samples are provided (an appropriate gamma matrix) using beta_index = NULL will convert the provided samples. See also 'Details' for which columns of the gamma_fixed matrix can and which cannot be converted to criteria using this function.

gamma_link

is either 'softmax' (described in the paper), 'log_distance', 'log_ratio', or 'parsimonious' (See the Readme file in the github repository)

s

a criteria scaling factor (a scalar), which is relevant only for the softmax link function. WARNING: must be equal to the value used when fitting the model.

Details

In general, in an SDT model there is only one sensitivity (there are two or even three in a meta-d' model) but there can be more than one criterion. When there is more than one criterion the regression coefficients that represent the dependence of criteria on additional variables form a matrix, not a vector. Row j of this fixed effects matrix contains regression coefficients for the j-th criterion. Let's say we have data from a simple experiment with experimental and control groups and we want to test if criteria depend on group membership. If we specify the fixed effects model matrix by calling make_stan_data with fixed = list(gamma = ~ condition, ...) then the first column of the gamma_fixed parameter matrix will contain the intercepts for every criterion (in the gamma space), which is the value of gamma in the condition chosen as base level, and the second column will contain the difference in gamma values between experimental and control groups. In this case gamma_to_crit(samples, 1) will work, but gamma_to_crit(samples, 2) will not work. If, on the other hand, we wanted to work with the actual criteria, not the gamma values from which criteria are derived, then fixed = list(gamma = ~ -1 + condition, ...) would allow us to apply the gamma_to_crit function to both columns of the gamma_fixed matrix because ~ -1 + condition results in a separate intercepts and slopes parametrization of the gamma fixed effects model matrix. This way we could easily estimate the criteria for both conditions.

Value

a data frame containing posterior samples of midpoint centered criteria.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## First we apply the inverse of what happens inside the gamma_to_crit function
criteria = c(-2, -1, 0, 1, 2)
cumprobs = pnorm(criteria)
cumprobs = c(pnorm(criteria, sd = 2), 1)
areas = c(cumprobs[1], cumprobs[-1] - cumprobs[-length(cumprobs)])
gamma = log(areas / areas[length(areas)])
## than we apply the simplified version of gamma_to_crit (link softmax)
g_to_c = function(x, s = 2){
  x = exp(x)
  s * qnorm(cumsum(x/sum(x))[-length(x)])
}
## so that we can see that all is well...
rbind(g_to_c(gamma), criteria)

boryspaulewicz/bhsdtr documentation built on March 8, 2020, 8:24 a.m.