# RUN PRIOR TO TUTORIAL ----------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# Prepare multi-item data --------------------------------------------------------------------
# Read in my addm project data ---------------------------------------------------------------
afdat_eye8 = as.data.table(read.table(file = 'temp/data/eye8.txt',
header = TRUE,
sep = ' '))
afdat_choice8 = as.data.table(read.table(file = 'temp/data/choice8.txt',
header = TRUE,
sep = ' '))
# --------------------------------------------------------------------------------------------
# Take Subset --------------------------------------------------------------------------------
rows.usable = createDataPartition(1:length(afdat_choice8$id),times=1, p=0.05)
afdat_choice = afdat_choice8[rows.usable[[1]],]
setkey(afdat_choice, id)
setkey(afdat_eye8, id)
afdat_eye = afdat_choice[afdat_eye8]
afdat_eye = afdat_eye[complete.cases(afdat_eye)] %>% select(id,fixloc,fixdur,fixnr)
# Prepare multiattribute data ----------------------------------------------------------------
ma_eye = as.data.table(read.table(file = 'temp/data/addm_data_eye_ma.txt',
header = TRUE,
sep = ' '))
ma_choice = as.data.table(read.table(file = 'temp/data/addm_data_choice_ma.txt',
header = TRUE,
sep = ' '))
ma_choice$decision = ma_choice$decision + 1
# --------------------------------------------------------------------------------------------
rm(rows.usable)
# --------------------------------------------------------------------------------------------
########################### START TUTORIAL ###################################################
# INSTALL PACKAGE IF NECESSARY ---------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
devtools::install_github('AlexanderFengler/addmtoolbox',build_vignette=TRUE)
library("addmtoolbox")
# --------------------------------------------------------------------------------------------
# INPUT DATA ---------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# STANDARD 2 ITEM ----------------------------------------------------------------------------
# Choice Data
View(head(addm_data_choice))
# Eyetracking Data
View(head(addm_data_eye))
# --------------------------------------------------------------------------------------------
# MORE ITEMS ---------------------------------------------------------------------------------
# Choice Data
View(head(afdat_choice))
# Eyetracking Data
View(head(afdat_eye))
# --------------------------------------------------------------------------------------------
# MULTIATTRIBUTE -----------------------------------------------------------------------------
# Choice Data
View(head(ma_choice))
# Eyetracking
View(head(ma_eye))
# --------------------------------------------------------------------------------------------
# PREPROCESS DATA FOR USAGE WITH ADDMTOOLBOX -------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# Preprocess supplied data-frame -------------------------------------------------------------
addm.dat = addm_preprocess(choice.dat = addm_data_choice,
eye.dat = addm_data_eye,
rtbinsize = 100,
timestep = 10)
# --------------------------------------------------------------------------------------------
# Look at what we get ------------------------------------------------------------------------
addm.dat
# --------------------------------------------------------------------------------------------
# DO A GRID SEARCH ---------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# Perform grid search by trial:
addm_loglik_trial = addm_fit_grid(addm.dat,
nr.reps = 1000,
drifts = c(0.001,0.003,0.005),
thetas = c(0, 0.5, 1),
sds = c(0.02,0.04,0.06,0.08,0.1),
fit.type = 'trial')
addm_plot_loglik(addm_loglik_trial)
# Perform grid search by condition
addm_loglik_condition = addm_fit_grid(addm.dat,
nr.reps = 1000,
drifts = c(0.001,0.003,0.005),
thetas = c(0,0.5,1),
sds = c(0.06,0.08,0.1),
fit.type = 'condition',
fixation.model = 'random') # can be 'fixedpath' or 'user'
addm_plot_loglik(addm_loglik_condition)
# EXPERIMENTAL
addm_loglik_dyn = addm_fit_grid(addm.dat,
drifts = c(0.001,0.003,0.005),
thetas = c(0,0.5,1),
sds = c(0.06,0.08,0.1),
fit.type = 'dyn')
addm_plot_loglik(addm_loglik_dyn)
# --------------------------------------------------------------------------------------------
# GENERATE DETAILED OUTPUT -------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# Generate
addm_output = addm_run_by_condition(choice.dat = addm.dat$choice.dat,
conditions.dat = addm.dat$conditions.dat,
model.parameters = c(0,0.0014,0.071,1), # mention order
nr.reps = 500,
fixation.model = 'random', # can be 'fixedpath' or 'user'
output.type = 'full')
# Take a look at whats included
View(addm_output)
# --------------------------------------------------------------------------------------------
# PLOT PSYCHOMETRICS -------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
addm2_plot_family(choice.dat = addm.dat$choice.dat,
addm.output = addm_output)
# --------------------------------------------------------------------------------------------
# GENERATE FAKE DATA -------------------------------------------------------------------------
addm.fake = addm_generate_artificial(set.size = 6,
possible.valuations = c(0,1,2,3),
model.parameters = c(0,0.006,0.06,0.5),
nr.attributes = 1,
nr.condition = 20,
nr.reps = 1000,
timestep = 10,
rtbinsize = 100,
model.type = 'standard')
# --------------------------------------------------------------------------------------------
# MULTIPLE -----------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------
# SET SIZE 8 ---------------------------------------------------------------------------------
# Preprocess my data
afdat = addm_preprocess(choice.dat = afdat_choice, eye.dat = afdat_eye)
# Run Grid Search
afloglik = addm_fit_grid(afdat,
drifts = c(0.005,0.006,0.007),
sds = c(0.08, 0.06, 0.04),
theta = c(0,0.5,1),
fit.type = 'trial')
addm_plot_loglik(afloglik)
# --------------------------------------------------------------------------------------------
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.