Homework 1: Anxiety Statement

Load data file

## ─ Attaching packages ────────────────────────── tidyverse 1.3.0 ─
## ✓ ggplot2 3.2.1     ✓ purrr   0.3.3
## ✓ tibble  2.1.3     ✓ dplyr   0.8.4
## ✓ tidyr   1.0.2     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ─ Conflicts ─────────────────────────── tidyverse_conflicts() ─
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
##   f1 f2 f3 f4 f5 m1 m2 m3 m4 m5
## 1 13 17 18 20 24  6 14 22 20 24
## 2 26 31 33 38 42  4 11 14 12 23
## 3 13 17 24 29 32 17 25 26 29 38
## 4 22 24 26 27 29 19 22 26 30 34
## 5 18 19 19 22 30 12 21 21 23 24
## 6 32 31 30 31 32 11 16 20 19 22

Translate the data formate from wide to long

##   ID Gender Week Score
## 1 f1      f    1    13
## 2 f2      f    1    26
## 3 f3      f    1    13
## 4 f4      f    1    22
## 5 f5      f    1    18
## 6 f6      f    1    32

The figure revealed that the anxiety and week may be caused by individual differences.

Homework 2:

T.L., Milic, N.M., Winham, S.J., Garovic, V.D. (2015). Beyond Bar and Line Graphs: Time for a New Data Presentation Paradigm. PLOS Biology , 13

Homework 3: Emotions and Coping Strategies

Load data file

##   annoy sad afraid angry approach avoid support agressive situation sbj
## 1     4   2      2     2     1.00  2.00    1.00      2.50      Fail  S2
## 2     4   4      4     2     4.00  3.00    1.25      1.50    NoPart  S2
## 3     2   2      2     2     2.67  3.00    1.00      2.33    TeacNo  S2
## 4     4   3      4     4     4.00  1.50    3.25      1.00     Bully  S2
## 5     4   2      1     1     1.00  2.75    1.25      1.50      Work  S2
## 6     4   3      1     4     2.33  2.50    1.00      3.67     MomNo  S2

Show the summary table

##      annoy            sad           afraid          angry          approach    
##  Min.   :1.000   Min.   :1.00   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:2.000   1st Qu.:1.00   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:1.670  
##  Median :3.000   Median :2.00   Median :1.000   Median :2.000   Median :2.000  
##  Mean   :2.762   Mean   :1.81   Mean   :1.405   Mean   :2.131   Mean   :2.236  
##  3rd Qu.:4.000   3rd Qu.:2.00   3rd Qu.:2.000   3rd Qu.:2.250   3rd Qu.:3.000  
##  Max.   :4.000   Max.   :4.00   Max.   :4.000   Max.   :9.000   Max.   :4.000  
##                                                                                
##      avoid          support        agressive      situation       sbj    
##  Min.   :1.000   Min.   :0.000   Min.   :1.000   Bully :14   S135   : 6  
##  1st Qu.:1.750   1st Qu.:1.330   1st Qu.:1.000   Fail  :14   S137   : 6  
##  Median :2.500   Median :2.000   Median :1.500   MomNo :14   S139   : 6  
##  Mean   :2.398   Mean   :1.959   Mean   :1.542   NoPart:14   S17    : 6  
##  3rd Qu.:3.000   3rd Qu.:2.373   3rd Qu.:1.670   TeacNo:14   S185   : 6  
##  Max.   :4.000   Max.   :4.000   Max.   :4.000   Work  :14   S2     : 6  
##                                                              (Other):48

Translate the data format from wide to long

##   Situation Subject Emotions Values
## 1      Fail      S2    annoy      4
## 2    NoPart      S2    annoy      4
## 3    TeacNo      S2    annoy      2
## 4     Bully      S2    annoy      4
## 5      Work      S2    annoy      4
## 6     MomNo      S2    annoy      4

Quick plot the density plot across Situation and Emotions to look the pattern

Homework 4:

assume that the subject data files are downloaded into the data folder in the current working directory

## Parsed with column specification:
## cols(
##   subject = col_character(),
##   contrast = col_double(),
##   sf = col_double(),
##   target_side = col_character(),
##   response = col_character(),
##   unique_id = col_character()
## )
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   contrast = col_double(),
##   sf = col_double(),
##   target_side = col_character(),
##   response = col_character(),
##   unique_id = col_character()
## )
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   contrast = col_double(),
##   sf = col_double(),
##   target_side = col_character(),
##   response = col_character(),
##   unique_id = col_character()
## )
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   contrast = col_double(),
##   sf = col_double(),
##   target_side = col_character(),
##   response = col_character(),
##   unique_id = col_character()
## )
## Parsed with column specification:
## cols(
##   subject = col_character(),
##   contrast = col_double(),
##   sf = col_double(),
##   target_side = col_character(),
##   response = col_character(),
##   unique_id = col_character()
## )

have a look

##   subject    contrast        sf target_side response
## 1      S1 0.069483451  0.500000       right    right
## 2      S1 0.013123729 40.000000       right     left
## 3      S1 0.069483451  4.472136        left     left
## 4      S1 0.069483451 40.000000        left    right
## 5      S1 0.367879441 13.374806        left     left
## 6      S1 0.002478752  0.500000        left    right
##                              unique_id
## 1 544ee9ff-2569-4f38-b04e-7e4d0a0be4d2
## 2 b27fe910-e3ba-48fb-b168-5afb1f115d8f
## 3 72c9d6ce-0a90-4d4b-a199-03435c15291b
## 4 48b5bbb2-e6ee-4848-b77e-839ed5320c01
## 5 32a5cce4-3f8a-4e63-80c1-3fee3230d1bd
## 6 47ebce53-9d5a-48de-936b-25d5105a0784

score the correct responses

##   subject    contrast        sf target_side response
## 1      S1 0.069483451  0.500000       right    right
## 2      S1 0.013123729 40.000000       right     left
## 3      S1 0.069483451  4.472136        left     left
## 4      S1 0.069483451 40.000000        left    right
## 5      S1 0.367879441 13.374806        left     left
## 6      S1 0.002478752  0.500000        left    right
##                              unique_id correct
## 1 544ee9ff-2569-4f38-b04e-7e4d0a0be4d2       1
## 2 b27fe910-e3ba-48fb-b168-5afb1f115d8f       0
## 3 72c9d6ce-0a90-4d4b-a199-03435c15291b       1
## 4 48b5bbb2-e6ee-4848-b77e-839ed5320c01       0
## 5 32a5cce4-3f8a-4e63-80c1-3fee3230d1bd       1
## 6 47ebce53-9d5a-48de-936b-25d5105a0784       0

fit a detection model in which the chance of correct response is .5

Homework 5:

Load data file

##    Tetrahydrocortisone Pregnanetriol Type
## a1                 3.1         11.70    a
## a2                 3.0          1.30    a
## a3                 1.9          0.10    a
## a4                 3.8          0.04    a
## a5                 4.1          1.10    a
## a6                 1.9          0.40    a

Show the data structure

## 'data.frame':    27 obs. of  3 variables:
##  $ Tetrahydrocortisone: num  3.1 3 1.9 3.8 4.1 1.9 8.3 3.8 3.9 7.8 ...
##  $ Pregnanetriol      : num  11.7 1.3 0.1 0.04 1.1 0.4 1 0.2 0.6 1.2 ...
##  $ Type               : Factor w/ 4 levels "a","b","c","u": 1 1 1 1 1 1 2 2 2 2 ...