AI Experiment Analysis

Loading Libraries

library(afex) # to run the ANOVA and plot results
library(psych) # for the describe() command
library(ggplot2) # to visualize our results
library(expss) # for the cross_cases() command
library(car) # for the leveneTest() command
library(emmeans) # for posthoc tests
library(effsize) # for the cohen.d() command
library(apaTables) # to create our correlation table
library(kableExtra) # to create our correlation table
library(sjPlot) # to visualize our results

Importing Data

# # import your AI results dataset
d <- read.csv(file="Data/finalresults.csv", header=T)

State Your Hypotheses & Chosen Tests

H1: Participants who experience higher stress will report higher levels of isolation. I will assess this using a correlation test. H2: Participants in the social support condition will report lower levels of isolation. I will assess this using a correlation test.

Check Your Variables

This is just basic variable checking that is used across all HW assignments.

colnames(d)[8] <- "stress"
colnames(d)[9] <- "isolation"
colnames(d)[10] <- "social_support"
# to view stats for all variables
describe(d)
               vars   n  mean    sd median trimmed   mad min   max range  skew
id                1 100 50.50 29.01   50.5   50.50 37.06   1 100.0  99.0  0.00
identity*         2 100 50.50 29.01   50.5   50.50 37.06   1 100.0  99.0  0.00
consent*          3 100  2.21  0.43    2.0    2.15  0.00   1   3.0   2.0  1.03
age               4 100 42.20 14.89   35.0   39.71  4.45  21  93.0  72.0  1.45
race              5 100  4.53  1.52    4.5    4.62  2.22   1   7.0   6.0 -0.30
gender            6 100  1.55  0.50    2.0    1.56  0.00   1   2.0   1.0 -0.20
manip_out*        7 100 50.50 29.01   50.5   50.50 37.06   1 100.0  99.0  0.00
stress            8 100  2.56  0.45    2.6    2.56  0.59   2   3.4   1.4 -0.14
isolation         9 100  2.56  0.40    2.5    2.53  0.44   2   3.5   1.5  0.57
social_support   10 100  4.19  0.51    4.0    4.17  0.00   3   6.0   3.0  0.74
ai_manip*        11 100 50.50 29.01   50.5   50.50 37.06   1 100.0  99.0  0.00
condition        12 100  1.50  0.50    1.5    1.50  0.74   1   2.0   1.0  0.00
               kurtosis   se
id                -1.24 2.90
identity*         -1.24 2.90
consent*           0.08 0.04
age                1.41 1.49
race              -1.34 0.15
gender            -1.98 0.05
manip_out*        -1.24 2.90
stress            -1.67 0.05
isolation         -0.88 0.04
social_support     0.82 0.05
ai_manip*         -1.24 2.90
condition         -2.02 0.05
# we'll use the describeBy() command to view skew and kurtosis across our IVs
describeBy(d, group = d$stress)

 Descriptive statistics by group 
group: 2
               vars  n  mean    sd median trimmed   mad  min   max range  skew
id                1 34 50.94 27.39   50.5   50.43 30.39  2.0 100.0  98.0  0.11
identity          2 34 45.59 28.73   44.5   44.96 36.32  1.0  94.0  93.0  0.18
consent           3 34  2.18  0.46    2.0    2.14  0.00  1.0   3.0   2.0  0.65
age               4 34 39.56 12.45   34.5   37.86  3.71 21.0  71.0  50.0  1.31
race              5 34  4.71  1.45    5.5    4.79  0.74  2.0   6.0   4.0 -0.37
gender            6 34  1.50  0.51    1.5    1.50  0.74  1.0   2.0   1.0  0.00
manip_out         7 34 53.44 30.11   56.0   53.89 34.10  1.0 100.0  99.0 -0.23
stress            8 34  2.00  0.00    2.0    2.00  0.00  2.0   2.0   0.0   NaN
isolation         9 34  2.52  0.38    2.5    2.48  0.44  2.1   3.5   1.4  0.88
social_support   10 34  4.25  0.56    4.0    4.26  0.00  3.0   5.2   2.2  0.30
ai_manip         11 34 49.53 26.76   47.5   49.21 31.88  4.0  98.0  94.0  0.17
condition        12 34  1.50  0.51    1.5    1.50  0.74  1.0   2.0   1.0  0.00
               kurtosis   se
id                -1.06 4.70
identity          -1.25 4.93
consent            0.43 0.08
age                0.55 2.13
race              -1.69 0.25
gender            -2.06 0.09
manip_out         -1.23 5.16
stress              NaN 0.00
isolation         -0.19 0.06
social_support    -0.83 0.10
ai_manip          -1.24 4.59
condition         -2.06 0.09
------------------------------------------------------------ 
group: 2.2
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 95.0 NA   95.0    95.0   0 95.0 95.0     0   NA       NA
identity          2 1 96.0 NA   96.0    96.0   0 96.0 96.0     0   NA       NA
consent           3 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
age               4 1 93.0 NA   93.0    93.0   0 93.0 93.0     0   NA       NA
race              5 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
gender            6 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
manip_out         7 1 18.0 NA   18.0    18.0   0 18.0 18.0     0   NA       NA
stress            8 1  2.2 NA    2.2     2.2   0  2.2  2.2     0   NA       NA
isolation         9 1  3.2 NA    3.2     3.2   0  3.2  3.2     0   NA       NA
social_support   10 1  3.5 NA    3.5     3.5   0  3.5  3.5     0   NA       NA
ai_manip         11 1 61.0 NA   61.0    61.0   0 61.0 61.0     0   NA       NA
condition        12 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
------------------------------------------------------------ 
group: 2.3
               vars n  mean    sd median trimmed   mad  min  max range  skew
id                1 3 74.67 18.88   79.0   74.67 17.79 54.0 91.0  37.0 -0.22
identity          2 3 81.67 27.43   97.0   81.67  1.48 50.0 98.0  48.0 -0.38
consent           3 3  2.00  0.00    2.0    2.00  0.00  2.0  2.0   0.0   NaN
age               4 3 65.00 25.98   80.0   65.00  0.00 35.0 80.0  45.0 -0.38
race              5 3  4.67  1.15    4.0    4.67  0.00  4.0  6.0   2.0  0.38
gender            6 3  1.67  0.58    2.0    1.67  0.00  1.0  2.0   1.0 -0.38
manip_out         7 3 64.67 36.12   77.0   64.67 23.72 24.0 93.0  69.0 -0.30
stress            8 3  2.30  0.00    2.3    2.30  0.00  2.3  2.3   0.0   NaN
isolation         9 3  2.60  0.56    2.5    2.60  0.59  2.1  3.2   1.1  0.17
social_support   10 3  4.00  1.00    4.0    4.00  1.48  3.0  5.0   2.0  0.00
ai_manip         11 3 66.67 20.50   78.0   66.67  1.48 43.0 79.0  36.0 -0.38
condition        12 3  1.00  0.00    1.0    1.00  0.00  1.0  1.0   0.0   NaN
               kurtosis    se
id                -2.33 10.90
identity          -2.33 15.84
consent             NaN  0.00
age               -2.33 15.00
race              -2.33  0.67
gender            -2.33  0.33
manip_out         -2.33 20.85
stress              NaN  0.00
isolation         -2.33  0.32
social_support    -2.33  0.58
ai_manip          -2.33 11.84
condition           NaN  0.00
------------------------------------------------------------ 
group: 2.4
               vars n  mean    sd median trimmed   mad  min  max range  skew
id                1 3 32.00 20.66   35.0   32.00 23.72 10.0 51.0  41.0 -0.14
identity          2 3 51.67 47.00   51.0   51.67 68.20  5.0 99.0  94.0  0.01
consent           3 3  2.00  0.00    2.0    2.00  0.00  2.0  2.0   0.0   NaN
age               4 3 50.33 27.43   35.0   50.33  1.48 34.0 82.0  48.0  0.38
race              5 3  3.67  2.52    4.0    3.67  2.97  1.0  6.0   5.0 -0.13
gender            6 3  1.67  0.58    2.0    1.67  0.00  1.0  2.0   1.0 -0.38
manip_out         7 3 42.33 17.21   48.0   42.33 11.86 23.0 56.0  33.0 -0.29
stress            8 3  2.40  0.00    2.4    2.40  0.00  2.4  2.4   0.0   NaN
isolation         9 3  2.70  0.56    2.8    2.70  0.59  2.1  3.2   1.1 -0.17
social_support   10 3  4.17  0.58    4.5    4.17  0.00  3.5  4.5   1.0 -0.38
ai_manip         11 3 41.00 37.59   44.0   41.00 48.93  2.0 77.0  75.0 -0.08
condition        12 3  1.67  0.58    2.0    1.67  0.00  1.0  2.0   1.0 -0.38
               kurtosis    se
id                -2.33 11.93
identity          -2.33 27.14
consent             NaN  0.00
age               -2.33 15.84
race              -2.33  1.45
gender            -2.33  0.33
manip_out         -2.33  9.94
stress              NaN  0.00
isolation         -2.33  0.32
social_support    -2.33  0.33
ai_manip          -2.33 21.70
condition         -2.33  0.33
------------------------------------------------------------ 
group: 2.5
               vars n  mean    sd median trimmed   mad  min  max range  skew
id                1 7 50.29 37.53   56.0   50.29 48.93  3.0 97.0  94.0 -0.04
identity          2 7 57.57 25.66   59.0   57.57 38.55 27.0 87.0  60.0 -0.04
consent           3 7  2.29  0.49    2.0    2.29  0.00  2.0  3.0   1.0  0.75
age               4 7 43.00 12.01   37.0   43.00  5.93 33.0 60.0  27.0  0.50
race              5 7  4.43  1.51    4.0    4.43  1.48  3.0  6.0   3.0  0.12
gender            6 7  1.57  0.53    2.0    1.57  0.00  1.0  2.0   1.0 -0.23
manip_out         7 7 33.43 28.72   22.0   33.43 28.17  3.0 71.0  68.0  0.21
stress            8 7  2.50  0.00    2.5    2.50  0.00  2.5  2.5   0.0   NaN
isolation         9 7  2.59  0.47    2.5    2.59  0.59  2.1  3.2   1.1  0.29
social_support   10 7  4.14  0.38    4.0    4.14  0.00  4.0  5.0   1.0  1.62
ai_manip         11 7 53.43 35.52   57.0   53.43 45.96  5.0 92.0  87.0 -0.37
condition        12 7  1.43  0.53    1.0    1.43  0.00  1.0  2.0   1.0  0.23
               kurtosis    se
id                -1.97 14.18
identity          -2.00  9.70
consent           -1.60  0.18
age               -1.79  4.54
race              -2.16  0.57
gender            -2.20  0.20
manip_out         -1.99 10.86
stress              NaN  0.00
isolation         -1.83  0.18
social_support     0.80  0.14
ai_manip          -1.72 13.43
condition         -2.20  0.20
------------------------------------------------------------ 
group: 2.6
               vars n  mean    sd median trimmed   mad  min   max range  skew
id                1 4 59.00 18.49  59.50   59.00 17.79 36.0  81.0    45 -0.06
identity          2 4 57.00 40.77  57.50   57.00 49.67 13.0 100.0    87 -0.01
consent           3 4  2.25  0.50   2.00    2.25  0.00  2.0   3.0     1  0.75
age               4 4 51.50 24.96  45.00   51.50 18.53 31.0  85.0    54  0.38
race              5 4  5.00  1.83   5.00    5.00  2.22  3.0   7.0     4  0.00
gender            6 4  1.75  0.50   2.00    1.75  0.00  1.0   2.0     1 -0.75
manip_out         7 4 68.25 34.64  82.00   68.25 10.38 17.0  92.0    75 -0.69
stress            8 4  2.60  0.00   2.60    2.60  0.00  2.6   2.6     0   NaN
isolation         9 4  2.58  0.43   2.45    2.58  0.22  2.2   3.2     1  0.56
social_support   10 4  4.62  0.95   4.25    4.62  0.37  4.0   6.0     2  0.62
ai_manip         11 4 36.00 30.47  32.00   36.00 31.88  9.0  71.0    62  0.12
condition        12 4  1.25  0.50   1.00    1.25  0.00  1.0   2.0     1  0.75
               kurtosis    se
id                -1.90  9.25
identity          -2.29 20.38
consent           -1.69  0.25
age               -2.01 12.48
race              -2.24  0.91
gender            -1.69  0.25
manip_out         -1.73 17.32
stress              NaN  0.00
isolation         -1.79  0.22
social_support    -1.79  0.47
ai_manip          -2.30 15.24
condition         -1.69  0.25
------------------------------------------------------------ 
group: 2.7
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 86.0 NA   86.0    86.0   0 86.0 86.0     0   NA       NA
identity          2 1 28.0 NA   28.0    28.0   0 28.0 28.0     0   NA       NA
consent           3 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
age               4 1 33.0 NA   33.0    33.0   0 33.0 33.0     0   NA       NA
race              5 1  6.0 NA    6.0     6.0   0  6.0  6.0     0   NA       NA
gender            6 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
manip_out         7 1 89.0 NA   89.0    89.0   0 89.0 89.0     0   NA       NA
stress            8 1  2.7 NA    2.7     2.7   0  2.7  2.7     0   NA       NA
isolation         9 1  2.1 NA    2.1     2.1   0  2.1  2.1     0   NA       NA
social_support   10 1  4.0 NA    4.0     4.0   0  4.0  4.0     0   NA       NA
ai_manip         11 1 94.0 NA   94.0    94.0   0 94.0 94.0     0   NA       NA
condition        12 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
------------------------------------------------------------ 
group: 2.8
               vars n  mean    sd median trimmed   mad  min  max range  skew
id                1 6 42.00 32.60   26.0   42.00 12.60 14.0 94.0  80.0  0.60
identity          2 6 40.83 36.12   40.0   40.83 55.60  2.0 81.0  79.0  0.02
consent           3 6  2.17  0.41    2.0    2.17  0.00  2.0  3.0   1.0  1.36
age               4 6 40.83 10.70   35.0   40.83  2.97 32.0 56.0  24.0  0.52
race              5 6  3.83  1.17    3.5    3.83  0.74  3.0  6.0   3.0  0.88
gender            6 6  1.83  0.41    2.0    1.83  0.00  1.0  2.0   1.0 -1.36
manip_out         7 6 44.83 28.18   40.5   44.83 32.62  6.0 80.0  74.0  0.01
stress            8 6  2.80  0.00    2.8    2.80  0.00  2.8  2.8   0.0   NaN
isolation         9 6  2.28  0.22    2.2    2.28  0.15  2.0  2.6   0.6  0.26
social_support   10 6  4.32  0.49    4.0    4.32  0.00  4.0  5.0   1.0  0.55
ai_manip         11 6 58.17 24.00   53.0   58.17 26.69 30.0 87.0  57.0  0.19
condition        12 6  1.67  0.52    2.0    1.67  0.00  1.0  2.0   1.0 -0.54
               kurtosis    se
id                -1.67 13.31
identity          -2.10 14.75
consent           -0.08  0.17
age               -1.91  4.37
race              -0.90  0.48
gender            -0.08  0.17
manip_out         -1.80 11.50
stress              NaN  0.00
isolation         -1.73  0.09
social_support    -1.93  0.20
ai_manip          -1.97  9.80
condition         -1.96  0.21
------------------------------------------------------------ 
group: 3
               vars  n  mean    sd median trimmed   mad  min   max range  skew
id                1 38 46.95 29.09   45.5   46.72 36.32  1.0  98.0  97.0  0.02
identity          2 38 50.34 26.86   50.0   50.41 34.10  6.0  95.0  89.0 -0.05
consent           3 38  2.24  0.43    2.0    2.19  0.00  2.0   3.0   1.0  1.19
age               4 38 40.34 12.12   35.0   39.22  5.93 21.0  76.0  55.0  1.10
race              5 38  4.55  1.59    5.5    4.69  0.74  1.0   6.0   5.0 -0.41
gender            6 38  1.50  0.51    1.5    1.50  0.74  1.0   2.0   1.0  0.00
manip_out         7 38 48.39 27.63   44.5   47.84 28.91  4.0  98.0  94.0  0.23
stress            8 38  3.00  0.00    3.0    3.00  0.00  3.0   3.0   0.0   NaN
isolation         9 38  2.65  0.40    2.6    2.64  0.59  2.1   3.5   1.4  0.27
social_support   10 38  4.10  0.38    4.0    4.08  0.00  3.3   5.0   1.7  0.64
ai_manip         11 38 50.08 30.80   51.5   49.78 41.51  1.0 100.0  99.0  0.11
condition        12 38  1.58  0.50    2.0    1.59  0.00  1.0   2.0   1.0 -0.31
               kurtosis   se
id                -1.28 4.72
identity          -1.33 4.36
consent           -0.60 0.07
age                0.56 1.97
race              -1.38 0.26
gender            -2.05 0.08
manip_out         -1.09 4.48
stress              NaN 0.00
isolation         -1.09 0.06
social_support     0.66 0.06
ai_manip          -1.34 5.00
condition         -1.95 0.08
------------------------------------------------------------ 
group: 3.2
               vars n mean    sd median trimmed   mad  min  max range skew
id                1 2 87.0  4.24   87.0    87.0  4.45 84.0 90.0     6    0
identity          2 2 66.5  9.19   66.5    66.5  9.64 60.0 73.0    13    0
consent           3 2  3.0  0.00    3.0     3.0  0.00  3.0  3.0     0  NaN
age               4 2 41.0  5.66   41.0    41.0  5.93 37.0 45.0     8    0
race              5 2  5.0  1.41    5.0     5.0  1.48  4.0  6.0     2    0
gender            6 2  1.5  0.71    1.5     1.5  0.74  1.0  2.0     1    0
manip_out         7 2 76.5 24.75   76.5    76.5 25.95 59.0 94.0    35    0
stress            8 2  3.2  0.00    3.2     3.2  0.00  3.2  3.2     0  NaN
isolation         9 2  2.1  0.00    2.1     2.1  0.00  2.1  2.1     0  NaN
social_support   10 2  4.5  0.71    4.5     4.5  0.74  4.0  5.0     1    0
ai_manip         11 2 44.5 53.03   44.5    44.5 55.60  7.0 82.0    75    0
condition        12 2  1.0  0.00    1.0     1.0  0.00  1.0  1.0     0  NaN
               kurtosis   se
id                -2.75  3.0
identity          -2.75  6.5
consent             NaN  0.0
age               -2.75  4.0
race              -2.75  1.0
gender            -2.75  0.5
manip_out         -2.75 17.5
stress              NaN  0.0
isolation           NaN  0.0
social_support    -2.75  0.5
ai_manip          -2.75 37.5
condition           NaN  0.0
------------------------------------------------------------ 
group: 3.4
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 19.0 NA   19.0    19.0   0 19.0 19.0     0   NA       NA
identity          2 1 54.0 NA   54.0    54.0   0 54.0 54.0     0   NA       NA
consent           3 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
age               4 1 36.0 NA   36.0    36.0   0 36.0 36.0     0   NA       NA
race              5 1  3.0 NA    3.0     3.0   0  3.0  3.0     0   NA       NA
gender            6 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
manip_out         7 1 37.0 NA   37.0    37.0   0 37.0 37.0     0   NA       NA
stress            8 1  3.4 NA    3.4     3.4   0  3.4  3.4     0   NA       NA
isolation         9 1  2.1 NA    2.1     2.1   0  2.1  2.1     0   NA       NA
social_support   10 1  4.0 NA    4.0     4.0   0  4.0  4.0     0   NA       NA
ai_manip         11 1 29.0 NA   29.0    29.0   0 29.0 29.0     0   NA       NA
condition        12 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
describeBy(d, group = d$social_support)

 Descriptive statistics by group 
group: 3
               vars n  mean    sd median trimmed   mad  min  max range skew
id                1 2 65.00 36.77  65.00   65.00 38.55 39.0 91.0  52.0    0
identity          2 2 74.50 31.82  74.50   74.50 33.36 52.0 97.0  45.0    0
consent           3 2  2.00  0.00   2.00    2.00  0.00  2.0  2.0   0.0  NaN
age               4 2 57.50 31.82  57.50   57.50 33.36 35.0 80.0  45.0    0
race              5 2  5.00  1.41   5.00    5.00  1.48  4.0  6.0   2.0    0
gender            6 2  1.50  0.71   1.50    1.50  0.74  1.0  2.0   1.0    0
manip_out         7 2 80.00  4.24  80.00   80.00  4.45 77.0 83.0   6.0    0
stress            8 2  2.15  0.21   2.15    2.15  0.22  2.0  2.3   0.3    0
isolation         9 2  2.20  0.14   2.20    2.20  0.15  2.1  2.3   0.2    0
social_support   10 2  3.00  0.00   3.00    3.00  0.00  3.0  3.0   0.0  NaN
ai_manip         11 2 60.00 25.46  60.00   60.00 26.69 42.0 78.0  36.0    0
condition        12 2  1.50  0.71   1.50    1.50  0.74  1.0  2.0   1.0    0
               kurtosis    se
id                -2.75 26.00
identity          -2.75 22.50
consent             NaN  0.00
age               -2.75 22.50
race              -2.75  1.00
gender            -2.75  0.50
manip_out         -2.75  3.00
stress            -2.75  0.15
isolation         -2.75  0.10
social_support      NaN  0.00
ai_manip          -2.75 18.00
condition         -2.75  0.50
------------------------------------------------------------ 
group: 3.3
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 92.0 NA   92.0    92.0   0 92.0 92.0     0   NA       NA
identity          2 1 10.0 NA   10.0    10.0   0 10.0 10.0     0   NA       NA
consent           3 1  3.0 NA    3.0     3.0   0  3.0  3.0     0   NA       NA
age               4 1 28.0 NA   28.0    28.0   0 28.0 28.0     0   NA       NA
race              5 1  6.0 NA    6.0     6.0   0  6.0  6.0     0   NA       NA
gender            6 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
manip_out         7 1 69.0 NA   69.0    69.0   0 69.0 69.0     0   NA       NA
stress            8 1  3.0 NA    3.0     3.0   0  3.0  3.0     0   NA       NA
isolation         9 1  2.1 NA    2.1     2.1   0  2.1  2.1     0   NA       NA
social_support   10 1  3.3 NA    3.3     3.3   0  3.3  3.3     0   NA       NA
ai_manip         11 1 99.0 NA   99.0    99.0   0 99.0 99.0     0   NA       NA
condition        12 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
------------------------------------------------------------ 
group: 3.5
               vars n  mean    sd median trimmed   mad  min  max range  skew
id                1 7 42.86 27.33   37.0   42.86 16.31 10.0 95.0  85.0  0.73
identity          2 7 56.00 26.92   51.0   56.00 23.72 17.0 96.0  79.0  0.08
consent           3 7  2.00  0.00    2.0    2.00  0.00  2.0  2.0   0.0   NaN
age               4 7 46.43 22.02   35.0   46.43  4.45 32.0 93.0  61.0  1.25
race              5 7  4.57  1.81    6.0    4.57  0.00  2.0  6.0   4.0 -0.31
gender            6 7  1.43  0.53    1.0    1.43  0.00  1.0  2.0   1.0  0.23
manip_out         7 7 35.86 25.52   28.0   35.86 23.72  8.0 84.0  76.0  0.71
stress            8 7  2.51  0.47    2.4    2.51  0.59  2.0  3.0   1.0  0.05
isolation         9 7  2.89  0.44    3.2    2.89  0.00  2.1  3.2   1.1 -0.70
social_support   10 7  3.50  0.00    3.5    3.50  0.00  3.5  3.5   0.0   NaN
ai_manip         11 7 53.14 29.39   61.0   53.14 25.20 13.0 96.0  83.0 -0.05
condition        12 7  1.71  0.49    2.0    1.71  0.00  1.0  2.0   1.0 -0.75
               kurtosis    se
id                -0.77 10.33
identity          -1.54 10.17
consent             NaN  0.00
age               -0.07  8.32
race              -2.04  0.69
gender            -2.20  0.20
manip_out         -0.93  9.65
stress            -2.10  0.18
isolation         -1.33  0.17
social_support      NaN  0.00
ai_manip          -1.61 11.11
condition         -1.60  0.18
------------------------------------------------------------ 
group: 3.8
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 72.0 NA   72.0    72.0   0 72.0 72.0     0   NA       NA
identity          2 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
consent           3 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
age               4 1 32.0 NA   32.0    32.0   0 32.0 32.0     0   NA       NA
race              5 1  4.0 NA    4.0     4.0   0  4.0  4.0     0   NA       NA
gender            6 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
manip_out         7 1 74.0 NA   74.0    74.0   0 74.0 74.0     0   NA       NA
stress            8 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
isolation         9 1  2.5 NA    2.5     2.5   0  2.5  2.5     0   NA       NA
social_support   10 1  3.8 NA    3.8     3.8   0  3.8  3.8     0   NA       NA
ai_manip         11 1 25.0 NA   25.0    25.0   0 25.0 25.0     0   NA       NA
condition        12 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
------------------------------------------------------------ 
group: 4
               vars  n  mean    sd median trimmed   mad min   max range  skew
id                1 59 52.05 28.54   53.0   52.41 38.55   1 100.0  99.0 -0.14
identity          2 59 48.64 28.26   48.0   48.69 37.06   2  95.0  93.0  0.01
consent           3 59  2.29  0.46    2.0    2.24  0.00   2   3.0   1.0  0.91
age               4 59 40.47 12.01   35.0   39.08  4.45  21  76.0  55.0  1.19
race              5 59  4.64  1.54    6.0    4.78  0.00   1   6.0   5.0 -0.46
gender            6 59  1.47  0.50    1.0    1.47  0.00   1   2.0   1.0  0.10
manip_out         7 59 52.88 30.81   53.0   53.45 38.55   1 100.0  99.0 -0.11
stress            8 59  2.59  0.45    2.8    2.60  0.30   2   3.4   1.4 -0.29
isolation         9 59  2.55  0.39    2.5    2.53  0.44   2   3.5   1.5  0.53
social_support   10 59  4.00  0.00    4.0    4.00  0.00   4   4.0   0.0   NaN
ai_manip         11 59 51.27 30.50   54.0   51.51 38.55   1 100.0  99.0 -0.04
condition        12 59  1.47  0.50    1.0    1.47  0.00   1   2.0   1.0  0.10
               kurtosis   se
id                -1.22 3.72
identity          -1.32 3.68
consent           -1.19 0.06
age                0.52 1.56
race              -1.35 0.20
gender            -2.02 0.07
manip_out         -1.30 4.01
stress            -1.58 0.06
isolation         -0.79 0.05
social_support      NaN 0.00
ai_manip          -1.37 3.97
condition         -2.02 0.07
------------------------------------------------------------ 
group: 4.1
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 98.0 NA   98.0    98.0   0 98.0 98.0     0   NA       NA
identity          2 1 83.0 NA   83.0    83.0   0 83.0 83.0     0   NA       NA
consent           3 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
age               4 1 58.0 NA   58.0    58.0   0 58.0 58.0     0   NA       NA
race              5 1  3.0 NA    3.0     3.0   0  3.0  3.0     0   NA       NA
gender            6 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
manip_out         7 1 60.0 NA   60.0    60.0   0 60.0 60.0     0   NA       NA
stress            8 1  3.0 NA    3.0     3.0   0  3.0  3.0     0   NA       NA
isolation         9 1  2.2 NA    2.2     2.2   0  2.2  2.2     0   NA       NA
social_support   10 1  4.1 NA    4.1     4.1   0  4.1  4.1     0   NA       NA
ai_manip         11 1 55.0 NA   55.0    55.0   0 55.0 55.0     0   NA       NA
condition        12 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
------------------------------------------------------------ 
group: 4.4
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 60.0 NA   60.0    60.0   0 60.0 60.0     0   NA       NA
identity          2 1 23.0 NA   23.0    23.0   0 23.0 23.0     0   NA       NA
consent           3 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
age               4 1 32.0 NA   32.0    32.0   0 32.0 32.0     0   NA       NA
race              5 1  6.0 NA    6.0     6.0   0  6.0  6.0     0   NA       NA
gender            6 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
manip_out         7 1 68.0 NA   68.0    68.0   0 68.0 68.0     0   NA       NA
stress            8 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
isolation         9 1  2.5 NA    2.5     2.5   0  2.5  2.5     0   NA       NA
social_support   10 1  4.4 NA    4.4     4.4   0  4.4  4.4     0   NA       NA
ai_manip         11 1 26.0 NA   26.0    26.0   0 26.0 26.0     0   NA       NA
condition        12 1  1.0 NA    1.0     1.0   0  1.0  1.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
------------------------------------------------------------ 
group: 4.5
               vars n  mean    sd median trimmed   mad  min  max range  skew
id                1 9 41.11 25.32   36.0   41.11 23.72  7.0 78.0  71.0  0.22
identity          2 9 46.22 31.14   45.0   46.22 31.13  5.0 99.0  94.0  0.23
consent           3 9  2.22  0.44    2.0    2.22  0.00  2.0  3.0   1.0  1.12
age               4 9 41.78 16.55   35.0   41.78  4.45 30.0 82.0  52.0  1.53
race              5 9  4.67  2.00    6.0    4.67  1.48  1.0  7.0   6.0 -0.51
gender            6 9  1.56  0.53    2.0    1.56  0.00  1.0  2.0   1.0 -0.19
manip_out         7 9 44.67 26.67   34.0   44.67 16.31 19.0 88.0  69.0  0.65
stress            8 9  2.82  0.27    3.0    2.82  0.00  2.4  3.0   0.6 -0.70
isolation         9 9  2.62  0.54    2.5    2.62  0.59  2.1  3.5   1.4  0.43
social_support   10 9  4.50  0.00    4.5    4.50  0.00  4.5  4.5   0.0   NaN
ai_manip         11 9 49.44 33.19   53.0   49.44 44.48  2.0 95.0  93.0 -0.09
condition        12 9  1.67  0.50    2.0    1.67  0.00  1.0  2.0   1.0 -0.59
               kurtosis    se
id                -1.52  8.44
identity          -1.40 10.38
consent           -0.80  0.15
age                0.96  5.52
race              -1.34  0.67
gender            -2.17  0.18
manip_out         -1.38  8.89
stress            -1.56  0.09
isolation         -1.68  0.18
social_support      NaN  0.00
ai_manip          -1.72 11.06
condition         -1.81  0.17
------------------------------------------------------------ 
group: 4.9
               vars n mean sd median trimmed mad  min  max range skew kurtosis
id                1 1 30.0 NA   30.0    30.0   0 30.0 30.0     0   NA       NA
identity          2 1 56.0 NA   56.0    56.0   0 56.0 56.0     0   NA       NA
consent           3 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
age               4 1 36.0 NA   36.0    36.0   0 36.0 36.0     0   NA       NA
race              5 1  3.0 NA    3.0     3.0   0  3.0  3.0     0   NA       NA
gender            6 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
manip_out         7 1  6.0 NA    6.0     6.0   0  6.0  6.0     0   NA       NA
stress            8 1  2.8 NA    2.8     2.8   0  2.8  2.8     0   NA       NA
isolation         9 1  2.2 NA    2.2     2.2   0  2.2  2.2     0   NA       NA
social_support   10 1  4.9 NA    4.9     4.9   0  4.9  4.9     0   NA       NA
ai_manip         11 1 46.0 NA   46.0    46.0   0 46.0 46.0     0   NA       NA
condition        12 1  2.0 NA    2.0     2.0   0  2.0  2.0     0   NA       NA
               se
id             NA
identity       NA
consent        NA
age            NA
race           NA
gender         NA
manip_out      NA
stress         NA
isolation      NA
social_support NA
ai_manip       NA
condition      NA
------------------------------------------------------------ 
group: 5
               vars  n  mean    sd median trimmed   mad  min  max range  skew
id                1 15 38.20 29.09   29.0   37.00 37.06  2.0 90.0  88.0  0.32
identity          2 15 59.47 28.40   60.0   60.62 35.58  6.0 98.0  92.0 -0.35
consent           3 15  2.07  0.46    2.0    2.08  0.00  1.0  3.0   2.0  0.28
age               4 15 45.27 16.56   37.0   44.46  8.90 21.0 80.0  59.0  0.64
race              5 15  4.00  1.13    4.0    3.92  1.48  3.0  6.0   3.0  0.55
gender            6 15  1.87  0.35    2.0    1.92  0.00  1.0  2.0   1.0 -1.95
manip_out         7 15 49.60 24.29   51.0   48.85 29.65 10.0 99.0  89.0  0.10
stress            8 15  2.39  0.48    2.0    2.35  0.00  2.0  3.2   1.2  0.52
isolation         9 15  2.50  0.36    2.5    2.48  0.44  2.1  3.2   1.1  0.60
social_support   10 15  5.00  0.00    5.0    5.00  0.00  5.0  5.0   0.0   NaN
ai_manip         11 15 51.47 22.78   50.0   51.31 29.65 15.0 90.0  75.0 -0.04
condition        12 15  1.60  0.51    2.0    1.62  0.00  1.0  2.0   1.0 -0.37
               kurtosis   se
id                -1.49 7.51
identity          -1.21 7.33
consent            1.27 0.12
age               -0.84 4.28
race              -1.31 0.29
gender             1.93 0.09
manip_out         -0.82 6.27
stress            -1.61 0.12
isolation         -1.00 0.09
social_support      NaN 0.00
ai_manip          -1.20 5.88
condition         -1.98 0.13
------------------------------------------------------------ 
group: 5.2
               vars n mean    sd median trimmed   mad  min  max range skew
id                1 2 96.0  4.24   96.0    96.0  4.45 93.0 99.0   6.0    0
identity          2 2 29.0 18.38   29.0    29.0 19.27 16.0 42.0  26.0    0
consent           3 2  2.0  0.00    2.0     2.0  0.00  2.0  2.0   0.0  NaN
age               4 2 33.0  1.41   33.0    33.0  1.48 32.0 34.0   2.0    0
race              5 2  4.5  2.12    4.5     4.5  2.22  3.0  6.0   3.0    0
gender            6 2  1.5  0.71    1.5     1.5  0.74  1.0  2.0   1.0    0
manip_out         7 2 39.5 43.13   39.5    39.5 45.22  9.0 70.0  61.0    0
stress            8 2  2.0  0.00    2.0     2.0  0.00  2.0  2.0   0.0  NaN
isolation         9 2  2.8  0.42    2.8     2.8  0.44  2.5  3.1   0.6    0
social_support   10 2  5.2  0.00    5.2     5.2  0.00  5.2  5.2   0.0  NaN
ai_manip         11 2 28.0 28.28   28.0    28.0 29.65  8.0 48.0  40.0    0
condition        12 2  1.0  0.00    1.0     1.0  0.00  1.0  1.0   0.0  NaN
               kurtosis   se
id                -2.75  3.0
identity          -2.75 13.0
consent             NaN  0.0
age               -2.75  1.0
race              -2.75  1.5
gender            -2.75  0.5
manip_out         -2.75 30.5
stress              NaN  0.0
isolation         -2.75  0.3
social_support      NaN  0.0
ai_manip          -2.75 20.0
condition           NaN  0.0
------------------------------------------------------------ 
group: 6
               vars n  mean sd median trimmed mad   min   max range skew
id                1 1  62.0 NA   62.0    62.0   0  62.0  62.0     0   NA
identity          2 1 100.0 NA  100.0   100.0   0 100.0 100.0     0   NA
consent           3 1   2.0 NA    2.0     2.0   0   2.0   2.0     0   NA
age               4 1  85.0 NA   85.0    85.0   0  85.0  85.0     0   NA
race              5 1   4.0 NA    4.0     4.0   0   4.0   4.0     0   NA
gender            6 1   2.0 NA    2.0     2.0   0   2.0   2.0     0   NA
manip_out         7 1  17.0 NA   17.0    17.0   0  17.0  17.0     0   NA
stress            8 1   2.6 NA    2.6     2.6   0   2.6   2.6     0   NA
isolation         9 1   2.4 NA    2.4     2.4   0   2.4   2.4     0   NA
social_support   10 1   6.0 NA    6.0     6.0   0   6.0   6.0     0   NA
ai_manip         11 1   9.0 NA    9.0     9.0   0   9.0   9.0     0   NA
condition        12 1   1.0 NA    1.0     1.0   0   1.0   1.0     0   NA
               kurtosis se
id                   NA NA
identity             NA NA
consent              NA NA
age                  NA NA
race                 NA NA
gender               NA NA
manip_out            NA NA
stress               NA NA
isolation            NA NA
social_support       NA NA
ai_manip             NA NA
condition            NA NA
# also use histograms and scatterplots to examine your continuous variables
hist(d$isolation)

hist(d$stress)

hist(d$social_support)

plot(d$isolation, d$social_support)

Check Your Assumptions

Pearson’s Correlation Coefficient Assumptions

  • Should have two measurements for each participant for each variable (confirmed by earlier procedures – we dropped any participants with missing data)
  • Variables should be continuous and normally distributed, or assessments of the relationship may be inaccurate (will do below)
  • Outliers should be identified and removed, or results will be inaccurate (will do below)
  • Relationship between the variables should be linear, or they will not be detected (will do below)

Run a Multiple Linear Regression

To check the assumptions for Pearson’s correlation coefficient, we run our regression and then check our diagnostic plots.

# use the lm() command to run the regression
# dependent/outcome variable on the left, independent/predictor variables on the right
reg_model <- lm(d$isolation ~ d$stress + d$social_support, data = d)

Check linearity with Residuals vs Fitted plot

For some examples of good Residuals vs Fitted plot and ones that show serious errors, check out this page.

For your homework, you’ll simply need to generate this plot and talk about how your plot compares to the good and problematic plots linked to above. Is it closer to the ‘good’ plots or one of the ‘bad’ plots? This is going to be a judgement call, and that’s okay! In practice, you’ll always be making these judgement calls as part of a team, so this assignment is just about getting experience with it, not making the perfect call.

plot(reg_model, 1)

Check for outliers using Cook’s distance and a Residuals vs Leverage plot

For your homework, you’ll simply need to generate these plots, assess Cook’s distance in your dataset, and then identify any potential cases that are prominent outliers.

# Cook's distance
plot(reg_model, 4)

# Residuals vs Leverage
plot(reg_model, 5)

Issues with My Data

Cook’s distance and Residuals show considerable variation in the data. This could be caused by a fairly low sample size, or issues with the AI data training. Respondent 52 shows a high enough Cook’s distance to be considered an outlier and would be dropped under normal circumstances.

Run Your Analysis

Run a Correlation Test

Create a Correlation Matrix

# d2 <- subset(d, select=-c(DROP ANY VARIABLES YOU DO NOT WANT IN THE CORRELATION))
corr_output_m <- corr.test(d$stress, d$isolation)

View Test Output

  • Strong effect: Between |0.50| and |1|
  • Moderate effect: Between |0.30| and |0.49|
  • Weak effect: Between |0.10| and |0.29|
  • Trivial effect: Less than |0.09|
corr_output_m
Call:corr.test(x = d$stress, y = d$isolation)
Correlation matrix 
[1] 0.02
Sample Size 
[1] 100
These are the unadjusted probability values.
  The probability values  adjusted for multiple tests are in the p.adj object. 
[1] 0.81

 To see confidence intervals of the correlations, print with the short=FALSE option

Run a Correlation Test

Create a Correlation Matrix

# d2 <- subset(d, select=-c(DROP ANY VARIABLES YOU DO NOT WANT IN THE CORRELATION))
corr_output_m <- corr.test(d$social_support, d$isolation)

View Test Output

  • Strong effect: Between |0.50| and |1|
  • Moderate effect: Between |0.30| and |0.49|
  • Weak effect: Between |0.10| and |0.29|
  • Trivial effect: Less than |0.09|
corr_output_m
Call:corr.test(x = d$social_support, y = d$isolation)
Correlation matrix 
[1] -0.04
Sample Size 
[1] 100
These are the unadjusted probability values.
  The probability values  adjusted for multiple tests are in the p.adj object. 
[1] 0.69

 To see confidence intervals of the correlations, print with the short=FALSE option

Write Up Results

Correlation Test

My hypothesis was that higher levels of reported perceived stress would correlate with higher levels of isolation, and that higher levels of social support would correlate with lower levels of isolation. The data showed significant variance and one outlier was present, but not removed. The correlation tests found a trivial positive relationship between stress and isolation (r = 0.02) and a trivial negative relationship between social support and isolation (r = -0.04). As such, there is not enough evidence to support either H1 or H2.

References

Cohen J. (1988). Statistical Power Analysis for the Behavioral Sciences. New York, NY: Routledge Academic.