Setting up the Packages

knitr::opts_chunk$set(echo = TRUE)

#Set up the packages
if(!require(rcompanion)){install.packages('rcompanion', dependencies = TRUE)}   #For cramer V
## Loading required package: rcompanion
## Warning: package 'rcompanion' was built under R version 4.0.3
if(!require(readxl)){install.packages('readxl', dependencies = TRUE)}           #For reading excel file
## Loading required package: readxl
if(!require(compute.es)){install.packages('compute.es', dependencies = TRUE)}   #For effect size conversion
## Loading required package: compute.es
## Warning: package 'compute.es' was built under R version 4.0.3
if(!require(DescTools)){install.packages('DescTools', dependencies = TRUE)}     #For cramer V CIs calculations
## Loading required package: DescTools
## Warning: package 'DescTools' was built under R version 4.0.3
if(!require(corpora)){install.packages('corpora', dependencies = TRUE)}         #For z score
## Loading required package: corpora
## Warning: package 'corpora' was built under R version 4.0.3
if(!require(pander)){install.packages('pander', dependencies = TRUE)}           #For session info
## Loading required package: pander
## Warning: package 'pander' was built under R version 4.0.3
if(!require(exact2x2)){install.packages('exact2x2', dependencies = TRUE)}       #For McNemar test
## Loading required package: exact2x2
## Warning: package 'exact2x2' was built under R version 4.0.3
## Loading required package: exactci
## Warning: package 'exactci' was built under R version 4.0.3
## Loading required package: ssanv
## Warning: package 'ssanv' was built under R version 4.0.3
if(!require(haven)){install.packages('haven', dependencies = TRUE)}             #For reading SPSS file
## Loading required package: haven
if(!require(tidyverse)){install.packages('tidyverse', dependencies = TRUE)}     #For cleaning
## Loading required package: tidyverse
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.4     v dplyr   1.0.2
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## Warning: package 'tibble' was built under R version 4.0.3
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(rcompanion)
library(readxl)
library(compute.es)
library(DescTools)
library(corpora)
library(pander)
library(exact2x2)
library(haven)
library(tidyverse)

Study 1

##Study 1A General Action and Inaction Regret

#Read the datafile
datagmr <- read_sav("C:/Users/u3517/Dropbox/Gilovich and Medvec (1994) Replication/Datasets/Gilovich+and+Medvec+(1994)+replication+and+extension+V3-G_May+4,+2021_10.10.sav")
#Count action and inaction frequencies and no. of participants. There are two columns for the same question with different orders
inaction1a_a <- sum((datagmr$actinactregret_a[!is.na(datagmr$actinactregret_a)])==1)
action1a_a <- sum((datagmr$actinactregret_a[!is.na(datagmr$actinactregret_a)])==2)
n1_a <- length(datagmr$actinactregret_a[!is.na(datagmr$actinactregret_a)])
inaction1a_b <- sum((datagmr$actinactregret_b[!is.na(datagmr$actinactregret_b)])==1)
action1a_b <- sum((datagmr$actinactregret_b[!is.na(datagmr$actinactregret_b)])==2)
n1_b <- length(datagmr$actinactregret_b[!is.na(datagmr$actinactregret_b)])
inaction1a <- inaction1a_a + inaction1a_b
inaction1a
## [1] 341
action1a <- action1a_a + action1a_b
action1a
## [1] 205
n1 <- n1_a+n1_b
n1
## [1] 546
#Create a vector with action and inaction
observed1areg   = c( action1a,    inaction1a)
#Calculate chi square
chisqstudy1a <- chisq.test(observed1areg, p = c(1/2, 1/2))
chisqstudy1a
## 
##  Chi-squared test for given probabilities
## 
## data:  observed1areg
## X-squared = 33.875, df = 1, p-value = 5.876e-09
#Calculate z score
z.score(action1a, n1, p = 0.5, correct = TRUE)
## [1] -5.777467
#Calculate proportions and CIs of action and inaction
propaction1a <- prop.test(x = action1a, n = n1, p = 0.5, 
                 correct = FALSE)
propaction1a
## 
##  1-sample proportions test without continuity correction
## 
## data:  action1a out of n1, null probability 0.5
## X-squared = 33.875, df = 1, p-value = 5.876e-09
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3358433 0.4168127
## sample estimates:
##         p 
## 0.3754579
propinaction1a <- prop.test(x = inaction1a, n = n1, p = 0.5, 
                 correct = FALSE)
propinaction1a
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction1a out of n1, null probability 0.5
## X-squared = 33.875, df = 1, p-value = 5.876e-09
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5831873 0.6641567
## sample estimates:
##         p 
## 0.6245421
#Calculate cramer V
expected1areg   = c( 1/2,   1/2)
oneacramerreg <- cramerVFit(x = observed1areg, p = expected1areg, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
oneacramerreg
##   Cramer.V lower.ci upper.ci
## 1   0.2491   0.1648    0.326
#Transform the counts into percentages
inaction1a_perc <- inaction1a/n1 * 100
action1a_perc <- action1a/n1 * 100
observed1areg_per <- c(action1a_perc, inaction1a_perc)



## Study 1A General Action and Inaction Responsibility

#Count action and inaction frequencies and no. of participants. There are two columns for the same question with different orders
inaction1aresp_a <- sum((datagmr$actinactres_a[!is.na(datagmr$actinactres_a)])==1)
action1aresp_a <- sum((datagmr$actinactres_a[!is.na(datagmr$actinactres_a)])==2)
n1res_a <- length(datagmr$actinactres_a[!is.na(datagmr$actinactres_a)])
inaction1aresp_b <- sum((datagmr$actinactres_b[!is.na(datagmr$actinactres_b)])==1)
action1aresp_b <- sum((datagmr$actinactres_b[!is.na(datagmr$actinactres_b)])==2)
n1res_b <- length(datagmr$actinactres_b[!is.na(datagmr$actinactres_b)])
inaction1aresp <- inaction1aresp_a + inaction1aresp_b
inaction1aresp
## [1] 181
action1aresp <- action1aresp_a + action1aresp_b
action1aresp
## [1] 290
n1resp <- n1res_a+n1res_b
n1resp
## [1] 471
#Create a vector with action and inaction
observed1aresp  = c( action1aresp,    inaction1aresp)
#Calculate chi square
chisqstudy1a_resp <- chisq.test(observed1aresp, p = c(1/2, 1/2))
chisqstudy1a_resp
## 
##  Chi-squared test for given probabilities
## 
## data:  observed1aresp
## X-squared = 25.225, df = 1, p-value = 5.102e-07
#Calculate z score
z.score(action1aresp, n1resp, p = 0.5, correct = TRUE)
## [1] 4.976377
#Calculate proportions and CIs of action and inaction
propaction1aresp <- prop.test(x = action1aresp, n = n1resp, p = 0.5, 
                 correct = FALSE)
propaction1aresp
## 
##  1-sample proportions test without continuity correction
## 
## data:  action1aresp out of n1resp, null probability 0.5
## X-squared = 25.225, df = 1, p-value = 5.102e-07
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5710138 0.6585365
## sample estimates:
##         p 
## 0.6157113
propinaction1aresp <- prop.test(x = inaction1aresp, n = n1resp, p = 0.5, 
                 correct = FALSE)
propinaction1aresp
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction1aresp out of n1resp, null probability 0.5
## X-squared = 25.225, df = 1, p-value = 5.102e-07
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3414635 0.4289862
## sample estimates:
##         p 
## 0.3842887
#Calculate cramer V
expected1aresp   = c( 1/2,   1/2)
oneacramerresp <- cramerVFit(x = observed1aresp, p = expected1aresp, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
oneacramerresp
##   Cramer.V lower.ci upper.ci
## 1   0.2314   0.1465   0.3163
#Transform the counts into percentages
inaction1a_resp_perc <- inaction1aresp/n1resp * 100
action1a_resp_perc <- action1aresp/n1resp * 100
observed1aresp_per <- c(action1a_resp_perc, inaction1a_resp_perc)


#Combine regret plot with responsibility plot
par(mfrow=c(1,2))
barplot(observed1areg_per, main = "Study 1A: Regret",
        ylab = "Percentage Experiencing Stronger Regret",
        names.arg = c("Action", "Inaction"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)
barplot(observed1aresp_per, main = "Study 1A: Responsibility",
        ylab = "Percentage Experiencing Stronger Responsibility",
        names.arg = c("Action", "Inaction"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)

Study 5

## Study 5 Short Term Regret

#Read the datafile
datagmr <- read_sav("C:/Users/u3517/Dropbox/Gilovich and Medvec (1994) Replication/Datasets/Gilovich+and+Medvec+(1994)+replication+and+extension+V3-G_May+4,+2021_10.10.sav")
#Set up the table
tablestudy5regst <- table(datagmr$pastweekactinactreg)
tablestudy5regst
## 
##   1   2 
## 262 284
#Run the chi-square test
chisqstudy5regst <- chisq.test(tablestudy5regst, p = c(1/2, 1/2))
chisqstudy5regst
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy5regst
## X-squared = 0.88645, df = 1, p-value = 0.3464
#Count action and inaction frequencies and no. of participants
inaction5regst <- sum((datagmr$pastweekactinactreg[!is.na(datagmr$pastweekactinactreg)])==1)
action5regst <- sum((datagmr$pastweekactinactreg[!is.na(datagmr$pastweekactinactreg)])==2)
n5regst <- length(datagmr$pastweekactinactreg[!is.na(datagmr$pastweekactinactreg)])
#Calculate z score
z.score(action5regst, n5regst, p = 0.5, correct = TRUE)
## [1] 0.898717
#Calculate proportions and CIs of action and inaction
propaction5regst <- prop.test(x = action5regst, n = n5regst, p = 0.5, 
                 correct = FALSE)
propaction5regst
## 
##  1-sample proportions test without continuity correction
## 
## data:  action5regst out of n5regst, null probability 0.5
## X-squared = 0.88645, df = 1, p-value = 0.3464
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4782469 0.5617647
## sample estimates:
##         p 
## 0.5201465
propinaction5regst <- prop.test(x = inaction5regst, n = n5regst, p = 0.5, 
                 correct = FALSE)
propinaction5regst
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction5regst out of n5regst, null probability 0.5
## X-squared = 0.88645, df = 1, p-value = 0.3464
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4382353 0.5217531
## sample estimates:
##         p 
## 0.4798535
#Calculate cramer V
observed5regst   = c( inaction5regst,    action5regst)
expected5regst   = c( 1/2,   1/2)
fivecramerregst <- cramerVFit(x = observed5regst, p = expected5regst, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fivecramerregst
##   Cramer.V lower.ci upper.ci
## 1  0.04029        0   0.1209
#Transform the counts into percentages
inaction5_regst_perc <- inaction5regst/n5regst * 100
action5_regst_perc <- action5regst/n5regst * 100
observed5regst_per <- c(action5_regst_perc, inaction5_regst_perc)


#Study 5 Lifetime Regret

tablestudy5reglt <- table(datagmr$gr8actinactreg)
tablestudy5reglt
## 
##   1   2 
## 262 284
chisqstudy5reglt <- chisq.test(tablestudy5reglt, p = c(1/2, 1/2))
chisqstudy5reglt
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy5reglt
## X-squared = 0.88645, df = 1, p-value = 0.3464
#Count action and inaction frequencies and no. of participants
inaction5reglt <- sum((datagmr$gr8actinactreg[!is.na(datagmr$gr8actinactreg)])==1)
action5reglt <- sum((datagmr$gr8actinactreg[!is.na(datagmr$gr8actinactreg)])==2)
n5reglt <- length(datagmr$gr8actinactreg[!is.na(datagmr$gr8actinactreg)])
#Calculate z score
z.score(action5reglt, n5reglt, p = 0.5, correct = TRUE)
## [1] 0.898717
#Calculate proportions and CIs of action and inaction
propaction5reglt <- prop.test(x = action5reglt, n = n5reglt, p = 0.5, 
                 correct = FALSE)
propaction5reglt
## 
##  1-sample proportions test without continuity correction
## 
## data:  action5reglt out of n5reglt, null probability 0.5
## X-squared = 0.88645, df = 1, p-value = 0.3464
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4782469 0.5617647
## sample estimates:
##         p 
## 0.5201465
propinaction5reglt <- prop.test(x = inaction5reglt, n = n5reglt, p = 0.5, 
                 correct = FALSE)
propinaction5reglt
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction5reglt out of n5reglt, null probability 0.5
## X-squared = 0.88645, df = 1, p-value = 0.3464
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4382353 0.5217531
## sample estimates:
##         p 
## 0.4798535
#Calculate cramer V
observed5reglt   = c( inaction5reglt,    action5reglt)
expected5reglt   = c( 1/2,   1/2)
fivecramerreglt <- cramerVFit(x = observed5reglt, p = expected5reglt, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fivecramerreglt
##   Cramer.V lower.ci upper.ci
## 1  0.04029 0.003663   0.1281
#Transform the counts into percentages
inaction5_reglt_perc <- inaction5reglt/n5reglt * 100
action5_reglt_perc <- action5reglt/n5reglt * 100
observed5reglt_per <- c(action5_reglt_perc, inaction5_reglt_perc)


#Combine past week regret plot with lifetime regret plot
par(mfrow=c(1,2)) 
barplot(observed5regst_per, main = "Study 5: Past Week Regret",
        ylab = "Percentage Experiencing Stronger Regret",
        names.arg = c("Action", "Inaction"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)
barplot(observed5reglt_per, main = "Study 5: Lifetime Regret",
        ylab = "Percentage Experiencing Stronger Regret",
        names.arg = c("Action", "Inaction"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)

#Study 5 Change from Action to Inaction vs Inaction to Action Regret
tablereg <- table(datagmr$pastweekactinactreg, datagmr$gr8actinactreg)
tablereg
##    
##       1   2
##   1 127 135
##   2 135 149
observed5chan = c(135, 135)
#Calculate chi square
chisqstudy5regchan <- chisq.test(observed5chan, p = c(1/2, 1/2))
chisqstudy5regchan
## 
##  Chi-squared test for given probabilities
## 
## data:  observed5chan
## X-squared = 0, df = 1, p-value = 1
#Calculate Cramer V
expected5chan  = c( 1/2,   1/2)
fivechancramer <- cramerVFit(x = observed5chan, p = expected5chan, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fivechancramer 
##   Cramer.V lower.ci upper.ci
## 1        0        0   0.1333
#Calculate z score
z.score(135, 270, p = 0.5, correct = TRUE)
## [1] 0
#Calculate proportions and CIs of action to inaction change and inaction to action change
propacttoinactreg <- prop.test(x = 135, n = 270, p = 0.5, 
                 correct = FALSE)
propacttoinactreg
## 
##  1-sample proportions test without continuity correction
## 
## data:  135 out of 270, null probability 0.5
## X-squared = 0, df = 1, p-value = 1
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.44078 0.55922
## sample estimates:
##   p 
## 0.5
propinacttoactreg <- prop.test(x = 135, n = 270, p = 0.5, 
                 correct = FALSE)
propinacttoactreg
## 
##  1-sample proportions test without continuity correction
## 
## data:  135 out of 270, null probability 0.5
## X-squared = 0, df = 1, p-value = 1
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.44078 0.55922
## sample estimates:
##   p 
## 0.5
#Transform the counts into percentages
acttoinactreg_perc <- 135/270 * 100
inacttoactreg_perc <- 135/270 * 100
observed5regchan <- c(acttoinactreg_perc, inacttoactreg_perc)


#Study 5 McNemar tests for Regret
#Chi square
mcnemar.test(tablereg,
             correct = TRUE)
## 
##  McNemar's Chi-squared test
## 
## data:  tablereg
## McNemar's chi-squared = 0, df = 1, p-value = 1
library(exact2x2)
#Odds ratio with CIs
mcnemar.exact(tablereg, conf.level = 0.95)
## 
##  Exact McNemar test (with central confidence intervals)
## 
## data:  tablereg
## b = 135, c = 135, p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.781879 1.278970
## sample estimates:
## odds ratio 
##          1
#Study 5 Short Term Responsibility

#Set up the table
tablestudy5respst <- table(datagmr$pastweekactinactres)
tablestudy5respst
## 
##   1   2 
## 207 264
#Run Chi-Square test
chisqstudy5respst <- chisq.test(tablestudy5respst, p = c(1/2, 1/2))
chisqstudy5respst
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy5respst
## X-squared = 6.8981, df = 1, p-value = 0.008629
#Count action and inaction frequencies and no. of participants
inaction5respst <- sum((datagmr$pastweekactinactres[!is.na(datagmr$pastweekactinactres)])==1)
action5respst <- sum((datagmr$pastweekactinactres[!is.na(datagmr$pastweekactinactres)])==2)
n5respst <- length(datagmr$pastweekactinactres[!is.na(datagmr$pastweekactinactres)])
#Calculate z score
z.score(action5respst, n5respst, p = 0.5, correct = TRUE)
## [1] 2.580344
#Calculate proportions and CIs of action and inaction
propaction5respst <- prop.test(x = action5respst, n = n5respst, p = 0.5, 
                 correct = FALSE)
propaction5respst
## 
##  1-sample proportions test without continuity correction
## 
## data:  action5respst out of n5respst, null probability 0.5
## X-squared = 6.8981, df = 1, p-value = 0.008629
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5153757 0.6046643
## sample estimates:
##         p 
## 0.5605096
propinaction5respst <- prop.test(x = inaction5respst, n = n5respst, p = 0.5, 
                 correct = FALSE)
propinaction5respst
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction5respst out of n5respst, null probability 0.5
## X-squared = 6.8981, df = 1, p-value = 0.008629
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3953357 0.4846243
## sample estimates:
##         p 
## 0.4394904
#Calculate Cramer V
observed5respst   = c( inaction5respst,    action5respst)
expected5respst   = c( 1/2,   1/2)
fivecramerrespst <- cramerVFit(x = observed5respst, p = expected5respst, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fivecramerrespst
##   Cramer.V lower.ci upper.ci
## 1    0.121  0.03609   0.2102
#Transform the counts into percentages
inaction5_respst_perc <- inaction5respst/n5respst * 100
action5_respst_perc <- action5respst/n5respst * 100
observed5respst_per <- c(inaction5_respst_perc, action5_respst_perc)


#Study 5 Long Term Responsibility

#Set up the table
tablestudy5resplt <- table(datagmr$lifetimeactinactres)
tablestudy5resplt
## 
##   1   2 
## 204 267
chisqstudy5resplt <- chisq.test(tablestudy5resplt, p = c(1/2, 1/2))
chisqstudy5resplt
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy5resplt
## X-squared = 8.4268, df = 1, p-value = 0.003697
#Count action and inaction frequencies and no. of participants
inaction5resplt <- sum((datagmr$lifetimeactinactres[!is.na(datagmr$lifetimeactinactres)])==1)
action5resplt <- sum((datagmr$lifetimeactinactres[!is.na(datagmr$lifetimeactinactres)])==2)
n5resplt <- length(datagmr$lifetimeactinactres[!is.na(datagmr$lifetimeactinactres)])
#Calculate z score
z.score(action5resplt, n5resplt, p = 0.5, correct = TRUE)
## [1] 2.856809
#Calculate proportions and CIs of action and inaction
propaction5resplt <- prop.test(x = action5resplt, n = n5resplt, p = 0.5, 
                 correct = FALSE)
propaction5resplt
## 
##  1-sample proportions test without continuity correction
## 
## data:  action5resplt out of n5resplt, null probability 0.5
## X-squared = 8.4268, df = 1, p-value = 0.003697
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5217666 0.6109093
## sample estimates:
##        p 
## 0.566879
propinaction5resplt <- prop.test(x = inaction5resplt, n = n5resplt, p = 0.5, 
                 correct = FALSE)
propinaction5resplt
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction5resplt out of n5resplt, null probability 0.5
## X-squared = 8.4268, df = 1, p-value = 0.003697
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3890907 0.4782334
## sample estimates:
##        p 
## 0.433121
#Calculate cramer V
observed5resplt   = c( inaction5resplt,    action5resplt)
expected5resplt   = c( 1/2,   1/2)
fivecramerresplt <- cramerVFit(x = observed5resplt, p = expected5resplt, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fivecramerresplt
##   Cramer.V lower.ci upper.ci
## 1   0.1338  0.04045   0.2271
#Transform the counts into percentages
inaction5_resplt_perc <- inaction5resplt/n5resplt * 100
inaction5_resplt_perc
## [1] 43.3121
action5_resplt_perc <- action5resplt/n5resplt * 100
action5_resplt_perc
## [1] 56.6879
observed5resplt_per <- c(inaction5_resplt_perc, action5_resplt_perc)



#Combine past week responsibility plot with lifetime responsibility plot
par(mfrow=c(1,2))
barplot(observed5respst_per, main = "Study 5: Week Responsibility",
        ylab = "Percentage Experiencing Stronger Responsibility",
        names.arg = c("Inaction", "Action"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)
barplot(observed5resplt_per, main = "Study 5: Lifetime Responsibility",
        ylab = "Percentage Experiencing Stronger Responsibility",
        names.arg = c("Inaction", "Action"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)

#Study 5 Change from Action to Inaction vs Inaction to Action Responsibility
tableresp <- table(datagmr$pastweekactinactres, datagmr$lifetimeactinactres)
tableresp
##    
##       1   2
##   1 102 105
##   2 102 162
observed5chan_resp = c(102, 105)
#Calculate chi square
chisqstudy5chan_resp <- chisq.test(observed5chan_resp, p = c(1/2, 1/2))
chisqstudy5chan_resp
## 
##  Chi-squared test for given probabilities
## 
## data:  observed5chan_resp
## X-squared = 0.043478, df = 1, p-value = 0.8348
#Calculate Cramer V
expected5chan_resp  = c( 1/2,   1/2)
fivechancramer_resp <- cramerVFit(x = observed5chan_resp, p = expected5chan_resp, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fivechancramer_resp 
##   Cramer.V lower.ci upper.ci
## 1  0.01449 0.004831   0.1498
#Calculate z score
z.score(102, 207, p = 0.5, correct = TRUE)
## [1] -0.1390096
#Calculate proportions and CIs of action to inaction change and inaction to action change
propacttoinactresp <- prop.test(x = 102, n = 207, p = 0.5, 
                 correct = FALSE)
propacttoinactresp
## 
##  1-sample proportions test without continuity correction
## 
## data:  102 out of 207, null probability 0.5
## X-squared = 0.043478, df = 1, p-value = 0.8348
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4254025 0.5603688
## sample estimates:
##         p 
## 0.4927536
propinacttoactresp <- prop.test(x = 105, n = 207, p = 0.5, 
                 correct = FALSE)
propinacttoactresp
## 
##  1-sample proportions test without continuity correction
## 
## data:  105 out of 207, null probability 0.5
## X-squared = 0.043478, df = 1, p-value = 0.8348
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4396312 0.5745975
## sample estimates:
##         p 
## 0.5072464
#Transform the counts into percentages
acttoinactresp_perc <- 102/207 * 100
inacttoactresp_perc <- 105/207 * 100
observed5respchan <- c(acttoinactresp_perc, inacttoactresp_perc)


#Study 5 McNemar tests for Responsibility
#Chi square
mcnemar.test(tableresp,
             correct = TRUE)
## 
##  McNemar's Chi-squared test with continuity correction
## 
## data:  tableresp
## McNemar's chi-squared = 0.019324, df = 1, p-value = 0.8894
library(exact2x2)
#Odds ratio with CIs
mcnemar.exact(tableresp, conf.level = 0.95)
## 
##  Exact McNemar test (with central confidence intervals)
## 
## data:  tableresp
## b = 105, c = 102, p-value = 0.8895
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.7763553 1.3653674
## sample estimates:
## odds ratio 
##   1.029412

Study 3

#Study 3 Short Term Regret

#Read the datafile
datagmr <- read_sav("C:/Users/u3517/Dropbox/Gilovich and Medvec (1994) Replication/Datasets/Gilovich+and+Medvec+(1994)+replication+and+extension+V3-G_May+4,+2021_10.10.sav")
#Set up the table for frequencies of action Jim and inaction Dave
tablestudy3regst <- table(datagmr$regretdavejimshort)
tablestudy3regst
## 
##   1   2 
## 195 313
#Run chi-square test
chisqstudy3regst <- chisq.test(tablestudy3regst, p = c(1/2, 1/2))
chisqstudy3regst
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy3regst
## X-squared = 27.409, df = 1, p-value = 1.646e-07
#Count action and inaction frequencies and no. of participants
inaction3regst <- sum((datagmr$regretdavejimshort[!is.na(datagmr$regretdavejimshort)])==1)
action3regst <- sum((datagmr$regretdavejimshort[!is.na(datagmr$regretdavejimshort)])==2)
n3regst <- length(datagmr$regretdavejimshort[!is.na(datagmr$regretdavejimshort)])
#Calculate z score
z.score(action3regst, n3regst, p = 0.5, correct = TRUE)
## [1] 5.191036
#Calculate proportions and CIs of action and inaction
propaction3regst <- prop.test(x = action3regst, n = n3regst, p = 0.5, 
                 correct = FALSE)
propaction3regst
## 
##  1-sample proportions test without continuity correction
## 
## data:  action3regst out of n3regst, null probability 0.5
## X-squared = 27.409, df = 1, p-value = 1.646e-07
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5731296 0.6574105
## sample estimates:
##         p 
## 0.6161417
propinaction3regst <- prop.test(x = inaction3regst, n = n3regst, p = 0.5, 
                 correct = FALSE)
propinaction3regst
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction3regst out of n3regst, null probability 0.5
## X-squared = 27.409, df = 1, p-value = 1.646e-07
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3425895 0.4268704
## sample estimates:
##         p 
## 0.3838583
#Calculate cramer V
observed3regst   = c( inaction3regst,    action3regst)
expected3regst   = c( 1/2,   1/2)
threecramerregst <- cramerVFit(x = observed3regst, p = expected3regst, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
threecramerregst
##   Cramer.V lower.ci upper.ci
## 1   0.2323   0.1457    0.311
#Transform the counts into percentages
inaction3_regst_perc <- inaction3regst/n3regst * 100
action3_regst_perc <- action3regst/n3regst * 100
observed3regst_per <- c(action3_regst_perc, inaction3_regst_perc)


#Study 3 Long Term Regret

#Set up the table for frequencies of action Jim and inaction Dave
tablestudy3reglt <- table(datagmr$regdavejimlong)
tablestudy3reglt
## 
##   1   2 
## 295 213
#Run chi-square test
chisqstudy3reglt <- chisq.test(tablestudy3reglt, p = c(1/2, 1/2))
chisqstudy3reglt
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy3reglt
## X-squared = 13.236, df = 1, p-value = 0.0002746
#Count action and inaction frequencies and no. of participants
inaction3reglt <- sum((datagmr$regdavejimlong[!is.na(datagmr$regdavejimlong)])==1)
action3reglt <- sum((datagmr$regdavejimlong[!is.na(datagmr$regdavejimlong)])==2)
n3reglt <- length(datagmr$regdavejimlong[!is.na(datagmr$regdavejimlong)])
#Calculate z score
z.score(action3reglt, n3reglt, p = 0.5, correct = TRUE)
## [1] -3.593794
#Calculate proportions and CIs of action and inaction
propaction3reglt <- prop.test(x = action3reglt, n = n3reglt, p = 0.5, 
                 correct = FALSE)
propaction3reglt
## 
##  1-sample proportions test without continuity correction
## 
## data:  action3reglt out of n3reglt, null probability 0.5
## X-squared = 13.236, df = 1, p-value = 0.0002746
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3771446 0.4626495
## sample estimates:
##         p 
## 0.4192913
propinaction3reglt <- prop.test(x = inaction3reglt, n = n3reglt, p = 0.5, 
                 correct = FALSE)
propinaction3reglt
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction3reglt out of n3reglt, null probability 0.5
## X-squared = 13.236, df = 1, p-value = 0.0002746
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5373505 0.6228554
## sample estimates:
##         p 
## 0.5807087
#Calculate cramer V
observed3reglt   = c( inaction3reglt,    action3reglt)
expected3reglt   = c( 1/2,   1/2)
threecramerreglt <- cramerVFit(x = observed3reglt, p = expected3reglt, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
threecramerreglt
##   Cramer.V lower.ci upper.ci
## 1   0.1614   0.0748   0.2441
#Transform the counts into percentages
inaction3_reglt_perc <- inaction3reglt/n3reglt * 100
action3_reglt_perc <- action3reglt/n3reglt * 100
observed3reglt_per <- c(action3_reglt_perc, inaction3_reglt_perc)


#Combine short term regret plot with long term regret plot
par(mfrow=c(1,2))
barplot(observed3regst_per, main = "Study 3: Short-Term Regret",
        ylab = "Percentage Perceiving Stronger Regret",
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)
barplot(observed3reglt_per, main = "Study 3: Long-Term Regret",
        ylab = "Percentage Perceiving Stronger Regret",
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)

#Study 3 Change from Action to Inaction vs Inaction to Action Regret
tablestudy3reg <- table(datagmr$regretdavejimshort, datagmr$regdavejimlong)
tablestudy3reg
##    
##       1   2
##   1 174  21
##   2 121 192
observed3chan = c(121, 21)
#Calculate chi square
chisqstudy3chan <- chisq.test(observed3chan, p = c(1/2, 1/2))
chisqstudy3chan
## 
##  Chi-squared test for given probabilities
## 
## data:  observed3chan
## X-squared = 70.423, df = 1, p-value < 2.2e-16
#Calculate Cramer V
expected3chan  = c( 1/2,   1/2)
threechancramer <- cramerVFit(x = observed3chan, p = expected3chan, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
threechancramer
##   Cramer.V lower.ci upper.ci
## 1   0.7042   0.5915    0.831
#Calculate z score
z.score(121, 142, p = 0.5, correct = TRUE)
## [1] 8.307895
#Calculate proportions and CIs of action to inaction change and inaction to action change
prop3regacttoinact <- prop.test(x = 121, n = 142, p = 0.5, 
                 correct = FALSE)
prop3regacttoinact
## 
##  1-sample proportions test without continuity correction
## 
## data:  121 out of 142, null probability 0.5
## X-squared = 70.423, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.7844831 0.9011929
## sample estimates:
##         p 
## 0.8521127
prop3reginacttoact <- prop.test(x = 21, n = 142, p = 0.5, 
                 correct = FALSE)
prop3reginacttoact
## 
##  1-sample proportions test without continuity correction
## 
## data:  21 out of 142, null probability 0.5
## X-squared = 70.423, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.09880707 0.21551685
## sample estimates:
##         p 
## 0.1478873
#Transform the counts into percentages
acttoinactreg3_perc <- 121/142 * 100
inacttoactreg3_perc <- 21/142 * 100
observed3regchan <- c(acttoinactreg3_perc, inacttoactreg3_perc)

#Study 3 McNemar tests for Regret
#Chi square
mcnemar.test(tablestudy3reg,
             correct = TRUE)
## 
##  McNemar's Chi-squared test with continuity correction
## 
## data:  tablestudy3reg
## McNemar's chi-squared = 69.021, df = 1, p-value < 2.2e-16
library(exact2x2)
#Odds ratio with CIs
mcnemar.exact(tablestudy3reg, conf.level = 0.95)
## 
##  Exact McNemar test (with central confidence intervals)
## 
## data:  tablestudy3reg
## b = 21, c = 121, p-value < 2.2e-16
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1036746 0.2773605
## sample estimates:
## odds ratio 
##  0.1735537
#Study 3 Short Term Responsibility

#Set up the table for frequencies of action Jim and inaction Dave
tablestudy3respst <- table(datagmr$respdavejimshort)
tablestudy3respst
## 
##   1   2 
## 132 376
#Run chi-square test
chisqstudy3respst <- chisq.test(tablestudy3respst, p = c(1/2, 1/2))
chisqstudy3respst
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy3respst
## X-squared = 117.2, df = 1, p-value < 2.2e-16
#Count action and inaction frequencies and no. of participants
inaction3respst <- sum((datagmr$respdavejimshort[!is.na(datagmr$respdavejimshort)])==1)
action3respst <- sum((datagmr$respdavejimshort[!is.na(datagmr$respdavejimshort)])==2)
n3respst <- length(datagmr$respdavejimshort[!is.na(datagmr$respdavejimshort)])
#Calculate z score
z.score(action3respst, n3respst, p = 0.5, correct = TRUE)
## [1] 10.78138
#Calculate proportions and CIs of action and inaction
propaction3respst <- prop.test(x = action3respst, n = n3respst, p = 0.5, 
                 correct = FALSE)
propaction3respst
## 
##  1-sample proportions test without continuity correction
## 
## data:  action3respst out of n3respst, null probability 0.5
## X-squared = 117.2, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.7003199 0.7763903
## sample estimates:
##         p 
## 0.7401575
propinaction3respst <- prop.test(x = inaction3respst, n = n3respst, p = 0.5, 
                 correct = FALSE)
propinaction3respst
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction3respst out of n3respst, null probability 0.5
## X-squared = 117.2, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.2236097 0.2996801
## sample estimates:
##         p 
## 0.2598425
#Calculate cramer V
observed3respst   = c( inaction3respst,    action3respst)
expected3respst   = c( 1/2,   1/2)
threecramerrespst <- cramerVFit(x = observed3respst, p = expected3respst, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
threecramerrespst
##   Cramer.V lower.ci upper.ci
## 1   0.4803   0.3976   0.5551
#Transform the counts into percentages
inaction3_respst_perc <- inaction3respst/n3respst * 100
action3_respst_perc <- action3respst/n3respst * 100
observed3respst_per <- c(action3_respst_perc, inaction3_respst_perc)


#Study 3 Long Term Responsibility

#Set up the table for frequencies of action Jim and inaction Dave
tablestudy3resplt <- table(datagmr$respdavejimlong)
tablestudy3resplt
## 
##   1   2 
## 200 308
#Run chi-square test
chisqstudy3resplt <- chisq.test(tablestudy3resplt, p = c(1/2, 1/2))
chisqstudy3resplt
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy3resplt
## X-squared = 22.961, df = 1, p-value = 1.654e-06
#Count action and inaction frequencies and no. of participants
inaction3resplt <- sum((datagmr$respdavejimlong[!is.na(datagmr$respdavejimlong)])==1)
action3resplt <- sum((datagmr$respdavejimlong[!is.na(datagmr$respdavejimlong)])==2)
n3resplt <- length(datagmr$respdavejimlong[!is.na(datagmr$respdavejimlong)])
#Calculate z score
z.score(action3resplt, n3resplt, p = 0.5, correct = TRUE)
## [1] 4.747357
#Calculate proportions and CIs of action and inaction
propaction3resplt <- prop.test(x = action3resplt, n = n3resplt, p = 0.5, 
                 correct = FALSE)
propaction3resplt
## 
##  1-sample proportions test without continuity correction
## 
## data:  action3resplt out of n3resplt, null probability 0.5
## X-squared = 22.961, df = 1, p-value = 1.654e-06
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5631679 0.6478349
## sample estimates:
##         p 
## 0.6062992
propinaction3resplt <- prop.test(x = inaction3resplt, n = n3resplt, p = 0.5, 
                 correct = FALSE)
propinaction3resplt
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction3resplt out of n3resplt, null probability 0.5
## X-squared = 22.961, df = 1, p-value = 1.654e-06
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3521651 0.4368321
## sample estimates:
##         p 
## 0.3937008
#Calculate cramer V
observed3resplt   = c( inaction3resplt,    action3resplt)
expected3resplt   = c( 1/2,   1/2)
threecramerresplt <- cramerVFit(x = observed3resplt, p = expected3resplt, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
threecramerresplt
##   Cramer.V lower.ci upper.ci
## 1   0.2126   0.1299    0.307
#Transform the counts into percentages
inaction3_resplt_perc <- inaction3resplt/n3resplt * 100
action3_resplt_perc <- action3resplt/n3resplt * 100
observed3resplt_per <- c(action3_resplt_perc, inaction3_resplt_perc)


#Combine short term responsibility plot with long term responsibility plot
par(mfrow=c(1,2))
barplot(observed3respst_per, main = "Study 3: Short-Term Responsibility",
        cex.main = 0.85,
        ylab = "Percentage Perceiving Stronger Regret",
        cex.lab = 0.85,
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        cex.axis = 0.85,
        horiz = FALSE)
barplot(observed3resplt_per, main = "Study 3: Long-Term Responsibility",
        cex.main = 0.85,
        ylab = "Percentage Perceiving Stronger Regret",
        cex.lab = 0.85,
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        cex.axis = 0.85,
        horiz = FALSE)

#Study 3 Change from Action to Inaction vs Inaction to Action Responsibility
tablestudy3resp <- table(datagmr$respdavejimshort, datagmr$respdavejimlong)
tablestudy3resp
##    
##       1   2
##   1 103  29
##   2  97 279
observed3chanresp = c(97, 29)
#Calculate chi square
chisqstudy3chanresp <- chisq.test(observed3chanresp, p = c(1/2, 1/2))
chisqstudy3chanresp
## 
##  Chi-squared test for given probabilities
## 
## data:  observed3chanresp
## X-squared = 36.698, df = 1, p-value = 1.379e-09
#Calculate Cramer V
expected3chanresp  = c( 1/2,   1/2)
threechancramer <- cramerVFit(x = observed3chanresp, p = expected3chanresp, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
threechancramer
##   Cramer.V lower.ci upper.ci
## 1   0.5397   0.3968   0.6825
#Calculate z score
z.score(97, 126, p = 0.5, correct = TRUE)
## [1] 5.968834
#Calculate proportions and CIs of action to inaction change and inaction to action change
prop3respacttoinact <- prop.test(x = 97, n = 126, p = 0.5, 
                 correct = FALSE)
prop3respacttoinact
## 
##  1-sample proportions test without continuity correction
## 
## data:  97 out of 126, null probability 0.5
## X-squared = 36.698, df = 1, p-value = 1.379e-09
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.6890161 0.8346995
## sample estimates:
##         p 
## 0.7698413
prop3respinacttoact <- prop.test(x = 29, n = 126, p = 0.5, 
                 correct = FALSE)
prop3respinacttoact
## 
##  1-sample proportions test without continuity correction
## 
## data:  29 out of 126, null probability 0.5
## X-squared = 36.698, df = 1, p-value = 1.379e-09
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.1653005 0.3109839
## sample estimates:
##         p 
## 0.2301587
#Transform the counts into percentages
acttoinactresp3_perc <- 97/126 * 100
inacttoactresp3_perc <- 29/126 * 100
observed3respchan <- c(acttoinactresp3_perc, inacttoactresp3_perc)


#Study 3 McNemar tests for Responsibility
#Chi square
mcnemar.test(tablestudy3resp,
             correct = TRUE)
## 
##  McNemar's Chi-squared test with continuity correction
## 
## data:  tablestudy3resp
## McNemar's chi-squared = 35.627, df = 1, p-value = 2.39e-09
library(exact2x2)
#Odds ratio with CIs
mcnemar.exact(tablestudy3resp, conf.level = 0.95)
## 
##  Exact McNemar test (with central confidence intervals)
## 
## data:  tablestudy3resp
## b = 29, c = 97, p-value = 9.245e-10
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1903086 0.4567414
## sample estimates:
## odds ratio 
##  0.2989691

Study 4

# Study 4 Short Term Regret

#Read the datafile
datagmr <- read_sav("C:/Users/u3517/Dropbox/Gilovich and Medvec (1994) Replication/Datasets/Gilovich+and+Medvec+(1994)+replication+and+extension+V3-G_May+4,+2021_10.10.sav")
#Set up the table for frequencies of action Jim and inaction Dave 
tablestudy4regst <- table(datagmr$regretdavejimshort4)
tablestudy4regst
## 
##   1   2 
##  95 159
#Run chi-square test
chisqstudy4regst <- chisq.test(tablestudy4regst, p = c(1/2, 1/2))
chisqstudy4regst
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy4regst
## X-squared = 16.126, df = 1, p-value = 5.927e-05
#Count action and inaction frequencies and no. of participants
inaction4regst <- sum((datagmr$regretdavejimshort4[!is.na(datagmr$regretdavejimshort4)])==1)
action4regst <- sum((datagmr$regretdavejimshort4[!is.na(datagmr$regretdavejimshort4)])==2)
n4regst <- length(datagmr$regretdavejimshort4[!is.na(datagmr$regretdavejimshort4)])
#Calculate z score
z.score(action4regst, n4regst, p = 0.5, correct = TRUE)
## [1] 3.952972
#Calculate proportions and CIs of action and inaction
propaction4regst <- prop.test(x = action4regst, n = n4regst, p = 0.5, 
                 correct = FALSE)
propaction4regst
## 
##  1-sample proportions test without continuity correction
## 
## data:  action4regst out of n4regst, null probability 0.5
## X-squared = 16.126, df = 1, p-value = 5.927e-05
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5650168 0.6831978
## sample estimates:
##         p 
## 0.6259843
propinaction4regst <- prop.test(x = inaction4regst, n = n4regst, p = 0.5, 
                 correct = FALSE)
propinaction4regst
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction4regst out of n4regst, null probability 0.5
## X-squared = 16.126, df = 1, p-value = 5.927e-05
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3168022 0.4349832
## sample estimates:
##         p 
## 0.3740157
#Calculate cramer V
observed4regst   = c( inaction4regst,    action4regst)
expected4regst   = c( 1/2,   1/2)
fourcramerregst <- cramerVFit(x = observed4regst, p = expected4regst, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fourcramerregst
##   Cramer.V lower.ci upper.ci
## 1    0.252   0.1339    0.378
#Transform the counts into percentages
inaction4_regst_perc <- inaction4regst/n4regst * 100
action4_regst_perc <- action4regst/n4regst * 100
observed4regst_per <- c(action4_regst_perc, inaction4_regst_perc)


# Study 4 Long Term Regret

#Set up the table for frequencies of action Jim and inaction Dave
tablestudy4reglt <- table(datagmr$regdavejimlong4)
tablestudy4reglt
## 
##   1   2 
## 142 113
#Run chi-square test
chisqstudy4reglt <- chisq.test(tablestudy4reglt, p = c(1/2, 1/2))
chisqstudy4reglt
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy4reglt
## X-squared = 3.298, df = 1, p-value = 0.06936
#Count action and inaction frequencies and no. of participants
inaction4reglt <- sum((datagmr$regdavejimlong4[!is.na(datagmr$regdavejimlong4)])==1)
action4reglt <- sum((datagmr$regdavejimlong4[!is.na(datagmr$regdavejimlong4)])==2)
n4reglt <- length(datagmr$regdavejimlong4[!is.na(datagmr$regdavejimlong4)])
#Calculate z score
z.score(action4reglt, n4reglt, p = 0.5, correct = TRUE)
## [1] -1.753428
#Calculate proportions and CIs of action and inaction
propaction4reglt <- prop.test(x = action4reglt, n = n4reglt, p = 0.5, 
                 correct = FALSE)
propaction4reglt
## 
##  1-sample proportions test without continuity correction
## 
## data:  action4reglt out of n4reglt, null probability 0.5
## X-squared = 3.298, df = 1, p-value = 0.06936
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.3834587 0.5045036
## sample estimates:
##         p 
## 0.4431373
propinaction4reglt <- prop.test(x = inaction4reglt, n = n4reglt, p = 0.5, 
                 correct = FALSE)
propinaction4reglt
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction4reglt out of n4reglt, null probability 0.5
## X-squared = 3.298, df = 1, p-value = 0.06936
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4954964 0.6165413
## sample estimates:
##         p 
## 0.5568627
#Calculate cramer V
observed4reglt   = c( inaction4reglt,    action4reglt)
expected4reglt   = c( 1/2,   1/2)
fourcramerreglt <- cramerVFit(x = observed4reglt, p = expected4reglt, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fourcramerreglt
##   Cramer.V lower.ci upper.ci
## 1   0.1137  0.01176   0.2314
#Transform the counts into percentages
inaction4_reglt_perc <- inaction4reglt/n4reglt * 100
action4_reglt_perc <- action4reglt/n4reglt * 100
observed4reglt_per <- c(action4_reglt_perc, inaction4_reglt_perc)


#Combine short term regret plot with long term regret plot
par(mfrow=c(1,2))
barplot(observed4regst_per, main = "Study 4: Short-Term Regret",
        ylab = "Percentage Perceiving Stronger Regret",
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)
barplot(observed4reglt_per, main = "Study 4: Long-Term Regret",
        ylab = "Percentage Perceiving Stronger Regret",
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        horiz = FALSE)

#Study 4 Test of Independence Regret

#Combine short-term tables and long-term tables
tab4reg <- as.table(rbind(tablestudy4regst, tablestudy4reglt))
tab4reg
##                    1   2
## tablestudy4regst  95 159
## tablestudy4reglt 142 113
#COnduct chi-square test
study4regtestindependence <- chisq.test(tab4reg, correct = FALSE)
study4regtestindependence
## 
##  Pearson's Chi-squared test
## 
## data:  tab4reg
## X-squared = 17.098, df = 1, p-value = 3.55e-05
#Cramer V
CramerV(tab4reg, conf.level = 0.95)
##   Cramer V     lwr.ci     upr.ci 
## 0.18328046 0.09640944 0.27015113
# Study 4 Short Term Responsibility

#Set up the table for frequencies of action Jim and inaction Dave
tablestudy4respst <- table(datagmr$respdavejimshort4)
tablestudy4respst
## 
##   1   2 
##  64 190
#Run chi-square test
chisqstudy4respst <- chisq.test(tablestudy4respst, p = c(1/2, 1/2))
chisqstudy4respst
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy4respst
## X-squared = 62.504, df = 1, p-value = 2.659e-15
#Count action and inaction frequencies and no. of participants
inaction4respst <- sum((datagmr$respdavejimshort4[!is.na(datagmr$respdavejimshort4)])==1)
action4respst <- sum((datagmr$respdavejimshort4[!is.na(datagmr$respdavejimshort4)])==2)
n4respst <- length(datagmr$respdavejimshort4[!is.na(datagmr$respdavejimshort4)])
#Calculate z score
z.score(action4respst, n4respst, p = 0.5, correct = TRUE)
## [1] 7.843198
#Calculate proportions and CIs of action and inaction
propaction4respst <- prop.test(x = action4respst, n = n4respst, p = 0.5, 
                 correct = FALSE)
propaction4respst
## 
##  1-sample proportions test without continuity correction
## 
## data:  action4respst out of n4respst, null probability 0.5
## X-squared = 62.504, df = 1, p-value = 2.659e-15
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.6912162 0.7974562
## sample estimates:
##         p 
## 0.7480315
propinaction4respst <- prop.test(x = inaction4respst, n = n4respst, p = 0.5, 
                 correct = FALSE)
propinaction4respst
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction4respst out of n4respst, null probability 0.5
## X-squared = 62.504, df = 1, p-value = 2.659e-15
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.2025438 0.3087838
## sample estimates:
##         p 
## 0.2519685
#Calculate cramer V
observed4respst   = c( inaction4respst,    action4respst)
expected4respst   = c( 1/2,   1/2)
fourcramerrespst <- cramerVFit(x = observed4respst, p = expected4respst, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fourcramerrespst
##   Cramer.V lower.ci upper.ci
## 1   0.4961   0.3858   0.6063
#Transform the counts into percentages
inaction4_respst_perc <- inaction4respst/n4respst * 100
action4_respst_perc <- action4respst/n4respst * 100
observed4respst_per <- c(action4_respst_perc, inaction4_respst_perc)


# Study 4 Long Term Responsibility

#Set up the table for frequencies of action Jim and inaction Dave
tablestudy4resplt <- table(datagmr$respdavejimlong4)
tablestudy4resplt
## 
##   1   2 
##  79 176
#Run chi-square test
chisqstudy4resplt <- chisq.test(tablestudy4resplt, p = c(1/2, 1/2))
chisqstudy4resplt
## 
##  Chi-squared test for given probabilities
## 
## data:  tablestudy4resplt
## X-squared = 36.898, df = 1, p-value = 1.245e-09
#Count action and inaction frequencies and no. of participants
inaction4resplt <- sum((datagmr$respdavejimlong4[!is.na(datagmr$respdavejimlong4)])==1)
action4resplt <- sum((datagmr$respdavejimlong4[!is.na(datagmr$respdavejimlong4)])==2)
n4resplt <- length(datagmr$respdavejimlong4[!is.na(datagmr$respdavejimlong4)])
#Calculate z score
z.score(action4resplt, n4resplt, p = 0.5, correct = TRUE)
## [1] 6.011753
#Calculate proportions and CIs of action and inaction
propaction4resplt <- prop.test(x = action4resplt, n = n4resplt, p = 0.5, 
                 correct = FALSE)
propaction4resplt
## 
##  1-sample proportions test without continuity correction
## 
## data:  action4resplt out of n4resplt, null probability 0.5
## X-squared = 36.898, df = 1, p-value = 1.245e-09
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.6309700 0.7437768
## sample estimates:
##         p 
## 0.6901961
propinaction4resplt <- prop.test(x = inaction4resplt, n = n4resplt, p = 0.5, 
                 correct = FALSE)
propinaction4resplt
## 
##  1-sample proportions test without continuity correction
## 
## data:  inaction4resplt out of n4resplt, null probability 0.5
## X-squared = 36.898, df = 1, p-value = 1.245e-09
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.2562232 0.3690300
## sample estimates:
##         p 
## 0.3098039
#Calculate cramer V
observed4resplt   = c( inaction4resplt,    action4resplt)
expected4resplt   = c( 1/2,   1/2)
fourcramerresplt <- cramerVFit(x = observed4resplt, p = expected4resplt, ci = TRUE, conf = 0.95, type = "perc", R = 1000, reportIncomplete = TRUE)
fourcramerresplt
##   Cramer.V lower.ci upper.ci
## 1   0.3804   0.2706    0.498
#Transform the counts into percentages
inaction4_resplt_perc <- inaction4resplt/n4resplt * 100
action4_resplt_perc <- action4resplt/n4resplt * 100
observed4resplt_per <- c(action4_resplt_perc, inaction4_resplt_perc)


#Combine short term responsibility plot with long term responsibility plot
par(mfrow=c(1,2))
barplot(observed4respst_per, main = "Study 4: Short-Term Responsibility",
        cex.main = 0.85,
        ylab = "Percentage Perceiving Stronger Regret",
        cex.lab = 0.85,
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        cex.axis = 0.85,
        horiz = FALSE)
barplot(observed4resplt_per, main = "Study 4: Long-Term Responsibility",
        cex.main = 0.85,
        ylab = "Percentage Perceiving Stronger Regret",
        cex.lab = 0.85,
        names.arg = c("Action Jim", "Inaction Dave"),
        col = c("darkblue","red"),
        ylim=c(0,100),
        cex.axis = 0.85,
        horiz = FALSE)

#Study 4 Test of Independence Responsibility

#Combine short-term tables and long-term tables
tab4resp <- as.table(rbind(tablestudy4respst, tablestudy4resplt))
tab4resp
##                     1   2
## tablestudy4respst  64 190
## tablestudy4resplt  79 176
#COnduct chi-square test
study4resptestindependence <- chisq.test(tab4resp, correct = FALSE)
study4resptestindependence
## 
##  Pearson's Chi-squared test
## 
## data:  tab4resp
## X-squared = 2.107, df = 1, p-value = 0.1466
#Cramer V
CramerV(tab4resp, conf.level = 0.95)
##  Cramer V    lwr.ci    upr.ci 
## 0.0643387 0.0000000 0.1512088

Gender and Age Information

#Age summary
summary(datagmr$Age)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   18.00   33.00   41.00   43.84   54.25   89.00       1
#Gender distribution
table(datagmr$Gender)
## 
##   1   2   3   4 
## 421 581   8   6

Acknowledgement

We thank Qinyu Xiao for his comments and suggesstions on the RMarkdown.

Session information

pander(sessionInfo(), compact = FALSE)

R version 4.0.2 (2020-06-22)

Platform: x86_64-w64-mingw32/x64 (64-bit)

locale: LC_COLLATE=English_Hong Kong SAR.1252, LC_CTYPE=English_Hong Kong SAR.1252, LC_MONETARY=English_Hong Kong SAR.1252, LC_NUMERIC=C and LC_TIME=English_Hong Kong SAR.1252

attached base packages:

  • stats
  • graphics
  • grDevices
  • utils
  • datasets
  • methods
  • base

other attached packages:

  • forcats(v.0.5.0)
  • stringr(v.1.4.0)
  • dplyr(v.1.0.2)
  • purrr(v.0.3.4)
  • readr(v.1.3.1)
  • tidyr(v.1.1.2)
  • tibble(v.3.0.4)
  • ggplot2(v.3.3.2)
  • tidyverse(v.1.3.0)
  • haven(v.2.3.1)
  • exact2x2(v.1.6.5)
  • exactci(v.1.3-3)
  • ssanv(v.1.1)
  • pander(v.0.6.3)
  • corpora(v.0.5)
  • DescTools(v.0.99.38)
  • compute.es(v.0.2-5)
  • readxl(v.1.3.1)
  • rcompanion(v.2.3.25)

loaded via a namespace (and not attached):

  • httr(v.1.4.2)
  • jsonlite(v.1.7.1)
  • splines(v.4.0.2)
  • modelr(v.0.1.8)
  • assertthat(v.0.2.1)
  • expm(v.0.999-5)
  • gld(v.2.6.2)
  • lmom(v.2.8)
  • stats4(v.4.0.2)
  • blob(v.1.2.1)
  • coin(v.1.3-1)
  • cellranger(v.1.1.0)
  • yaml(v.2.2.1)
  • pillar(v.1.4.6)
  • backports(v.1.1.10)
  • lattice(v.0.20-41)
  • glue(v.1.4.2)
  • digest(v.0.6.25)
  • rvest(v.0.3.6)
  • colorspace(v.1.4-1)
  • sandwich(v.2.5-1)
  • htmltools(v.0.5.0)
  • Matrix(v.1.2-18)
  • plyr(v.1.8.6)
  • pkgconfig(v.2.0.3)
  • broom(v.0.7.0)
  • EMT(v.1.1)
  • mvtnorm(v.1.1-1)
  • scales(v.1.1.1)
  • generics(v.0.0.2)
  • ellipsis(v.0.3.1)
  • withr(v.2.3.0)
  • TH.data(v.1.0-10)
  • cli(v.2.2.0)
  • survival(v.3.1-12)
  • magrittr(v.1.5)
  • crayon(v.1.3.4)
  • evaluate(v.0.14)
  • fansi(v.0.4.1)
  • fs(v.1.5.0)
  • MASS(v.7.3-51.6)
  • xml2(v.1.3.2)
  • class(v.7.3-17)
  • tools(v.4.0.2)
  • hms(v.0.5.3)
  • lifecycle(v.0.2.0)
  • matrixStats(v.0.56.0)
  • multcomp(v.1.4-14)
  • Exact(v.2.0)
  • reprex(v.0.3.0)
  • munsell(v.0.5.0)
  • compiler(v.4.0.2)
  • e1071(v.1.7-3)
  • multcompView(v.0.1-8)
  • rlang(v.0.4.10)
  • grid(v.4.0.2)
  • rstudioapi(v.0.11)
  • rmarkdown(v.2.3)
  • boot(v.1.3-25)
  • gtable(v.0.3.0)
  • codetools(v.0.2-16)
  • DBI(v.1.1.0)
  • R6(v.2.5.0)
  • lubridate(v.1.7.9)
  • zoo(v.1.8-8)
  • knitr(v.1.30)
  • nortest(v.1.0-4)
  • libcoin(v.1.0-6)
  • modeltools(v.0.2-23)
  • stringi(v.1.5.3)
  • parallel(v.4.0.2)
  • Rcpp(v.1.0.5)
  • vctrs(v.0.3.4)
  • dbplyr(v.1.4.4)
  • tidyselect(v.1.1.0)
  • xfun(v.0.17)
  • lmtest(v.0.9-38)