General preparation

Read in code

source("rulexj_functions.R")

Set up exemplar matrix

  • columns correspond to cues, last column is criterion value
  • rows correspond to exemplars
exemplars <- matrix(
  ncol=5,byrow=TRUE,dimnames = list(NULL,c("c1","c2","c3","c4","crit")),
  data = c(
    0,0,0,1,23,
    0,0,1,0,25,
    0,1,0,0,30,
    0,1,0,1,43,
    1,0,0,0,35,
    1,0,1,1,70,
    1,1,0,1,68,
    1,1,1,0,63))

Simulation settings

nsim <- 500 # Number of simulated participants per recovery simulation
cues <- exemplars[,1:4] # Use all exemplar cue patterns as cues

Recovery simulation with mixed strategy

50 % rule, 50 % probex

Simulate data

# Generate separate predictions
sim_data_alpha_0.0  <- simulate_rulexj(n=nsim,cues=cues,exemplars=exemplars,alpha_fix=0.0,w_sum_max = 100)
sim_data_alpha_1.0  <- simulate_rulexj(n=nsim,cues=cues,exemplars=exemplars,alpha_fix=1.0,w_sum_max = 100)

# Combine them to implement a mixed strategy
# i.e., 50 % of judgments follow exemplar approach, 50 % rule
# (this is achieved by combining the judgments, so that each exemplar is judged twice)
sim_data_mix_5050 <- sim_data_alpha_1.0
sim_data_mix_5050$judgments <- rbind(sim_data_mix_5050$judgments,sim_data_alpha_0.0$judgments)
sim_data_mix_5050$parameters[,"s"] <- sim_data_alpha_0.0$parameters[,"s"]
sim_data_mix_5050$parameters[,"alpha"] <- 0.5

Fit the simulated data

rec_data_mix_5050  <- fit_rulexj(dataset=sim_data_mix_5050$judgments, exemplars=exemplars)

Assessing the recovery performance

# Summary of fitted alpha values
summary(rec_data_mix_5050$alpha_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1828  0.5000  0.5000  0.4976  0.5000  0.5034
hist(rec_data_mix_5050$alpha_joint,breaks=seq(-.025,1.025,.05))

# Alpha values close to .50
table(abs(rec_data_mix_5050$alpha_joint-.50)<.01)
## 
## FALSE  TRUE 
##    13   487
# Summary of sums of squares of the RulEx-J model
summary(rec_data_mix_5050$SS_RulExJ_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   60.19  693.23 1243.41 1489.26 1892.64 7407.10
# Summary of differences between data generating and fitted parameters
summary(subset(sim_data_mix_5050$parameters,select=c(alpha:s))-
          subset(rec_data_mix_5050,select=c(alpha_joint:s_joint)),
        digits = 2)
##   alpha_joint          w0_joint           w1_joint           w2_joint       
##  Min.   :-3.4e-03   Min.   :-3.6e-01   Min.   :-2.2e+01   Min.   :-4.6e+01  
##  1st Qu.:-2.0e-07   1st Qu.:-9.0e-06   1st Qu.:-9.9e-05   1st Qu.:-2.6e-04  
##  Median : 1.0e-07   Median : 3.0e-06   Median :-2.0e-06   Median : 0.0e+00  
##  Mean   : 2.4e-03   Mean   : 1.2e-01   Mean   :-8.3e-02   Mean   :-1.2e-01  
##  3rd Qu.: 1.1e-05   3rd Qu.: 3.0e-04   3rd Qu.: 8.0e-06   3rd Qu.: 1.0e-05  
##  Max.   : 3.2e-01   Max.   : 1.7e+01   Max.   : 6.6e-01   Max.   : 4.0e-01  
##     w3_joint           w4_joint           s_joint        
##  Min.   :-3.0e+01   Min.   :-43.8662   Min.   :-1.2e-01  
##  1st Qu.:-1.7e-04   1st Qu.: -0.0002   1st Qu.:-6.4e-06  
##  Median :-2.0e-06   Median :  0.0000   Median :-7.0e-08  
##  Mean   :-1.7e-01   Mean   : -0.1237   Mean   :-9.9e-04  
##  3rd Qu.: 4.0e-06   3rd Qu.:  0.0000   3rd Qu.: 1.2e-07  
##  Max.   : 2.3e-01   Max.   :  0.0799   Max.   : 1.4e-03

75 % probex, 25 % rule

Simulate data

# Generate separate predictions
sim_data_alpha_0.0  <- simulate_rulexj(n=nsim,cues=cues,exemplars=exemplars,alpha_fix=0.0,w_sum_max = 100)
sim_data_alpha_1.0  <- simulate_rulexj(n=nsim,cues=cues,exemplars=exemplars,alpha_fix=1.0,w_sum_max = 100)

# Combine them to implement a mixed strategy
# i.e., 50 % of judgments follow exemplar approach, 50 % rule
# (this is achieved by combining the judgments, so that each exemplar is judged twice)
sim_data_mix_7525 <- sim_data_alpha_1.0
sim_data_mix_7525$judgments <- rbind(sim_data_mix_7525$judgments,sim_data_alpha_0.0$judgments)
sim_data_mix_7525$judgments <- rbind(sim_data_mix_7525$judgments,sim_data_alpha_0.0$judgments)
sim_data_mix_7525$judgments <- rbind(sim_data_mix_7525$judgments,sim_data_alpha_0.0$judgments)
sim_data_mix_7525$parameters[,"s"] <- sim_data_alpha_0.0$parameters[,"s"]
sim_data_mix_7525$parameters[,"alpha"] <- 0.25

Fit the simulated data

rec_data_mix_7525  <- fit_rulexj(dataset=sim_data_mix_7525$judgments, exemplars=exemplars)

Assessing the recovery performance

# Summary of fitted alpha values
summary(rec_data_mix_7525$alpha_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.06087 0.24998 0.25000 0.24714 0.25000 0.25924
hist(rec_data_mix_7525$alpha_joint,breaks=seq(-.025,1.025,.05))

# Alpha values close to .25
table(abs(rec_data_mix_7525$alpha_joint-.25)<.01)
## 
## FALSE  TRUE 
##    16   484
# Summary of sums of squares of the RulEx-J model
summary(rec_data_mix_7525$SS_RulExJ_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   116.8  1072.3  1810.0  2113.2  2837.0  7547.1
# Summary of differences between data generating and fitted parameters
summary(subset(sim_data_mix_7525$parameters,select=c(alpha:s))-
          subset(rec_data_mix_7525,select=c(alpha_joint:s_joint)),
        digits = 2)
##   alpha_joint          w0_joint           w1_joint           w2_joint       
##  Min.   :-9.2e-03   Min.   :-2.1e+01   Min.   :-4.3e+01   Min.   :-4.7e+01  
##  1st Qu.:-1.0e-07   1st Qu.:-1.1e-05   1st Qu.:-1.8e-04   1st Qu.:-4.1e-04  
##  Median : 2.3e-07   Median : 9.0e-06   Median : 0.0e+00   Median :-1.0e-05  
##  Mean   : 2.9e-03   Mean   : 7.1e-02   Mean   :-2.5e-01   Mean   :-3.4e-01  
##  3rd Qu.: 1.6e-05   3rd Qu.: 7.3e-04   3rd Qu.: 1.0e-05   3rd Qu.: 1.0e-05  
##  Max.   : 1.9e-01   Max.   : 1.7e+01   Max.   : 2.6e-01   Max.   : 1.5e+00  
##     w3_joint           w4_joint           s_joint        
##  Min.   :-6.4e+01   Min.   :-4.4e+01   Min.   :-5.0e-02  
##  1st Qu.:-2.9e-04   1st Qu.:-4.4e-04   1st Qu.:-5.5e-06  
##  Median : 0.0e+00   Median :-1.0e-05   Median :-9.0e-08  
##  Mean   :-4.0e-01   Mean   :-2.3e-01   Mean   :-8.1e-04  
##  3rd Qu.: 1.0e-05   3rd Qu.: 1.0e-05   3rd Qu.: 4.0e-08  
##  Max.   : 9.1e-01   Max.   : 8.2e-01   Max.   : 2.8e-03

25 % probex, 75 % rule

Simulate data

# Generate separate predictions
sim_data_alpha_0.0  <- simulate_rulexj(n=nsim,cues=cues,exemplars=exemplars,alpha_fix=0.0,w_sum_max = 100)
sim_data_alpha_1.0  <- simulate_rulexj(n=nsim,cues=cues,exemplars=exemplars,alpha_fix=1.0,w_sum_max = 100)

# Combine them to implement a mixed strategy
# i.e., 50 % of judgments follow exemplar approach, 50 % rule
# (this is achieved by combining the judgments, so that each exemplar is judged twice)
sim_data_mix_2575 <- sim_data_alpha_1.0
sim_data_mix_2575$judgments <- rbind(sim_data_mix_2575$judgments,sim_data_alpha_0.0$judgments)
sim_data_mix_2575$judgments <- rbind(sim_data_mix_2575$judgments,sim_data_alpha_1.0$judgments)
sim_data_mix_2575$judgments <- rbind(sim_data_mix_2575$judgments,sim_data_alpha_1.0$judgments)
sim_data_mix_2575$parameters[,"s"] <- sim_data_alpha_0.0$parameters[,"s"]
sim_data_mix_2575$parameters[,"alpha"] <- 0.75

Fit the simulated data

rec_data_mix_2575  <- fit_rulexj(dataset=sim_data_mix_2575$judgments, exemplars=exemplars)

Assessing the recovery performance

# Summary of fitted alpha values
summary(rec_data_mix_2575$alpha_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.7163  0.7500  0.7500  0.7497  0.7500  0.7521
hist(rec_data_mix_2575$alpha_joint,breaks=seq(-.025,1.025,.05))

# Alpha values close to .75
table(abs(rec_data_mix_2575$alpha_joint-.75)<.01)
## 
## FALSE  TRUE 
##     4   496
# Summary of sums of squares of the RulEx-J model
summary(rec_data_mix_2575$SS_RulExJ_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   166.2  1102.7  1754.5  2101.6  2725.8 11913.4
# Summary of differences between data generating and fitted parameters
summary(subset(sim_data_mix_2575$parameters,select=c(alpha:s))-
          subset(rec_data_mix_2575,select=c(alpha_joint:s_joint)),
        digits = 2)
##   alpha_joint          w0_joint           w1_joint           w2_joint       
##  Min.   :-2.1e-03   Min.   :-8.7e-01   Min.   :-6.7e-01   Min.   :-1.2e+00  
##  1st Qu.:-1.3e-07   1st Qu.:-5.6e-06   1st Qu.:-3.0e-05   1st Qu.:-5.6e-05  
##  Median : 5.0e-08   Median : 7.0e-07   Median :-4.0e-07   Median :-9.0e-07  
##  Mean   : 3.1e-04   Mean   : 2.9e-03   Mean   :-2.9e-03   Mean   :-7.8e-03  
##  3rd Qu.: 5.9e-06   3rd Qu.: 1.1e-04   3rd Qu.: 6.0e-06   3rd Qu.: 3.2e-06  
##  Max.   : 3.4e-02   Max.   : 8.4e-01   Max.   : 9.3e-02   Max.   : 5.9e-02  
##     w3_joint           w4_joint           s_joint        
##  Min.   :-4.5e-01   Min.   :-7.3e-01   Min.   :-2.7e-02  
##  1st Qu.:-4.7e-05   1st Qu.:-5.8e-05   1st Qu.:-6.2e-06  
##  Median :-1.0e-06   Median :-1.3e-06   Median :-1.0e-07  
##  Mean   :-3.6e-03   Mean   :-7.4e-03   Mean   :-2.5e-04  
##  3rd Qu.: 2.9e-06   3rd Qu.: 2.6e-06   3rd Qu.: 2.5e-07  
##  Max.   : 5.0e-02   Max.   : 1.5e-01   Max.   : 1.7e-03

Recovery simulation with random data

Simulate data

# Generate random predictions
sim_data_random  <- simulate_rulexj(n=nsim,cues=cues,exemplars=exemplars,w_sum_max = 100)
sim_data_random$judgments[,"judgment"] <- sample(seq(min(exemplars[,"crit"]),max(exemplars[,"crit"]),1),replace = TRUE,size = nrow(sim_data_random$judgments))

Fit the simulated data

rec_data_random  <- fit_rulexj(dataset=sim_data_random$judgments, exemplars=exemplars)

Assessing the fitted parameter values

# Summary of fitted alpha values
summary(rec_data_random$alpha_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.2017  1.0000  1.0000  0.9802  1.0000  1.0000
hist(rec_data_random$alpha_joint,breaks=seq(-.025,1.025,.05),ylim = c(0,500))

# Alpha values close to 1
table(abs(rec_data_random$alpha_joint-1)<.01)
## 
## FALSE  TRUE 
##    30   470
# Summary of sums of squares of the different models
summary(rec_data_random$SS_RulExJ_joint)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   46.41  549.42  871.73  965.19 1351.98 2724.01
summary(rec_data_random$SS_Exemplar_sep)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     164    1410    1859    1930    2395    4287
summary(rec_data_random$SS_Rule_sep)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   49.33  549.42  871.73  967.21 1353.78 2724.00