Professional Documents
Culture Documents
Applied Exercise 4
Applied Exercise 4
1.8years, Excluding high school and elementary school, most of those with 8 years of
employment are those with higher education.
2. According to survivor analysis, it can be determined that after 15 years, employees will tend to
leave and choose more possible opportunities.
3. Gender and educational attainment will affect the employment of employees, as will regional
radiation.
4. The educational level and location of the employed person, as well as the gender, will affect
the number of years the employed person has worked.
5. In addition to the above reference points, staff salary, working environment and promotion
space will also become the factors for staff to leave or not
Code
library(ggplot2)
library(dplyr)
library(psych) # describe
library(GGally) # ggpairs plot
library(reshape)
library(purrr) # Organizing
library(tidyr) # Organize/tidy data
library(forcats) # fct_reorder
library(MASS) # stepAIC
library(descr) # for pseudo R2
library(pROC)
library(survival)
dataset2$urbanicity<- as.factor(
ifelse(dataset2$urbanicity<=0.74,"Normal",
ifelse(dataset2$urbanicity<=0.949,"Medium","High")))
dd<-datadist(dataset2)
options(datadist="dd")
fitCPH<-cph(Surv(yearsatfirm,quit)~locationcode+urbanicity+gender+
hiredonexperience+currentnlyinschool+
education+degreefield+
employeesinfirm+company_type+totalcertificationhours,data=dataset2, x=TRUE,
y=TRUE, surv=TRUE)
print(fitCPH)
exp(fitCPH$coefficients)