Skip to content

Commit

Permalink
change "bias" to "mu"
Browse files Browse the repository at this point in the history
  • Loading branch information
GidonFrischkorn committed Feb 12, 2024
1 parent 1d976a9 commit ab76a47
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
42 changes: 21 additions & 21 deletions R/bmm_model_IMM.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ configure_model.IMMabc <- function(model, data, formula) {
pform_names <- names(formula)
pform <- formula

# add fixed intercept for bias if no formula was included
if (!"bias" %in% pform_names) {
bias_form <- bias ~ 1
pform <- c(pform, bias_form)
names(pform) <- c(pform_names,"bias")
# add fixed intercept for mu if no formula was included
if (!"mu" %in% pform_names) {
mu_form <- mu ~ 1
pform <- c(pform, mu_form)
names(pform) <- c(pform_names,"mu")
}

# names for parameters
Expand All @@ -181,7 +181,7 @@ configure_model.IMMabc <- function(model, data, formula) {
mu_unif <- paste0('mu', max_setsize + 1)

# construct formula
formula <- brms::bf(paste0(respErr,"~ bias"), nl = T)
formula <- brms::bf(paste0(respErr,"~ mu"), nl = T)

# add parameter formulas to model formula
for (i in 1:length(pform)) {
Expand Down Expand Up @@ -213,7 +213,7 @@ configure_model.IMMabc <- function(model, data, formula) {

# define prior
prior <- # fix mean of the first von Mises to zero
brms::prior_("constant(0)", nlpar = "bias") +
brms::prior_("constant(0)", nlpar = "mu") +
# fix mean of the guessing distribution to zero
brms::prior_("constant(0)", class = "Intercept", dpar = mu_unif) +
# fix kappa of the second von Mises to (alomst) zero
Expand Down Expand Up @@ -247,11 +247,11 @@ configure_model.IMMbsc <- function(model, data, formula) {
pform_names <- names(formula)
pform <- formula

# add fixed intercept for bias if no formula was included
if (!"bias" %in% pform_names) {
bias_form <- bias ~ 1
pform <- c(pform, bias_form)
names(pform) <- c(pform_names,"bias")
# add fixed intercept for mu if no formula was included
if (!"mu" %in% pform_names) {
mu_form <- mu ~ 1
pform <- c(pform, mu_form)
names(pform) <- c(pform_names,"mu")
}

# names for parameters
Expand All @@ -262,7 +262,7 @@ configure_model.IMMbsc <- function(model, data, formula) {
mu_unif <- paste0('mu', max_setsize + 1)

# construct formula
formula <- brms::bf(paste0(respErr,"~ bias"), nl = T)
formula <- brms::bf(paste0(respErr,"~ mu"), nl = T)

# add parameter formulas to model formula
for (i in 1:length(pform)) {
Expand Down Expand Up @@ -295,7 +295,7 @@ configure_model.IMMbsc <- function(model, data, formula) {

# define prior
prior <- # fix mean of the first von Mises to zero
brms::prior_("constant(0)", nlpar = "bias") +
brms::prior_("constant(0)", nlpar = "mu") +
# fix mean of the guessing distribution to zero
brms::prior_("constant(0)", class = "Intercept", dpar = mu_unif) +
# fix kappa of the second von Mises to (alomst) zero
Expand Down Expand Up @@ -329,11 +329,11 @@ configure_model.IMMfull <- function(model, data, formula) {
pform_names <- names(formula)
pform <- formula

# add fixed intercept for bias if no formula was included
if (!"bias" %in% pform_names) {
bias_form <- bias ~ 1
pform <- c(pform, bias_form)
names(pform) <- c(pform_names,"bias")
# add fixed intercept for mu if no formula was included
if (!"mu" %in% pform_names) {
mu_form <- mu ~ 1
pform <- c(pform, mu_form)
names(pform) <- c(pform_names,"mu")
}

# names for parameters
Expand All @@ -344,7 +344,7 @@ configure_model.IMMfull <- function(model, data, formula) {
mu_unif <- paste0('mu', max_setsize + 1)

# construct formula
formula <- brms::bf(paste0(respErr,"~ bias"), nl = T)
formula <- brms::bf(paste0(respErr,"~ mu"), nl = T)

# add parameter formulas to model formula
for (i in 1:length(pform)) {
Expand Down Expand Up @@ -377,7 +377,7 @@ configure_model.IMMfull <- function(model, data, formula) {

# define prior
prior <- # fix mean of the first von Mises to zero
brms::prior_("constant(0)", nlpar = "bias") +
brms::prior_("constant(0)", nlpar = "mu") +
# fix mean of the guessing distribution to zero
brms::prior_("constant(0)", class = "Intercept", dpar = mu_unif) +
# fix kappa of the second von Mises to (alomst) zero
Expand Down
12 changes: 6 additions & 6 deletions R/bmm_model_mixture2p.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ configure_model.mixture2p <- function(model, data, formula) {
pform_names <- names(formula)
pform <- formula

if (!"bias" %in% pform_names) {
bias_form <- bias ~ 1
pform <- c(pform, bias_form)
names(pform) <- c(pform_names,"bias")
if (!"mu" %in% pform_names) {
mu_form <- mu ~ 1
pform <- c(pform, mu_form)
names(pform) <- c(pform_names,"mu")
}

# specify the formula for the mixture model
formula <- brms::bf(paste0(respErr,"~ bias"), nl = T)
formula <- brms::bf(paste0(respErr,"~ mu"), nl = T)

# add parameter formulas to model formula
for (i in 1:length(pform)) {
Expand All @@ -95,7 +95,7 @@ configure_model.mixture2p <- function(model, data, formula) {

# set priors for the estimated parameters
prior <- # fix mean of the first von Mises to zero
brms::prior_("constant(0)", nlpar = "bias") +
brms::prior_("constant(0)", nlpar = "mu") +
# fix mean of the second von Mises to zero
brms::prior_("constant(0)", class = "Intercept", dpar = "mu2") +
# fix kappa of the second von Mises to (alomst) zero
Expand Down
14 changes: 7 additions & 7 deletions R/bmm_model_mixture3p.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ configure_model.mixture3p <- function(model, data, formula) {
pform_names <- names(formula)
pform <- formula

# add fixed intercept for bias if no formula was included
if (!"bias" %in% pform_names) {
bias_form <- bias ~ 1
pform <- c(pform, bias_form)
names(pform) <- c(pform_names,"bias")
# add fixed intercept for mu if no formula was included
if (!"mu" %in% pform_names) {
mu_form <- mu ~ 1
pform <- c(pform, mu_form)
names(pform) <- c(pform_names,"mu")
}

# names for parameters
Expand All @@ -105,7 +105,7 @@ configure_model.mixture3p <- function(model, data, formula) {
mu_unif <- paste0('mu', max_setsize + 1)

# construct formula
formula <- brms::bf(paste0(respErr,"~ bias"), nl = T)
formula <- brms::bf(paste0(respErr,"~ mu"), nl = T)

# add parameter formulas to model formula
for (i in 1:length(pform)) {
Expand Down Expand Up @@ -137,7 +137,7 @@ configure_model.mixture3p <- function(model, data, formula) {

# define prior
prior <-
brms::prior_("constant(0)", nlpar = "bias") +
brms::prior_("constant(0)", nlpar = "mu") +
brms::prior_("constant(0)", class = "Intercept", dpar = mu_unif) +
brms::prior_("constant(-100)", class = "Intercept", dpar = kappa_unif) +
brms::prior_("normal(2, 1)", class = "b", nlpar = "kappa") +
Expand Down
12 changes: 6 additions & 6 deletions R/bmm_model_sdmSimple.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ configure_model.sdmSimple <- function(model, data, formula) {
pform_names <- names(formula)
pform <- formula

if (!"bias" %in% pform_names) {
bias_form <- bias ~ 1
pform <- c(pform, bias_form)
names(pform) <- c(pform_names,"bias")
if (!"mu" %in% pform_names) {
mu_form <- mu ~ 1
pform <- c(pform, mu_form)
names(pform) <- c(pform_names,"mu")
}

# specify the formula for the mixture model
formula <- brms::bf(paste0(respErr,"~ bias"), nl = T)
formula <- brms::bf(paste0(respErr,"~ mu"), nl = T)

# add parameter formulas to model formula
for (i in 1:length(pform)) {
Expand All @@ -130,7 +130,7 @@ configure_model.sdmSimple <- function(model, data, formula) {
# TODO: add a proper prior
prior <-
# fix mu to 0 (when I change mu to be the center, not c)
brms::prior_("constant(0)", nlpar = "bias")
brms::prior_("constant(0)", class = "Intercept", dpar = "mu")

# set initial values to be sampled between [-1,1] to avoid extreme SDs that
# can cause the sampler to fail // TODO: test extensively if this works in
Expand Down

0 comments on commit ab76a47

Please sign in to comment.