Dataset Description

View of dataset

About

Structure of the dataset

Structure of the dataset

'data.frame':   32 obs. of  10 variables:
 $ Class      : int  12 12 12 12 12 12 12 12 12 12 ...
 $ Year       : int  2023 2023 2023 2023 2023 2023 2023 2023 2023 2023 ...
 $ Region     : chr  "Ajmer" "Ajmer" "Bhubaneswar" "Bhubaneswar" ...
 $ Status     : chr  "Regd" "Appd" "Regd" "Appd" ...
 $ CTSA       : int  0 0 103 101 0 0 0 0 0 0 ...
 $ GOVT       : int  4533 4524 7746 7688 13060 13025 100216 99566 1535 1534 ...
 $ GOVT.AIDED : int  0 0 0 0 55 55 6420 6393 0 0 ...
 $ INDEPENDENT: int  86178 85839 69835 69506 89637 89317 64953 64774 22801 22742 ...
 $ JNV        : int  3741 3730 3823 3809 2549 2537 81 81 1673 1662 ...
 $ KV         : int  7736 7725 11465 11431 5861 5844 6669 6661 4859 4849 ...

Summary

Summary

Summary

     Class         Year         Region             Status         
 Min.   :12   Min.   :2023   Length:32          Length:32         
 1st Qu.:12   1st Qu.:2023   Class :character   Class :character  
 Median :12   Median :2023   Mode  :character   Mode  :character  
 Mean   :12   Mean   :2023                                        
 3rd Qu.:12   3rd Qu.:2023                                        
 Max.   :12   Max.   :2023                                        
      CTSA             GOVT            GOVT.AIDED      INDEPENDENT    
 Min.   :  0.00   Min.   :    70.0   Min.   :   0.0   Min.   : 12214  
 1st Qu.:  0.00   1st Qu.:   337.2   1st Qu.:   0.0   1st Qu.: 38593  
 Median :  0.00   Median :  2346.5   Median :   0.0   Median : 66326  
 Mean   : 24.72   Mean   : 14191.1   Mean   : 954.0   Mean   : 66485  
 3rd Qu.:  9.50   3rd Qu.:  9065.8   3rd Qu.:  66.5   3rd Qu.: 86963  
 Max.   :164.00   Max.   :100216.0   Max.   :7775.0   Max.   :131729  
      JNV             KV       
 Min.   :  65   Min.   : 2361  
 1st Qu.:1105   1st Qu.: 4147  
 Median :2063   Median : 5626  
 Mean   :2240   Mean   : 5780  
 3rd Qu.:3647   3rd Qu.: 6966  
 Max.   :4536   Max.   :11465  

Tail

   Class Year     Region Status CTSA  GOVT GOVT.AIDED INDEPENDENT  JNV   KV
27    12 2023 Trivandrum   Regd    0    82          0       33500  973 3666
28    12 2023 Trivandrum   Appd    0    82          0       33462  972 3661
29    12 2023   Dehradun   Regd  164  1555         22       62473 1120 4312
30    12 2023   Dehradun   Appd  162  1552         22       62094 1117 4307
31    12 2023 Delhi West   Regd    0 69504       7775       40461   65 2872
32    12 2023 Delhi West   Appd    0 69109       7743       40291   65 2872

Checking missing values

[1] 0

EDA

Histogram

Histogram for Government Insitution

Histogram for KV Insitution

Histogram for Government aided Insitution

Histogram for JNV Insitution

Histogram for INDEPENDENT Insitution

Box plot

Box Plot for GOVT

Box Plot for GOVT AIDED

Box Plot for KV Insitution

Box Plot for Independent Insitution

Box Plot for JNV Insitution

Scatter plot

Scater plot GOVERNMENT vs GOVERNMENT AIDED

Scater plot for GOVT vs INDEPENDENT

Scater plot for GOVT AIDED vs KV

Scater plot for KV vs JNV INSITUTION

Scater plot for GOVT vs INDEPENDENT

Linear Regression

Visualize the data: GOVT vs INDEPENDENT

Fit Linear Regression Model


Call:
lm(formula = GOVT.AIDED ~ GOVT, data = cls)

Residuals:
    Min      1Q  Median      3Q     Max 
-1361.6  -256.7    48.9   155.2  2472.0 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -1.617e+02  1.757e+02   -0.92    0.365    
GOVT         7.862e-02  5.648e-03   13.92 1.25e-14 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 884.5 on 30 degrees of freedom
Multiple R-squared:  0.8659,    Adjusted R-squared:  0.8615 
F-statistic: 193.8 on 1 and 30 DF,  p-value: 1.254e-14

Evaluate the Model

Mean Squared Error (MSE)

Mean Squared Error (MSE): 733504.8 

Root Mean Squared Error (RMSE)

Root Mean Squared Error (RMSE): 856.449 

Visualize the regression line

---
title: "Linear_Regressions"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    theme: flatly
    social: menu
    source_code: embed
    color: blue
---

```{r setup, include=FALSE}
library(flexdashboard)
library(flexdashboard)
library(MASS)
library(lattice)
library(dplyr)
library(ggplot2)
library(shiny)
library(DT)
```

# Dataset Description

## View of dataset

```{r}
cls <- read.csv("/cloud/project/8725922/class12-2023.csv")

datatable(cls, extensions = "Buttons",options=list(dom='Bfrtip',Buttons=c('copy','csv','print','pdf')))


```

# About

## Structure of the dataset

### Structure of the dataset

```{r}
str(cls)
```

# Summary

## Summary

### Summary

```{r}
summary(cls)
```

### Tail

```{r}
tail(cls)
```

### Head

```{r}
head(cls)
```

### Checking missing values

```{r}
print(sum(is.na(cls)))
```

# EDA

## Histogram

### Histogram for Government Insitution


```{r}
ggplot(cls ,aes(x = GOVT)) +
  geom_histogram(fill = "lightblue", color = "black") +
  geom_vline(aes(xintercept = mean(GOVT)), color = "red", lwd = 1) +
  labs(title = "Histogram of Government", x = "government")

```


### Histogram for KV Insitution

```{r}
ggplot(cls ,aes(x = KV)) +
  geom_histogram(fill = "lightblue", color = "black") +
  geom_vline(aes(xintercept = mean(KV)), color = "red", lwd = 1) +
  labs(title = "Histogram of Government", x = "government")
```

### Histogram for Government aided Insitution

```{r}
ggplot(cls ,aes(x = `GOVT.AIDED`)) +
  geom_histogram(fill = "lightblue", color = "black") +
  geom_vline(aes(xintercept = mean(`GOVT.AIDED`)), color = "red", lwd = 1) +
  labs(title = "Histogram of Government Aided", x = "government aided")

```



### Histogram for JNV Insitution

```{r}
ggplot(cls ,aes(x = JNV)) +
  geom_histogram(fill = "lightblue", color = "black") +
  geom_vline(aes(xintercept = mean(JNV)), color = "red", lwd = 1) +
  labs(title = "Histogram of JNV Insitution", x = "JNV Insitution")

```

### Histogram for INDEPENDENT Insitution

```{r}
ggplot(cls ,aes(x = INDEPENDENT)) +
  geom_histogram(fill = "lightblue", color = "black") +
  geom_vline(aes(xintercept = mean(INDEPENDENT)), color = "red", lwd = 1) +
  labs(title = "Histogram of INDEPENDENT Insitution", x = "INDEPENDENT Insitution")

```


## Box plot

### Box Plot for GOVT

```{r}
boxplot(cls$GOVT)
```

### Box Plot for GOVT AIDED

```{r}
boxplot(cls$`GOVT.AIDED`)
```

### Box Plot for KV Insitution

```{r}
boxplot(cls$KV)
```

### Box Plot for Independent Insitution

```{r}
boxplot(cls$INDEPENDENT)
```

### Box Plot for JNV Insitution

```{r}
boxplot(cls$JNV)
```

## Scatter plot

### Scater plot GOVERNMENT vs GOVERNMENT AIDED

```{r}
ggplot(cls, aes(x = GOVT, y = `GOVT.AIDED`)) +
  geom_point() +
  labs(title = "Scatter plot of GOVT vs. GOVT AIDED")
```


### Scater plot for  GOVT vs INDEPENDENT

```{r}

ggplot(cls, aes(x = GOVT, y = INDEPENDENT)) +
  geom_point() +
  labs(title = "Scatter plot of GOVT vs. INDEPENDENT")
```


### Scater plot for GOVT AIDED vs KV

```{r}
ggplot(cls, aes(x = `GOVT.AIDED`, y = KV)) +
  geom_point() +
  labs(title = "Scatter plot of GOVT AIDED vs. KV")
```


### Scater plot for KV vs JNV INSITUTION

```{r}

ggplot(cls, aes(x = KV, y =JNV)) +
  geom_point() +
  labs(title = "Scatter plot of KV vs. JNV")
```

### Scater plot for GOVT vs  INDEPENDENT

```{r}

ggplot(cls, aes(x = GOVT, y =INDEPENDENT)) +
  geom_point() +
  labs(title = "Scatter plot of GOVT vs. INDEPENDENT")
```


# Linear Regression

### Visualize the data: GOVT vs INDEPENDENT

```{r}
ggplot(cls, aes(x = GOVT, y =`GOVT.AIDED`)) +
  geom_point(color = "blue") +
  ggtitle("Scatter Plot of GOVT vs GOVT AIDED Insituttion") +
  xlab("GOVT Schools") +
  ylab("GOVT AIDED Insitution")
```



### Fit Linear Regression Model

```{r}
model <- lm(`GOVT.AIDED` ~ GOVT, data = cls)
summary(model)
predicted <- predict(model, cls)
```


# Evaluate the Model

### Mean Squared Error (MSE)

```{r}
mse <- mean((cls$`GOVT.AIDED` - predicted) ^ 2)
cat("Mean Squared Error (MSE):", mse, "\n")

```

### Root Mean Squared Error (RMSE)

```{r}
rmse <- sqrt(mse)
cat("Root Mean Squared Error (RMSE):", rmse, "\n")

```

# Visualize the regression line

```{r}
ggplot(cls, aes(x = GOVT, y = `GOVT.AIDED`)) +
  geom_point(color = "blue") +
  geom_smooth(method = "lm", color = "red") +
  ggtitle("Linear Regression: GOVT vs INDEPENDENT Schools") +
  xlab("GOVT Schools") +
  ylab("INDEPENDENT Schools")

```