#a) Create a scatterplot
plot(x = performance$motiv, y = performance$perf)
#b) test if the correlation betwee motivation & performance differs from 0
cor.test(x = performance$motiv, y = performance$perf, method = "pearson")
#g) Does the correlation differ significantly from 0? Report t, df, and p
t(281) = 7.0994, p < .001
#calculate the Pearson r between X & Y and formulate hypotheses
r = 6.00/(8 − 1) = .857
H0 : ρ = 0 and Ha : ρ ̸= 0
#Test with the t-test whether the correlation coefficient deviates significantly from
0.Formulate both a statistical and a substantive conclusion.
p < α → H0 rejected: Strong, positive
association between emotional stability and immunity to stress
# Calculate p value: 2 * pt(4.07, df = 6, lower.tail = FALSE)
Week 2: Simple Linear Regression—----------------------------------------------------------------------
2.2 #a) Set up linear model to predict school performance from motivation
lm_perf <- lm(perf ~ motiv, data = performance)
#b) show results in console: summary(lm_perf)
#c) What is value of R2 ?What will happen to R2 if a second predictor is added to the model?
R^2 = .1521: proportion of variance accounted for in the sample, becomes higher
#d) What is value of R2 adj? What is the meaning of this value? Why is this value always lower
than that of R2 ? R^2 adj = .1491; proportion of variance accounted for in the population
#e) Write down the regression equation. What is the meaning of the coefficients? Is
motivation a significant predictor or school performance? Report t, df, and p.
Yes, t(281) = 7.099, p < .001
#i) Determine 90%, 95%, and 99% confidence intervals
, # add regression line to scatterplot
abline(lm_perf, col = "red", lwd = 2, lty = "dashed")
#Formulate a substantive conclusion and report the statistics in APA style
Motivation is a significant predictor of school performance, b = 0.01, t(281) = 7.10, p < .001.
Motivation explains 15.2% of the variance in school performance.
2.3 #Determine the 95% CI of regression coefficient b1 (SEb1 = 0.157). Formulate the
hypotheses to test the regression coefficient b1
CI = 0.637 ± 2.447 × 0.157 → [0.253; 1.021]
H0 : β1 = 0 and Ha : β1 ̸= 0
# Test whether regression coefficient b1 differs significantly from 0 (SEb1 = 0.157). Formulate
both a statistical and a substantive conclusion.
t(6) = 0.637 0.157 = 4.057, p = .007
p < α → H0 rejected: Emotional stability significant predictor of immunity to stress.
Week 3: Multiple Linear Regression ---------------------------------------------------------------------
3.3 #a) Carry out a regression analysis to predict school performance based on intelligence
and motivation. Store the model as lm perf2
lm_perf2 <- lm(perf ~ motiv + intel, data = performance)
summary(lm_perf2)
#g) Calculate the value of R? What is the meaning of this value?
R^2 = R2 = .5066; proportion of variance accounted for in the sample
R = √ .5066 = .7118; correlation between observed and predicted values
#h) Is the F-value for testing the model significant? (F, df, and p)
Yes, F(2, 280) = 143.8, p < .001
#i) Write down the regression equation. What is the meaning of the coefficients? j) Are
intelligence and motivation significant predictors of performance? (t, df, and p)
Motivation +1 → predicted performance +0.012
Intelligence +1 → predicted performance +0.059 1
Intelligence = Motivation = 0 → predicted performance = −1.451
Intelligence is significant, t(280) = 8.049, p < .001 and motivation is signficant, t(280) = 14.186, p
< .001.
#k) Determine confidence intervals
confint(object = lm_perf2, level = 0.95)