Skip to content

Commit

Permalink
updates to JAGS models
Browse files Browse the repository at this point in the history
- removing ExpPower hierarchical model. Hierarchical inference on (k,
tau) needs more thought #147
- introduces (epsilon_alpha, epsilon_beta) which will help with the
hierarchical / mixed / separate models #161
  • Loading branch information
Ben Vincent committed Jan 8, 2017
1 parent 8e208c7 commit 3409cbd
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 222 deletions.
10 changes: 8 additions & 2 deletions ddToolbox/models/nonparametric_models/separateNonParametric.jags
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@

model{

groupALPHAmu <- 0 # TODO: NEEDS ATTENTION
groupALPHAsigma <-0.01 # TODO: NEEDS ATTENTION

epsilon_alpha <- 1+1
epsilon_beta <- 1+100

# priors
for (p in participantIndexList){
epsilon[p] ~ dbeta(1+1 , 1+100) T(,0.5)
alpha[p] ~ dnorm(0, 1/0.1^2) T(0,) # <--------------- FIGURE OUT BEST PRIOR.
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
alpha[p] ~ dnorm(groupALPHAmu, 1/(groupALPHAsigma^2)) T(0,)

# PRIOR OVER DISCOUNT FRACTION
# prior over A/B should be centered on 1 if we are expecting discounting and anti-discounting, and can be truncates
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
% Generate initial values of the root nodes
nExperimentFiles = obj.data.getNExperimentFiles();
for chain = 1:nchains
%initialParams(chain).k = unifrnd(0, 0.5, [nExperimentFiles,1]);
%initialParams(chain).tau = unifrnd(0.01, 2, [nExperimentFiles,1]);
% initialParams(chain).k = unifrnd(0.01, 0.5, [nExperimentFiles,1]);
% initialParams(chain).tau = unifrnd(0.01, 2, [nExperimentFiles,1]);

initialParams(chain).groupW = rand;
initialParams(chain).groupALPHAmu = rand*100;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,22 @@ for (t in 1:length(ID)) {


# RESPONSE ERROR PARAMETERS ====================================================

# comparison acuity (alpha) hyperprior
groupALPHAmu ~ dnorm(0,1/(100^2)) T(0,)
groupALPHAsigma ~ dunif(0,100)

# error rates (epsilon) hyperprior
groupW ~ dbeta(1.1, 10.9) # mode for lapse rate
groupKminus2 ~ dgamma(0.5,0.5) # concentration parameter ## UPDATED SINCE PAPER
groupK <- groupKminus2+2

epsilon_alpha <- groupW*(groupK-2)+1
epsilon_beta <- (1-groupW)*(groupK-2)+1

for (p in 1:(nRealExperimentFiles+1)){ # +1 for unobserved participant
alpha[p] ~ dnorm(groupALPHAmu, 1/(groupALPHAsigma^2)) T(0,)
epsilon[p] ~ dbeta(groupW*(groupK-2)+1 , (1-groupW)*(groupK-2)+1 ) T(,0.5)
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ for (t in 1:length(ID)) {


# RESPONSE ERROR PARAMETERS ====================================================
epsilon_alpha <- 1.1
epsilon_beta <- 10.9

for (p in 1:(nRealExperimentFiles)){ # no +1 because no shrinkage hyperprior
epsilon[p] ~ dbeta(1.1 , 10.9) T(,0.5)
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
alpha[p] ~ dexp(0.01)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ model{
# DISCOUNT FUNCTION PARAMETERS =================================================
# RANDOM (BY PARTICIPANT) FACTORS; HYPER-PRIORS = YES

groupKmu ~ dnorm(0.01, 1/(0.5^2))
groupKsigma ~ dgamma(0.1, 0.1)
K_MEAN ~ dnorm(0.01, 1/(0.5^2))
Ksigma ~ dgamma(0.1, 0.1)
K_PRECISION <- 1/((Ksigma+0.0001)^2)

for (p in 1:(nRealExperimentFiles+1)){ # +1 for unobserved participant
k[p] ~ dnorm(groupKmu, 1/((groupKsigma+0.0001)^2))
k[p] ~ dnorm(K_MEAN, K_PRECISION)
}

# MODEL-SPECIFIC: CALCULATION OF PRESENT SUBJECTIVE VALUES
Expand All @@ -25,16 +26,22 @@ for (t in 1:length(ID)) {


# RESPONSE ERROR PARAMETERS ====================================================

# comparison acuity (alpha) hyperprior
groupALPHAmu ~ dnorm(0,1/(100^2)) T(0,)
groupALPHAsigma ~ dunif(0,100)

# error rates (epsilon) hyperprior
groupW ~ dbeta(1.1, 10.9) # mode for lapse rate
groupKminus2 ~ dgamma(0.5,0.5) # concentration parameter ## UPDATED SINCE PAPER
groupK <- groupKminus2+2

epsilon_alpha <- groupW*(groupK-2)+1
epsilon_beta <- (1-groupW)*(groupK-2)+1

for (p in 1:(nRealExperimentFiles+1)){ # +1 for unobserved participant
alpha[p] ~ dnorm(groupALPHAmu, 1/(groupALPHAsigma^2)) T(0,)
epsilon[p] ~ dbeta(groupW*(groupK-2)+1 , (1-groupW)*(groupK-2)+1 ) T(,0.5)
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
}


Expand All @@ -47,7 +54,7 @@ for (t in 1:length(ID)) {

# response likelihood
for (t in 1:length(ID)) {
R[t] ~ dbern(P[t]) # likelihood of actual response
R[t] ~ dbern(P[t])
}

# POSTERIOR PREDICTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ for (t in 1:length(ID)) {


# RESPONSE ERROR PARAMETERS ====================================================

# comparison acuity (alpha) hyperprior
groupALPHAmu ~ dnorm(0,1/(100^2)) T(0,)
groupALPHAsigma ~ dunif(0,100)

# error rates (epsilon) hyperprior
groupW ~ dbeta(1.1, 10.9) # mode for lapse rate
groupKminus2 ~ dgamma(0.5,0.5) # concentration parameter ## UPDATED SINCE PAPER
groupK <- groupKminus2+2

epsilon_alpha <- groupW*(groupK-2)+1
epsilon_beta <- (1-groupW)*(groupK-2)+1

for (p in 1:(nRealExperimentFiles+1)){ # +1 for unobserved participant
alpha[p] ~ dnorm(groupALPHAmu, 1/(groupALPHAsigma^2)) T(0,)
epsilon[p] ~ dbeta(groupW*(groupK-2)+1 , (1-groupW)*(groupK-2)+1 ) T(,0.5)
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
}


Expand All @@ -47,7 +53,7 @@ for (t in 1:length(ID)) {

# response likelihood
for (t in 1:length(ID)) {
R[t] ~ dbern(P[t]) # likelihood of actual response
R[t] ~ dbern(P[t])
}

# POSTERIOR PREDICTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ for (t in 1:length(ID)) {


# RESPONSE ERROR PARAMETERS ====================================================
epsilon_alpha <- 1.1
epsilon_beta <- 10.9

for (p in 1:(nRealExperimentFiles)){ # no +1 because no shrinkage hyperprior
epsilon[p] ~ dbeta(1.1 , 10.9) T(,0.5)
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
alpha[p] ~ dexp(0.01)
}

Expand All @@ -48,7 +51,7 @@ for (t in 1:length(ID)) {

# response likelihood
for (t in 1:length(ID)) {
R[t] ~ dbern(P[t]) # likelihood of actual response
R[t] ~ dbern(P[t])
}

# POSTERIOR PREDICTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ groupALPHAsigma ~ dunif(0,1000)
groupW ~ dbeta(1.1, 10.9) # mode for lapse rate
groupKminus2 ~ dgamma(0.01,0.01) # concentration parameter
groupK <- groupKminus2+2

epsilon_alpha <- groupW*(groupK-2)+1
epsilon_beta <- (1-groupW)*(groupK-2)+1

for (p in 1:(nRealExperimentFiles+1)){ # +1 for unobserved participant
epsilon[p] ~ dbeta(groupW*(groupK-2)+1 , (1-groupW)*(groupK-2)+1 ) T(,0.5)
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
alpha[p] ~ dnorm(groupALPHAmu, 1/(groupALPHAsigma^2)) T(0,)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ groupW ~ dbeta(1.1, 10.9) # mode for lapse rate
groupKminus2 ~ dgamma(0.5,0.5) # concentration parameter ## UPDATED SINCE PAPER
groupK <- groupKminus2+2

epsilon_alpha <- groupW*(groupK-2)+1
epsilon_beta <- (1-groupW)*(groupK-2)+1

for (p in 1:(nRealExperimentFiles+1)){ # +1 for unobserved participant
epsilon[p] ~ dbeta(groupW*(groupK-2)+1 , (1-groupW)*(groupK-2)+1 ) T(,0.5)
epsilon[p] ~ dbeta(epsilon_alpha , epsilon_beta ) T(,0.5)
alpha[p] ~ dnorm(groupALPHAmu, 1/(groupALPHAsigma^2)) T(0,)
}

Expand Down
Loading

0 comments on commit 3409cbd

Please sign in to comment.