Week 8

cor_values <- c(0.55, 0.09, -0.77, 0.1, 1.05)
valid_cor_values <- cor_values[cor_values >= -1 & cor_values <= 1]
absolute_values <- abs(valid_cor_values)
strongest_correlation <- valid_cor_values[which.max(absolute_values)]
cat("Q1:The strongest correlation coefficient is:", strongest_correlation, "\n")
Q1:The strongest correlation coefficient is: -0.77 
positive_correlations <- valid_cor_values[valid_cor_values > 0]
cat("Q2:Coefficients indicating a positive relationship (X and Y above average):", positive_correlations, "\n")
Q2:Coefficients indicating a positive relationship (X and Y above average): 0.55 0.09 0.1 
r_values <- c(1, -1)     
zx_values <- c(-0.5, 0.8) 
zy_values <- r_values * zx_values
cat("Q10:Case 1: If r = 1 and zx = -0.5, zy =", zy_values[1], "\n")
Q10:Case 1: If r = 1 and zx = -0.5, zy = -0.5 
cat("Q10:Case 2: If r = -1 and zx = 0.8, zy =", zy_values[2], "\n")
Q10:Case 2: If r = -1 and zx = 0.8, zy = -0.8 
r_values <- c(-0.2, 0.4)
shared_variance <- r_values^2
change_ratio <- shared_variance[2] / shared_variance[1]
cat("Q13: Shared variance proportion change is", change_ratio, "times\n")
Q13: Shared variance proportion change is 4 times
r_values <- c(0.1, 0.21)
shared_variance <- r_values^2
cat("Q18: Shared variance between study results and teaching ability is", shared_variance[1], "\n")
Q18: Shared variance between study results and teaching ability is 0.01 
cat("Q18: Shared variance between evaluations by two teachers is", shared_variance[2], "\n")
Q18: Shared variance between evaluations by two teachers is 0.0441 
zx_values <- c(-0.8, 0.4, -1.2, 0.9)
zy_values <- c(0.5, -0.7, 1.1, -0.3)
r <- cor(zx_values, zy_values)
cat("Q21: The Pearson correlation coefficient between the given z-scores is", r, "\n")
Q21: The Pearson correlation coefficient between the given z-scores is -0.9061334