Replace “Your Name” with your actual name.
Please complete this exam on your own. Include your R code, interpretations, and answers within this document.
Read Chapter 2 (Types of Data Psychologists Collect) and answer the following:
Nominal data is data that consists of categories and does not have a order. This type of data does not represent quantities. Ordinal data is categorical data that have a meaningful order but they are not consistent. Lastly, interval data is the data that has order and categories and has equal intervals between them.
Scores on a depression inventory would be intervals because with intervals there is no true zero point. Response time would be ratio because it has a zero point. Likert scale ratings of agreement is ordinal because the intervals between categories are not equal. diagnostic categories are nominal because they are categories with a specific order. Lastly, age in years would be ratio becuase it has a true zero point.
Referring to Chapter 3 (Measurement Errors in Psychological Research):
A random error is the arrors that happen at anytime and there affect has a unpredictable measurement. An example of that is an error with participant attentiveness. Systematic error is the errors that happen in a predictable manner. An example of this the environment you put the participants in (to loud, to distracting).
Measurement error could not predict or detect the problem with environmental factors or external factors that no one could ever know about. A way to minimize this is to control the participants environment for time before an experimenter and during the experiment.
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*:
# Using the psych package to calculate the summary statistics
library(psych)
# Reaction time and accuracy by condition
desc_stats <- describeBy(data[, c("reaction_time", "accuracy")], group = data$condition)
desc_stats##
## Descriptive statistics by group
## group: Control
## vars n mean sd median trimmed mad min max range
## reaction_time 1 30 301.40 48.54 299.68 300.42 55.38 201.67 408.45 206.78
## accuracy 2 29 85.49 9.86 85.53 85.68 8.77 61.91 105.50 43.59
## skew kurtosis se
## reaction_time 0.14 -0.66 8.86
## accuracy -0.15 -0.35 1.83
## ------------------------------------------------------------
## group: Experimental
## vars n mean sd median trimmed mad min max range
## reaction_time 1 17 295.75 38.37 288.49 295.61 43.74 215.67 377.94 162.27
## accuracy 2 19 88.06 8.20 88.32 87.76 9.86 74.28 106.87 32.59
## skew kurtosis se
## reaction_time 0.00 -0.27 9.31
## accuracy 0.45 -0.45 1.88
anxiety_change that represents the difference between pre
and post anxiety scores (pre minus post). Then calculate the mean
anxiety change for each condition.# Create the 'anxiety_change' variable
data <- data %>% mutate(anxiety_change = anxiety_pre - anxiety_post)
# Calculate the mean anxiety change by condition
anxiety_change_stats <- data %>%
group_by(condition) %>%
summarize(mean_anxiety_change = mean(anxiety_change, na.rm = TRUE))
anxiety_change_stats## # A tibble: 2 × 2
## condition mean_anxiety_change
## <chr> <dbl>
## 1 Control 3.79
## 2 Experimental 8.64
Write your answer(s) here
Using the concepts from Chapter 4 (Descriptive Statistics and Basic Probability in Psychological Research):
Write your answer(s) here
Using the dataset created in Part 2, perform the following data cleaning and manipulation tasks:
clean_data.performance_category that
categorizes participants based on their accuracy:
Write your answer(s) here describing your data cleaning process.
Using the psych package, create a correlation plot for the simulated dataset created in Part 2. Include the following steps:
corPlot()
function to create a correlation plot.# Your code here. Hint: first, with dplyr create a new dataset that selects only the numeric variable (reaction_time, accuracy, anxiety_pre, anxiety_post, and anxiety_change if you created it).Write your answer(s) here
Reflect on how the statistical concepts and R techniques covered in this course apply to psychological research:
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?
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?
1: How does vaping affect cognitive performance. I would take a group of student who vape and a group who don’t and see what there attention span adn grade look like. I don’t know all outside factors, if they are sleep deprived, if they have a drinking problem, if they have a learning disability. 2: It has changed my understanding because I have learned that it is much easier to run code and have readable psychological data to present. It also make analysis much easier because having raw data can be much easier to comprehend to the common eye.
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.