-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegression_Analysis.Rmd
More file actions
145 lines (91 loc) · 2.12 KB
/
Regression_Analysis.Rmd
File metadata and controls
145 lines (91 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
title: "Research ADDS- Jonathan 2"
author: "Jonathan Mishayel"
date: "2024-08-27"
output: html_document
---
```{r}
getwd()
```
```{r}
df <- read.csv(file.choose(), header =T)
df
```
```{r}
View(df)
```
```{r}
str(df)
```
```{r}
sum(is.na(df))
```
```{r}
table(df$guardian_education)
```
```{r}
library(ggplot2)
ggplot(df , aes(final_grade,absences))+
geom_point(color = 'blue')+
labs(title ='Scatter Plot')
```
```{r}
# Convert variables to factor
df$guardian_education <- as.factor(df$guardian_education)
df$family_relationship <- as.factor(df$family_relationship)
df$family_size <- as.factor(df$family_size)
df$parent_status <- as.factor(df$parent_status)
df$family_support <- as.factor(df$family_support)
```
# Regression
```{r}
# Fit multiple linear regression
objective1 <- lm(final_grade ~
family_relationship +
guardian_education +
family_size+
parent_status+
family_support+
absences,
data = df)
summary(objective1)
```
#Distribution of Final Grade
```{r}
library(ggplot2)
ggplot(df, aes(x = final_grade)) +
geom_histogram(bins = 10) +
labs(title = "Distribution of Final Grade",
x = "Final Grade",
y = "Count") +
theme_minimal()
```
```{r}
ggplot(df, aes(x = final_grade)) +
geom_density() +
labs(title = "Density Plot of Final Grade",
x = "Final Grade",
y = "Density") +
theme_minimal()
```
#Distribution of Absences
```{r}
ggplot(df, aes(x = absences)) +
geom_histogram(bins = 15) +
labs(title = "Distribution of Absences",
x = "Number of Absences",
y = "Count") +
theme_minimal()
```
#Final Grade by Guardian Education
```{r}
ggplot(df, aes(x = guardian_education, y = final_grade)) +
geom_boxplot() +
labs(title = "Final Grade by Guardian Education",
x = "Guardian Education",
y = "Final Grade") +
theme_minimal()
```
```{r}
barplot(table(df$guardian_education), col = c("red", "green"), main = "Guardian Education Level", xlab = "Category", ylab = "Count")
```