library(readxl)
Dataexam <- read_excel("D:/MARV BS MATH/Marv 4th year, 1st sem/Regression Analysis/Dataexam.xlsx")
New names:
• `` -> `...1`
• `` -> `...22`
• `` -> `...23`
• `DDP` -> `DDP...75`
• `DDP` -> `DDP...82`
Dataexam
# A tibble: 298 × 126
...1 Gender Year.l…¹ Devic…² Stude…³ Stude…⁴ Inter…⁵ Frequ…⁶ Elect…⁷ Attit…⁸
<dbl> <chr> <chr> <chr> <chr> <chr> <lgl> <chr> <chr> <dbl>
1 1 Female 4th Year Deskto… Person… Broadb… NA At mos… At mos… 4
2 2 Female 4th Year Deskto… Shared… Mobile… NA At mos… A few … 2
3 3 Female 2nd Year Deskto… Person… Broadb… NA A few … At mos… 3
4 4 Female 4th Year Deskto… Person… Pocket… NA Daily,… A few … 4
5 5 Female 4th Year Mobile… Person… Mobile… NA At mos… At mos… 1
6 6 Female 4th Year Mobile… Person… Mobile… NA Daily,… A few … 3
7 7 Female 1st Year Deskto… Person… Broadb… NA At mos… At mos… 2
8 8 Female 3rd Year Deskto… Person… Broadb… NA Daily,… Daily,… 3
9 9 Male 2nd Year Deskto… Person… Broadb… NA Daily,… Daily,… 5
10 10 Female 2nd Year Deskto… Shared… Broadb… NA At mos… A few … 3
# … with 288 more rows, 116 more variables: Attitude2 <dbl>, Attitude3 <dbl>,
# Attitude4 <dbl>, Attitude5 <dbl>, LDAttitude <dbl>, Mental.Health1 <dbl>,
# Mental.Health2 <dbl>, Mental.Health3 <dbl>, mental1 <dbl>, mental2 <dbl>,
# mental3 <dbl>, ...22 <dbl>, ...23 <dbl>, Mental.Health4 <dbl>,
# Mental.Health5 <dbl>, LDMental <dbl>,
# `Self-efficacy [1. I feel confident while operating on flexible learning system (FLS) platforms.]` <dbl>,
# `Self-efficacy [2. I am sure that I can complete all the tasks that exist in the FLS.]` <dbl>, …
library(dplyr)
Warning: package 'dplyr' was built under R version 4.2.2
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
summary<-Dataexam %>%
group_by(Devices.used) %>%
summarize(count=n())%>%
mutate(Percentage =round((count/sum(count)*100),3))
summary
# A tibble: 6 × 3
Devices.used count Percentage
<chr> <int> <dbl>
1 Desktop or laptop 61 20.5
2 Desktop/ Laptop and Mobile Phone 126 42.3
3 Desktop/ Laptop, Mobile Phone and Tablet 3 1.01
4 Mobile phone 105 35.2
5 Mobile Phone and Tablet 1 0.336
6 Tablet 2 0.671
summary<-Dataexam %>%
group_by(Internet.connectivity) %>%
summarize(count=n())%>%
mutate(Percentage =round((count/sum(count)*100),3))
summary
# A tibble: 1 × 3
Internet.connectivity count Percentage
<lgl> <int> <dbl>
1 NA 298 100
summary<-Dataexam %>%
group_by(Year.level) %>%
summarize(count=n())%>%
mutate(Percentage =round((count/sum(count)*100),3))
summary
# A tibble: 4 × 3
Year.level count Percentage
<chr> <int> <dbl>
1 1st Year 96 32.2
2 2nd Year 97 32.6
3 3rd Year 61 20.5
4 4th Year 44 14.8
summary<-Dataexam %>%
group_by(Gender) %>%
summarize(count=n())%>%
mutate(Percentage =round((count/sum(count)*100),3))
summary
# A tibble: 2 × 3
Gender count Percentage
<chr> <int> <dbl>
1 Female 224 75.2
2 Male 74 24.8
library(readxl)
Dataexam <- read_excel("D:/MARV BS MATH/Marv 4th year, 1st sem/Regression Analysis/Dataexam.xlsx")
New names:
• `` -> `...1`
• `` -> `...22`
• `` -> `...23`
• `DDP` -> `DDP...75`
• `DDP` -> `DDP...82`
Dataexam
# A tibble: 298 × 126
...1 Gender Year.l…¹ Devic…² Stude…³ Stude…⁴ Inter…⁵ Frequ…⁶ Elect…⁷ Attit…⁸
<dbl> <chr> <chr> <chr> <chr> <chr> <lgl> <chr> <chr> <dbl>
1 1 Female 4th Year Deskto… Person… Broadb… NA At mos… At mos… 4
2 2 Female 4th Year Deskto… Shared… Mobile… NA At mos… A few … 2
3 3 Female 2nd Year Deskto… Person… Broadb… NA A few … At mos… 3
4 4 Female 4th Year Deskto… Person… Pocket… NA Daily,… A few … 4
5 5 Female 4th Year Mobile… Person… Mobile… NA At mos… At mos… 1
6 6 Female 4th Year Mobile… Person… Mobile… NA Daily,… A few … 3
7 7 Female 1st Year Deskto… Person… Broadb… NA At mos… At mos… 2
8 8 Female 3rd Year Deskto… Person… Broadb… NA Daily,… Daily,… 3
9 9 Male 2nd Year Deskto… Person… Broadb… NA Daily,… Daily,… 5
10 10 Female 2nd Year Deskto… Shared… Broadb… NA At mos… A few … 3
# … with 288 more rows, 116 more variables: Attitude2 <dbl>, Attitude3 <dbl>,
# Attitude4 <dbl>, Attitude5 <dbl>, LDAttitude <dbl>, Mental.Health1 <dbl>,
# Mental.Health2 <dbl>, Mental.Health3 <dbl>, mental1 <dbl>, mental2 <dbl>,
# mental3 <dbl>, ...22 <dbl>, ...23 <dbl>, Mental.Health4 <dbl>,
# Mental.Health5 <dbl>, LDMental <dbl>,
# `Self-efficacy [1. I feel confident while operating on flexible learning system (FLS) platforms.]` <dbl>,
# `Self-efficacy [2. I am sure that I can complete all the tasks that exist in the FLS.]` <dbl>, …
head(Dataexam)
# A tibble: 6 × 126
...1 Gender Year.le…¹ Devic…² Stude…³ Stude…⁴ Inter…⁵ Frequ…⁶ Elect…⁷ Attit…⁸
<dbl> <chr> <chr> <chr> <chr> <chr> <lgl> <chr> <chr> <dbl>
1 1 Female 4th Year Deskto… Person… Broadb… NA At mos… At mos… 4
2 2 Female 4th Year Deskto… Shared… Mobile… NA At mos… A few … 2
3 3 Female 2nd Year Deskto… Person… Broadb… NA A few … At mos… 3
4 4 Female 4th Year Deskto… Person… Pocket… NA Daily,… A few … 4
5 5 Female 4th Year Mobile… Person… Mobile… NA At mos… At mos… 1
6 6 Female 4th Year Mobile… Person… Mobile… NA Daily,… A few … 3
# … with 116 more variables: Attitude2 <dbl>, Attitude3 <dbl>, Attitude4 <dbl>,
# Attitude5 <dbl>, LDAttitude <dbl>, Mental.Health1 <dbl>,
# Mental.Health2 <dbl>, Mental.Health3 <dbl>, mental1 <dbl>, mental2 <dbl>,
# mental3 <dbl>, ...22 <dbl>, ...23 <dbl>, Mental.Health4 <dbl>,
# Mental.Health5 <dbl>, LDMental <dbl>,
# `Self-efficacy [1. I feel confident while operating on flexible learning system (FLS) platforms.]` <dbl>,
# `Self-efficacy [2. I am sure that I can complete all the tasks that exist in the FLS.]` <dbl>, …
x <- mean(Dataexam$Attitude1)
x
[1] 3.016779
y <- mean(Dataexam$Attitude2)
y
[1] 2.855705
z <- mean(Dataexam$Attitude3)
z
[1] 2.483221
u <- mean(Dataexam$Attitude4)
u
[1] 2.765101
v <- mean(Dataexam$Attitude5)
v
[1] 2.402685
w <- mean(Dataexam$LDAttitude)
w
[1] 2.704698
dat <- Dataexam
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.2.2
ggplot(dat, aes(x = LDAttitude, y = GWA)) +
geom_point() +
labs(
y = "General Weighted Average",
x = "Attitude of the Learners"
) +
theme_minimal()
model <- lm(GWA ~ LDAttitude, data = dat)
summary(model)
Call:
lm(formula = GWA ~ LDAttitude, data = dat)
Residuals:
Min 1Q Median 3Q Max
-0.41418 -0.16639 -0.03046 0.12689 1.11874
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.66034 0.04386 37.856 <2e-16 ***
LDAttitude -0.02908 0.01548 -1.878 0.0614 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2249 on 296 degrees of freedom
Multiple R-squared: 0.01177, Adjusted R-squared: 0.008435
F-statistic: 3.527 on 1 and 296 DF, p-value: 0.06137
The intercept 1.66034 indicates that, for a hypothetical Attitude of the Learners which is 0, we can expect, on average, a General Weighted Average of 1.66034. The slope -0.02908 indicates that there is a negative relationship between the General Weighted Average and Attitude of the Learners. But more importantly, a slope of -0.02908 means that, for an increase of one unit in the Attitude of the Learners, the number of General Weighted Average decreases, on average, by 0.02908 units.
Since the p-value = 0.0614 > 0.05 so we fail reject the null hypothesis at the significance level α=5%. We therefore conclude that there is no significant relationship between the General Weighted Average and Attitude of the Learners.
library(performance)
check_model(model)
library(visreg)
Warning: package 'visreg' was built under R version 4.2.2
visreg(model)
p <- mean(Dataexam$Mental.Health1)
p
[1] 1.942953
q <- mean(Dataexam$Mental.Health2)
q
[1] 1.979866
r <- mean(Dataexam$Mental.Health3)
r
[1] 2.020134
x <- mean(Dataexam$Mental.Health4)
x
[1] 2.828859
y <- mean(Dataexam$Mental.Health5)
y
[1] 2.805369
dat1 <- Dataexam
library(ggplot2)
ggplot(dat1, aes(x = LDMental, y = GWA)) +
geom_point() +
labs(
y = "General Weighted Average",
x = "Mental Health of the Learners"
) +
theme_minimal()
model1 <- lm(GWA ~ LDMental, data = dat1)
summary(model1)
Call:
lm(formula = GWA ~ LDMental, data = dat1)
Residuals:
Min 1Q Median 3Q Max
-0.39376 -0.16239 -0.03346 0.13131 1.16718
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.51719 0.07384 20.548 <2e-16 ***
LDMental 0.01823 0.02054 0.888 0.375
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2259 on 296 degrees of freedom
Multiple R-squared: 0.002655, Adjusted R-squared: -0.0007148
F-statistic: 0.7879 on 1 and 296 DF, p-value: 0.3755
The intercept 1.51719 indicates that, for a hypothetical Mental health of the Learners which is 0, we can expect, on average, a General Weighted Average of 1.51719 . The slope 0.01823 indicates that there is a positive relationship between the General Weighted Average and Mental Health of the Learners. But more importantly, a slope of 0.01823 means that, for an increase of one unit in the Mental Health of the Learners, the number of General Weighted Average increases, on average, by 0.01823 units.
Since the p-value = 0.375 > 0.05 so we fail reject the null hypothesis at the significance level α=5%. We therefore conclude that there is no significant relationship between the General Weighted Average and Attitude of the Learners.
library(performance)
check_model(model1)
library(visreg)
visreg(model1)
Dependent Variable: Column “DV” Independent Variables: Column “AM”, Column “BB”, Column “BQ”, and Column “CF”
model2 <- lm(GWA ~ LD + ID + CD + DD, data = Dataexam)
summary(model2)
##
## Call:
## lm(formula = GWA ~ LD + ID + CD + DD, data = Dataexam)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.41212 -0.16709 -0.04072 0.12679 1.14108
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.708347 0.091216 18.729 <2e-16 ***
## LD -0.032404 0.033657 -0.963 0.336
## ID -0.007099 0.023529 -0.302 0.763
## CD 0.030347 0.034165 0.888 0.375
## DD -0.030337 0.035991 -0.843 0.400
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2263 on 293 degrees of freedom
## Multiple R-squared: 0.009546, Adjusted R-squared: -0.003975
## F-statistic: 0.706 on 4 and 293 DF, p-value: 0.5884
3.1 Which of the independent variables significantly predicts the dependent variable?
Hence, the independent variable, Column AM(LD) has the coefficient with the largest absolute value which significantly predicts the dependent variable, Column DV. This measure suggests that Column AM(LD) is the most important independent variable in the regression model.
3.2 Provide the coefficient of the independent variables.
library(performance)
check_model(model2)
Coefficients: Estimate
Column AM (LD) -0.032404
Column BB (ID) -0.007099
Column BQ (CD) 0.030347
Column CF (DD) -0.030337
3.3 Can we conclude that the model is better than a model having the intercept alone?
The p-value = 0.5884. Thus we don’t have enough evidence to reject the null hypothesis, so we conclude that our model is not better than a model with only the intercept because at least one coefficient β is not significantly different from 0. It means that none of the variables we selected help in explaining the dependent variable. In other words, we should completely forget about this model because it cannot do better than simply taking the mean of the dependent variable.