Reading PISA data

t = "/Users/tuannguyen/Dropbox/_Conferences and Workshops/Banking University/Data/PISA Data Vietnam 2015.csv"

pisa = read.csv(t)

head(pisa)
##     School SchoolSize ClassSize STratio SchoolType  Area Region   Age
## 1 70400001        883        18  22.075          3 URBAN  SOUTH 15.58
## 2 70400001        883        18  22.075          3 URBAN  SOUTH 15.92
## 3 70400001        883        18  22.075          3 URBAN  SOUTH 15.42
## 4 70400001        883        18  22.075          3 URBAN  SOUTH 15.58
## 5 70400001        883        18  22.075          3 URBAN  SOUTH 15.92
## 6 70400001        883        18  22.075          3 URBAN  SOUTH 16.25
##   Gender PARED HISCED  WEALTH INSTSCIE JOYSCIE  ICTRES    Math    Read
## 1   Boys     9      2 -2.0697   0.9798  2.1635 -1.5244 439.923 412.290
## 2   Boys    12      4 -1.7903   1.7359  2.1635 -1.9305 406.251 409.598
## 3  Girls     9      2 -2.1942  -0.2063 -0.1808 -1.6093 414.369 384.307
## 4  Girls     5      1 -2.0301  -0.3115 -0.4318 -1.6250 468.801 459.104
## 5  Girls     9      2 -1.0522   0.7648  1.3031 -0.5305 355.432 402.435
## 6  Girls     5      1 -3.0570   0.3708  0.5094 -2.5873 458.955 483.885
##   Science
## 1 475.612
## 2 450.320
## 3 405.787
## 4 462.968
## 5 453.736
## 6 529.866
dim(pisa)
## [1] 5826   18

Descriptive analyses

summary(pisa)
##      School           SchoolSize     ClassSize        STratio      
##  Min.   :70400001   Min.   : 113   Min.   :13.00   Min.   : 4.314  
##  1st Qu.:70400052   1st Qu.: 650   1st Qu.:38.00   1st Qu.:14.024  
##  Median :70400096   Median :1090   Median :38.00   Median :16.627  
##  Mean   :70400097   Mean   :1082   Mean   :40.57   Mean   :16.497  
##  3rd Qu.:70400143   3rd Qu.:1419   3rd Qu.:43.00   3rd Qu.:18.983  
##  Max.   :70400188   Max.   :4016   Max.   :53.00   Max.   :38.651  
##                                    NA's   :34                      
##    SchoolType        Area          Region          Age          Gender    
##  Min.   :1.000   REMOTE: 410   CENTRAL:2006   Min.   :15.33   Boys :2786  
##  1st Qu.:3.000   RURAL :2368   NORTH  :1958   1st Qu.:15.50   Girls:3040  
##  Median :3.000   URBAN :3048   SOUTH  :1862   Median :15.75               
##  Mean   :2.849                                Mean   :15.78               
##  3rd Qu.:3.000                                3rd Qu.:16.00               
##  Max.   :3.000                                Max.   :16.25               
##  NA's   :35                                                               
##      PARED            HISCED         WEALTH          INSTSCIE      
##  Min.   : 3.000   Min.   :0.00   Min.   :-7.635   Min.   :-1.9301  
##  1st Qu.: 9.000   1st Qu.:2.00   1st Qu.:-2.829   1st Qu.: 0.0125  
##  Median : 9.000   Median :2.00   Median :-2.163   Median : 0.3708  
##  Mean   : 9.374   Mean   :2.58   Mean   :-2.219   Mean   : 0.4835  
##  3rd Qu.:12.000   3rd Qu.:4.00   3rd Qu.:-1.504   3rd Qu.: 1.0218  
##  Max.   :17.000   Max.   :6.00   Max.   : 3.211   Max.   : 1.7359  
##  NA's   :14       NA's   :14     NA's   :15       NA's   :17       
##     JOYSCIE            ICTRES            Math            Read      
##  Min.   :-2.1154   Min.   :-3.508   Min.   :201.7   Min.   :107.1  
##  1st Qu.: 0.5094   1st Qu.:-2.587   1st Qu.:440.0   1st Qu.:442.5  
##  Median : 0.5094   Median :-1.855   Median :493.4   Median :489.5  
##  Mean   : 0.6448   Mean   :-1.795   Mean   :496.1   Mean   :489.9  
##  3rd Qu.: 1.1049   3rd Qu.:-1.117   3rd Qu.:551.5   3rd Qu.:537.6  
##  Max.   : 2.1635   Max.   : 3.497   Max.   :820.1   Max.   :744.1  
##  NA's   :19        NA's   :34                                      
##     Science     
##  Min.   :292.7  
##  1st Qu.:470.9  
##  Median :523.9  
##  Mean   :524.8  
##  3rd Qu.:574.8  
##  Max.   :807.3  
## 
# Mean and SD of Science
m = mean(pisa$Science)
s = sd(pisa$Science)

# 95% Confidence Interval (CI) 
L95 = m - 1.96*s
U95 = m + 1.96*s

# Report 95% CI 
c(L95, m, U95)
## [1] 377.9063 524.8112 671.7161

Histogram

# Simple distribution plot
hist(pisa$Science, col="blue", border="white", xlab="Science Score", ylab="Number of students", main="Distribution of Science Scores")

# Use probability 
hist(pisa$Science, col="blue", border="white", xlab="Science Score", ylab="Number of students", main="Distribution of Science Scores", prob=T)

# Density line
lines(density(pisa$Science), col="red", lwd=2)