Replace “Your Name” with your actual name.

Instructions

Please complete this exam on your own. Include your R code, interpretations, and answers within this document.

Part 1: Types of Data and Measurement Errors

Question 1: Data Types in Psychological Research

Read Chapter 2 (Types of Data Psychologists Collect) and answer the following:

  1. Describe the key differences between nominal, ordinal, interval, and ratio data. Provide one example of each from psychological research.

Nominal data is categorical data with no inherent order like gender. This allows for counting and frequency analysis. Ordinal data is categorical data with a meaningful order but unequal intervals like education levels. This allows for comparisons but not arithmetic operations. Interval data is numerical data with equal intervals but no true zero point such as IQ scores. Ratio data is numerical data with equal intervals and a true zero point such as weight. While interval and ratio data both permit arithmetic operations, ratio data is the only one that allows for meaningful ratios.

  1. For each of the following variables, identify the appropriate level of measurement (nominal, ordinal, interval, or ratio) and explain your reasoning:
    • Scores on a depression inventory (0-63)
    • Response time in milliseconds
    • Likert scale ratings of agreement (1-7)
    • Diagnostic categories (e.g., ADHD, anxiety disorder, no diagnosis)
    • Age in years

Scores on a depression inventory are an example of interval data. This is due to the scores being numerical data but not having a true point of zero. Response time is an example of ratio data due to it being numerical with a true zero point. The likert scale is an example of ordinal data because the scores can be compared as greater or less than each other but doesn’t have a definitive difference. Diagnostic categories such as ADHD and anxiety are examples of nominal data due to being able to be categorized but not having an inherent order or scale of measurement. Age in years is an example of ratio data due to having a true zero point.

Question 2: Measurement Error

Referring to Chapter 3 (Measurement Errors in Psychological Research):

  1. Explain the difference between random and systematic error, providing an example of each in the context of a memory experiment.

Random error comes from unpredictable variables that reduces reliability but doesn’t create bias in the results, such as someone getting distracted for a moment when takinnng a memory test. Systematic errors are predictable and consistent variables that can create bias towards a certain direction in an experiments results. For example, an experimenter giving certain participants a more difficult list of things to memorize than other participants.

  1. How might measurement error affect the validity of a study examining the relationship between stress and academic performance? What steps could researchers take to minimize these errors?

Measurement error could create more deviation in the study’s results, making the study less reliable and therefore less valid as a result. Researchers can minimize these errors by making sure that they are conducting the test as unbiased as possible and that their equipment is working properly.


Part 2: Descriptive Statistics and Basic Probability

Question 3: Descriptive Analysis

The code below creates a simulated dataset for a psychological experiment. Run the below code chunk without making any changes:

# Create a simulated dataset
set.seed(123)  # For reproducibility

# Number of participants
n <- 50

# Create the data frame
data <- data.frame(
  participant_id = 1:n,
  reaction_time = rnorm(n, mean = 300, sd = 50),
  accuracy = rnorm(n, mean = 85, sd = 10),
  gender = sample(c("Male", "Female"), n, replace = TRUE),
  condition = sample(c("Control", "Experimental"), n, replace = TRUE),
  anxiety_pre = rnorm(n, mean = 25, sd = 8),
  anxiety_post = NA  # We'll fill this in based on condition
)

# Make the experimental condition reduce anxiety more than control
data$anxiety_post <- ifelse(
  data$condition == "Experimental",
  data$anxiety_pre - rnorm(n, mean = 8, sd = 3),  # Larger reduction
  data$anxiety_pre - rnorm(n, mean = 3, sd = 2)   # Smaller reduction
)

# Ensure anxiety doesn't go below 0
data$anxiety_post <- pmax(data$anxiety_post, 0)

# Add some missing values for realism
data$reaction_time[sample(1:n, 3)] <- NA
data$accuracy[sample(1:n, 2)] <- NA

# View the first few rows of the dataset
head(data)
##   participant_id reaction_time  accuracy gender    condition anxiety_pre
## 1              1      271.9762  87.53319 Female      Control    31.30191
## 2              2      288.4911  84.71453 Female Experimental    31.15234
## 3              3      377.9354  84.57130 Female Experimental    27.65762
## 4              4      303.5254  98.68602   Male      Control    16.93299
## 5              5      306.4644  82.74229 Female      Control    24.04438
## 6              6      385.7532 100.16471 Female      Control    22.75684
##   anxiety_post
## 1     29.05312
## 2     19.21510
## 3     20.45306
## 4     13.75199
## 5     17.84736
## 6     19.93397

Now, perform the following computations*:

  1. Calculate the mean, median, standard deviation, minimum, and maximum for reaction time and accuracy, grouped by condition (hint: use the psych package).
#your code here
conditiondata <- data %>%
  group_by(condition) %>%
  summarize(
    mean_rt = mean(reaction_time, na.rm = TRUE),
    mean_acc = mean(accuracy, na.rm = TRUE),
    median_rt = median(reaction_time, na.rm = TRUE),
    median_acc = median(accuracy, na.rm = TRUE),
    sd_rt = sd(reaction_time, na.rm = TRUE),
    sd_acc = sd(accuracy, na.rm = TRUE),
    min_rt = min(reaction_time, na.rm = TRUE),
    min_acc = min(accuracy, na.rm = TRUE),
    max_rt = max(reaction_time, na.rm = TRUE),
    max_acc = max(accuracy, na.rm = TRUE) )
print(conditiondata)
## # A tibble: 2 × 11
##   condition    mean_rt mean_acc median_rt median_acc sd_rt sd_acc min_rt min_acc
##   <chr>          <dbl>    <dbl>     <dbl>      <dbl> <dbl>  <dbl>  <dbl>   <dbl>
## 1 Control         301.     85.5      300.       85.5  48.5   9.86   202.    61.9
## 2 Experimental    296.     88.1      288.       88.3  38.4   8.20   216.    74.3
## # ℹ 2 more variables: max_rt <dbl>, max_acc <dbl>
  1. Using dplyr and piping, create a new variable anxiety_change that represents the difference between pre and post anxiety scores (pre minus post). Then calculate the mean anxiety change for each condition.
# Your code here
maindata <- data%>%
  mutate(anxiety_change = anxiety_pre - anxiety_post)
controlgroup <- maindata %>%
  filter(condition == "Control")
  mean(controlgroup$anxiety_change)
## [1] 3.794972
print(controlgroup)
##    participant_id reaction_time  accuracy gender condition anxiety_pre
## 1               1      271.9762  87.53319 Female   Control    31.30191
## 2               4      303.5254  98.68602   Male   Control    16.93299
## 3               5      306.4644  82.74229 Female   Control    24.04438
## 4               6      385.7532 100.16471 Female   Control    22.75684
## 5               7      323.0458  69.51247 Female   Control    29.50392
## 6               8      236.7469  90.84614   Male   Control    22.02049
## 7              10      277.7169  87.15942 Female   Control    22.00335
## 8              14      305.5341  74.81425 Female   Control    50.92832
## 9              16            NA  88.03529 Female   Control    27.38582
## 10             18      201.6691  85.53004   Male   Control    21.12975
## 11             19      335.0678  94.22267 Female   Control    29.13490
## 12             20      276.3604 105.50085   Male   Control    27.95172
## 13             21      246.6088  80.08969 Female   Control    23.27696
## 14             22      289.1013  61.90831   Male   Control    25.52234
## 15             23      248.6998  95.05739   Male   Control    24.72746
## 16             25      268.7480  78.11991 Female   Control    19.06931
## 17             27      341.8894  82.15227   Male   Control    25.30231
## 18             28      307.6687  72.79282   Male   Control    27.48385
## 19             29      243.0932  86.81303 Female   Control    28.49219
## 20             30      362.6907        NA   Male   Control    21.33308
## 21             33      344.7563  81.29340 Female   Control    22.20280
## 22             34      343.9067  91.44377   Male   Control    18.07590
## 23             35      341.0791  82.79513 Female   Control    23.10976
## 24             39      284.7019  81.74068 Female   Control    31.03243
## 25             41      265.2647  94.93504   Male   Control    26.71556
## 26             42      289.6041  90.48397 Female   Control    22.40251
## 27             43      236.7302        NA   Male   Control    25.75667
## 28             44      408.4478  78.72094 Female   Control    17.83709
## 29             45      360.3981  98.60652   Male   Control    14.51359
## 30             49      338.9983  82.64300 Female   Control    20.11067
## 31             50      295.8315  74.73579 Female   Control    15.51616
##    anxiety_post anxiety_change
## 1     29.053117     2.24879426
## 2     13.751994     3.18099329
## 3     17.847362     6.19701754
## 4     19.933968     2.82286978
## 5     24.342317     5.16159899
## 6     17.758982     4.26150823
## 7     22.069157    -0.06580401
## 8     45.327922     5.60039736
## 9     21.290659     6.09516212
## 10    21.642810    -0.51305479
## 11    26.912456     2.22244027
## 12    24.773302     3.17841445
## 13    18.586930     4.69002601
## 14    20.597288     4.92505594
## 15    20.358843     4.36861886
## 16    14.370025     4.69928609
## 17    21.952702     3.34960540
## 18    24.334744     3.14910235
## 19    24.635854     3.85633353
## 20    18.283727     3.04934997
## 21    18.430744     3.77205314
## 22    15.607200     2.46869675
## 23    19.873474     3.23628902
## 24    28.470531     2.56189924
## 25    21.378795     5.33676775
## 26    17.294151     5.10836205
## 27    20.466142     5.29052622
## 28    15.992029     1.84506400
## 29     7.508622     7.00496546
## 30    17.068705     3.04196717
## 31    10.016330     5.49982914
experimentalgroup <- maindata %>%
  filter(condition == "Experimental")
  mean(experimentalgroup$anxiety_change) 
## [1] 8.642833
print(experimentalgroup)
##    participant_id reaction_time  accuracy gender    condition anxiety_pre
## 1               2      288.4911  84.71453 Female Experimental    31.15234
## 2               3      377.9354  84.57130 Female Experimental    27.65762
## 3               9            NA  86.23854 Female Experimental    32.81579
## 4              11            NA  88.79639 Female Experimental    33.42169
## 5              12      317.9907  79.97677   Male Experimental    16.60658
## 6              13      320.0386  81.66793   Male Experimental    14.91876
## 7              15      272.2079  74.28209 Female Experimental    21.66514
## 8              17      324.8925  89.48210 Female Experimental    30.09256
## 9              24      263.5554  77.90799   Male Experimental    42.02762
## 10             26      215.6653  95.25571 Female Experimental    16.23203
## 11             31      321.3232  85.05764   Male Experimental    16.49339
## 12             32      285.2464  88.85280 Female Experimental    35.10548
## 13             36      334.4320  88.31782 Female Experimental    23.42259
## 14             37      327.6959  95.96839 Female Experimental    33.87936
## 15             38      296.9044  89.35181 Female Experimental    25.67790
## 16             40      280.9764  96.48808   Male Experimental    21.00566
## 17             46      243.8446  78.99740   Male Experimental    40.97771
## 18             47      279.8558 106.87333   Male Experimental    29.80567
## 19             48      276.6672 100.32611 Female Experimental    14.98983
##    anxiety_post anxiety_change
## 1     19.215099      11.937239
## 2     20.453056       7.204565
## 3     19.863065      12.952722
## 4     25.063956       8.357736
## 5      7.875522       8.731062
## 6      3.221330      11.697428
## 7     16.642661       5.022479
## 8     23.416047       6.676510
## 9     31.904850      10.122765
## 10     8.052780       8.179250
## 11     2.627509      13.865882
## 12    27.376440       7.729041
## 13    19.373641       4.048952
## 14    26.428138       7.451224
## 15    16.420951       9.256947
## 16    15.350273       5.655391
## 17    27.270622      13.707085
## 18    22.108595       7.697075
## 19    11.069351       3.920478

For the control group reaction time had a mean of 301.4, a median of 299.7, standard deviation of 48.5, minimum of 201.7, and maximum of 408.5. Accuracy for the control group had a mean of 85.5, median of 85.5, standard deviation of 9.9, minimum of 61.9, and maximum of 105.5. For the experimental group reaction time had a mean of 295.8, median of 288.5, standard deviation of 38.4, minimum of 215.7, and maximum of 377.9. Accuracy for the experimental group had a mean of 88.1, median of 88.3, standard deviation of 8.2, minimum of 74.3, and maximum of 106.9. The mean anxiety change for the control group was 3.8 and for the experimental group was 8.6.

Question 4: Probability Calculations

Using the concepts from Chapter 4 (Descriptive Statistics and Basic Probability in Psychological Research):

  1. If reaction times in a cognitive task are normally distributed with a mean of 350ms and a standard deviation of 75ms:
    1. What is the probability that a randomly selected participant will have a reaction time greater than 450ms?
    2. What is the probability that a participant will have a reaction time between 300ms and 400ms?
# Your code here
mean <- 350
sd <- 75
1 - pnorm(450, mean, sd)
## [1] 0.09121122
pnorm(400, mean, sd) - pnorm(300, mean, sd)
## [1] 0.4950149

A reaction time greater than 450ms has a probability of 9%. Having a reaction time between 300ms and 400ms has a probability of 50%.


Part 3: Data Cleaning and Manipulation

Question 5: Data Cleaning with dplyr

Using the data set created in Part 2, perform the following data cleaning and manipulation tasks:

  1. Remove all rows with missing values and create a new data set called clean_data.
# Your code here
clean_data <- data %>%
  na.omit()
print(clean_data)
##    participant_id reaction_time  accuracy gender    condition anxiety_pre
## 1               1      271.9762  87.53319 Female      Control    31.30191
## 2               2      288.4911  84.71453 Female Experimental    31.15234
## 3               3      377.9354  84.57130 Female Experimental    27.65762
## 4               4      303.5254  98.68602   Male      Control    16.93299
## 5               5      306.4644  82.74229 Female      Control    24.04438
## 6               6      385.7532 100.16471 Female      Control    22.75684
## 7               7      323.0458  69.51247 Female      Control    29.50392
## 8               8      236.7469  90.84614   Male      Control    22.02049
## 10             10      277.7169  87.15942 Female      Control    22.00335
## 12             12      317.9907  79.97677   Male Experimental    16.60658
## 13             13      320.0386  81.66793   Male Experimental    14.91876
## 14             14      305.5341  74.81425 Female      Control    50.92832
## 15             15      272.2079  74.28209 Female Experimental    21.66514
## 17             17      324.8925  89.48210 Female Experimental    30.09256
## 18             18      201.6691  85.53004   Male      Control    21.12975
## 19             19      335.0678  94.22267 Female      Control    29.13490
## 20             20      276.3604 105.50085   Male      Control    27.95172
## 21             21      246.6088  80.08969 Female      Control    23.27696
## 22             22      289.1013  61.90831   Male      Control    25.52234
## 23             23      248.6998  95.05739   Male      Control    24.72746
## 24             24      263.5554  77.90799   Male Experimental    42.02762
## 25             25      268.7480  78.11991 Female      Control    19.06931
## 26             26      215.6653  95.25571 Female Experimental    16.23203
## 27             27      341.8894  82.15227   Male      Control    25.30231
## 28             28      307.6687  72.79282   Male      Control    27.48385
## 29             29      243.0932  86.81303 Female      Control    28.49219
## 31             31      321.3232  85.05764   Male Experimental    16.49339
## 32             32      285.2464  88.85280 Female Experimental    35.10548
## 33             33      344.7563  81.29340 Female      Control    22.20280
## 34             34      343.9067  91.44377   Male      Control    18.07590
## 35             35      341.0791  82.79513 Female      Control    23.10976
## 36             36      334.4320  88.31782 Female Experimental    23.42259
## 37             37      327.6959  95.96839 Female Experimental    33.87936
## 38             38      296.9044  89.35181 Female Experimental    25.67790
## 39             39      284.7019  81.74068 Female      Control    31.03243
## 40             40      280.9764  96.48808   Male Experimental    21.00566
## 41             41      265.2647  94.93504   Male      Control    26.71556
## 42             42      289.6041  90.48397 Female      Control    22.40251
## 44             44      408.4478  78.72094 Female      Control    17.83709
## 45             45      360.3981  98.60652   Male      Control    14.51359
## 46             46      243.8446  78.99740   Male Experimental    40.97771
## 47             47      279.8558 106.87333   Male Experimental    29.80567
## 48             48      276.6672 100.32611 Female Experimental    14.98983
## 49             49      338.9983  82.64300 Female      Control    20.11067
## 50             50      295.8315  74.73579 Female      Control    15.51616
##    anxiety_post
## 1     29.053117
## 2     19.215099
## 3     20.453056
## 4     13.751994
## 5     17.847362
## 6     19.933968
## 7     24.342317
## 8     17.758982
## 10    22.069157
## 12     7.875522
## 13     3.221330
## 14    45.327922
## 15    16.642661
## 17    23.416047
## 18    21.642810
## 19    26.912456
## 20    24.773302
## 21    18.586930
## 22    20.597288
## 23    20.358843
## 24    31.904850
## 25    14.370025
## 26     8.052780
## 27    21.952702
## 28    24.334744
## 29    24.635854
## 31     2.627509
## 32    27.376440
## 33    18.430744
## 34    15.607200
## 35    19.873474
## 36    19.373641
## 37    26.428138
## 38    16.420951
## 39    28.470531
## 40    15.350273
## 41    21.378795
## 42    17.294151
## 44    15.992029
## 45     7.508622
## 46    27.270622
## 47    22.108595
## 48    11.069351
## 49    17.068705
## 50    10.016330
  1. Create a new variable performance_category that categorizes participants based on their accuracy:
    • “High” if accuracy is greater than or equal to 90
    • “Medium” if accuracy is between 70 and 90
    • “Low” if accuracy is less than 70
# Your code here
clean_data %>%
  mutate(performance_category = ifelse(accuracy >= 90, "High", ifelse(accuracy >= 70, "Medium", "Low")))
##    participant_id reaction_time  accuracy gender    condition anxiety_pre
## 1               1      271.9762  87.53319 Female      Control    31.30191
## 2               2      288.4911  84.71453 Female Experimental    31.15234
## 3               3      377.9354  84.57130 Female Experimental    27.65762
## 4               4      303.5254  98.68602   Male      Control    16.93299
## 5               5      306.4644  82.74229 Female      Control    24.04438
## 6               6      385.7532 100.16471 Female      Control    22.75684
## 7               7      323.0458  69.51247 Female      Control    29.50392
## 8               8      236.7469  90.84614   Male      Control    22.02049
## 10             10      277.7169  87.15942 Female      Control    22.00335
## 12             12      317.9907  79.97677   Male Experimental    16.60658
## 13             13      320.0386  81.66793   Male Experimental    14.91876
## 14             14      305.5341  74.81425 Female      Control    50.92832
## 15             15      272.2079  74.28209 Female Experimental    21.66514
## 17             17      324.8925  89.48210 Female Experimental    30.09256
## 18             18      201.6691  85.53004   Male      Control    21.12975
## 19             19      335.0678  94.22267 Female      Control    29.13490
## 20             20      276.3604 105.50085   Male      Control    27.95172
## 21             21      246.6088  80.08969 Female      Control    23.27696
## 22             22      289.1013  61.90831   Male      Control    25.52234
## 23             23      248.6998  95.05739   Male      Control    24.72746
## 24             24      263.5554  77.90799   Male Experimental    42.02762
## 25             25      268.7480  78.11991 Female      Control    19.06931
## 26             26      215.6653  95.25571 Female Experimental    16.23203
## 27             27      341.8894  82.15227   Male      Control    25.30231
## 28             28      307.6687  72.79282   Male      Control    27.48385
## 29             29      243.0932  86.81303 Female      Control    28.49219
## 31             31      321.3232  85.05764   Male Experimental    16.49339
## 32             32      285.2464  88.85280 Female Experimental    35.10548
## 33             33      344.7563  81.29340 Female      Control    22.20280
## 34             34      343.9067  91.44377   Male      Control    18.07590
## 35             35      341.0791  82.79513 Female      Control    23.10976
## 36             36      334.4320  88.31782 Female Experimental    23.42259
## 37             37      327.6959  95.96839 Female Experimental    33.87936
## 38             38      296.9044  89.35181 Female Experimental    25.67790
## 39             39      284.7019  81.74068 Female      Control    31.03243
## 40             40      280.9764  96.48808   Male Experimental    21.00566
## 41             41      265.2647  94.93504   Male      Control    26.71556
## 42             42      289.6041  90.48397 Female      Control    22.40251
## 44             44      408.4478  78.72094 Female      Control    17.83709
## 45             45      360.3981  98.60652   Male      Control    14.51359
## 46             46      243.8446  78.99740   Male Experimental    40.97771
## 47             47      279.8558 106.87333   Male Experimental    29.80567
## 48             48      276.6672 100.32611 Female Experimental    14.98983
## 49             49      338.9983  82.64300 Female      Control    20.11067
## 50             50      295.8315  74.73579 Female      Control    15.51616
##    anxiety_post performance_category
## 1     29.053117               Medium
## 2     19.215099               Medium
## 3     20.453056               Medium
## 4     13.751994                 High
## 5     17.847362               Medium
## 6     19.933968                 High
## 7     24.342317                  Low
## 8     17.758982                 High
## 10    22.069157               Medium
## 12     7.875522               Medium
## 13     3.221330               Medium
## 14    45.327922               Medium
## 15    16.642661               Medium
## 17    23.416047               Medium
## 18    21.642810               Medium
## 19    26.912456                 High
## 20    24.773302                 High
## 21    18.586930               Medium
## 22    20.597288                  Low
## 23    20.358843                 High
## 24    31.904850               Medium
## 25    14.370025               Medium
## 26     8.052780                 High
## 27    21.952702               Medium
## 28    24.334744               Medium
## 29    24.635854               Medium
## 31     2.627509               Medium
## 32    27.376440               Medium
## 33    18.430744               Medium
## 34    15.607200                 High
## 35    19.873474               Medium
## 36    19.373641               Medium
## 37    26.428138                 High
## 38    16.420951               Medium
## 39    28.470531               Medium
## 40    15.350273                 High
## 41    21.378795                 High
## 42    17.294151                 High
## 44    15.992029               Medium
## 45     7.508622                 High
## 46    27.270622               Medium
## 47    22.108595                 High
## 48    11.069351                 High
## 49    17.068705               Medium
## 50    10.016330               Medium
print(clean_data)
##    participant_id reaction_time  accuracy gender    condition anxiety_pre
## 1               1      271.9762  87.53319 Female      Control    31.30191
## 2               2      288.4911  84.71453 Female Experimental    31.15234
## 3               3      377.9354  84.57130 Female Experimental    27.65762
## 4               4      303.5254  98.68602   Male      Control    16.93299
## 5               5      306.4644  82.74229 Female      Control    24.04438
## 6               6      385.7532 100.16471 Female      Control    22.75684
## 7               7      323.0458  69.51247 Female      Control    29.50392
## 8               8      236.7469  90.84614   Male      Control    22.02049
## 10             10      277.7169  87.15942 Female      Control    22.00335
## 12             12      317.9907  79.97677   Male Experimental    16.60658
## 13             13      320.0386  81.66793   Male Experimental    14.91876
## 14             14      305.5341  74.81425 Female      Control    50.92832
## 15             15      272.2079  74.28209 Female Experimental    21.66514
## 17             17      324.8925  89.48210 Female Experimental    30.09256
## 18             18      201.6691  85.53004   Male      Control    21.12975
## 19             19      335.0678  94.22267 Female      Control    29.13490
## 20             20      276.3604 105.50085   Male      Control    27.95172
## 21             21      246.6088  80.08969 Female      Control    23.27696
## 22             22      289.1013  61.90831   Male      Control    25.52234
## 23             23      248.6998  95.05739   Male      Control    24.72746
## 24             24      263.5554  77.90799   Male Experimental    42.02762
## 25             25      268.7480  78.11991 Female      Control    19.06931
## 26             26      215.6653  95.25571 Female Experimental    16.23203
## 27             27      341.8894  82.15227   Male      Control    25.30231
## 28             28      307.6687  72.79282   Male      Control    27.48385
## 29             29      243.0932  86.81303 Female      Control    28.49219
## 31             31      321.3232  85.05764   Male Experimental    16.49339
## 32             32      285.2464  88.85280 Female Experimental    35.10548
## 33             33      344.7563  81.29340 Female      Control    22.20280
## 34             34      343.9067  91.44377   Male      Control    18.07590
## 35             35      341.0791  82.79513 Female      Control    23.10976
## 36             36      334.4320  88.31782 Female Experimental    23.42259
## 37             37      327.6959  95.96839 Female Experimental    33.87936
## 38             38      296.9044  89.35181 Female Experimental    25.67790
## 39             39      284.7019  81.74068 Female      Control    31.03243
## 40             40      280.9764  96.48808   Male Experimental    21.00566
## 41             41      265.2647  94.93504   Male      Control    26.71556
## 42             42      289.6041  90.48397 Female      Control    22.40251
## 44             44      408.4478  78.72094 Female      Control    17.83709
## 45             45      360.3981  98.60652   Male      Control    14.51359
## 46             46      243.8446  78.99740   Male Experimental    40.97771
## 47             47      279.8558 106.87333   Male Experimental    29.80567
## 48             48      276.6672 100.32611 Female Experimental    14.98983
## 49             49      338.9983  82.64300 Female      Control    20.11067
## 50             50      295.8315  74.73579 Female      Control    15.51616
##    anxiety_post
## 1     29.053117
## 2     19.215099
## 3     20.453056
## 4     13.751994
## 5     17.847362
## 6     19.933968
## 7     24.342317
## 8     17.758982
## 10    22.069157
## 12     7.875522
## 13     3.221330
## 14    45.327922
## 15    16.642661
## 17    23.416047
## 18    21.642810
## 19    26.912456
## 20    24.773302
## 21    18.586930
## 22    20.597288
## 23    20.358843
## 24    31.904850
## 25    14.370025
## 26     8.052780
## 27    21.952702
## 28    24.334744
## 29    24.635854
## 31     2.627509
## 32    27.376440
## 33    18.430744
## 34    15.607200
## 35    19.873474
## 36    19.373641
## 37    26.428138
## 38    16.420951
## 39    28.470531
## 40    15.350273
## 41    21.378795
## 42    17.294151
## 44    15.992029
## 45     7.508622
## 46    27.270622
## 47    22.108595
## 48    11.069351
## 49    17.068705
## 50    10.016330
  1. Filter the data set to include only participants in the Experimental condition with reaction times faster than the overall mean reaction time.
# Your code here
clean_data %>%
  filter(reaction_time > mean(reaction_time))
##    participant_id reaction_time  accuracy gender    condition anxiety_pre
## 1               3      377.9354  84.57130 Female Experimental    27.65762
## 2               4      303.5254  98.68602   Male      Control    16.93299
## 3               5      306.4644  82.74229 Female      Control    24.04438
## 4               6      385.7532 100.16471 Female      Control    22.75684
## 5               7      323.0458  69.51247 Female      Control    29.50392
## 6              12      317.9907  79.97677   Male Experimental    16.60658
## 7              13      320.0386  81.66793   Male Experimental    14.91876
## 8              14      305.5341  74.81425 Female      Control    50.92832
## 9              17      324.8925  89.48210 Female Experimental    30.09256
## 10             19      335.0678  94.22267 Female      Control    29.13490
## 11             27      341.8894  82.15227   Male      Control    25.30231
## 12             28      307.6687  72.79282   Male      Control    27.48385
## 13             31      321.3232  85.05764   Male Experimental    16.49339
## 14             33      344.7563  81.29340 Female      Control    22.20280
## 15             34      343.9067  91.44377   Male      Control    18.07590
## 16             35      341.0791  82.79513 Female      Control    23.10976
## 17             36      334.4320  88.31782 Female Experimental    23.42259
## 18             37      327.6959  95.96839 Female Experimental    33.87936
## 19             44      408.4478  78.72094 Female      Control    17.83709
## 20             45      360.3981  98.60652   Male      Control    14.51359
## 21             49      338.9983  82.64300 Female      Control    20.11067
##    anxiety_post
## 1     20.453056
## 2     13.751994
## 3     17.847362
## 4     19.933968
## 5     24.342317
## 6      7.875522
## 7      3.221330
## 8     45.327922
## 9     23.416047
## 10    26.912456
## 11    21.952702
## 12    24.334744
## 13     2.627509
## 14    18.430744
## 15    15.607200
## 16    19.873474
## 17    19.373641
## 18    26.428138
## 19    15.992029
## 20     7.508622
## 21    17.068705
print(clean_data)
##    participant_id reaction_time  accuracy gender    condition anxiety_pre
## 1               1      271.9762  87.53319 Female      Control    31.30191
## 2               2      288.4911  84.71453 Female Experimental    31.15234
## 3               3      377.9354  84.57130 Female Experimental    27.65762
## 4               4      303.5254  98.68602   Male      Control    16.93299
## 5               5      306.4644  82.74229 Female      Control    24.04438
## 6               6      385.7532 100.16471 Female      Control    22.75684
## 7               7      323.0458  69.51247 Female      Control    29.50392
## 8               8      236.7469  90.84614   Male      Control    22.02049
## 10             10      277.7169  87.15942 Female      Control    22.00335
## 12             12      317.9907  79.97677   Male Experimental    16.60658
## 13             13      320.0386  81.66793   Male Experimental    14.91876
## 14             14      305.5341  74.81425 Female      Control    50.92832
## 15             15      272.2079  74.28209 Female Experimental    21.66514
## 17             17      324.8925  89.48210 Female Experimental    30.09256
## 18             18      201.6691  85.53004   Male      Control    21.12975
## 19             19      335.0678  94.22267 Female      Control    29.13490
## 20             20      276.3604 105.50085   Male      Control    27.95172
## 21             21      246.6088  80.08969 Female      Control    23.27696
## 22             22      289.1013  61.90831   Male      Control    25.52234
## 23             23      248.6998  95.05739   Male      Control    24.72746
## 24             24      263.5554  77.90799   Male Experimental    42.02762
## 25             25      268.7480  78.11991 Female      Control    19.06931
## 26             26      215.6653  95.25571 Female Experimental    16.23203
## 27             27      341.8894  82.15227   Male      Control    25.30231
## 28             28      307.6687  72.79282   Male      Control    27.48385
## 29             29      243.0932  86.81303 Female      Control    28.49219
## 31             31      321.3232  85.05764   Male Experimental    16.49339
## 32             32      285.2464  88.85280 Female Experimental    35.10548
## 33             33      344.7563  81.29340 Female      Control    22.20280
## 34             34      343.9067  91.44377   Male      Control    18.07590
## 35             35      341.0791  82.79513 Female      Control    23.10976
## 36             36      334.4320  88.31782 Female Experimental    23.42259
## 37             37      327.6959  95.96839 Female Experimental    33.87936
## 38             38      296.9044  89.35181 Female Experimental    25.67790
## 39             39      284.7019  81.74068 Female      Control    31.03243
## 40             40      280.9764  96.48808   Male Experimental    21.00566
## 41             41      265.2647  94.93504   Male      Control    26.71556
## 42             42      289.6041  90.48397 Female      Control    22.40251
## 44             44      408.4478  78.72094 Female      Control    17.83709
## 45             45      360.3981  98.60652   Male      Control    14.51359
## 46             46      243.8446  78.99740   Male Experimental    40.97771
## 47             47      279.8558 106.87333   Male Experimental    29.80567
## 48             48      276.6672 100.32611 Female Experimental    14.98983
## 49             49      338.9983  82.64300 Female      Control    20.11067
## 50             50      295.8315  74.73579 Female      Control    15.51616
##    anxiety_post
## 1     29.053117
## 2     19.215099
## 3     20.453056
## 4     13.751994
## 5     17.847362
## 6     19.933968
## 7     24.342317
## 8     17.758982
## 10    22.069157
## 12     7.875522
## 13     3.221330
## 14    45.327922
## 15    16.642661
## 17    23.416047
## 18    21.642810
## 19    26.912456
## 20    24.773302
## 21    18.586930
## 22    20.597288
## 23    20.358843
## 24    31.904850
## 25    14.370025
## 26     8.052780
## 27    21.952702
## 28    24.334744
## 29    24.635854
## 31     2.627509
## 32    27.376440
## 33    18.430744
## 34    15.607200
## 35    19.873474
## 36    19.373641
## 37    26.428138
## 38    16.420951
## 39    28.470531
## 40    15.350273
## 41    21.378795
## 42    17.294151
## 44    15.992029
## 45     7.508622
## 46    27.270622
## 47    22.108595
## 48    11.069351
## 49    17.068705
## 50    10.016330

I used na.omit() to remove any rows that contained NA values. Then I used mutate() to create a new column called performance_category and imbedded an ifelse statement inside another ifelse statement to label each row of data as high, medium, or low based on their accuracy. Finally I used filter() to show the rows that had reaction times greater than the overall mean reaction time.


Part 4: Visualization and Correlation Analysis

Question 6: Correlation Analysis with the psych Package

Using the psych package, create a correlation plot for the simulated data set created in Part 2. Include the following steps:

  1. Select the numeric variables from the data set (reaction_time, accuracy, anxiety_pre, anxiety_post, and anxiety_change if you created it).
  2. Use the psych package’s corPlot() function to create a correlation plot.
  3. Interpret the resulting plot by addressing:
    • Which variables appear to be strongly correlated?
    • Are there any surprising relationships?
    • How might these correlations inform further research in psychology?
# Your code here. Hint: first, with dplyr create a new data set that selects only the numeric variable (reaction_time, accuracy, anxiety_pre, anxiety_post, and anxiety_change if you created it).
cordata <- maindata %>%
  select(reaction_time, accuracy, anxiety_pre, anxiety_post, anxiety_change)
corPlot(cordata)
## Error in plot.new(): figure margins too large

There is a strong positive correlation between anxiety_pre and anxiety_post. There is a surprisingly weak positive correlation between anxiety_pre and anxiety_change, which could inform further psychological research that there may be methods to reduce stress that are more effective in an individual with higher stress levels.


Part 5: Reflection and Application

Question 7: Reflection

Reflect on how the statistical concepts and R techniques covered in this course apply to psychological research:

  1. Describe a specific research question in psychology that interests you. What type of data would you collect, what statistical analyses would be appropriate, and what potential measurement errors might you need to address?

  2. How has learning R for data analysis changed your understanding of psychological statistics? What do you see as the biggest advantages and challenges of using R compared to other statistical software?

I’m interested in how stress has changed from older generations. Data collection that comes to mind includes the levels of stress felt by different age groups, the different sources of stress, and how people relieve stress. I would likely need to address measurement errors mainly based on human error such as how honest each person who I collect data from would be or how mine and other researcher’s personal bias would affect how we view the data. Learning R for data analysis has helped me understand how many ways you can compare data to derive different answers and theories. Using R has the advantage of being flexible in it’s applications for processing data, but it may take more time for someone to learn to use it compared to other statistical software.


Submission Instructions:

Ensure to knit your document to HTML format, checking that all content is correctly displayed before submission. Publish your assignment to RPubs and submit the URL to canvas.