#Importing required libraries
library(readxl)
library(raincloudplots)
## Loading required package: ggplot2
library(ggrain)
## Warning: package 'ggrain' was built under R version 4.3.1
library(table1)
## Warning: package 'table1' was built under R version 4.3.1
##
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
##
## units, units<-
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
library(gridExtra)
## Warning: package 'gridExtra' was built under R version 4.3.1
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.3.1
## corrplot 0.92 loaded
library(stats)
library(rpart)
library(rpart.plot)
## Warning: package 'rpart.plot' was built under R version 4.3.1
library(caret)
## Warning: package 'caret' was built under R version 4.3.2
## Loading required package: lattice
library(e1071)
## Warning: package 'e1071' was built under R version 4.3.2
library(writexl)
## Warning: package 'writexl' was built under R version 4.3.1
#importing the data
data <- read_excel("C:\\Users\\Angat\\OneDrive\\Desktop\\STM5IPL_HYBRID_LEARNING\\Deidentified Data Detailed Complie-03-02-2023 (no qual).xlsx", sheet = "Matched Data Compile 12.11.22")
## New names:
## • `` -> `...2`
## • `` -> `...66`
data<-data[-89,]
data <- subset(data, select = -c(...2,...66))
data
#selecting relevant columns for analysis
selected_columns <-subset(data, select =c("Mode", "Region origin", "Campus", "ATAR", "Course Weighted Average","Age", "Gender", "IMI Total","IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness","SUS", "AT2 article summary Wk 5?","AT 3: Critical appraisal essay Wk9", "IM_Percentage", "EM_Percentage","Motivation_Type", "Like_Hybrid","TOTAL","AT3_Performance","AT3_Median_Performance","TOTAL_Performance"))
# Display the names of the selected columns
names(selected_columns)
## [1] "Mode" "Region origin"
## [3] "Campus" "ATAR"
## [5] "Course Weighted Average" "Age"
## [7] "Gender" "IMI Total"
## [9] "IMI - Interest/Enjoyment" "IMI - Perceived Competence"
## [11] "IMI - Effort/Importance" "IMI - Pressure/Tension"
## [13] "IMI - Perceived Choice" "IMI - Value/Usefulness"
## [15] "IMI - Relatedness" "SUS"
## [17] "AT2 article summary Wk 5?" "AT 3: Critical appraisal essay Wk9"
## [19] "IM_Percentage" "EM_Percentage"
## [21] "Motivation_Type" "Like_Hybrid"
## [23] "TOTAL" "AT3_Performance"
## [25] "AT3_Median_Performance" "TOTAL_Performance"
#Data Cleaning
#Check the ATAR with 0 values
data[data$ATAR==0,]
# Replace 0 values in ATAR column with "NA"
selected_columns$ATAR <- ifelse(selected_columns$ATAR == 0,NA, selected_columns$ATAR)
# Replace "-" with NA in specific columns using mutate_at
selected_columns <- selected_columns %>%
mutate_at(
vars( `AT2 article summary Wk 5?`, `AT 3: Critical appraisal essay Wk9`),
~ifelse(. %in% c("-", " ","0"), NA, .)
)
#Data Exploration
my.render.cont <- function(x) {
with(stats.apply.rounding(stats.default(x), digits=2), c("",
"Mean (SD)"=sprintf("%s (± %s)", MEAN, SD)))
}
# Generate Table 1
table1(
~ Age + ATAR + `Course Weighted Average` +`IMI Total`+`SUS` + `AT2 article summary Wk 5?` + `AT 3: Critical appraisal essay Wk9` +`IM_Percentage` + `EM_Percentage`+`Like_Hybrid` | Mode,
data=selected_columns,
render.continuous = my.render.cont,
caption="Table 1 : Descriptive statistics exploration for all variables wrt Study Mode"
)
| Hybrid/Class.com (N=64) |
Online/Zoom (N=62) |
Overall (N=126) |
|
|---|---|---|---|
| Age | |||
| Mean (SD) | 21 (± 7.6) | 22 (± 5.7) | 22 (± 6.7) |
| ATAR | |||
| Mean (SD) | 75 (± 18) | 72 (± 17) | 74 (± 17) |
| Missing | 6 (9.4%) | 11 (17.7%) | 17 (13.5%) |
| Course Weighted Average | |||
| Mean (SD) | 72 (± 15) | 75 (± 8.6) | 74 (± 12) |
| IMI Total | |||
| Mean (SD) | 92 (± 13) | 90 (± 14) | 91 (± 14) |
| Missing | 0 (0%) | 1 (1.6%) | 1 (0.8%) |
| SUS | |||
| Mean (SD) | 64 (± 19) | 73 (± 15) | 69 (± 17) |
| Missing | 6 (9.4%) | 0 (0%) | 6 (4.8%) |
| AT2 article summary Wk 5? | |||
| Mean (SD) | 16 (± 1.8) | 16 (± 2.7) | 16 (± 2.3) |
| Missing | 5 (7.8%) | 1 (1.6%) | 6 (4.8%) |
| AT 3: Critical appraisal essay Wk9 | |||
| Mean (SD) | 75 (± 15) | 75 (± 12) | 75 (± 13) |
| Missing | 2 (3.1%) | 4 (6.5%) | 6 (4.8%) |
| IM_Percentage | |||
| Mean (SD) | 67 (± 11) | 66 (± 14) | 66 (± 12) |
| EM_Percentage | |||
| Mean (SD) | 63 (± 9.1) | 59 (± 13) | 61 (± 11) |
| Like_Hybrid | |||
| NO | 23 (35.9%) | 22 (35.5%) | 45 (35.7%) |
| YES | 41 (64.1%) | 40 (64.5%) | 81 (64.3%) |
#Stat summary for Mode
table1(~Age + ATAR + `Course Weighted Average`+`SUS`+`AT2 article summary Wk 5?`+`AT 3: Critical appraisal essay Wk9`+`IM_Percentage`+`EM_Percentage`|Mode,data=selected_columns,caption="Table 1 : Descriptive statistics for Mode",render.continuous = my.render.cont)
| Hybrid/Class.com (N=64) |
Online/Zoom (N=62) |
Overall (N=126) |
|
|---|---|---|---|
| Age | |||
| Mean (SD) | 21 (± 7.6) | 22 (± 5.7) | 22 (± 6.7) |
| ATAR | |||
| Mean (SD) | 75 (± 18) | 72 (± 17) | 74 (± 17) |
| Missing | 6 (9.4%) | 11 (17.7%) | 17 (13.5%) |
| Course Weighted Average | |||
| Mean (SD) | 72 (± 15) | 75 (± 8.6) | 74 (± 12) |
| SUS | |||
| Mean (SD) | 64 (± 19) | 73 (± 15) | 69 (± 17) |
| Missing | 6 (9.4%) | 0 (0%) | 6 (4.8%) |
| AT2 article summary Wk 5? | |||
| Mean (SD) | 16 (± 1.8) | 16 (± 2.7) | 16 (± 2.3) |
| Missing | 5 (7.8%) | 1 (1.6%) | 6 (4.8%) |
| AT 3: Critical appraisal essay Wk9 | |||
| Mean (SD) | 75 (± 15) | 75 (± 12) | 75 (± 13) |
| Missing | 2 (3.1%) | 4 (6.5%) | 6 (4.8%) |
| IM_Percentage | |||
| Mean (SD) | 67 (± 11) | 66 (± 14) | 66 (± 12) |
| EM_Percentage | |||
| Mean (SD) | 63 (± 9.1) | 59 (± 13) | 61 (± 11) |
#Stat summary for Mode and Motivation Type
table1(~Age + ATAR + `Course Weighted Average`+`SUS`+`AT2 article summary Wk 5?`+`AT 3: Critical appraisal essay Wk9`+`IM_Percentage`+`EM_Percentage`|Mode*Motivation_Type,data=selected_columns,caption="Table 2 : Descriptive statistics for Mode and Motivation type",render.continuous = my.render.cont)
Hybrid/Class.com |
Online/Zoom |
Overall |
||||
|---|---|---|---|---|---|---|
| EXTRINSIC (N=21) |
INTRINSIC (N=43) |
EXTRINSIC (N=19) |
INTRINSIC (N=43) |
EXTRINSIC (N=40) |
INTRINSIC (N=86) |
|
| Age | ||||||
| Mean (SD) | 20 (± 3.5) | 22 (± 9.0) | 24 (± 8.5) | 21 (± 3.6) | 22 (± 6.6) | 21 (± 6.8) |
| ATAR | ||||||
| Mean (SD) | 71 (± 19) | 78 (± 17) | 72 (± 15) | 72 (± 18) | 71 (± 17) | 75 (± 17) |
| Missing | 2 (9.5%) | 4 (9.3%) | 3 (15.8%) | 8 (18.6%) | 5 (12.5%) | 12 (14.0%) |
| Course Weighted Average | ||||||
| Mean (SD) | 73 (± 13) | 72 (± 16) | 74 (± 11) | 76 (± 7.0) | 74 (± 12) | 74 (± 13) |
| SUS | ||||||
| Mean (SD) | 64 (± 20) | 64 (± 19) | 68 (± 13) | 76 (± 15) | 66 (± 16) | 70 (± 18) |
| Missing | 3 (14.3%) | 3 (7.0%) | 0 (0%) | 0 (0%) | 3 (7.5%) | 3 (3.5%) |
| AT2 article summary Wk 5? | ||||||
| Mean (SD) | 16 (± 1.8) | 16 (± 1.9) | 16 (± 2.8) | 16 (± 2.6) | 16 (± 2.3) | 16 (± 2.3) |
| Missing | 1 (4.8%) | 4 (9.3%) | 0 (0%) | 1 (2.3%) | 1 (2.5%) | 5 (5.8%) |
| AT 3: Critical appraisal essay Wk9 | ||||||
| Mean (SD) | 70 (± 19) | 77 (± 12) | 77 (± 14) | 74 (± 11) | 74 (± 17) | 76 (± 11) |
| Missing | 1 (4.8%) | 1 (2.3%) | 2 (10.5%) | 2 (4.7%) | 3 (7.5%) | 3 (3.5%) |
| IM_Percentage | ||||||
| Mean (SD) | 61 (± 7.4) | 70 (± 11) | 59 (± 16) | 68 (± 12) | 60 (± 12) | 69 (± 11) |
| EM_Percentage | ||||||
| Mean (SD) | 66 (± 6.2) | 61 (± 10) | 61 (± 17) | 58 (± 11) | 64 (± 12) | 60 (± 10) |
#Stat summary for Mode and Gender
table1(~Age + ATAR + `Course Weighted Average`+`SUS`+`AT2 article summary Wk 5?`+`AT 3: Critical appraisal essay Wk9`+`IM_Percentage`+`EM_Percentage`|Mode*Gender,data=selected_columns,caption="Table 3 : Descriptive statistics for Mode and Gender",render.continuous = my.render.cont)
Hybrid/Class.com |
Online/Zoom |
Overall |
||||
|---|---|---|---|---|---|---|
| Female (N=49) |
Male (N=15) |
Female (N=47) |
Male (N=15) |
Female (N=96) |
Male (N=30) |
|
| Age | ||||||
| Mean (SD) | 22 (± 8.6) | 19 (± 1.5) | 22 (± 6.0) | 22 (± 4.8) | 22 (± 7.4) | 20 (± 3.7) |
| ATAR | ||||||
| Mean (SD) | 76 (± 17) | 74 (± 20) | 72 (± 18) | 72 (± 14) | 74 (± 17) | 73 (± 17) |
| Missing | 4 (8.2%) | 2 (13.3%) | 6 (12.8%) | 5 (33.3%) | 10 (10.4%) | 7 (23.3%) |
| Course Weighted Average | ||||||
| Mean (SD) | 73 (± 15) | 71 (± 14) | 76 (± 8.2) | 74 (± 9.7) | 74 (± 12) | 73 (± 12) |
| SUS | ||||||
| Mean (SD) | 64 (± 18) | 63 (± 23) | 76 (± 13) | 67 (± 17) | 70 (± 17) | 65 (± 20) |
| Missing | 5 (10.2%) | 1 (6.7%) | 0 (0%) | 0 (0%) | 5 (5.2%) | 1 (3.3%) |
| AT2 article summary Wk 5? | ||||||
| Mean (SD) | 16 (± 1.7) | 16 (± 2.1) | 16 (± 2.2) | 15 (± 3.7) | 16 (± 2.0) | 15 (± 3.0) |
| Missing | 4 (8.2%) | 1 (6.7%) | 1 (2.1%) | 0 (0%) | 5 (5.2%) | 1 (3.3%) |
| AT 3: Critical appraisal essay Wk9 | ||||||
| Mean (SD) | 75 (± 13) | 73 (± 19) | 77 (± 12) | 72 (± 11) | 76 (± 13) | 72 (± 15) |
| Missing | 2 (4.1%) | 0 (0%) | 4 (8.5%) | 0 (0%) | 6 (6.3%) | 0 (0%) |
| IM_Percentage | ||||||
| Mean (SD) | 67 (± 11) | 67 (± 10) | 65 (± 15) | 69 (± 9.7) | 66 (± 13) | 68 (± 9.9) |
| EM_Percentage | ||||||
| Mean (SD) | 62 (± 9.5) | 65 (± 8.0) | 59 (± 14) | 62 (± 8.2) | 60 (± 12) | 63 (± 8.1) |
#Stat summary for Motivation type and Gender
table1(~Age + ATAR + `Course Weighted Average`+`SUS`+`AT2 article summary Wk 5?`+`AT 3: Critical appraisal essay Wk9`+`IM_Percentage`+`EM_Percentage`|Motivation_Type*Gender,data=selected_columns,caption="Table 4 : Descriptive statistics for Motivation Type and Gender")
EXTRINSIC |
INTRINSIC |
Overall |
||||
|---|---|---|---|---|---|---|
| Female (N=30) |
Male (N=10) |
Female (N=66) |
Male (N=20) |
Female (N=96) |
Male (N=30) |
|
| Age | ||||||
| Mean (SD) | 22.3 (7.06) | 20.9 (5.00) | 21.7 (7.60) | 20.2 (3.04) | 21.9 (7.40) | 20.4 (3.73) |
| Median [Min, Max] | 19.5 [18.0, 48.0] | 19.5 [18.0, 35.0] | 19.0 [18.0, 62.0] | 19.0 [18.0, 31.0] | 19.0 [18.0, 62.0] | 19.0 [18.0, 35.0] |
| ATAR | ||||||
| Mean (SD) | 71.8 (17.8) | 69.6 (16.9) | 74.9 (17.3) | 75.6 (17.6) | 74.0 (17.4) | 73.2 (17.2) |
| Median [Min, Max] | 67.4 [33.8, 97.8] | 74.1 [40.9, 90.3] | 73.7 [19.5, 99.6] | 74.4 [43.9, 98.3] | 71.5 [19.5, 99.6] | 74.2 [40.9, 98.3] |
| Missing | 4 (13.3%) | 1 (10.0%) | 6 (9.1%) | 6 (30.0%) | 10 (10.4%) | 7 (23.3%) |
| Course Weighted Average | ||||||
| Mean (SD) | 75.8 (9.12) | 67.0 (16.8) | 73.3 (13.7) | 75.8 (7.42) | 74.1 (12.5) | 72.9 (11.9) |
| Median [Min, Max] | 76.3 [47.3, 92.0] | 72.6 [32.7, 84.3] | 76.5 [0, 91.0] | 78.3 [62.8, 85.8] | 76.4 [0, 92.0] | 77.0 [32.7, 85.8] |
| SUS | ||||||
| Mean (SD) | 66.8 (15.8) | 64.8 (18.7) | 71.3 (16.8) | 65.1 (21.3) | 69.9 (16.5) | 65.0 (20.1) |
| Median [Min, Max] | 70.0 [30.0, 95.0] | 62.5 [40.0, 95.0] | 72.5 [35.0, 100] | 60.0 [25.0, 97.5] | 72.5 [30.0, 100] | 60.0 [25.0, 97.5] |
| Missing | 3 (10.0%) | 0 (0%) | 2 (3.0%) | 1 (5.0%) | 5 (5.2%) | 1 (3.3%) |
| AT2 article summary Wk 5? | ||||||
| Mean (SD) | 16.2 (2.18) | 15.7 (2.71) | 16.4 (1.88) | 15.2 (3.19) | 16.3 (1.97) | 15.4 (2.99) |
| Median [Min, Max] | 17.0 [9.00, 18.0] | 17.0 [11.0, 18.0] | 17.0 [11.0, 18.0] | 16.0 [4.00, 18.0] | 17.0 [9.00, 18.0] | 16.0 [4.00, 18.0] |
| Missing | 1 (3.3%) | 0 (0%) | 4 (6.1%) | 1 (5.0%) | 5 (5.2%) | 1 (3.3%) |
| AT 3: Critical appraisal essay Wk9 | ||||||
| Mean (SD) | 76.2 (16.3) | 66.9 (17.0) | 75.8 (10.8) | 75.2 (13.6) | 75.9 (12.6) | 72.4 (15.1) |
| Median [Min, Max] | 81.0 [25.0, 95.0] | 75.0 [31.0, 84.0] | 76.0 [50.0, 97.0] | 74.5 [50.0, 97.0] | 77.5 [25.0, 97.0] | 75.0 [31.0, 97.0] |
| Missing | 3 (10.0%) | 0 (0%) | 3 (4.5%) | 0 (0%) | 6 (6.3%) | 0 (0%) |
| IM_Percentage | ||||||
| Mean (SD) | 59.2 (13.9) | 62.0 (6.19) | 68.8 (11.7) | 70.3 (10.4) | 65.8 (13.1) | 67.5 (9.94) |
| Median [Min, Max] | 60.0 [0, 75.0] | 60.6 [55.0, 72.5] | 70.0 [38.8, 88.8] | 68.8 [50.0, 87.5] | 65.0 [0, 88.8] | 67.5 [50.0, 87.5] |
| EM_Percentage | ||||||
| Mean (SD) | 62.7 (14.0) | 67.0 (4.97) | 59.4 (10.9) | 61.3 (8.75) | 60.4 (12.0) | 63.2 (8.09) |
| Median [Min, Max] | 65.0 [0, 80.0] | 67.5 [57.5, 72.5] | 60.0 [30.0, 82.5] | 61.3 [45.0, 75.0] | 62.5 [0, 82.5] | 65.0 [45.0, 75.0] |
#Checking for missing values after imputation of null values
relevant_cols <- c("Mode", "Region origin", "Campus", "ATAR", "Course Weighted Average","Age", "Gender", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI Total","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness","SUS", "AT2 article summary Wk 5?","AT 3: Critical appraisal essay Wk9", "IM_Percentage", "EM_Percentage","Motivation_Type", "Like_Hybrid","TOTAL","AT3_Performance","AT3_Median_Performance","TOTAL_Performance")
complete_data <- selected_columns[complete.cases(selected_columns[, relevant_cols]), ]
colSums(is.na(complete_data))
## Mode Region origin
## 0 0
## Campus ATAR
## 0 0
## Course Weighted Average Age
## 0 0
## Gender IMI Total
## 0 0
## IMI - Interest/Enjoyment IMI - Perceived Competence
## 0 0
## IMI - Effort/Importance IMI - Pressure/Tension
## 0 0
## IMI - Perceived Choice IMI - Value/Usefulness
## 0 0
## IMI - Relatedness SUS
## 0 0
## AT2 article summary Wk 5? AT 3: Critical appraisal essay Wk9
## 0 0
## IM_Percentage EM_Percentage
## 0 0
## Motivation_Type Like_Hybrid
## 0 0
## TOTAL AT3_Performance
## 0 0
## AT3_Median_Performance TOTAL_Performance
## 0 0
# Create a count plot for Motivation_Type
ggplot(complete_data, aes(y = Motivation_Type)) +
geom_bar(fill = "#3676e8", color = "black") +
labs(y = "Motivation Type", x = "Count") +
ggtitle("Count of Motivation Types")
# Create a count plot for Motivation_Type
ggplot(complete_data, aes(y = Like_Hybrid)) +
geom_bar(fill = "#ff6767", color = "black") +
labs(y = "Like Hybrid", x = "Count") +
ggtitle("Count of Students Liking Hybrid")
like_hybrid_yes<-dplyr::filter(complete_data,Like_Hybrid=="YES")
like_hybrid_yes<-dplyr::select(like_hybrid_yes,Motivation_Type)
like_hybrid_yes<-dplyr::count(like_hybrid_yes,Motivation_Type)
intrinsic_count <- like_hybrid_yes$n[like_hybrid_yes$Motivation_Type == "INTRINSIC"]
extrinsic_count <- like_hybrid_yes$n[like_hybrid_yes$Motivation_Type == "EXTRINSIC"]
ratio <- intrinsic_count / extrinsic_count
print(ratio)
## [1] 2.15
# Create the first plot
plot1 <- ggplot(complete_data, aes(y = Motivation_Type,fill=Motivation_Type)) +
geom_bar(position = "dodge", color = "black") +
labs(y = "Motivation Type", x = "Count") +scale_fill_manual(values = c("INTRINSIC" = "#a8dbad", "EXTRINSIC" = "#3498db"))+
ggtitle("Count of Motivation Types")
# Create the second plot
plot2 <- ggplot(complete_data, aes(y = Motivation_Type, fill = Like_Hybrid)) +
geom_bar(position = "dodge", color = "black") +
labs(y = "Motivation Type", x = "Count") +
ggtitle("Ratio of Intrinsic to Extrinsic motivated students") +
scale_fill_manual(values = c("YES" = "#3498db", "NO" = "#e30022"))
# Arrange the plots in a single frame
grid.arrange(plot1, plot2, nrow = 2)
plot.1<-ggplot(complete_data, aes(y = Mode, x = `AT 3: Critical appraisal essay Wk9`, fill = Mode)) +
geom_boxplot() +
labs(y = "Mode", x = "AT 3: Critical appraisal essay Wk9") +
ggtitle("AT3 Grade distribution for different Modes") +
theme_minimal() +
scale_fill_manual(values = c("Hybrid/Class.com" = "#3498db", "Online/Zoom" = "#a8dbad")) # Assuming these are the
plot.2<-ggplot(complete_data, aes(y = Motivation_Type, x = `AT 3: Critical appraisal essay Wk9`, fill = Motivation_Type)) +
geom_boxplot() +
labs(y = "Motivation Type", x = "AT 3: Critical appraisal essay Wk9") +
ggtitle("AT3 Grade distribution for different Motivation Types") +
theme_minimal() +
scale_fill_manual(values = c("INTRINSIC" = "#a8dbad", "EXTRINSIC" = "#3498db")) # Assign colors as per your
# Arrange the plots in a single frame
plt.3<-grid.arrange(plot.1, plot.2, nrow = 2)
# Assuming 'Mode' is a factor variable
plt.4<-ggplot(complete_data, aes(x = Gender, y = `AT 3: Critical appraisal essay Wk9`, fill = Gender)) +
geom_boxplot() +
labs(x = "Gender", y = "AT 3: Critical appraisal essay Wk9") +
ggtitle("Distribution of 'AT 3: Critical appraisal essay Wk9' by Gender") +
theme_minimal()+ggtitle("AT3 distribution for different Gender")+
scale_fill_manual(values = c("Female" = "pink", "Male" = "#add8e6"))
grid.arrange(plt.3,plt.4,ncol=2)
# Box plot for Gender
p1 <- ggplot(complete_data, aes(x = Gender, y = `AT 3: Critical appraisal essay Wk9`, fill = Gender)) +
geom_boxplot() +
labs(y = "Gender", x = "AT 3: Critical appraisal essay Wk9") +
ggtitle("Distribution of AT 3 by Gender") +
scale_fill_manual(values = c("Female" = "pink", "Male" = "#add8e6"))+
theme_minimal()
# Box plot for Like_Hybrid
p2 <- ggplot(complete_data, aes(x = as.factor(Like_Hybrid), y = `AT 3: Critical appraisal essay Wk9`, fill = Like_Hybrid)) +
geom_boxplot() +
labs(y = "Like_Hybrid", x = "AT 3: Critical appraisal essay Wk9") +
ggtitle("Distribution of 'AT 3 by Like_Hybrid") +
scale_fill_manual(values = c("NO" = "#e30022", "YES" = "#a8dbad"))+
theme_minimal()
# Arrange the two plots in a 2x1 grid
plot.3<-grid.arrange(p1, p2, ncol = 2)
grid.arrange(plt.3,plot.3,nrow=2)
# List of numerical variable names with double quotes
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness","SUS", "AT2 article summary Wk 5?", "AT 3: Critical appraisal essay Wk9","TOTAL","IM_Percentage", "EM_Percentage")
# Reshape the data into a long format
data_long <- complete_data %>%
pivot_longer(cols = all_of(numerical_vars))
# Create a grid of histograms
hist_grid <- ggplot(data_long, aes(x = value)) +
geom_boxplot(fill = "#a8dbad", color = "black") +
facet_wrap(~ name, scales = "free") +
labs(x = "Value", y = "Frequency") +
theme_minimal()+ggtitle("Outlier Analysis for Variables")
# Print the histogram grid
print(hist_grid)
#For Hybrid
# Load the required packages
library(ggplot2)
library(tidyr)
# Assuming your data is loaded into a dataframe called 'data'
# Replace 'data' with your actual dataframe name
# List of numerical variable names with double quotes
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness","SUS", "AT2 article summary Wk 5?", "AT 3: Critical appraisal essay Wk9","TOTAL","IM_Percentage", "EM_Percentage")
# Reshape the data into a long format
data_long <- complete_data %>%filter(Mode=="Hybrid/Class.com")%>%pivot_longer(cols = all_of(numerical_vars))
# Create a grid of histograms
hist_grid <- ggplot(data_long, aes(x = value)) +
geom_boxplot(fill = "#4169e1", color = "black") +
facet_wrap(~ name, scales = "free") +
labs(x = "Value", y = "Frequency") +
theme_minimal()+ggtitle("Outlier Analysis for Variables For Hybrid Mode")
# Print the histogram grid
print(hist_grid)
#Outlier analysis for Online Mode
# Load the required packages
library(ggplot2)
library(tidyr)
# Assuming your data is loaded into a dataframe called 'data'
# Replace 'data' with your actual dataframe name
# List of numerical variable names with double quotes
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness","SUS", "AT2 article summary Wk 5?", "AT 3: Critical appraisal essay Wk9","TOTAL","IM_Percentage", "EM_Percentage")
# Reshape the data into a long format
data_long <- complete_data %>%filter(Mode=="Online/Zoom")%>%pivot_longer(cols = all_of(numerical_vars))
# Create a grid of histograms
hist_grid <- ggplot(data_long, aes(x = value)) +
geom_boxplot(fill = "#e8f48c", color = "black") +
facet_wrap(~ name, scales = "free") +
labs(x = "Value", y = "Frequency") +
theme_minimal()+ggtitle("Outlier Analysis for Variables For Online Mode")
# Print the histogram grid
print(hist_grid)
#Outlier analysis for INTRINSIC motivation type
# Load the required packages
library(ggplot2)
library(tidyr)
# Assuming your data is loaded into a dataframe called 'data'
# Replace 'data' with your actual dataframe name
# List of numerical variable names with double quotes
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness","SUS", "AT2 article summary Wk 5?", "AT 3: Critical appraisal essay Wk9","TOTAL","IM_Percentage", "EM_Percentage")
# Reshape the data into a long format
data_long <- complete_data %>%filter(Motivation_Type=="INTRINSIC")%>%pivot_longer(cols = all_of(numerical_vars))
# Create a grid of histograms
hist_grid <- ggplot(data_long, aes(x = value)) +
geom_boxplot(fill = "#6f2da8", color = "black") +
facet_wrap(~ name, scales = "free") +
labs(x = "Value", y = "Frequency") +
theme_minimal()+ggtitle("Outlier Analysis for Variables Intrinsic Motivation")
# Print the histogram grid
print(hist_grid)
library(psych)
## Warning: package 'psych' was built under R version 4.3.1
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
describe(complete_data[,c("ATAR", "Course Weighted Average","Age","IMI Total","AT2 article summary Wk 5?","AT 3: Critical appraisal essay Wk9","IM_Percentage", "EM_Percentage","TOTAL")])
#storing the cleaned dataset
write_xlsx(complete_data, path = "C:\\Users\\Angat\\Downloads\\hybrid_teaching_cleaned.xlsx")
#Statistical testing
#Statistical test to check pvalues for different groups for AT3
atar_hybrid <- complete_data$Age[complete_data$Mode == "Hybrid/Class.com"]
atar_online <- complete_data$Age[complete_data$Mode == "Online/Zoom"]
# Perform Mann-Whitney U test
result <- wilcox.test(atar_hybrid, atar_online)
## Warning in wilcox.test.default(atar_hybrid, atar_online): cannot compute exact
## p-value with ties
# Print the result
print(result$p.value)
## [1] 0.3575078
#Like Mode we can use different col names and their values to test against AT3
perform_stat_test <- function(data, variable, grouping_variable) {
# Shapiro-Wilk Test for Normality
shapiro_test_result <- shapiro.test(data[[variable]])
if (shapiro_test_result$p.value < 0.05) {
cat("For ",grouping_variable,"\n")
cat("The variable", variable, "is not normally distributed.\n p-value:", shapiro_test_result$p.value)
# Mann-Whitney U Test
mwu_test_result <- wilcox.test(data[[variable]] ~ data[[grouping_variable]])
# Print the Mann-Whitney U test results
print(mwu_test_result)
# Provide insights based on p-value
if (mwu_test_result$p.value < 0.05) {
cat("Based on the Mann-Whitney U test, there is a statistically significant difference in", variable, "between groups for .\n")
} else {
cat("Based on the Mann-Whitney U test, there is no statistically significant difference in", variable, "between groups.\n")
}
} else {
cat("The variable", variable, "is normally distributed.\n p-value:", shapiro_test_result$p.value)
# Independent Samples t-test
t_test_result <- t.test(data[[variable]] ~ data[[grouping_variable]])
# Print the t-test results
print(t_test_result)
# Provide insights based on p-value
if (t_test_result$p.value < 0.05) {
cat("Based on the Independent Samples t-test, there is a statistically significant difference in", variable, "between groups.\n")
} else {
cat("Based on the Independent Samples t-test, there is no statistically significant difference in", variable, "between groups.\n")
}
}
}
#Stat test between Mode and AT3
perform_stat_test(complete_data, "AT 3: Critical appraisal essay Wk9", "Mode")
## For Mode
## The variable AT 3: Critical appraisal essay Wk9 is not normally distributed.
## p-value: 0.0007149615
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: data[[variable]] by data[[grouping_variable]]
## W = 1178.5, p-value = 0.1205
## alternative hypothesis: true location shift is not equal to 0
##
## Based on the Mann-Whitney U test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
perform_stat_test(complete_data, "AT 3: Critical appraisal essay Wk9", "Motivation_Type")
## For Motivation_Type
## The variable AT 3: Critical appraisal essay Wk9 is not normally distributed.
## p-value: 0.0007149615
## Wilcoxon rank sum test with continuity correction
##
## data: data[[variable]] by data[[grouping_variable]]
## W = 900.5, p-value = 0.6842
## alternative hypothesis: true location shift is not equal to 0
##
## Based on the Mann-Whitney U test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
perform_stat_test(complete_data, "AT 3: Critical appraisal essay Wk9","Like_Hybrid")
## For Like_Hybrid
## The variable AT 3: Critical appraisal essay Wk9 is not normally distributed.
## p-value: 0.0007149615
## Wilcoxon rank sum test with continuity correction
##
## data: data[[variable]] by data[[grouping_variable]]
## W = 802, p-value = 0.8816
## alternative hypothesis: true location shift is not equal to 0
##
## Based on the Mann-Whitney U test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
perform_stat_test(complete_data, "AT 3: Critical appraisal essay Wk9","Gender")
## For Gender
## The variable AT 3: Critical appraisal essay Wk9 is not normally distributed.
## p-value: 0.0007149615
## Wilcoxon rank sum test with continuity correction
##
## data: data[[variable]] by data[[grouping_variable]]
## W = 818, p-value = 0.3169
## alternative hypothesis: true location shift is not equal to 0
##
## Based on the Mann-Whitney U test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
# Filter the data for Intrinsic motivation type
intrinsic_data <- complete_data %>%
filter(Motivation_Type == "INTRINSIC")
# Perform your statistical test on the filtered data
perform_stat_test(intrinsic_data, "AT 3: Critical appraisal essay Wk9", "Mode")
## The variable AT 3: Critical appraisal essay Wk9 is normally distributed.
## p-value: 0.6156469
## Welch Two Sample t-test
##
## data: data[[variable]] by data[[grouping_variable]]
## t = 2.6471, df = 56.44, p-value = 0.0105
## alternative hypothesis: true difference in means between group Hybrid/Class.com and group Online/Zoom is not equal to 0
## 95 percent confidence interval:
## 1.740724 12.564652
## sample estimates:
## mean in group Hybrid/Class.com mean in group Online/Zoom
## 78.41935 71.26667
##
## Based on the Independent Samples t-test, there is a statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
# Filter the data for Extrinsic motivation type
extrinsic_data <- complete_data %>%
filter(Motivation_Type == "EXTRINSIC")
# Perform your statistical test on the filtered data
perform_stat_test(extrinsic_data, "AT 3: Critical appraisal essay Wk9", "Mode")
## For Mode
## The variable AT 3: Critical appraisal essay Wk9 is not normally distributed.
## p-value: 0.001434532
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: data[[variable]] by data[[grouping_variable]]
## W = 79, p-value = 0.4061
## alternative hypothesis: true location shift is not equal to 0
##
## Based on the Mann-Whitney U test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
# Filter the data for Like Hybrid
love_hybrid <- complete_data %>%
filter(Like_Hybrid == "YES")
# Perform your statistical test on the filtered data
perform_stat_test(love_hybrid, "AT 3: Critical appraisal essay Wk9", "Mode")
## For Mode
## The variable AT 3: Critical appraisal essay Wk9 is not normally distributed.
## p-value: 0.0008998547
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: data[[variable]] by data[[grouping_variable]]
## W = 569, p-value = 0.2772
## alternative hypothesis: true location shift is not equal to 0
##
## Based on the Mann-Whitney U test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
# Filter the data for dont Like Hybrid
dont_love_hybrid <- complete_data %>%
filter(Like_Hybrid == "NO")
# Perform your statistical test on the filtered data
perform_stat_test(dont_love_hybrid, "AT 3: Critical appraisal essay Wk9", "Mode")
## The variable AT 3: Critical appraisal essay Wk9 is normally distributed.
## p-value: 0.7125226
## Welch Two Sample t-test
##
## data: data[[variable]] by data[[grouping_variable]]
## t = 1.284, df = 21.874, p-value = 0.2126
## alternative hypothesis: true difference in means between group Hybrid/Class.com and group Online/Zoom is not equal to 0
## 95 percent confidence interval:
## -3.791261 16.106412
## sample estimates:
## mean in group Hybrid/Class.com mean in group Online/Zoom
## 78.09091 71.93333
##
## Based on the Independent Samples t-test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
# Filter the data for dont Like Hybrid
hybrid_learning <- complete_data %>%
filter(Mode == "Hybrid/Class.com")
#Stat test between Gender and AT3
perform_stat_test(hybrid_learning, "AT 3: Critical appraisal essay Wk9", "Gender")
## For Gender
## The variable AT 3: Critical appraisal essay Wk9 is not normally distributed.
## p-value: 0.0008149351
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: data[[variable]] by data[[grouping_variable]]
## W = 213.5, p-value = 0.8217
## alternative hypothesis: true location shift is not equal to 0
##
## Based on the Mann-Whitney U test, there is no statistically significant difference in AT 3: Critical appraisal essay Wk9 between groups.
table <- table(complete_data$Mode,complete_data$Motivation_Type)
# Chi-square test
test_result <- fisher.test(table)
# Print the result
print(test_result)
##
## Fisher's Exact Test for Count Data
##
## data: table
## p-value = 0.8237
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.4150904 3.0250859
## sample estimates:
## odds ratio
## 1.115242
table <- table(complete_data$Mode,complete_data$Like_Hybrid)
# Chi-square test
test_result <- fisher.test(table)
# Print the result
print(test_result)
##
## Fisher's Exact Test for Count Data
##
## data: table
## p-value = 0.3512
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.2086007 1.6249698
## sample estimates:
## odds ratio
## 0.5902404
table <- table(complete_data$Like_Hybrid,complete_data$Motivation_Type)
# Chi-square test
test_result <- fisher.test(table)
# Print the result
print(test_result)
##
## Fisher's Exact Test for Count Data
##
## data: table
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.3058587 2.8069536
## sample estimates:
## odds ratio
## 0.9560346
table <- table(complete_data$Gender,complete_data$Motivation_Type)
# Chi-square test
test_result <- fisher.test(table)
# Print the result
print(test_result)
##
## Fisher's Exact Test for Count Data
##
## data: table
## p-value = 0.2818
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.1683795 1.6438627
## sample estimates:
## odds ratio
## 0.5211097
write.csv(complete_data, file ="C:\\Users\\Angat\\OneDrive\\Desktop\\STM5IPL_HYBRID_LEARNING\\hybrid_dataset.csv", row.names = FALSE)
#Transforming nominal categorical variables
complete_data$Gender <- factor(complete_data$Gender, labels = c(0, 1))
complete_data$Campus_transformed <- as.numeric(factor(ifelse(complete_data$Campus == "Bundoora", 0, 1) ) )
complete_data$Age_Group <- ifelse(complete_data$Age <= 19,1,0)
#Transforming binary categorical variables
regression_data<-complete_data
regression_data$Mode<- as.numeric(factor(regression_data$Mode, labels = c(0, 1)))
regression_data$Gender <- as.numeric(factor(regression_data$Gender, labels = c(0, 1)))
regression_data$Motivation_Type<- as.numeric(factor(regression_data$Motivation_Type, labels = c(0, 1)))
regression_data$Like_Hybrid<- as.numeric(factor(regression_data$Like_Hybrid, labels = c(0, 1)))
# List of numerical variable names with double quotes
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness", "AT2 article summary Wk 5?", "AT 3: Critical appraisal essay Wk9","TOTAL","IM_Percentage", "EM_Percentage")
# Reshape the data into a long format
data_long <- regression_data %>%
pivot_longer(cols = all_of(numerical_vars))
# Create a grid of histograms
hist_grid <- ggplot(data_long, aes(x = value)) +
geom_histogram(bins = 20, fill = "#3498db", color = "black") +
facet_wrap(~ name, scales = "free") +
labs(x = "Value", y = "Frequency") +
ggtitle("Distribution of Variables")+
theme_minimal()
# Print the histogram grid
print(hist_grid)
# Assuming your data is loaded into a dataframe called 'regression_data'
# Replace 'regression_data' with your actual dataframe name
# Add a unique identifier to the original data
regression_data <- regression_data %>% mutate(id = row_number())
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness", "AT2 article summary Wk 5?","IM_Percentage", "EM_Percentage")
# Reshape the data into a long format and add a unique identifier
data_long <- regression_data %>%
pivot_longer(cols = all_of(numerical_vars), names_to = "Variable", values_to = "Value") %>%
mutate(id = rep(regression_data$id, length(numerical_vars)))
# Join with the original data to bring in the "AT 3: Critical appraisal essay Wk9" values
data_long <- left_join(data_long, dplyr::select(regression_data, id, `AT 3: Critical appraisal essay Wk9`), by = "id")
target<-data_long$`AT 3: Critical appraisal essay Wk9.x`
# Create a grid of scatter plots with linear lines
scatter_grid <- ggplot(data_long, aes(x = target, y = Value)) +
geom_point(aes(color = Variable), alpha = 0.6) +
geom_smooth(method = "lm", se = FALSE, aes(color = Variable)) +
facet_wrap(~ Variable, scales = "free") +
labs(x = "AT 3: Critical appraisal essay Wk9", y = "Value") +
ggtitle("Correlation Between Independent and AT3 variable",subtitle = "Assesing linear relationship to confirm Regression assumption")
theme_minimal()
## List of 97
## $ line :List of 6
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ lineend : chr "butt"
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ rect :List of 5
## ..$ fill : chr "white"
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_rect" "element"
## $ text :List of 11
## ..$ family : chr ""
## ..$ face : chr "plain"
## ..$ colour : chr "black"
## ..$ size : num 11
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : num 0
## ..$ lineheight : num 0.9
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ title : NULL
## $ aspect.ratio : NULL
## $ axis.title : NULL
## $ axis.title.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.75points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.75points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.bottom : NULL
## $ axis.title.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.75points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.y.left : NULL
## $ axis.title.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.75points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey30"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.2points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.2points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.bottom : NULL
## $ axis.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 1
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.2points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.y.left : NULL
## $ axis.text.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.2points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.ticks : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.ticks.x : NULL
## $ axis.ticks.x.top : NULL
## $ axis.ticks.x.bottom : NULL
## $ axis.ticks.y : NULL
## $ axis.ticks.y.left : NULL
## $ axis.ticks.y.right : NULL
## $ axis.ticks.length : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ axis.ticks.length.x : NULL
## $ axis.ticks.length.x.top : NULL
## $ axis.ticks.length.x.bottom: NULL
## $ axis.ticks.length.y : NULL
## $ axis.ticks.length.y.left : NULL
## $ axis.ticks.length.y.right : NULL
## $ axis.line : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.line.x : NULL
## $ axis.line.x.top : NULL
## $ axis.line.x.bottom : NULL
## $ axis.line.y : NULL
## $ axis.line.y.left : NULL
## $ axis.line.y.right : NULL
## $ legend.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ legend.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ legend.spacing.x : NULL
## $ legend.spacing.y : NULL
## $ legend.key : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.key.size : 'simpleUnit' num 1.2lines
## ..- attr(*, "unit")= int 3
## $ legend.key.height : NULL
## $ legend.key.width : NULL
## $ legend.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.text.align : NULL
## $ legend.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.title.align : NULL
## $ legend.position : chr "right"
## $ legend.direction : NULL
## $ legend.justification : chr "center"
## $ legend.box : NULL
## $ legend.box.just : NULL
## $ legend.box.margin : 'margin' num [1:4] 0cm 0cm 0cm 0cm
## ..- attr(*, "unit")= int 1
## $ legend.box.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.box.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ panel.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.border : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.spacing : 'simpleUnit' num 5.5points
## ..- attr(*, "unit")= int 8
## $ panel.spacing.x : NULL
## $ panel.spacing.y : NULL
## $ panel.grid :List of 6
## ..$ colour : chr "grey92"
## ..$ linewidth : NULL
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major : NULL
## $ panel.grid.minor :List of 6
## ..$ colour : NULL
## ..$ linewidth : 'rel' num 0.5
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major.x : NULL
## $ panel.grid.major.y : NULL
## $ panel.grid.minor.x : NULL
## $ panel.grid.minor.y : NULL
## $ panel.ontop : logi FALSE
## $ plot.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ plot.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.title.position : chr "panel"
## $ plot.subtitle :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : num 1
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 5.5points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption.position : chr "panel"
## $ plot.tag :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.tag.position : chr "topleft"
## $ plot.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ strip.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ strip.background.x : NULL
## $ strip.background.y : NULL
## $ strip.clip : chr "inherit"
## $ strip.placement : chr "inside"
## $ strip.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey10"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 4.4points 4.4points 4.4points 4.4points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.x : NULL
## $ strip.text.x.bottom : NULL
## $ strip.text.x.top : NULL
## $ strip.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.y.left :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.y.right : NULL
## $ strip.switch.pad.grid : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ strip.switch.pad.wrap : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## - attr(*, "class")= chr [1:2] "theme" "gg"
## - attr(*, "complete")= logi TRUE
## - attr(*, "validate")= logi TRUE
# Print the scatter plot grid
print(scatter_grid)
## `geom_smooth()` using formula = 'y ~ x'
# List of numerical variable names with double quotes
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness","SUS", "AT2 article summary Wk 5?","TOTAL","IM_Percentage", "EM_Percentage")
regression_data$`AT 3: Critical appraisal essay Wk9` <- log(regression_data$`AT 3: Critical appraisal essay Wk9`)
# Load the required packages
# Assuming your data is loaded into a dataframe called 'regression_data'
# Replace 'regression_data' with your actual dataframe name
# Add a unique identifier to the original data
regression_data <- regression_data %>% mutate(id = row_number())
numerical_vars <- c("ATAR", "Course Weighted Average", "Age", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness", "AT2 article summary Wk 5?","IM_Percentage", "EM_Percentage")
# Reshape the data into a long format and add a unique identifier
data_long <- regression_data %>%
pivot_longer(cols = all_of(numerical_vars), names_to = "Variable", values_to = "Value") %>%
mutate(id = rep(regression_data$id, length(numerical_vars)))
# Join with the original data to bring in the "AT 3: Critical appraisal essay Wk9" values
data_long <- left_join(data_long, dplyr::select(regression_data, id, `AT 3: Critical appraisal essay Wk9`), by = "id")
target<-data_long$`AT 3: Critical appraisal essay Wk9.x`
# Create a grid of scatter plots with linear lines
scatter_grid <- ggplot(data_long, aes(x = target, y = Value)) +
geom_point(aes(color = Variable), alpha = 0.6) +
geom_smooth(method = "lm", se = FALSE, aes(color = Variable)) +
facet_wrap(~ Variable, scales = "free") +
labs(x = "AT 3: Critical appraisal essay Wk9", y = "Value") +
ggtitle("Correlation Between Independent and AT3 variable",subtitle = "Assesing linear relationship to confirm Regression assumption After log transformation")
theme_minimal()
## List of 97
## $ line :List of 6
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ lineend : chr "butt"
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ rect :List of 5
## ..$ fill : chr "white"
## ..$ colour : chr "black"
## ..$ linewidth : num 0.5
## ..$ linetype : num 1
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_rect" "element"
## $ text :List of 11
## ..$ family : chr ""
## ..$ face : chr "plain"
## ..$ colour : chr "black"
## ..$ size : num 11
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : num 0
## ..$ lineheight : num 0.9
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ title : NULL
## $ aspect.ratio : NULL
## $ axis.title : NULL
## $ axis.title.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.75points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.75points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.x.bottom : NULL
## $ axis.title.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.75points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.title.y.left : NULL
## $ axis.title.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.75points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey30"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 2.2points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.top :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : num 0
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 2.2points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.x.bottom : NULL
## $ axis.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 1
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 2.2points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.text.y.left : NULL
## $ axis.text.y.right :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 0points 2.2points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ axis.ticks : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.ticks.x : NULL
## $ axis.ticks.x.top : NULL
## $ axis.ticks.x.bottom : NULL
## $ axis.ticks.y : NULL
## $ axis.ticks.y.left : NULL
## $ axis.ticks.y.right : NULL
## $ axis.ticks.length : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ axis.ticks.length.x : NULL
## $ axis.ticks.length.x.top : NULL
## $ axis.ticks.length.x.bottom: NULL
## $ axis.ticks.length.y : NULL
## $ axis.ticks.length.y.left : NULL
## $ axis.ticks.length.y.right : NULL
## $ axis.line : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ axis.line.x : NULL
## $ axis.line.x.top : NULL
## $ axis.line.x.bottom : NULL
## $ axis.line.y : NULL
## $ axis.line.y.left : NULL
## $ axis.line.y.right : NULL
## $ legend.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ legend.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ legend.spacing.x : NULL
## $ legend.spacing.y : NULL
## $ legend.key : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.key.size : 'simpleUnit' num 1.2lines
## ..- attr(*, "unit")= int 3
## $ legend.key.height : NULL
## $ legend.key.width : NULL
## $ legend.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.text.align : NULL
## $ legend.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ legend.title.align : NULL
## $ legend.position : chr "right"
## $ legend.direction : NULL
## $ legend.justification : chr "center"
## $ legend.box : NULL
## $ legend.box.just : NULL
## $ legend.box.margin : 'margin' num [1:4] 0cm 0cm 0cm 0cm
## ..- attr(*, "unit")= int 1
## $ legend.box.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ legend.box.spacing : 'simpleUnit' num 11points
## ..- attr(*, "unit")= int 8
## $ panel.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.border : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ panel.spacing : 'simpleUnit' num 5.5points
## ..- attr(*, "unit")= int 8
## $ panel.spacing.x : NULL
## $ panel.spacing.y : NULL
## $ panel.grid :List of 6
## ..$ colour : chr "grey92"
## ..$ linewidth : NULL
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major : NULL
## $ panel.grid.minor :List of 6
## ..$ colour : NULL
## ..$ linewidth : 'rel' num 0.5
## ..$ linetype : NULL
## ..$ lineend : NULL
## ..$ arrow : logi FALSE
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_line" "element"
## $ panel.grid.major.x : NULL
## $ panel.grid.major.y : NULL
## $ panel.grid.minor.x : NULL
## $ panel.grid.minor.y : NULL
## $ panel.ontop : logi FALSE
## $ plot.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ plot.title :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.title.position : chr "panel"
## $ plot.subtitle :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 0
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 0points 0points 5.5points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 0.8
## ..$ hjust : num 1
## ..$ vjust : num 1
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 5.5points 0points 0points 0points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.caption.position : chr "panel"
## $ plot.tag :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : 'rel' num 1.2
## ..$ hjust : num 0.5
## ..$ vjust : num 0.5
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.tag.position : chr "topleft"
## $ plot.margin : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
## ..- attr(*, "unit")= int 8
## $ strip.background : list()
## ..- attr(*, "class")= chr [1:2] "element_blank" "element"
## $ strip.background.x : NULL
## $ strip.background.y : NULL
## $ strip.clip : chr "inherit"
## $ strip.placement : chr "inside"
## $ strip.text :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : chr "grey10"
## ..$ size : 'rel' num 0.8
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : 'margin' num [1:4] 4.4points 4.4points 4.4points 4.4points
## .. ..- attr(*, "unit")= int 8
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.x : NULL
## $ strip.text.x.bottom : NULL
## $ strip.text.x.top : NULL
## $ strip.text.y :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num -90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.y.left :List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : num 90
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi TRUE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ strip.text.y.right : NULL
## $ strip.switch.pad.grid : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## $ strip.switch.pad.wrap : 'simpleUnit' num 2.75points
## ..- attr(*, "unit")= int 8
## - attr(*, "class")= chr [1:2] "theme" "gg"
## - attr(*, "complete")= logi TRUE
## - attr(*, "validate")= logi TRUE
# Print the scatter plot grid
print(scatter_grid)
## `geom_smooth()` using formula = 'y ~ x'
#Removing unwanted variables for linear regression modelling to avoid multicollinearity
lin_regression_data<-dplyr::select(regression_data,-c(Campus,`Region origin`,AT3_Performance,AT3_Median_Performance,TOTAL,TOTAL_Performance,SUS,`IMI - Interest/Enjoyment`,`IMI - Perceived Competence`,`IMI - Effort/Importance`,`IMI - Perceived Choice`,`IMI - Value/Usefulness`,`IMI - Relatedness`,`IMI Total`,EM_Percentage,Like_Hybrid,id,`Course Weighted Average`))
numerical_vars <- c("ATAR", "Course Weighted Average", "Age_Group", "IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness", "AT2 article summary Wk 5?","IM_Percentage","EM_Percentage","TOTAL","Gender","Motivation_Type","Campus_transformed","AT 3: Critical appraisal essay Wk9")
# Calculate the correlation matrix
correlation_matrix <- cor(regression_data[,numerical_vars])
# Create a correlation matrix plot using corrplot with labels
corrplot(correlation_matrix, method = "color", type = "upper", tl.col = "black", tl.srt = 45,
tl.cex = 0.7, addCoef.col = "black", number.cex = 0.5)
#Correlation plot after removing independent variables that were highly correlated among themsleves
numerical_vars <- c("Mode","ATAR",
"Age_Group","Gender","AT2 article summary Wk 5?","IMI - Pressure/Tension","IM_Percentage",
"Motivation_Type","Campus_transformed","AT 3: Critical appraisal essay Wk9")
# Calculate the correlation matrix
correlation_matrix <- cor(regression_data[,numerical_vars])
# Create a correlation matrix plot using corrplot with labels
corrplot(correlation_matrix, method = "color", type = "upper", tl.col = "black", tl.srt = 45,
tl.cex = 0.7, addCoef.col = "black", number.cex = 0.5)
# Function to calculate RMSE for a linear regression model
calculate_RMSE <- function(model, data, target_column) {
# Step 1: Predict values using the model
predicted_values <- predict(model, newdata = data)
# Step 2: Calculate the residuals
residuals <- data[[target_column]] - predicted_values
# Step 3: Square the residuals
squared_residuals <- residuals^2
# Step 4: Take the mean of squared residuals
mean_squared_residuals <- mean(squared_residuals)
# Step 5: Take the square root
RMSE <- sqrt(mean_squared_residuals)
# Print RMSE
print(paste("Root Mean Square Error (RMSE): ", RMSE))
}
#function to get regression details
get_regression_summary <- function(model) {
# Extract coefficients, standard errors, and p-values
coefficients <- coef(summary(model))
# Calculate the 95% confidence intervals
CI_lower <- coefficients[, "Estimate"] - 1.96 * coefficients[, "Std. Error"]
CI_upper <- coefficients[, "Estimate"] + 1.96 * coefficients[, "Std. Error"]
# Combine the results into a data frame
results <- data.frame(
Coefficient = coefficients[, "Estimate"],
CI_Lower = CI_lower,
CI_Upper = CI_upper,
P_Value = coefficients[, "Pr(>|t|)"]
)
return(results)
}
#function to calculate rsq for trees
calculate_rsq <- function(model, data, target_column) {
# Predict using the model
predicted_values <- predict(model, data)
# Calculate TSS and RSS
TSS <- sum((data[[target_column]] - mean(data[[target_column]]))^2)
RSS <- sum((data[[target_column]] - predicted_values)^2)
# Calculate R^2
R2 <- (RSS/TSS)
return(R2)
}
#function to calculate adj rsq for trees
calculate_adj_rsq<-function(data,k,model,target_column){
R2<-calculate_rsq(model,data,target_column)
adj.rsq<-1-((1-R2)*(nrow(data)/(nrow(data)-k-1)))
return(adj.rsq)
}
# Perform linear regression
model <- lm(`AT 3: Critical appraisal essay Wk9` ~ .-1,data = lin_regression_data)
# Print the model summary
summary(model)
##
## Call:
## lm(formula = `AT 3: Critical appraisal essay Wk9` ~ . - 1, data = lin_regression_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7182 -0.2027 0.0203 0.2399 0.8574
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## Mode 0.170110 0.070467 2.414 0.01809 *
## ATAR 0.011189 0.001914 5.846 1.08e-07 ***
## Age 0.009247 0.005653 1.636 0.10584
## Gender 0.261119 0.080417 3.247 0.00171 **
## `IMI - Pressure/Tension` 0.035386 0.011278 3.138 0.00239 **
## `AT2 article summary Wk 5?` 0.084012 0.012779 6.574 4.82e-09 ***
## IM_Percentage 0.005526 0.003271 1.689 0.09510 .
## Motivation_Type 0.171521 0.081384 2.108 0.03824 *
## Campus_transformed 0.188964 0.080311 2.353 0.02112 *
## Age_Group 0.152844 0.081024 1.886 0.06292 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3282 on 79 degrees of freedom
## Multiple R-squared: 0.9948, Adjusted R-squared: 0.9942
## F-statistic: 1514 on 10 and 79 DF, p-value: < 2.2e-16
get_regression_summary(model)
# Generate diagnostic plots
par(mfrow=c(2,2)) # Arrange plots in a 2x2 grid
plot(model)
calculate_RMSE(model, lin_regression_data, 'AT 3: Critical appraisal essay Wk9')
## [1] "Root Mean Square Error (RMSE): 0.309182039012836"
# Perform stepwise regression
stepwise_model <- step(model, direction = "both")
## Start: AIC=-188.94
## `AT 3: Critical appraisal essay Wk9` ~ (Mode + ATAR + Age + Gender +
## `IMI - Pressure/Tension` + `AT2 article summary Wk 5?` +
## IM_Percentage + Motivation_Type + Campus_transformed + Age_Group) -
## 1
##
## Df Sum of Sq RSS AIC
## <none> 8.5078 -188.94
## - Age 1 0.2882 8.7960 -187.98
## - IM_Percentage 1 0.3073 8.8152 -187.78
## - Age_Group 1 0.3832 8.8911 -187.02
## - Motivation_Type 1 0.4784 8.9862 -186.07
## - Campus_transformed 1 0.5962 9.1040 -184.91
## - Mode 1 0.6276 9.1354 -184.61
## - `IMI - Pressure/Tension` 1 1.0602 9.5680 -180.49
## - Gender 1 1.1355 9.6433 -179.79
## - ATAR 1 3.6810 12.1888 -158.94
## - `AT2 article summary Wk 5?` 1 4.6543 13.1621 -152.10
# Summary of the selected model
summary(stepwise_model)
##
## Call:
## lm(formula = `AT 3: Critical appraisal essay Wk9` ~ (Mode + ATAR +
## Age + Gender + `IMI - Pressure/Tension` + `AT2 article summary Wk 5?` +
## IM_Percentage + Motivation_Type + Campus_transformed + Age_Group) -
## 1, data = lin_regression_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7182 -0.2027 0.0203 0.2399 0.8574
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## Mode 0.170110 0.070467 2.414 0.01809 *
## ATAR 0.011189 0.001914 5.846 1.08e-07 ***
## Age 0.009247 0.005653 1.636 0.10584
## Gender 0.261119 0.080417 3.247 0.00171 **
## `IMI - Pressure/Tension` 0.035386 0.011278 3.138 0.00239 **
## `AT2 article summary Wk 5?` 0.084012 0.012779 6.574 4.82e-09 ***
## IM_Percentage 0.005526 0.003271 1.689 0.09510 .
## Motivation_Type 0.171521 0.081384 2.108 0.03824 *
## Campus_transformed 0.188964 0.080311 2.353 0.02112 *
## Age_Group 0.152844 0.081024 1.886 0.06292 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3282 on 79 degrees of freedom
## Multiple R-squared: 0.9948, Adjusted R-squared: 0.9942
## F-statistic: 1514 on 10 and 79 DF, p-value: < 2.2e-16
# Generate diagnostic plots
par(mfrow=c(2,2)) # Arrange plots in a 2x2 grid
plot(stepwise_model)
calculate_RMSE(stepwise_model, lin_regression_data, 'AT 3: Critical appraisal essay Wk9')
## [1] "Root Mean Square Error (RMSE): 0.309182039012836"
# Fit the model with interaction terms
linear_interaction_model <- lm(`AT 3: Critical appraisal essay Wk9` ~ (Mode * Motivation_Type + ATAR*Motivation_Type+ATAR*`AT2 article summary Wk 5?`)-1, data = lin_regression_data)
# # Summary of the model
summary(linear_interaction_model)
##
## Call:
## lm(formula = `AT 3: Critical appraisal essay Wk9` ~ (Mode * Motivation_Type +
## ATAR * Motivation_Type + ATAR * `AT2 article summary Wk 5?`) -
## 1, data = lin_regression_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.85029 -0.11522 0.02779 0.11944 0.54215
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## Mode 0.4505968 0.1648032 2.734 0.007661 **
## Motivation_Type 1.0629547 0.2709643 3.923 0.000181 ***
## ATAR 0.0450105 0.0040527 11.106 < 2e-16 ***
## `AT2 article summary Wk 5?` 0.1272550 0.0287986 4.419 3.01e-05 ***
## Mode:Motivation_Type -0.2681121 0.0943388 -2.842 0.005655 **
## Motivation_Type:ATAR -0.0082672 0.0029823 -2.772 0.006891 **
## ATAR:`AT2 article summary Wk 5?` -0.0015573 0.0003892 -4.002 0.000137 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2095 on 82 degrees of freedom
## Multiple R-squared: 0.9978, Adjusted R-squared: 0.9976
## F-statistic: 5325 on 7 and 82 DF, p-value: < 2.2e-16
get_regression_summary(linear_interaction_model)
# # Generate diagnostic plots
par(mfrow=c(2,2)) # Arrange plots in a 2x2 grid
plot(linear_interaction_model)
calculate_RMSE(linear_interaction_model, lin_regression_data, 'AT 3: Critical appraisal essay Wk9')
## [1] "Root Mean Square Error (RMSE): 0.201070787459201"
# List of IMI subscales vs AT3 for moderator analysis
regression_data_mod <- dplyr::select(regression_data,-Age)
imi_subscales <- c("IMI - Interest/Enjoyment","IMI - Perceived Competence","IMI - Effort/Importance","IMI - Pressure/Tension","IMI - Perceived Choice","IMI - Value/Usefulness","IMI - Relatedness")
# Loop through each IMI subscale and run the moderator analysis
for(subscale in imi_subscales) {
formula_str <- paste("`AT 3: Critical appraisal essay Wk9` ~ ATAR * `", subscale, "`","-1", sep = "")
fit <- lm(formula_str, data = regression_data_mod) # Note the data argument here
# Call the calculate_RMSE function for each fit
print(paste("Moderator Analysis for", subscale))
print(summary(fit))
print(get_regression_summary(fit))
calculate_RMSE(fit, regression_data_mod, "AT 3: Critical appraisal essay Wk9")
}
## [1] "Moderator Analysis for IMI - Interest/Enjoyment"
##
## Call:
## lm(formula = formula_str, data = regression_data_mod)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.1803 -0.1471 0.0482 0.2039 1.8421
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.0553617 0.0019061 29.05 <2e-16 ***
## `IMI - Interest/Enjoyment` 0.2081706 0.0098451 21.14 <2e-16 ***
## ATAR:`IMI - Interest/Enjoyment` -0.0027132 0.0001843 -14.72 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3579 on 86 degrees of freedom
## Multiple R-squared: 0.9933, Adjusted R-squared: 0.993
## F-statistic: 4237 on 3 and 86 DF, p-value: < 2.2e-16
##
## Coefficient CI_Lower CI_Upper
## ATAR 0.055361736 0.051625876 0.059097597
## `IMI - Interest/Enjoyment` 0.208170557 0.188874094 0.227467020
## ATAR:`IMI - Interest/Enjoyment` -0.002713169 -0.003074361 -0.002351976
## P_Value
## ATAR 3.163534e-46
## `IMI - Interest/Enjoyment` 7.974137e-36
## ATAR:`IMI - Interest/Enjoyment` 3.161978e-25
## [1] "Root Mean Square Error (RMSE): 0.351831488553872"
## [1] "Moderator Analysis for IMI - Perceived Competence"
##
## Call:
## lm(formula = formula_str, data = regression_data_mod)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.97209 -0.13306 0.04104 0.16412 0.44532
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.0566410 0.0018907 29.96 <2e-16 ***
## `IMI - Perceived Competence` 0.2484190 0.0078508 31.64 <2e-16 ***
## ATAR:`IMI - Perceived Competence` -0.0032699 0.0001538 -21.26 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2516 on 86 degrees of freedom
## Multiple R-squared: 0.9967, Adjusted R-squared: 0.9966
## F-statistic: 8605 on 3 and 86 DF, p-value: < 2.2e-16
##
## Coefficient CI_Lower CI_Upper
## ATAR 0.056640956 0.05293518 0.060346732
## `IMI - Perceived Competence` 0.248419049 0.23303155 0.263806551
## ATAR:`IMI - Perceived Competence` -0.003269881 -0.00357135 -0.002968412
## P_Value
## ATAR 2.803674e-47
## `IMI - Perceived Competence` 3.732866e-49
## ATAR:`IMI - Perceived Competence` 5.393075e-36
## [1] "Root Mean Square Error (RMSE): 0.247303866103271"
## [1] "Moderator Analysis for IMI - Effort/Importance"
##
## Call:
## lm(formula = formula_str, data = regression_data_mod)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.99722 -0.15899 0.00599 0.20501 0.56078
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.0543044 0.0017477 31.07 <2e-16 ***
## `IMI - Effort/Importance` 0.3584687 0.0118973 30.13 <2e-16 ***
## ATAR:`IMI - Effort/Importance` -0.0045313 0.0002419 -18.73 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2636 on 86 degrees of freedom
## Multiple R-squared: 0.9964, Adjusted R-squared: 0.9962
## F-statistic: 7837 on 3 and 86 DF, p-value: < 2.2e-16
##
## Coefficient CI_Lower CI_Upper
## ATAR 0.054304352 0.050878876 0.057729828
## `IMI - Effort/Importance` 0.358468739 0.335150106 0.381787372
## ATAR:`IMI - Effort/Importance` -0.004531323 -0.005005485 -0.004057161
## P_Value
## ATAR 1.576362e-48
## `IMI - Effort/Importance` 1.784312e-47
## ATAR:`IMI - Effort/Importance` 4.259977e-32
## [1] "Root Mean Square Error (RMSE): 0.259089318932842"
## [1] "Moderator Analysis for IMI - Pressure/Tension"
##
## Call:
## lm(formula = formula_str, data = regression_data_mod)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.72683 -0.15247 0.01736 0.20441 1.57200
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.0552960 0.0014471 38.21 <2e-16 ***
## `IMI - Pressure/Tension` 0.4130341 0.0177608 23.25 <2e-16 ***
## ATAR:`IMI - Pressure/Tension` -0.0053117 0.0002789 -19.05 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3332 on 86 degrees of freedom
## Multiple R-squared: 0.9942, Adjusted R-squared: 0.994
## F-statistic: 4894 on 3 and 86 DF, p-value: < 2.2e-16
##
## Coefficient CI_Lower CI_Upper
## ATAR 0.05529600 0.052459596 0.058132409
## `IMI - Pressure/Tension` 0.41303412 0.378222984 0.447845264
## ATAR:`IMI - Pressure/Tension` -0.00531172 -0.005858284 -0.004765155
## P_Value
## ATAR 9.830914e-56
## `IMI - Pressure/Tension` 7.433225e-39
## ATAR:`IMI - Pressure/Tension` 1.325870e-32
## [1] "Root Mean Square Error (RMSE): 0.327520247923084"
## [1] "Moderator Analysis for IMI - Perceived Choice"
##
## Call:
## lm(formula = formula_str, data = regression_data_mod)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.07587 -0.12751 0.01773 0.15807 1.04358
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.0541290 0.0017774 30.45 <2e-16 ***
## `IMI - Perceived Choice` 0.2673911 0.0097462 27.43 <2e-16 ***
## ATAR:`IMI - Perceived Choice` -0.0033662 0.0001857 -18.13 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2871 on 86 degrees of freedom
## Multiple R-squared: 0.9957, Adjusted R-squared: 0.9955
## F-statistic: 6599 on 3 and 86 DF, p-value: < 2.2e-16
##
## Coefficient CI_Lower CI_Upper
## ATAR 0.054129028 0.050645380 0.057612676
## `IMI - Perceived Choice` 0.267391096 0.248288480 0.286493711
## ATAR:`IMI - Perceived Choice` -0.003366222 -0.003730125 -0.003002319
## P_Value
## ATAR 7.684638e-48
## `IMI - Perceived Choice` 2.659295e-44
## ATAR:`IMI - Perceived Choice` 4.004899e-31
## [1] "Root Mean Square Error (RMSE): 0.282264192696926"
## [1] "Moderator Analysis for IMI - Value/Usefulness"
##
## Call:
## lm(formula = formula_str, data = regression_data_mod)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.04790 -0.13697 0.07434 0.16274 1.24184
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.0539609 0.0019476 27.71 <2e-16 ***
## `IMI - Value/Usefulness` 0.2435725 0.0093723 25.99 <2e-16 ***
## ATAR:`IMI - Value/Usefulness` -0.0030530 0.0001785 -17.11 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3021 on 86 degrees of freedom
## Multiple R-squared: 0.9952, Adjusted R-squared: 0.995
## F-statistic: 5960 on 3 and 86 DF, p-value: < 2.2e-16
##
## Coefficient CI_Lower CI_Upper
## ATAR 0.053960879 0.050143639 0.057778119
## `IMI - Value/Usefulness` 0.243572507 0.225202843 0.261942172
## ATAR:`IMI - Value/Usefulness` -0.003053019 -0.003402832 -0.002703207
## P_Value
## ATAR 1.241725e-44
## `IMI - Value/Usefulness` 1.708874e-42
## ATAR:`IMI - Value/Usefulness` 2.035914e-29
## [1] "Root Mean Square Error (RMSE): 0.296921693292781"
## [1] "Moderator Analysis for IMI - Relatedness"
##
## Call:
## lm(formula = formula_str, data = regression_data_mod)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.10996 -0.14677 0.03931 0.18643 0.65551
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.0562007 0.0018619 30.18 <2e-16 ***
## `IMI - Relatedness` 0.2652627 0.0099553 26.64 <2e-16 ***
## ATAR:`IMI - Relatedness` -0.0034785 0.0001862 -18.68 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2955 on 86 degrees of freedom
## Multiple R-squared: 0.9954, Adjusted R-squared: 0.9953
## F-statistic: 6230 on 3 and 86 DF, p-value: < 2.2e-16
##
## Coefficient CI_Lower CI_Upper P_Value
## ATAR 0.056200714 0.052551371 0.059850058 1.549552e-47
## `IMI - Relatedness` 0.265262689 0.245750319 0.284775059 2.525607e-43
## ATAR:`IMI - Relatedness` -0.003478526 -0.003843494 -0.003113558 5.123467e-32
## [1] "Root Mean Square Error (RMSE): 0.2904523239837"
# Build the regression tree
tree_model <- rpart(`AT 3: Critical appraisal essay Wk9` ~ .,
data = lin_regression_data,
method = "anova")
# Plot the decision tree with minimum sample sizes
rpart.plot(tree_model, type = 1, extra = 101)
# Calculate and print R^2 using the custom function
R2_value <- calculate_rsq(tree_model, lin_regression_data, 'AT 3: Critical appraisal essay Wk9')
cat("R-squared:", R2_value, "\n")
## R-squared: 0.6228491
Adj.RSQ<-calculate_adj_rsq(lin_regression_data,ncol(lin_regression_data) - 1,tree_model,'AT 3: Critical appraisal essay Wk9')
cat("Adj.R-squared:", Adj.RSQ, "\n")
## Adj.R-squared: 0.5696612
calculate_RMSE(tree_model,lin_regression_data,'AT 3: Critical appraisal essay Wk9')
## [1] "Root Mean Square Error (RMSE): 0.174307555930623"
printcp(tree_model)
##
## Regression tree:
## rpart(formula = `AT 3: Critical appraisal essay Wk9` ~ ., data = lin_regression_data,
## method = "anova")
##
## Variables actually used in tree construction:
## [1] AT2 article summary Wk 5? ATAR
## [3] Campus_transformed IM_Percentage
## [5] IMI - Pressure/Tension
##
## Root node error: 4.3415/89 = 0.048781
##
## n= 89
##
## CP nsplit rel error xerror xstd
## 1 0.179584 0 1.00000 1.01913 0.31537
## 2 0.078368 1 0.82042 0.95435 0.28168
## 3 0.061670 2 0.74205 1.10305 0.29990
## 4 0.024398 3 0.68038 1.01528 0.29015
## 5 0.016565 4 0.65598 1.10660 0.30665
## 6 0.010000 6 0.62285 1.10195 0.30431
# Calculate and print adjusted R-squared
low_cp<-tree_model$cptable[which.min(tree_model$cptable[,"xerror"]),"CP"]
#This Model of Dtree is better than pruned tree bcoz it has lower RMSE and compared to lin regression also this is better Model.
pruned_tree <- prune(tree_model, cp=0.078368)
rpart.plot(pruned_tree, type = 1, extra = 101)
R2_value <- calculate_rsq(pruned_tree, lin_regression_data, 'AT 3: Critical appraisal essay Wk9')
cat("R-squared:", R2_value, "\n")
## R-squared: 0.7420475
Adj.RSQ<-calculate_adj_rsq(lin_regression_data,ncol(lin_regression_data) - 1,pruned_tree,'AT 3: Critical appraisal essay Wk9')
cat("Adj.R-squared:", Adj.RSQ, "\n")
## Adj.R-squared: 0.7056696
calculate_RMSE(pruned_tree,lin_regression_data,'AT 3: Critical appraisal essay Wk9')
## [1] "Root Mean Square Error (RMSE): 0.190256997774071"
#Select impotrant variables for linear regression using decision tree
variable_importance <- tree_model$variable.importance
print(variable_importance)
## ATAR Campus_transformed IM_Percentage
## 1.16804346 0.34023589 0.19203968
## IMI - Pressure/Tension AT2 article summary Wk 5? Age
## 0.16130291 0.11816814 0.01224213
# Train linear regression model with important variables fron Decison tree Regression
best_lin_model <- lm(`AT 3: Critical appraisal essay Wk9` ~ (ATAR +IM_Percentage+`AT2 article summary Wk 5?`+`IMI - Pressure/Tension`+Campus_transformed)-1,data = lin_regression_data)
# Print the model summary
summary(best_lin_model)
##
## Call:
## lm(formula = `AT 3: Critical appraisal essay Wk9` ~ (ATAR + IM_Percentage +
## `AT2 article summary Wk 5?` + `IMI - Pressure/Tension` +
## Campus_transformed) - 1, data = lin_regression_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.93504 -0.21431 0.03132 0.24436 0.77615
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## ATAR 0.013427 0.002127 6.312 1.24e-08 ***
## IM_Percentage 0.014304 0.003066 4.665 1.15e-05 ***
## `AT2 article summary Wk 5?` 0.096645 0.013900 6.953 7.19e-10 ***
## `IMI - Pressure/Tension` 0.047705 0.012646 3.772 0.00030 ***
## Campus_transformed 0.251439 0.083657 3.006 0.00349 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.376 on 84 degrees of freedom
## Multiple R-squared: 0.9928, Adjusted R-squared: 0.9923
## F-statistic: 2303 on 5 and 84 DF, p-value: < 2.2e-16
calculate_RMSE(best_lin_model, lin_regression_data, 'AT 3: Critical appraisal essay Wk9')
## [1] "Root Mean Square Error (RMSE): 0.365260163323528"
get_regression_summary(best_lin_model)
# Generate diagnostic plots
par(mfrow=c(2,2)) # Arrange plots in a 2x2 grid
plot(best_lin_model)
#SVM regression
model_svm_linear <- svm(`AT 3: Critical appraisal essay Wk9` ~ .,data = lin_regression_data, type = "eps-regression", kernel = "linear")
predictions <- predict(model_svm_linear, newdata =lin_regression_data)
summary(model_svm_linear)
##
## Call:
## svm(formula = `AT 3: Critical appraisal essay Wk9` ~ ., data = lin_regression_data,
## type = "eps-regression", kernel = "linear")
##
##
## Parameters:
## SVM-Type: eps-regression
## SVM-Kernel: linear
## cost: 1
## gamma: 0.1
## epsilon: 0.1
##
##
## Number of Support Vectors: 81
# Assuming you have already fitted the SVM model and made predictions
# Calculate residuals
residuals <- predictions - lin_regression_data$`AT 3: Critical appraisal essay Wk9`
# Calculate MSE
mse <- mean(residuals^2)
# Calculate RMSE
rmse <- sqrt(mse)
print(rmse)
## [1] 0.2031634
# automated tuning of gamma paramter for RBF kernel
tuned_model <- tune.svm(`AT 3: Critical appraisal essay Wk9` ~ .,data = lin_regression_data, type = "eps-regression", kernel = "radial", gamma = 10^(-3:2))
best_model <- tuned_model$best.model
predictions <- predict(best_model, newdata =lin_regression_data)
# Calculate residuals of svm
residuals <- predictions - lin_regression_data$`AT 3: Critical appraisal essay Wk9`
# Calculate MSE
mse <- mean(residuals^2)
# Calculate RMSE
rmse <- sqrt(mse)
print(rmse)
## [1] 0.205446
#Logistic Regression
log_regression_data<-dplyr::select(regression_data,-c(Campus,`Region origin`,`AT 3: Critical appraisal essay Wk9`,AT3_Performance,TOTAL,TOTAL_Performance,SUS,`IMI - Interest/Enjoyment`,`IMI - Perceived Competence`,`IMI - Effort/Importance`,`IMI - Perceived Choice`,`IMI - Value/Usefulness`,`IMI - Relatedness`,`IMI Total`,EM_Percentage,Like_Hybrid,id,`Course Weighted Average`,Age))
model_log <- glm(AT3_Median_Performance ~.-1,data = log_regression_data,family = binomial)
# Print the model summary
summary(model_log)
##
## Call:
## glm(formula = AT3_Median_Performance ~ . - 1, family = binomial,
## data = log_regression_data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## Mode -0.34050 0.48596 -0.701 0.48350
## ATAR 0.04842 0.01580 3.064 0.00218 **
## Gender -0.81903 0.56527 -1.449 0.14736
## `IMI - Pressure/Tension` -0.11491 0.08028 -1.431 0.15233
## `AT2 article summary Wk 5?` 0.15973 0.10056 1.589 0.11217
## IM_Percentage -0.03399 0.02359 -1.440 0.14973
## Motivation_Type -0.49884 0.56664 -0.880 0.37867
## Campus_transformed -0.52310 0.53520 -0.977 0.32838
## Age_Group 0.17763 0.50270 0.353 0.72383
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 123.38 on 89 degrees of freedom
## Residual deviance: 100.47 on 80 degrees of freedom
## AIC: 118.47
##
## Number of Fisher Scoring iterations: 4
# Load necessary libraries
# Assuming you have a logistic regression model named 'model_log'
# Assuming 'regression_data' is your dataframe with the test data
# Make predictions using the logistic regression model
predictions <- predict(model_log, newdata = log_regression_data, type = "response")
# Convert probabilities to class predictions
predicted_classes <- ifelse(predictions > 0.5, 1,0)
# Create a data frame with actual and predicted class labels
confusion_data <- data.frame(Actual = regression_data$AT3_Median_Performance,
Predicted = predicted_classes)
print(paste("Accuracy of Basic Logistic Model is",(sum(confusion_data$Actual==confusion_data$Predicted)/nrow(confusion_data))*100))
## [1] "Accuracy of Basic Logistic Model is 75.2808988764045"
# Perform stepwise logistic regression
stepwise_log_model <- step(model_log, ,family = binomial)
## Start: AIC=118.47
## AT3_Median_Performance ~ (Mode + ATAR + Gender + `IMI - Pressure/Tension` +
## `AT2 article summary Wk 5?` + IM_Percentage + Motivation_Type +
## Campus_transformed + Age_Group) - 1
##
## Df Deviance AIC
## - Age_Group 1 100.60 116.60
## - Mode 1 100.97 116.97
## - Motivation_Type 1 101.26 117.26
## - Campus_transformed 1 101.44 117.44
## <none> 100.47 118.47
## - `IMI - Pressure/Tension` 1 102.59 118.59
## - Gender 1 102.64 118.64
## - IM_Percentage 1 102.66 118.66
## - `AT2 article summary Wk 5?` 1 103.38 119.38
## - ATAR 1 112.29 128.29
##
## Step: AIC=116.6
## AT3_Median_Performance ~ Mode + ATAR + Gender + `IMI - Pressure/Tension` +
## `AT2 article summary Wk 5?` + IM_Percentage + Motivation_Type +
## Campus_transformed - 1
##
## Df Deviance AIC
## - Mode 1 101.10 115.10
## - Motivation_Type 1 101.29 115.29
## - Campus_transformed 1 101.60 115.60
## <none> 100.60 116.60
## - Gender 1 102.66 116.66
## - `IMI - Pressure/Tension` 1 102.67 116.67
## - IM_Percentage 1 102.78 116.78
## - `AT2 article summary Wk 5?` 1 103.51 117.51
## - ATAR 1 112.55 126.55
##
## Step: AIC=115.1
## AT3_Median_Performance ~ ATAR + Gender + `IMI - Pressure/Tension` +
## `AT2 article summary Wk 5?` + IM_Percentage + Motivation_Type +
## Campus_transformed - 1
##
## Df Deviance AIC
## - Motivation_Type 1 101.95 113.95
## - Campus_transformed 1 102.67 114.67
## <none> 101.10 115.10
## - IM_Percentage 1 103.22 115.22
## - `IMI - Pressure/Tension` 1 103.41 115.41
## - Gender 1 103.43 115.43
## - `AT2 article summary Wk 5?` 1 103.60 115.60
## - ATAR 1 113.46 125.46
##
## Step: AIC=113.95
## AT3_Median_Performance ~ ATAR + Gender + `IMI - Pressure/Tension` +
## `AT2 article summary Wk 5?` + IM_Percentage + Campus_transformed -
## 1
##
## Df Deviance AIC
## - Campus_transformed 1 103.55 113.55
## <none> 101.95 113.95
## - Gender 1 104.03 114.03
## - `AT2 article summary Wk 5?` 1 104.38 114.38
## - `IMI - Pressure/Tension` 1 104.57 114.57
## - IM_Percentage 1 106.36 116.36
## - ATAR 1 113.60 123.60
##
## Step: AIC=113.55
## AT3_Median_Performance ~ ATAR + Gender + `IMI - Pressure/Tension` +
## `AT2 article summary Wk 5?` + IM_Percentage - 1
##
## Df Deviance AIC
## - Gender 1 105.41 113.41
## <none> 103.55 113.55
## - `AT2 article summary Wk 5?` 1 105.56 113.56
## - `IMI - Pressure/Tension` 1 107.35 115.35
## - IM_Percentage 1 109.59 117.59
## - ATAR 1 114.61 122.61
##
## Step: AIC=113.41
## AT3_Median_Performance ~ ATAR + `IMI - Pressure/Tension` + `AT2 article summary Wk 5?` +
## IM_Percentage - 1
##
## Df Deviance AIC
## - `AT2 article summary Wk 5?` 1 107.30 113.30
## <none> 105.41 113.41
## - `IMI - Pressure/Tension` 1 109.85 115.85
## - IM_Percentage 1 114.13 120.13
## - ATAR 1 115.34 121.34
##
## Step: AIC=113.3
## AT3_Median_Performance ~ ATAR + `IMI - Pressure/Tension` + IM_Percentage -
## 1
##
## Df Deviance AIC
## <none> 107.30 113.30
## - `IMI - Pressure/Tension` 1 110.71 114.71
## - IM_Percentage 1 114.80 118.80
## - ATAR 1 123.24 127.24
# Summary of the selected model
summary(stepwise_log_model)
##
## Call:
## glm(formula = AT3_Median_Performance ~ ATAR + `IMI - Pressure/Tension` +
## IM_Percentage - 1, family = binomial, data = log_regression_data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## ATAR 0.04777 0.01366 3.497 0.000471 ***
## `IMI - Pressure/Tension` -0.12884 0.07166 -1.798 0.072169 .
## IM_Percentage -0.03623 0.01427 -2.539 0.011127 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 123.38 on 89 degrees of freedom
## Residual deviance: 107.30 on 86 degrees of freedom
## AIC: 113.3
##
## Number of Fisher Scoring iterations: 3
# Make predictions using the logistic regression model
predictions <- predict(stepwise_log_model, newdata = log_regression_data, type = "response")
# Convert probabilities to class predictions
predicted_classes <- ifelse(predictions > 0.5, 1,0)
# Create a data frame with actual and predicted class labels
confusion_data <- data.frame(Actual = regression_data$AT3_Median_Performance,
Predicted = predicted_classes)
print(paste("Accuracy of Stepwise Logistic Model is",(sum(confusion_data$Actual==confusion_data$Predicted)/nrow(confusion_data))*100))
## [1] "Accuracy of Stepwise Logistic Model is 69.6629213483146"
# Assess variable importance using varImp
variable_importance_log <- varImp(model_log)
print(variable_importance_log)
## Overall
## ATAR 3.0640016
## Gender 1.4489126
## `IMI - Pressure/Tension` 1.4313441
## `AT2 article summary Wk 5?` 1.5885093
## IM_Percentage 1.4404798
## Motivation_Type 0.8803432
## Campus_transformed 0.9773905
## Age_Group 0.3533483
# Train logistic regression model with important variables
model_log <- glm(`AT3_Median_Performance` ~ (`ATAR`+Age_Group+Gender+`IMI - Pressure/Tension`+`AT2 article summary Wk 5?`+IM_Percentage+Motivation_Type+Campus_transformed)-1,data = log_regression_data,family = binomial)
# Print the model summary
summary(model_log)
##
## Call:
## glm(formula = AT3_Median_Performance ~ (ATAR + Age_Group + Gender +
## `IMI - Pressure/Tension` + `AT2 article summary Wk 5?` +
## IM_Percentage + Motivation_Type + Campus_transformed) - 1,
## family = binomial, data = log_regression_data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## ATAR 0.04924 0.01589 3.099 0.00194 **
## Age_Group 0.18198 0.50113 0.363 0.71649
## Gender -0.85649 0.55772 -1.536 0.12461
## `IMI - Pressure/Tension` -0.11956 0.07962 -1.502 0.13321
## `AT2 article summary Wk 5?` 0.14000 0.09335 1.500 0.13366
## IM_Percentage -0.03320 0.02333 -1.423 0.15477
## Motivation_Type -0.54299 0.55977 -0.970 0.33203
## Campus_transformed -0.62551 0.51533 -1.214 0.22482
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 123.38 on 89 degrees of freedom
## Residual deviance: 100.96 on 81 degrees of freedom
## AIC: 116.96
##
## Number of Fisher Scoring iterations: 4
# Make predictions using the logistic regression model
predictions <- predict(model_log, newdata = log_regression_data, type = "response")
# Convert probabilities to class predictions
predicted_classes <- ifelse(predictions > 0.5, 1,0)
# Create a data frame with actual and predicted class labels
confusion_data <- data.frame(Actual = log_regression_data$AT3_Median_Performance,
Predicted = predicted_classes)
print(paste("Accuracy of Logistic Model with Important Variables is",(sum(confusion_data$Actual==confusion_data$Predicted)/nrow(confusion_data))*100))
## [1] "Accuracy of Logistic Model with Important Variables is 68.5393258426966"
# Logistic Regression with Selected Two-Way Interaction Terms
interaction_model <- glm(AT3_Median_Performance ~ (ATAR + `AT2 article summary Wk 5?` + IM_Percentage + ATAR:`AT2 article summary Wk 5?` + ATAR:IM_Percentage + `AT2 article summary Wk 5?`:IM_Percentage)-1, data = log_regression_data, family = binomial)
# Summary of the model
summary(interaction_model)
##
## Call:
## glm(formula = AT3_Median_Performance ~ (ATAR + `AT2 article summary Wk 5?` +
## IM_Percentage + ATAR:`AT2 article summary Wk 5?` + ATAR:IM_Percentage +
## `AT2 article summary Wk 5?`:IM_Percentage) - 1, family = binomial,
## data = log_regression_data)
##
## Coefficients:
## Estimate Std. Error z value
## ATAR -0.1691877 0.1028682 -1.645
## `AT2 article summary Wk 5?` -0.1243174 0.4746902 -0.262
## IM_Percentage 0.1456666 0.1213790 1.200
## ATAR:`AT2 article summary Wk 5?` 0.0145163 0.0072852 1.993
## ATAR:IM_Percentage -0.0001782 0.0014452 -0.123
## `AT2 article summary Wk 5?`:IM_Percentage -0.0108165 0.0072240 -1.497
## Pr(>|z|)
## ATAR 0.1000
## `AT2 article summary Wk 5?` 0.7934
## IM_Percentage 0.2301
## ATAR:`AT2 article summary Wk 5?` 0.0463 *
## ATAR:IM_Percentage 0.9019
## `AT2 article summary Wk 5?`:IM_Percentage 0.1343
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 123.38 on 89 degrees of freedom
## Residual deviance: 100.35 on 83 degrees of freedom
## AIC: 112.35
##
## Number of Fisher Scoring iterations: 4
# Make predictions using the logistic regression model
predictions <- predict(interaction_model, newdata = log_regression_data, type = "response")
# Convert probabilities to class predictions
predicted_classes <- ifelse(predictions > 0.5, 1,0)
# Create a data frame with actual and predicted class labels
confusion_data <- data.frame(Actual = log_regression_data$AT3_Median_Performance,
Predicted = predicted_classes)
print(paste("Accuracy of Logistic Regression using interactions",(sum(confusion_data$Actual==confusion_data$Predicted)/nrow(confusion_data))*100))
## [1] "Accuracy of Logistic Regression using interactions 74.1573033707865"
# Logistic Regression with Only Significant Interaction Term
significant_logistic_interactions <- glm(AT3_Median_Performance ~ (ATAR + `AT2 article summary Wk 5?` + ATAR:`AT2 article summary Wk 5?`)-1,
data = log_regression_data,
family = binomial)
# Summary of the model
summary(significant_logistic_interactions)
##
## Call:
## glm(formula = AT3_Median_Performance ~ (ATAR + `AT2 article summary Wk 5?` +
## ATAR:`AT2 article summary Wk 5?`) - 1, family = binomial,
## data = log_regression_data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## ATAR -0.049389 0.025568 -1.932 0.05340 .
## `AT2 article summary Wk 5?` -0.236295 0.073522 -3.214 0.00131 **
## ATAR:`AT2 article summary Wk 5?` 0.006224 0.001897 3.280 0.00104 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 123.38 on 89 degrees of freedom
## Residual deviance: 105.33 on 86 degrees of freedom
## AIC: 111.33
##
## Number of Fisher Scoring iterations: 3
# Make predictions using the logistic regression model
predictions <- predict(significant_logistic_interactions, newdata = log_regression_data, type = "response")
# Convert probabilities to class predictions
predicted_classes <- ifelse(predictions > 0.5, 1,0)
# Create a data frame with actual and predicted class labels
confusion_data <- data.frame(Actual = log_regression_data$AT3_Median_Performance,
Predicted = predicted_classes)
print(paste("Accuracy of Logistic Regression using significant interactions",(sum(confusion_data$Actual==confusion_data$Predicted)/nrow(confusion_data))*100))
## [1] "Accuracy of Logistic Regression using significant interactions 67.4157303370787"
#SVM classification
model_svm_class <- svm(AT3_Median_Performance ~.,data = log_regression_data,type = "C-classification",kernel = "linear")
predictions <- predict(model_svm_class, newdata =log_regression_data)
# Evaluate the model
# Calculate accuracy
accuracy <- sum(predictions == log_regression_data$AT3_Median_Performance) / length(predictions)
print(accuracy*100)
## [1] 73.03371
# automated tuning of gamma paramter for RBF kernel
log_regression_data$AT3_Median_Performance <- as.factor(log_regression_data$AT3_Median_Performance)
tuned_model <- tune.svm(AT3_Median_Performance ~.,data = log_regression_data,type = "C-classification", kernel = "radial", gamma = 10^(-3:2))
best_model <- tuned_model$best.model
predictions <- predict(best_model, newdata =log_regression_data)
# Evaluate the model
# Calculate accuracy
accuracy <- sum(predictions == log_regression_data$AT3_Median_Performance) / length(predictions)
print(accuracy*100)
## [1] 82.02247
write_xlsx(lin_regression_data, path = "C:\\Users\\Angat\\Downloads\\hybrid_teaching_cleaned_transformed.xlsx")