Package 'cofad'

Title: Contrast Analyses for Factorial Designs
Description: Contrast analysis for factorial designs provides an alternative to the traditional ANOVA approach, offering the distinct advantage of testing targeted hypotheses. The foundation of this package is primarily rooted in the works of Rosenthal, Rosnow, and Rubin (2000, ISBN: 978-0521659802) as well as Sedlmeier and Renkewitz (2018, ISBN: 978-3868943214).
Authors: Johannes Titz [aut, cre], Markus Burkhardt [aut], Mirka Henninger [ctb], Simone Malejka [ctb]
Maintainer: Johannes Titz <[email protected]>
License: LGPL (>= 3)
Version: 0.3.1
Built: 2024-12-06 18:40:17 UTC
Source: CRAN

Help Index


Data from Akan et al. (2018), experiment 2B

Description

Data contains information from a within-subjects experiment with N = 90 participants. The goal of the experiment was to investigate the benefits of retrieval practice on memory performance. For the entire dataset and analysis scripts see: https://osf.io/bqr5f/. The data was licensed under CC-BY 4.0 Melisa Akan, Aaron Benjamin.

Usage

data(akan)

Format

a data frame with 270 rows and 3 variables:

subject

subject id

condition

experimental condition (test, restudy, control)

recalled

dependent variable

Source

Akan, M., Stanley, S. E., & Benjamin, A. S. (2018). Testing enhances memory for context. Journal of Memory and Language, 103, 19–27. doi:10.1016/j.jml.2018.07.003


Calculate contrast analysis for factorial designs

Description

Calculate contrast analysis for factorial designs

Usage

calc_contrast(
  dv,
  between = NULL,
  lambda_between = NULL,
  within = NULL,
  lambda_within = NULL,
  ID = NULL,
  id = NULL,
  data = NULL
)

Arguments

dv

dependent variable. Values must be numeric.

between

independent variable that divides the data into independent groups. Vector must be a factor.

lambda_between

contrast weights must be a named numeric. Names must match the levels of between. If lambda_between does not sum up to zero, this will be done automatically.

within

independent variable which divides the data into dependent groups. This must be a factor.

lambda_within

contrast must be a named numeric. Names must match the levels of between. If lambda_between does not sum up to zero, this will be done automatically.

ID

deprecated, use id instead

id

identifier for cases or subjects is needed for within- and mixed contrast analysis.

data

optional argument for the data.frame containing dv and groups.

Details

For multi-factorial designs, the lambda weights of the factors must be connected.

Note that cofad returns one-sided p-values for t-tests.

Value

an object of type cofad_bw or cofad_wi or cofad_mx, including p-value, F-value, contrast weights, different effect sizes. Call summary on this object to get a nice overview of all relevant statistics. Call print to get a short text that can be used for a report.

References

Rosenthal, R., Rosnow, R.L., & Rubin, D.B. (2000). Contrasts and effect sizes in behavioral research: A correlational approach. New York: Cambridge University Press.

Examples

# Example for between-subjects design Table 3.1 from
# Rosenthal, Rosnow and Rubin (2001)

data(rosenthal_tbl31)
contr_bw <- calc_contrast(
   dv = dv,
   between = between,
   lambda_between = c("A" = -3, "B" = -1, "C" = 1, "D" = 3),
   data = rosenthal_tbl31)
contr_bw
summary(contr_bw)

# Example for within-subjects design Calculation 16.6 from
# Sedlmeier and Renkewitz (2018, p. 537)

data(sedlmeier_p537)
contr_wi <- calc_contrast(
   dv = reading_test,
   within = music,
   id = participant,
   lambda_within = c(
     "without music" = 1.25,
     "white noise" = 0.25,
     "classic" = -0.75,
     "jazz" = -0.75
   ),
   data = sedlmeier_p537
 )
contr_wi
summary(contr_wi, ci = .90)

# Example for mixed-design Table 5.3 from
# Rosenthal, Rosnow and Rubin (2001)

data(rosenthal_tbl53)

contr_mx <- calc_contrast(dv = dv, between = between,
              lambda_between = c("age8" = -1, "age10" = 0, "age12" = 1),
              within = within,
              lambda_within = c("1" = -3, "2" = -1,"3" = 1, "4" = 3),
              id = id, data = rosenthal_tbl53
              )
contr_mx
summary(contr_mx)

Calculate between contrast analysis from aggregated data (means, sds and ns)

Description

Calculate between contrast analysis from aggregated data (means, sds and ns)

Usage

calc_contrast_aggregated(means, sds, ns, between, lambda_between, data)

Arguments

means

numeric vector of mean values for every condition

sds

numeric vector of standard deviation values for every condition

ns

numeric vector of sample size values for every condition

between

factor for the independent variable that divides the data into independent groups

lambda_between

numeric vector for contrast weights. Names must match the levels of between. If lambda_between does not sum up to zero, this will be done automatically (centering).

data

optional argument for the data.frame containing all variables except for lambda_between

Value

an object of type cofad_bw, including p-value, F-value, contrast weights, different effect sizes

References

Rosenthal, R., Rosnow, R.L., & Rubin, D.B. (2000). Contrasts and effect sizes in behavioral research: A correlational approach. New York: Cambridge University Press.

Examples

library(dplyr)
furr_agg <- furr_p4 %>%
  group_by(major) %>%
  summarize(mean = mean(empathy), sd = sd(empathy), n = n())
lambdas = c("psychology" = 1, "education" = -1, "business" = 0,
            "chemistry" = 0)
calc_contrast_aggregated(mean, sd, n, major, lambdas, furr_agg)

Calculate r_alerting from r_contrast and r_effectsize

Description

Convenience function to transform effect sizes in contrast analyses.

Usage

calc_r_alerting(r_contrast, r_effectsize)

Arguments

r_contrast

what it says

r_effectsize

what it says


Calculate r_alerting from F-values

Description

Convenience function to calculate effect sizes in contrast analyses.

Usage

calc_r_alerting_from_f(f_contrast, f_between, df_between)

Arguments

f_contrast

F value from contrast analysis

f_between

F value from ANOVA (one between variable!)

df_between

degrees of freedom of ANOVA


Calculate r_contrast from r_alerting and r_effectsize

Description

Convenience function to transform effect sizes in contrast analyses.

Usage

calc_r_contrast(r_alerting, r_effectsize)

Arguments

r_alerting

what it says

r_effectsize

what it says


Calculate r_effectsize from r_contrast and r_alerting

Description

Convenience function to transform effect sizes in contrast analyses.

Usage

calc_r_effectsize(r_alerting, r_contrast)

Arguments

r_alerting

what it says

r_contrast

what it says


Empathy data set by Furr (2004)

Description

fictitious data set on empathy ratings of students from different majors

Usage

data(furr_p4)

Format

a data frame with 20 rows and 2 columns

empathy

Empathy rating

major

major of student

Source

Furr, R. M. (2004). Interpreting effect sizes in contrast analysis. Understanding Statistics, 3, 1–25. https://doi.org/10.1207/s15328031us0301_1


Haans within data example

Description

Fictitious data set from Haans, A. (2018). Contrast Analysis: A Tutorial. https://doi.org/10.7275/7DEY-ZD62

Usage

data(haans_within1by4)

Format

a data frame with 20 rows and 3 variables:

person

person id

name

group name (sitting row 1 to 4)

value

dv, final exam grade


Calculate lambdas for two competing hypotheses

Description

If you want to test two competing hypotheses, you can use this helper function to create the correct difference lambdas. There is no magic here. The two contrasts are z-standardized first and then subtracted (lambda_preferred - lambda_competing). You can use the new difference lambdas as the input for calc_contrast.

Usage

lambda_diff(lambda_preferred, lambda_competing, labels = NULL)

Arguments

lambda_preferred

Lambdas of the preferred hypothesis. Has to be a named vector with the names corresponding with the groups in the analyzed data set. Alternatively, use the parameter labels.

lambda_competing

Lambdas of the competing hypothesis. Has to be a named vector with the names corresponding with the groups in the analyzed data set. Alternatively, use the parameter labels.

labels

If you provide lambdas without names, you can set the group labels for both contrasts here.

Value

Lambdas for difference between lambda_preferred and lambda_competing

Examples

lambda <- lambda_diff(c("A" = 1, "B" = 2, "C" = 3),
                      c("A" = 1, "B" = 2, "C" = 6))
lambda
# same result
lambda2 <- lambda_diff(c(1, 2, 3), c(1, 2, 6),
                       labels = c("A", "B", "C"))
lambda2

Data from Maraver et al. (2021)

Description

The dataset originates from a between-subjects experiment with N = 120 participants. The experiment aimed to examine whether instructions to imagine the study material could reduce false memories. Full dataset and analysis scripts are available at: https://osf.io/v8apj/?view_only=9969d17536f54053a72be19c050c4767.

Usage

data(maraver)

Format

a data frame with 120 rows and 3 variables:

id

subject id

condition

experimental condition (imagine, memorize, pay_attention)

prop_recalled

dependent variable

Source

Maraver, M. J., Lapa, A., Garcia-Marques, L., Carneiro, P., & Raposo, A. (2021). Imagination Reduces False Memories for Everyday Action Sentences: Evidence From Pragmatic Inferences. Frontiers in Psychology, 12. doi:10.3389/fpsyg.2021.668899


Output of between-subject design contrast analysis

Description

Output of between-subject design contrast analysis

Usage

## S3 method for class 'cofad_bw'
print(x, ...)

Arguments

x

output of calc_contrast

...

further arguments

Value

Displays the significance of the contrast analysis. The contrast weights, the corresponding group and an effectsize are given.


Output of a mixed design contrast analysis

Description

Output of a mixed design contrast analysis

Usage

## S3 method for class 'cofad_mx'
print(x, ...)

Arguments

x

output of calc_contrast

...

further arguments

Value

Displays the significance of the contrast analysis. The contrastweights, the corresponding group and an effectsize are given.


Output of a within subject design contrast analysis

Description

Output of a within subject design contrast analysis

Usage

## S3 method for class 'cofad_wi'
print(x, ...)

Arguments

x

output of calc_contrast

...

further arguments

Value

Displays the significance of the contrast analysis. The contrastweights, the corresponding group and an effectsize are given.


Complexity data set by Rosenthal and Rosnow (2000)

Description

Exercise 2 from Chapter 5 (table on p. 147) in Rosenthal and Rosnow (2000)

Usage

data(rosenthal_chap5_q2)

Format

a data frame with 12 rows and 4 columns

dv

dependent variable: rating of degree of complexity of social interaction from a series of clips

id

unique identifier of participant

within

within variable: complexity of interaction (low, medium high)

between

between variable: cognitive complexity of participant (high or low)

Source

Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.


Data set by Rosenthal and Rosnow (2000)

Description

Fictitious example corresponding to aggregated data set on p. 141 in Rosenthal and Rosnow (2000)

Usage

data(rosenthal_p141)

Format

a data frame with 12 rows and 4 columns

id

unique identifier of participant

dv

dependent variable

within

within variable

between

between variable

Source

Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.


Data set by Rosenthal and Rosnow (2000)

Description

Table 3.1 in Rosenthal and Rosnow (2000) on p. 38.

Usage

data(rosenthal_tbl31)

Format

a data frame with 20 rows and 2 columns

dv

dependent variable

between

group (A, B, C, D))

Source

Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.


Children data set by Rosenthal and Rosnow (2000)

Description

Table 5.3 in Rosenthal and Rosnow (2000) on p. 129.

Usage

data(rosenthal_tbl53)

Format

a data frame with 36 rows and 4 columns

dv

dependent variable

between

age group (8, 10, 12 years)

id

unique identifier for child

within

measurement (1, 2, 3, 4)

Source

Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.


Therapy data set by Rosenthal and Rosnow (2000)

Description

Table 5.9 in Rosenthal and Rosnow (2000)

Usage

data(rosenthal_tbl59)

Format

a data frame with 12 rows and 4 columns

id

unique identifier

dv

dependent variable

med

within variable: medication (treatment or placebo)

pt

between variable: psychotherapy (treatment or placebo)

Source

Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.


Data set by Rosenthal and Rosnow (2000)

Description

Fictitious example of children ability, Table 6.8 in Rosenthal and Rosnow (2000)

Usage

data(rosenthal_tbl68)

Format

a data frame with 8 rows and 4 columns

id

unique identifier of participant

dv

dependent variable

within

within variable

between

between variable

Source

Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.


Starts the mimosa shiny app

Description

Starts the mimosa shiny app

Usage

run_app()

Data from Schwoebel et al. (2018)

Description

For the entire dataset and analysis scripts see:

Usage

data(schwoebel)

Format

a data frame with 64 rows and 2 variables:

condition

experimental condition (massed-same, massed-different, spaced-same, spaced-different)

percent_recalled

dependent variable

Source

Schwoebel, J., Depperman, A. K., & Scott, J. L. (2018). Distinct episodic contexts enhance retrieval-based learning. Memory, 26(9), 1291–1296. doi:10.1080/09658211.2018.1464190


Problem solving data set by Sedlmeier & Renkewitz (2018)

Description

Example 16.2, table 16.1 in Sedlmeier & Renkewitz (2018). Fictitious data set with 15 boys divided into three groups (no training, boys-specific material, girls-specific training material). The DV is the number of solved problem (similar to the training).

Usage

data(sedlmeier_p525)

Format

a data frame with 15 rows and 3 columns

lsg

dv, number of solved exercises

between

group, KT=no training, JT=boys-specific, MT=girls-specific

lambda

lambdas used for this example

Source

Sedlmeier, P., & Renkewitz, F. (2018). Forschungsmethoden und Statistik für Psychologen und Sozialwissenschaftler (3rd ed.). Pearson Studium.


Music data set by Sedlmeier & Renkewitz (2018)

Description

Example 16.6, table 16.5 in Sedlmeier & Renkewitz (2018). Fictitious data set with 8 participants that listened to no music, white noise, classical music, and jazz music (within). The DV is a reading test.

Usage

data(sedlmeier_p537)

Format

a data frame with 32 rows and 3 columns

reading_test

dependent variable

participant

unique id

music

within variable

Source

Sedlmeier, P., & Renkewitz, F. (2018). Forschungsmethoden und Statistik für Psychologen und Sozialwissenschaftler (3rd ed.). Pearson Studium.


Summary of between subject design contrast analysis

Description

Summary of between subject design contrast analysis

Usage

## S3 method for class 'cofad_bw'
summary(object, ...)

Arguments

object

output of calc_contrast

...

further arguments

Value

Displays type of contrast analysis, lambdas, t-table, ANOVA table and typical effect sizes. If you assign this to a variable, it will be a list with the elements Lambdas, tTable, FTable, Effects.


Summary of a mixed design contrast analysis

Description

Summary of a mixed design contrast analysis

Usage

## S3 method for class 'cofad_mx'
summary(object, ...)

Arguments

object

output of calc_contrast

...

further arguments

Value

Displays type of contrast analysis, lambdas, t-table, ANOVA table and typical effect sizes. If you assign this to a variable, it will be a list with the elements Lambdas, tTable, FTable, Effects.


Summary of within subject design contrast analysis

Description

Summary of within subject design contrast analysis

Usage

## S3 method for class 'cofad_wi'
summary(object, ci = 0.95, ...)

Arguments

object

output of calc_contrast

ci

confidence intervall for composite Score (L-Values)

...

further arguments

Value

Displays type of contrast analysis, lambdas, t-table and typical effect sizes. If you assign this to a variable, it will be a list with the elements Lambdas, tTable, Effects.


Testing Effect data

Description

This dataset originates from a study conducted as part of a research seminar in the Psychology B.Sc. program of the University of Cologne. The study participants learned a list of 20 non-associated word pairs. Each half of the word pair was associated with one of two sources (imaginating the word pair in the sky or underwater). The final memory test (cued recall) was conducted two days later. Cued recall means that one word of the word pair was presented, and the participant had to recall the other word. The participants were randomly assigned into one of three between-participant conditions: restudy, source test, item test.

Usage

data(testing_effect)

Format

a data frame with 60 rows and 3 variables:

subject

the participant's id

condition

the between-partipant condition

recalled

the number of words recalled in the cued-recall test