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 |
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.
data(akan)
data(akan)
a data frame with 270 rows and 3 variables:
subject id
experimental condition (test, restudy, control)
dependent variable
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
calc_contrast( dv, between = NULL, lambda_between = NULL, within = NULL, lambda_within = NULL, ID = NULL, id = NULL, data = NULL )
calc_contrast( dv, between = NULL, lambda_between = NULL, within = NULL, lambda_within = NULL, ID = NULL, id = NULL, data = NULL )
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 |
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 |
ID |
deprecated, use id instead |
id |
identifier for cases or subjects is needed for within- and mixed contrast analysis. |
data |
optional argument for the |
For multi-factorial designs, the lambda weights of the factors must be connected.
Note that cofad returns one-sided p-values for t-tests.
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.
Rosenthal, R., Rosnow, R.L., & Rubin, D.B. (2000). Contrasts and effect sizes in behavioral research: A correlational approach. New York: Cambridge University Press.
# 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)
# 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)
calc_contrast_aggregated(means, sds, ns, between, lambda_between, data)
calc_contrast_aggregated(means, sds, ns, between, lambda_between, data)
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 |
data |
optional argument for the |
an object of type cofad_bw, including p-value, F-value, contrast weights, different effect sizes
Rosenthal, R., Rosnow, R.L., & Rubin, D.B. (2000). Contrasts and effect sizes in behavioral research: A correlational approach. New York: Cambridge University Press.
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)
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)
Convenience function to transform effect sizes in contrast analyses.
calc_r_alerting(r_contrast, r_effectsize)
calc_r_alerting(r_contrast, r_effectsize)
r_contrast |
what it says |
r_effectsize |
what it says |
Convenience function to calculate effect sizes in contrast analyses.
calc_r_alerting_from_f(f_contrast, f_between, df_between)
calc_r_alerting_from_f(f_contrast, f_between, df_between)
f_contrast |
F value from contrast analysis |
f_between |
F value from ANOVA (one between variable!) |
df_between |
degrees of freedom of ANOVA |
Convenience function to transform effect sizes in contrast analyses.
calc_r_contrast(r_alerting, r_effectsize)
calc_r_contrast(r_alerting, r_effectsize)
r_alerting |
what it says |
r_effectsize |
what it says |
Convenience function to transform effect sizes in contrast analyses.
calc_r_effectsize(r_alerting, r_contrast)
calc_r_effectsize(r_alerting, r_contrast)
r_alerting |
what it says |
r_contrast |
what it says |
fictitious data set on empathy ratings of students from different majors
data(furr_p4)
data(furr_p4)
a data frame with 20 rows and 2 columns
Empathy rating
major of student
Furr, R. M. (2004). Interpreting effect sizes in contrast analysis. Understanding Statistics, 3, 1–25. https://doi.org/10.1207/s15328031us0301_1
Fictitious data set from Haans, A. (2018). Contrast Analysis: A Tutorial. https://doi.org/10.7275/7DEY-ZD62
data(haans_within1by4)
data(haans_within1by4)
a data frame with 20 rows and 3 variables:
person id
group name (sitting row 1 to 4)
dv, final exam grade
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.
lambda_diff(lambda_preferred, lambda_competing, labels = NULL)
lambda_diff(lambda_preferred, lambda_competing, labels = NULL)
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. |
Lambdas for difference between lambda_preferred and lambda_competing
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
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
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.
data(maraver)
data(maraver)
a data frame with 120 rows and 3 variables:
subject id
experimental condition (imagine, memorize, pay_attention)
dependent variable
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
## S3 method for class 'cofad_bw' print(x, ...)
## S3 method for class 'cofad_bw' print(x, ...)
x |
output of calc_contrast |
... |
further arguments |
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
## S3 method for class 'cofad_mx' print(x, ...)
## S3 method for class 'cofad_mx' print(x, ...)
x |
output of calc_contrast |
... |
further arguments |
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
## S3 method for class 'cofad_wi' print(x, ...)
## S3 method for class 'cofad_wi' print(x, ...)
x |
output of calc_contrast |
... |
further arguments |
Displays the significance of the contrast analysis. The contrastweights, the corresponding group and an effectsize are given.
Exercise 2 from Chapter 5 (table on p. 147) in Rosenthal and Rosnow (2000)
data(rosenthal_chap5_q2)
data(rosenthal_chap5_q2)
a data frame with 12 rows and 4 columns
dependent variable: rating of degree of complexity of social interaction from a series of clips
unique identifier of participant
within variable: complexity of interaction (low, medium high)
between variable: cognitive complexity of participant (high or low)
Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.
Fictitious example corresponding to aggregated data set on p. 141 in Rosenthal and Rosnow (2000)
data(rosenthal_p141)
data(rosenthal_p141)
a data frame with 12 rows and 4 columns
unique identifier of participant
dependent variable
within variable
between variable
Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.
Table 3.1 in Rosenthal and Rosnow (2000) on p. 38.
data(rosenthal_tbl31)
data(rosenthal_tbl31)
a data frame with 20 rows and 2 columns
dependent variable
group (A, B, C, D))
Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.
Table 5.3 in Rosenthal and Rosnow (2000) on p. 129.
data(rosenthal_tbl53)
data(rosenthal_tbl53)
a data frame with 36 rows and 4 columns
dependent variable
age group (8, 10, 12 years)
unique identifier for child
measurement (1, 2, 3, 4)
Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.
Table 5.9 in Rosenthal and Rosnow (2000)
data(rosenthal_tbl59)
data(rosenthal_tbl59)
a data frame with 12 rows and 4 columns
unique identifier
dependent variable
within variable: medication (treatment or placebo)
between variable: psychotherapy (treatment or placebo)
Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.
Fictitious example of children ability, Table 6.8 in Rosenthal and Rosnow (2000)
data(rosenthal_tbl68)
data(rosenthal_tbl68)
a data frame with 8 rows and 4 columns
unique identifier of participant
dependent variable
within variable
between variable
Rosenthal, R., Rosnow, R. L., & Rubin, D. B. (2000). Contrasts and Effect Sizes in Behavioral Research: A Correlational Approach. Cambridge University Press.
For the entire dataset and analysis scripts see:
data(schwoebel)
data(schwoebel)
a data frame with 64 rows and 2 variables:
experimental condition (massed-same, massed-different, spaced-same, spaced-different)
dependent variable
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
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).
data(sedlmeier_p525)
data(sedlmeier_p525)
a data frame with 15 rows and 3 columns
dv, number of solved exercises
group, KT=no training, JT=boys-specific, MT=girls-specific
lambdas used for this example
Sedlmeier, P., & Renkewitz, F. (2018). Forschungsmethoden und Statistik für Psychologen und Sozialwissenschaftler (3rd ed.). Pearson Studium.
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.
data(sedlmeier_p537)
data(sedlmeier_p537)
a data frame with 32 rows and 3 columns
dependent variable
unique id
within variable
Sedlmeier, P., & Renkewitz, F. (2018). Forschungsmethoden und Statistik für Psychologen und Sozialwissenschaftler (3rd ed.). Pearson Studium.
Summary of between subject design contrast analysis
## S3 method for class 'cofad_bw' summary(object, ...)
## S3 method for class 'cofad_bw' summary(object, ...)
object |
output of calc_contrast |
... |
further arguments |
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
## S3 method for class 'cofad_mx' summary(object, ...)
## S3 method for class 'cofad_mx' summary(object, ...)
object |
output of calc_contrast |
... |
further arguments |
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
## S3 method for class 'cofad_wi' summary(object, ci = 0.95, ...)
## S3 method for class 'cofad_wi' summary(object, ci = 0.95, ...)
object |
output of calc_contrast |
ci |
confidence intervall for composite Score (L-Values) |
... |
further arguments |
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.
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.
data(testing_effect)
data(testing_effect)
a data frame with 60 rows and 3 variables:
the participant's id
the between-partipant condition
the number of words recalled in the cued-recall test