rrwSensitivityAnalysisWithFixedParameters: This function runs a sensisity analysis with a set of fixed...

View source: R/rrwSensitivityAnalysisWithFixedParameters.r

rrwSensitivityAnalysisWithFixedParametersR Documentation

This function runs a sensisity analysis with a set of fixed parameters (specified in a rrwModelList) to generate the fits to the data. It takes the raw data and the rrwModelList as input, collapses the data, codes the columns, gets the parameter information, runs the getMeanRRWfit, and outputs the smartGridSearch results. rrwModelList should only have fixed parameter values (upperBound==lowerBound). The sensitivity analysis will randomly drop probes from the probe list and check the fit.

Description

Function that runs a set of fixed parameters (specified in a rrwModelList) to generate the fits to the data.

Usage

rrwSensitivityAnalysisWithFixedParameters(
  data,
  rrwModelList,
  probeCols = NULL,
  numProbesToRemove = c(1),
  maxNumCombinations = 200,
  minN = 20,
  dataOverlapCol = "overlapRound",
  RwSamplesCol = "Q50",
  dataRtCol = "rt",
  correctCol = "correct",
  correctVals = c(TRUE, FALSE),
  loopsPerRWstep = 200,
  minimizeStat = "R_Square",
  equalizeRTandPhit = FALSE,
  pars.n = NULL,
  fileTag = NULL,
  numSimsToAverage = 10,
  savePlots = FALSE,
  ...
)

Arguments

data

This is a dataframe containing the raw trial-by-trial data that must contain the following columns: overlap; RT (often a median); the proportion correct/incorrect; whether or not the row specifies a correct or incorrect trial. The dataset can also contains columns that effect code the influence of different parameters.

rrwModelList

A list that specifies the rrw model. Build the rrwModelList useing rrwAddEffectToRRWModel

probeCols

a vector of strings that specifies the names of the columns in "data" that contains the the probes.

numProbesToRemove

A vector of integers that specifies the number of probes to remove with each run. DEFAULT = c(1); which is a "leave one out" protocol.

maxNumCombinations

An integer that specifies the maximum number of combinations to remove each run. When the eniter set is less than maxNumCombinations, the entire set of combinantions is removed. But often when the value of numProbesToRemove is large, the number of possible combinations gets very large, so it is best to randomly choose a subset of those to run. maxNumCombinations provides an upper limit on the random number of combinations. aDEFAULT = 200

minN

A a numeric value that specifies the minimum number of trials necessary for a condition to be included in the analysis. If the condition has less than minN trials, then that condition is assigned and NA. Default=20

dataOverlapCol

A string that identifies the name of the column in data that contains the distributional overlaps for each row. The default is "overlap"

RwSamplesCol

A string that identifies the name of the column in the RRW simulations that contains the summary of the samples that you want to use as a simulation for RT. The possible columns are: "Q25" (the 25th quartile); "Q50" (the median); "mean" (the mean); "Q75" (the 75th quartile). The default is "Q50" because the median is more robust than the mean.

dataRtCol

A string that identifies the name of the column in data that contains the RTs for the specific overlap/correct/condition combination. Default is "rt"

correctCol

a string that specifies the name of the column that specifies if the participant chose the item with the greatest value distribution (correct) or if they did not (incorrect).

correctVals

a vector of two values that specifies the "correct" value (index 1) and the "incorrect" value (index 2). e.g, c("yes", "no"). DEFAULT = c(TRUE, FALSE)

loopsPerRWstep

A number specifying the number of loops that will be run in the RRW simulation when it calculates the summary statistics for each number of samples for each boundary. Higher numbers produce more precise estimates, but also increase the time needed to converge on a solution. Default is 200.

minimizeStat

A string that specifies which statistic to minimize when optimizing the model fit. The options are: "BIC" , "AIC" , or "R_Square". Default is "BIC".

equalizeRTandPhit

A boolean that specifies whether the influence of the pHit should be equal to that of rt. Influence is a function of the number of observations. RT has more observations than pHit because it has both correct RTs and incorrect RTs. If this is set to TRUE, then the influence of the pHit and RT is equalized in the minimization statistic. If it is set to FALSE, then the the minimazation statistic is calculated as usual. DEFAULT = FALSE.

pars.n

The number of free parameters. When NULL, the program will attempt to calculate the number of free parameters from the input. Default = NULL.

fileTag

A string that is appended to the name of files to identify the analysis and experiment. The default is NULL, whereby the filetag will just be based on a timestamp.

numSimsToAverage

A number specifying how many simulation runs are in the dataset and should be averaged together to get the final fit. Default is 10.

savePlots

A boolean specifying whether to save plots for each sensitivity run. Default = FALSE. '

Value

Several files are saved, including <fileTag>rrwData.txt (which contains the inputData), <fileTag>FitResults.txt (which contains the final parameter fits), <fileTag>Fitted.txt (which contains the input data + simulation fit data). The function returns a list containing (1) a list of the parameter values and fit statistics [runStats], and (2) a dataframe containing the input data with the best fit prediction based on the parameter values [df.fitted].

Examples

rrwRunWithFixedParameters(tmp.df, tmpModelList, minN = 40, dataOverlapCol = "overlapRound", RwSamplesCol = "Q50", dataRtCol = "rt", correctCol = "correct01", correctVals = c(1,0), loopsPerRWstep = 200, minimizeStat = 'BIC', equalizeRTandPhit = TRUE, numSimsToAverage = 40, fileTag = NULL)

ccpluncw/ccpl_R_RRW documentation built on July 4, 2025, 3:24 p.m.