(First, we must load the required packages as well as the chosen dataset from the correct working directory)
#setwd("C:/Users/PC/Desktop/WU Wien/Semester 6/Applied Data Analysis with R/Home Assignments")
#df = read.csv("placement-dataset.csv")
df = read.table("./placement-dataset.csv", header = TRUE, sep = ",")
Now let’s look at the first 10 observations from this dataset:
head(df, 10)
## city cgpa iq placement
## 1 New York 6.8 123 1
## 2 Los Angeles 5.9 106 0
## 3 Chicago NA 121 0
## 4 New York 7.4 132 1
## 5 Los Angeles 5.8 142 0
## 6 Chicago 7.1 48 1
## 7 New York 5.7 NA 0
## 8 Los Angeles 5.0 63 0
## 9 Chicago 6.1 156 0
## 10 New York 5.1 66 0
# Additionally, we can look at the total number of rows in the data:
no_rows = nrow(df)
cat("Total number of observations:", no_rows)
## Total number of observations: 100
Looking at this dataset, and the metadata provided on kaggle.com regarding this dataset, we can provide some explanations about the data.
As such, the unit of observation in this dataset is an individual student, from which the city, gpa, iq and placement data are recorded.
As we have computed earlier, there are 100 total observations in this dataset. An individual unit of observation is a single person within the sample, we can say that the sample size of this dataset is 100. The geographical focus of this dataset is on New York, Chicago and Los Angeles, and hence is a US-based dataset.
Definitions of each variable:
Units of measurement:
Finding the data:
This dataset was found on Kaggle, an open-sourced database for various datasets often used for data science. The specific link to the dataset site is as follows:
https://www.kaggle.com/datasets/mahad049/college-placement/data
This is a “college placement” dataset that explores student placement by IQ and CGPA, owned and collaborated by Muhammad Mahad (author not specified).
Upon looking at this dataset, we need to carry out some data manipulation. The categorical variables need to be set to factors (specifically the “placement” variable), and the missing values must be handled.
# First, handling the categorical variables:
df$cityFactor = as.factor(df$city)
df$placementFactor = factor(df$placement,
levels = c(0,1),
labels = c("not placed", "placed"))
# Cleaning the data by excluding the missing values (NAs)
df_dropped = drop_na(df)
# Some descriptive statistics for the numerical variables:
round(stat.desc(df_dropped |> select(cgpa, iq)), 2)
## cgpa iq
## nbr.val 88.00 88.00
## nbr.null 0.00 0.00
## nbr.na 0.00 0.00
## min 3.30 37.00
## max 8.50 233.00
## range 5.20 196.00
## sum 528.10 10864.00
## median 6.00 127.50
## mean 6.00 123.45
## SE.mean 0.12 4.43
## CI.mean.0.95 0.25 8.80
## var 1.36 1723.97
## std.dev 1.17 41.52
## coef.var 0.19 0.34
# Now a little descriptive statistics for the categorical variables:
summary(df_dropped |> select(city, placement))
## city placement
## Length:88 Min. :0.0
## Class :character 1st Qu.:0.0
## Mode :character Median :0.5
## Mean :0.5
## 3rd Qu.:1.0
## Max. :1.0
Now to describe a descriptive statistic for each (numerical) variable:
CGPA
# First, let's look at the the histograms to check for distribution:
ggplot(df_dropped, aes(x = cgpa)) + geom_histogram(bins = 15) +
labs(title = "Distribution of CGPA") +
geom_vline(xintercept = mean(df_dropped$cgpa), color = "red")
# For a little extra visualization, we can create a density plot as well
# (using highcharter)
hchart(
density(df_dropped$cgpa),
type = "area", name = "Weight"
) |> hc_title(text = "Density plot of CGPA score Distribution") |>
hc_xAxis(title = list(text = "CGPA scores")) |>
hc_yAxis(title = list(text = "Density"))
Description & Explanation:
Looking at the histogram of the CGPA scores, we can observe that it is not particularly normally distributed. This could likely be due to sample size, or a sampling bias that impacted the distribution of the CGPA scores. Furthermore, looking at the distributive direction (skewness) in relation to the mean CGPA score (red line), the CGPA scores are not skewed in either direction.
The additonal density plot shows that there may be a bi-modal distribution, which may also indicate why the histogram does not appear normally distributed.
To further explore the potential of the CGPA scores being bi-modally distributed, we can look at the distribution of CGPA scores by whether the student was able to get a job/internship placement or not. This is a better starting point than looking at the city, as it is a more contextually relevant variable, as well as being binary rather than 3 categories (due to the distribution being bi-modal).
p = df_dropped |> filter(placementFactor == "placed")
np = df_dropped |> filter(placementFactor == "not placed")
hchart(density(p$cgpa), type = "area",
color = "steelblue", name = "placed") |>
hc_add_series(density(np$cgpa),
type = "area",
color = "red",
name = "not placed") |>
hc_title(text = "Density distribution of CGPA scores by Placement")
To look at the potential bi-modal distribution in this data, we use the highcharter library to look at the density plots of placed vs not placed students’ CGPA scores side-by-side. Looking at the above chart we can see that the placement variable may play a significant factor in this bi-modal distribution. As such, this is likely due to other factors that interact with one’s likelihood of acquiring a job/internship placement that also affects the distributive nature of the CGPA scores. However, this hypothesis would require extensive extra research to validate, which we will not touch on now.
IQ Level
# First, let's look at the the histograms to check for distribution:
ggplot(df_dropped, aes(x = iq)) + geom_histogram(bins = 15) +
labs(title = "Distribution of IQ") +
geom_vline(xintercept = mean(df_dropped$iq), color = "red")
# For a little extra visualization, we can create a density plot as well
# (using highcharter)
hchart(
density(df_dropped$iq),
type = "area", name = "Weight"
) |> hc_title(text = "Density plot of IQ level Distribution") |>
hc_xAxis(title = list(text = "IQ level")) |>
hc_yAxis(title = list(text = "Density"))
Description & Explanation:
As opposed to the CGPA distribution, the IQ level seems to somewhat display a normally distributed histogram (and density plot). Moreover, the distribution relative to the mean value is not shifted toward either side, meaning that there is no skewness in the distribution of IQ.
Looking at the Distribution of iq and cgpa scores through a scatter plot:
ggplot(df_dropped, aes(x = iq, y = cgpa)) +
geom_point() + geom_smooth() +
labs(title = "CGPA vs IQ") + theme_light()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Description & Explanation:
Looking at this scatter plot, there is not particular indicators that there is a positive correlation between the two variables. As such, this plot indicates that the increase in IQ level does not particularly lead to an increased CGPA score. Additionally, looking at the line of best fit, it is rather suggestive of a negative correlation between IQ and CGPA score. To add on, the widely distributed nature of this scatterplot suggests that there is no strong directional correlation between the two variables in this sample.
Looking at distribution by placement (Boxplots):
ggplot(df_dropped, aes(x = placement, y = cgpa)) + geom_boxplot() +
labs(title = "Distribution of CGPA scores by job/internship placement") +
theme_light()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?
ggplot(df_dropped, aes(x = placement, y = iq)) + geom_boxplot() +
labs(title = "Distribution of IQ level by job/internship placement") +
theme_light()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?
Description & Explanation:
Looking at the CGPA and IQ distributions by placement, we can observe that the CGPA is much more affected by the placement variable as opposed to the IQ level. As such, we can see that the overall distribution of the CGPA scores for those who secured a placement was significantly higher than those who were not able to secure a placement. Whereas, the IQ distribution is much closer, with the median IQ level being almost identical in either factions (placement). Moreover, we can even see that the interquartile range (IQR) of the non-placed students is overall higher than that of the placed students.
Looking at distribution by location (city):
ggplot(df_dropped, aes(x = city, y = cgpa)) + geom_boxplot() +
labs(title = "Distribution of CGPA scores by city") + theme_light()
ggplot(df_dropped, aes(x = city, y = iq)) + geom_boxplot() +
labs(title = "Distribution of IQ level by city") + theme_light()
Description & Explanation:
Looking at the distributions of the IQ level and CGPA scores by city, it is quite evident that the city does not play a significant role when it comes to the level and distribution of the aforementioned varaibles. However, there are some things to note regarding location in both metrics. As such, we can observe that Los Angeles produced an overall lower CGPA score (median & IQR), while the IQ levels in New York are more homogenous (less distributed). These observations can also be a topic of research in future studies, but there are not enough data and resources in this dataset to conduct such a study.