#Introduction This research looks into what determines how much professors get paid at universities, and it highlights how important it is to be clear and fair about their pay to keep a good learning environment. The study is driven by wanting to understand how paying professors well affects getting and keeping good teachers. The researchers will look at things like how long a professor has been teaching, how many years they’ve been working, and other factors using statistical methods. The goal is to find practical information that can help universities make better rules, improve how they pay professors, and be part of the conversation about fairness in education. The study hopes to find useful information to help universities make good decisions, be fair, and stay competitive in getting and keeping a diverse and talented group of professors. Later on, the study will give more details about the data they used, how they analyzed it, and what they found, with the aim of giving useful advice to universities dealing with paying professors and having a diverse staff. ##

if (!requireNamespace("readxl", quietly = TRUE)) {
  install.packages("readxl", repos = "http://cran.rstudio.com/")
}

library(readxl)
PS <- read_excel("E:/Khi tôi học/2023.1/Thống kê ứng dụng/xlsx/PS.xlsx")
summary(PS)
##  yrs.since.phd    yrs.service        salary      
##  Min.   : 1.00   Min.   : 0.00   Min.   : 57800  
##  1st Qu.:12.00   1st Qu.: 7.00   1st Qu.: 91000  
##  Median :21.00   Median :16.00   Median :107300  
##  Mean   :22.31   Mean   :17.61   Mean   :113706  
##  3rd Qu.:32.00   3rd Qu.:27.00   3rd Qu.:134185  
##  Max.   :56.00   Max.   :60.00   Max.   :231545
head(PS)
## # A tibble: 6 × 3
##   yrs.since.phd yrs.service salary
##           <dbl>       <dbl>  <dbl>
## 1            19          18 139750
## 2            20          16 173200
## 3             4           3  79750
## 4            45          39 115000
## 5            40          41 141500
## 6             6           6  97000
dim(PS)
## [1] 397   3

The data contain 397 individuals that are houses and 3 variables

names(PS)
## [1] "yrs.since.phd" "yrs.service"   "salary"

This is name of all the variable

pairs(PS, pch=20, col="blue",cex =0.7)

##Simple linear regression

cor(PS$salary,PS$yrs.service)
## [1] 0.3347447
plot(PS$yrs.service,PS$salary, col="red",pch=9)

Let us consider the model:

summary(lm(PS$salary~PS$yrs.service))
## 
## Call:
## lm(formula = PS$salary ~ PS$yrs.service)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -81933 -20511  -3776  16417 101947 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     99974.7     2416.6   41.37  < 2e-16 ***
## PS$yrs.service    779.6      110.4    7.06 7.53e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 28580 on 395 degrees of freedom
## Multiple R-squared:  0.1121, Adjusted R-squared:  0.1098 
## F-statistic: 49.85 on 1 and 395 DF,  p-value: 7.529e-12
summary(lm(PS$salary ~ 0 + PS$yrs.service))
## 
## Call:
## lm(formula = PS$salary ~ 0 + PS$yrs.service)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -177150    1854   51969   71313  172808 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## PS$yrs.service   4456.0      151.1   29.48   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 65910 on 396 degrees of freedom
## Multiple R-squared:  0.687,  Adjusted R-squared:  0.6862 
## F-statistic: 869.2 on 1 and 396 DF,  p-value: < 2.2e-16

We can observe that the model without the intercept term exhibits improved performance, indicated by a smaller MSE and a higher R^2 value compared to the model with the intercept term. The R^2 value close to 1 suggests that a significant proportion of the variability in the salary can be explained by the years of service. Therefore, we can consider the following simplified relationship for the salary: \[salary = coefficient * yrs_ service\]

plot(PS$yrs.service,PS$salary, col="green",pch=20)
abline(a = 99974.7, b= 779.6, col="blue", lty=3)

##Mutiple regression

summary(lm(PS$salary~PS$yrs.service + PS$yrs.since.phd ))
## 
## Call:
## lm(formula = PS$salary ~ PS$yrs.service + PS$yrs.since.phd)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -79735 -19823  -2617  15149 106149 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       89912.2     2843.6  31.620  < 2e-16 ***
## PS$yrs.service     -629.1      254.5  -2.472   0.0138 *  
## PS$yrs.since.phd   1562.9      256.8   6.086 2.75e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 27360 on 394 degrees of freedom
## Multiple R-squared:  0.1883, Adjusted R-squared:  0.1842 
## F-statistic: 45.71 on 2 and 394 DF,  p-value: < 2.2e-16
summary(lm(PS$salary~0+PS$yrs.service + PS$yrs.since.phd ))
## 
## Call:
## lm(formula = PS$salary ~ 0 + PS$yrs.service + PS$yrs.since.phd)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -129080   -7118   29905   56509  109874 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## PS$yrs.service    -2696.8      462.0  -5.838  1.1e-08 ***
## PS$yrs.since.phd   6284.9      392.5  16.013  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 51390 on 395 degrees of freedom
## Multiple R-squared:  0.8102, Adjusted R-squared:  0.8092 
## F-statistic: 843.1 on 2 and 395 DF,  p-value: < 2.2e-16

Conclusion

In conclusion, our exploration of professor salaries in higher education, facilitated by functions such as dim, name, head, and summary, began with a detailed examination of dataset dimensions, variable names, and initial data. Subsequently, leveraging functions like summary(lm()), pairs, and cor, we delved into intricate relationships through multiple and simple regression analyses. This comprehensive approach not only provided a nuanced understanding of compensation dynamics but also ensured transparency and accuracy in our exploration, highlighting the pivotal role of meticulous dataset exploration in drawing meaningful insights from the academic remuneration landscape.