ch.moralsRTpHitFit: A function to fit the RT and pHit function to morals data

ch.moralsRTpHitFitR Documentation

A function to fit the RT and pHit function to morals data

Description

This function attempts to fit a non-linear, decelerating function to the pHit data; a linear function to the RT data; plots the functions on a single graph; and returns a list with the fit statistics.

Usage

ch.moralsRTpHitFit(
  data,
  overlapRoundCol,
  RTCol,
  correctCol,
  correctVals = c(TRUE, FALSE),
  minNperOverlap = 0,
  useTwoParameterModel = FALSE,
  cex1 = 1.5,
  cex.topTile = 1.25,
  printR2 = F,
  topTitle = NULL,
  filename = NULL,
  minUniqueOverlaps = 2,
  ...
)

Arguments

data

the morals dataframe after running through ch.moralsDataPrep().

overlapRoundCol

a string that specifies the name of the column in "data" that contains the overlap column.

correctCol

a string that specifies the name of the new column that will contains a "1" if the participant chose the item with the greatest value distribution and a "0" if they did not.

correctVals

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

minNperOverlap

an integer that specifies the minimum number of trials necessary to include an overlap bin in the graph. DEFAULT = 0.

useTwoParameterModel

A boolean that specifies whether to use a two parameter p(HOV) model. If this is set to TRUE, then this function will fit a p(HVO) model whereby the rightmost point (overlap = 1.0) is not fixed at p(HVO) = 0.5. DEFAULT = FALSE.

cex1

sets the default font size. DEFAULT = 1.25.

cex.topTile

sets the default font size of the title at the top of the page. DEFAULT = 1.25.

printR2

a boolean that determines whether to print the r square on the graph. DEFAULT = FALSE.

topTitle

a string that will be the title at the top of the page. DEFAULT = NULL.

filename

the filename (pdf) to save the output of the graph. DEFAULT = NULL (no graph saved)

minUniqueOverlaps

An integer specifying the minimum number of unique overlap bins necessary for the program to calculate the pHVO and RT function. DEFAULT = 2.

RTcol

a string that specifies the name of the column in "data" that contains the RT for each trial.

Value

a list containing: RTfit = lm object with the fit of the RT data; pHitFit = the nls fit object with the fit of the pHit data; pHitR2 = the r2 of the pHitFit.

Examples

ch.moralsRTpHitFit (data=moralsData,"overlapRound", "resdRT", "correct", c("yes", "no"), filename = "plot.pdf")

ccpluncw/ccpl_R_chMorals documentation built on June 15, 2025, 3:02 a.m.