The significance of the sector on the salary in Sweden, a comparison between different occupational groups, part 3

[This article was first published on R Analystatistics Sweden , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

To complete the analysis on the significance of the sector on the salary for different occupational groups in Sweden I will in this post examine the correlation between salary and sector using statistics for education.

The F-value from the Anova table is used as the single value to discriminate how much the region and salary correlates. For exploratory analysis, the Anova value seems good enough.

First, define libraries and functions.

library (tidyverse)
## -- Attaching packages --------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.2.1     v purrr   0.3.3
## v tibble  2.1.3     v dplyr   0.8.3
## v tidyr   1.0.2     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.4.0
## -- Conflicts ------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library (broom)
library (car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
library (sjPlot)
## Registered S3 methods overwritten by 'lme4':
##   method                          from
##   cooks.distance.influence.merMod car 
##   influence.merMod                car 
##   dfbeta.influence.merMod         car 
##   dfbetas.influence.merMod        car
## Learn more about sjPlot with 'browseVignettes("sjPlot")'.
readfile <- function (file1){read_csv (file1, col_types = cols(), locale = readr::locale (encoding = "latin1"), na = c("..", "NA")) %>%
  gather (starts_with("19"), starts_with("20"), key = "year", value = salary) %>%
  drop_na() %>%
  mutate (year_n = parse_number (year))
}

The data table is downloaded from Statistics Sweden. It is saved as a comma-delimited file without heading, 000000CY.csv, http://www.statistikdatabasen.scb.se/pxweb/en/ssd/.

I have renamed the file to 000000CY_sector.csv because the filename 000000CY.csv was used in a previous post.

The table: Average basic salary, monthly salary and women´s salary as a percentage of men´s salary by sector, occupational group (SSYK 2012), sex and educational level (SUN). Year 2014 – 2018 Monthly salary 1-3 public sector 4-5 private sector

In the plot and tables, you can also find information on how the increase in salaries per year for each occupational group is affected when the interactions are taken into account.

tb <- readfile("000000CY_sector.csv") %>% 
  mutate(edulevel = `level of education`)

numedulevel <- read.csv("edulevel.csv") 

numedulevel %>%
  knitr::kable(
  booktabs = TRUE,
  caption = 'Initial approach, length of education') 
Table 1: Initial approach, length of education
level.of.educationeduyears
primary and secondary education 9-10 years (ISCED97 2)9
upper secondary education, 2 years or less (ISCED97 3C)11
upper secondary education 3 years (ISCED97 3A)12
post-secondary education, less than 3 years (ISCED97 4+5B)14
post-secondary education 3 years or more (ISCED97 5A)15
post-graduate education (ISCED97 6)19
no information about level of educational attainmentNA
tbnum <- tb %>% 
  right_join(numedulevel, by = c("level of education" = "level.of.education")) %>%
  filter(!is.na(eduyears)) %>%
  mutate(eduyears = factor(eduyears))
## Warning: Column `level of education`/`level.of.education` joining character
## vector and factor, coercing into character vector
summary_table = vector()
anova_table = vector()

for (i in unique(tbnum$`occuptional  (SSYK 2012)`)){
  temp <- filter(tbnum, `occuptional  (SSYK 2012)` == i)
  if (dim(temp)[1] > 90){
    model <- lm(log(salary) ~ edulevel + sex + year_n + sector, data = temp)
    summary_table <- rbind (summary_table, mutate (tidy (summary (model)), ssyk = i, interaction = "none"))
    anova_table <- rbind (anova_table, mutate (tidy (Anova (model, type = 2)), ssyk = i, interaction = "none"))  
  
    model <- lm(log(salary) ~ edulevel * sector + sex + year_n, data = temp)
    summary_table <- rbind (summary_table, mutate (tidy (summary (model)), ssyk = i, interaction = "sector and edulevel"))
    anova_table <- rbind (anova_table, mutate (tidy (Anova (model, type = 2)), ssyk = i, interaction = "sector and edulevel"))  
    
    model <- lm(log(salary) ~ edulevel + sector * sex + year_n, data = temp)
    summary_table <- rbind (summary_table, mutate (tidy (summary (model)), ssyk = i, interaction = "sector and sex"))
    anova_table <- rbind (anova_table, mutate (tidy (Anova (model, type = 2)), ssyk = i, interaction = "sector and sex"))  
    
    model <- lm(log(salary) ~ edulevel +  year_n * sector + sex, data = temp)
    summary_table <- rbind (summary_table, mutate (tidy (summary (model)), ssyk = i, interaction = "sector and year"))
    anova_table <- rbind (anova_table, mutate (tidy (Anova (model, type = 2)), ssyk = i, interaction = "sector and year"))  
    
    model <- lm(log(salary) ~ edulevel * sector * sex * year_n, data = temp)
    summary_table <- rbind (summary_table, mutate (tidy (summary (model)), ssyk = i, interaction = "sector, year, edulevel and sex"))
    anova_table <- rbind (anova_table, mutate (tidy (Anova (model, type = 2)), ssyk = i, interaction = "sector, year, edulevel and sex"))      
  }
}
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
## Note: model has aliased coefficients
##       sums of squares computed by model comparison
anova_table <- anova_table %>% rowwise() %>% mutate(contcol = str_count(term, ":")) 

summary_table <- summary_table %>% rowwise() %>% mutate(contcol = str_count(term, ":"))

merge(summary_table, anova_table, by = c("ssyk", "interaction"), all = TRUE) %>%
  filter (term.x == "year_n") %>%
  filter (term.y == "sector") %>%    
  filter (interaction == "none") %>%
  
  mutate (estimate = (exp(estimate) - 1) * 100) %>%  
  ggplot () +
    geom_point (mapping = aes(x = estimate, y = statistic.y, colour = interaction)) +
    labs(
      x = "Increase in salaries (% / year)",
      y = "F-value for sector"
    )   

The significance of the sector on the salary in Sweden, a comparison between different occupational groups, Year 2014 - 2018

Figure 1: The significance of the sector on the salary in Sweden, a comparison between different occupational groups, Year 2014 – 2018

merge(summary_table, anova_table, by = c("ssyk", "interaction"), all = TRUE) %>%
  filter (term.x == "year_n") %>%
  filter (contcol.y > 0) %>%    
  # only look at the interactions between all four variables in the case with interaction sector, year, edulevel and sex
  filter (!(contcol.y < 3 & interaction == "sector, year, edulevel and sex")) %>% 
  
  mutate (estimate = (exp(estimate) - 1) * 100) %>%  
  ggplot () +
    geom_point (mapping = aes(x = estimate, y = statistic.y, colour = interaction)) +
    labs(
      x = "Increase in salaries (% / year)",
      y = "F-value for interaction"
    ) 

The significance of the interaction between sector, edulevel, year and sex on the salary in Sweden, a comparison between different occupational groups, Year 2014 - 2018

Figure 2: The significance of the interaction between sector, edulevel, year and sex on the salary in Sweden, a comparison between different occupational groups, Year 2014 – 2018

The tables with all occupational groups sorted by F-value in descending order.

merge(summary_table, anova_table, c("ssyk", "interaction"), all = TRUE) %>%
  filter (term.x == "year_n") %>%
  filter (term.y == "sector") %>%   
  filter (interaction == "none") %>%
  mutate (estimate = (exp(estimate) - 1) * 100) %>%  
  select (ssyk, estimate, statistic.y, interaction) %>%
  rename (`F-value` = statistic.y) %>%
  rename (`Increase in salary` = estimate) %>%
  arrange (desc (`F-value`)) %>%
  knitr::kable(
    booktabs = TRUE,
    caption = 'Correlation for F-value (sector) and the yearly increase in salaries')
Table 2: Correlation for F-value (sector) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
242 Organisation analysts, policy administrators and human resource specialists1.609869515.5748558none
819 Process control technicians2.250895467.4732796none
251 ICT architects, systems analysts and test managers2.217446465.2253589none
331 Financial and accounting associate professionals1.964825340.2901702none
962 Newspaper distributors, janitors and other service workers1.971413336.7676606none
334 Administrative and specialized secretaries2.410127333.7196510none
351 ICT operations and user support technicians2.474549305.6052807none
241 Accountants, financial analysts and fund managers2.534461251.4058600none
335 Tax and related government associate professionals2.586686250.8147705none
515 Building caretakers and related workers2.522386250.0742967none
321 Medical and pharmaceutical technicians2.493038230.0064060none
213 Biologists, pharmacologists and specialists in agriculture and forestry2.303600228.0668837none
134 Architectural and engineering managers3.161068226.5669850none
333 Business services agents3.001597222.9774594none
411 Office assistants and other secretaries2.227235214.6750980none
243 Marketing and public relations professionals1.481519179.3099186none
264 Authors, journalists and linguists2.046538164.8394018none
129 Administration and service managers not elsewhere classified4.059900158.7687951none
342 Athletes, fitness instructors and recreational workers1.586943132.1816646none
159 Other social services managers2.54120569.9268014none
123 Administration and planning managers3.84920050.0164438none
541 Other surveillance and security workers2.46013041.9287342none
235 Teaching professionals not elsewhere classified1.41559140.1919620none
911 Cleaners and helpers1.93836635.3850213none
533 Health care assistants2.15737922.0488822none
534 Attendants, personal assistants and related workers1.95959521.6985964none
332 Insurance advisers, sales and purchasing agents2.63748619.1041252none
131 Information and communications technology service managers4.00060917.0841502none
311 Physical and engineering science technicians2.32595816.5471030none
214 Engineering professionals2.62626015.6152029none
432 Stores and transport clerks1.23185413.9155189none
723 Machinery mechanics and fitters2.36298412.5847785none
532 Personal care workers in health services2.9065786.3336230none
512 Cooks and cold-buffet managers2.4832805.4612144none
732 Printing trades workers2.1588545.2405535none
234 Primary- and pre-school teachers2.9856534.6801860none
422 Client information clerks2.5278011.7881181none
531 Child care workers and teachers aides1.8816150.8334164none
611 Market gardeners and crop growers1.9802880.3732826none
341 Social work and religious associate professionals2.3577870.0276157none
941 Fast-food workers, food preparation assistants1.9815120.0046670none
merge(summary_table, anova_table, c("ssyk", "interaction"), all = TRUE) %>%
  filter (term.x == "year_n") %>%
  filter (contcol.y > 0) %>%   
  filter (interaction == "sector and sex") %>%
  mutate (estimate = (exp(estimate) - 1) * 100) %>%  
  select (ssyk, estimate, statistic.y, interaction) %>%
  rename (`F-value` = statistic.y) %>%
  rename (`Increase in salary` = estimate) %>%
  arrange (desc (`F-value`)) %>%
  knitr::kable(
    booktabs = TRUE,
    caption = 'Correlation for F-value (sector and sex) and the yearly increase in salaries')
Table 3: Correlation for F-value (sector and sex) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
911 Cleaners and helpers1.966955183.3539258sector and sex
331 Financial and accounting associate professionals1.98862884.3723061sector and sex
342 Athletes, fitness instructors and recreational workers1.60940753.2856268sector and sex
351 ICT operations and user support technicians2.47454953.1541368sector and sex
241 Accountants, financial analysts and fund managers2.54916139.5233707sector and sex
333 Business services agents2.95297332.5926396sector and sex
611 Market gardeners and crop growers1.93633825.7248443sector and sex
243 Marketing and public relations professionals1.48986024.3260135sector and sex
533 Health care assistants2.15737919.0714901sector and sex
732 Printing trades workers2.20761716.8065594sector and sex
512 Cooks and cold-buffet managers2.49740815.7408059sector and sex
159 Other social services managers2.51155815.1529257sector and sex
123 Administration and planning managers3.81999514.2436097sector and sex
532 Personal care workers in health services2.89948213.1974037sector and sex
334 Administrative and specialized secretaries2.41695712.8317750sector and sex
213 Biologists, pharmacologists and specialists in agriculture and forestry2.31789310.2339741sector and sex
134 Architectural and engineering managers3.1610689.7816667sector and sex
321 Medical and pharmaceutical technicians2.4930388.6670096sector and sex
941 Fast-food workers, food preparation assistants1.9894658.6486138sector and sex
335 Tax and related government associate professionals2.5866868.4427211sector and sex
242 Organisation analysts, policy administrators and human resource specialists1.5949998.1271264sector and sex
723 Machinery mechanics and fitters2.3379836.4299201sector and sex
332 Insurance advisers, sales and purchasing agents2.6277365.7400150sector and sex
311 Physical and engineering science technicians2.3161385.3473607sector and sex
234 Primary- and pre-school teachers2.9991615.0012138sector and sex
129 Administration and service managers not elsewhere classified4.1210664.6687219sector and sex
819 Process control technicians2.2508953.7631281sector and sex
534 Attendants, personal assistants and related workers1.9595953.5292601sector and sex
131 Information and communications technology service managers4.0293032.5233240sector and sex
264 Authors, journalists and linguists2.0332032.5032667sector and sex
341 Social work and religious associate professionals2.3577872.2988889sector and sex
251 ICT architects, systems analysts and test managers2.2174462.1823519sector and sex
422 Client information clerks2.5196312.1300830sector and sex
432 Stores and transport clerks1.2318541.5040767sector and sex
541 Other surveillance and security workers2.4570071.3945913sector and sex
214 Engineering professionals2.6290571.3225970sector and sex
962 Newspaper distributors, janitors and other service workers1.9714130.3480210sector and sex
531 Child care workers and teachers aides1.8795810.1432868sector and sex
515 Building caretakers and related workers2.5228440.1379141sector and sex
235 Teaching professionals not elsewhere classified1.4244880.0670314sector and sex
411 Office assistants and other secretaries2.2272350.0001653sector and sex
merge(summary_table, anova_table, c("ssyk", "interaction"), all = TRUE) %>%
  filter (term.x == "year_n") %>%
  filter (contcol.y > 0) %>%   
  filter (interaction == "sector and edulevel") %>%
  mutate (estimate = (exp(estimate) - 1) * 100) %>%  
  select (ssyk, estimate, statistic.y, interaction) %>%
  rename (`F-value` = statistic.y) %>%
  rename (`Increase in salary` = estimate) %>%
  arrange (desc (`F-value`)) %>%
  knitr::kable(
    booktabs = TRUE,
    caption = 'Correlation for F-value (sector and edulevel) and the yearly increase in salaries')
Table 4: Correlation for F-value (sector and edulevel) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
335 Tax and related government associate professionals2.58668648.2902588sector and edulevel
234 Primary- and pre-school teachers2.93616232.3560802sector and edulevel
214 Engineering professionals2.63684329.4462376sector and edulevel
332 Insurance advisers, sales and purchasing agents2.42063226.7105578sector and edulevel
432 Stores and transport clerks1.23185424.9194979sector and edulevel
134 Architectural and engineering managers3.16106820.3665858sector and edulevel
321 Medical and pharmaceutical technicians2.49303818.1556092sector and edulevel
723 Machinery mechanics and fitters2.35817117.3272819sector and edulevel
311 Physical and engineering science technicians2.33030012.9686992sector and edulevel
123 Administration and planning managers3.80901911.7436022sector and edulevel
732 Printing trades workers2.22072811.0453452sector and edulevel
241 Accountants, financial analysts and fund managers2.64706810.5100504sector and edulevel
235 Teaching professionals not elsewhere classified1.3960768.6264575sector and edulevel
213 Biologists, pharmacologists and specialists in agriculture and forestry2.2641107.7952190sector and edulevel
941 Fast-food workers, food preparation assistants1.9815127.5766373sector and edulevel
331 Financial and accounting associate professionals1.9803386.9758948sector and edulevel
532 Personal care workers in health services2.9199336.6231457sector and edulevel
534 Attendants, personal assistants and related workers1.9595955.7464596sector and edulevel
962 Newspaper distributors, janitors and other service workers1.9714135.4435379sector and edulevel
131 Information and communications technology service managers3.9081114.9661376sector and edulevel
159 Other social services managers2.5655234.7197836sector and edulevel
129 Administration and service managers not elsewhere classified4.1609954.3062655sector and edulevel
251 ICT architects, systems analysts and test managers2.2091313.5539841sector and edulevel
512 Cooks and cold-buffet managers2.4359033.4242806sector and edulevel
333 Business services agents2.9559703.3635706sector and edulevel
243 Marketing and public relations professionals1.4730643.2639790sector and edulevel
264 Authors, journalists and linguists2.0436773.0449469sector and edulevel
334 Administrative and specialized secretaries2.3874672.8528940sector and edulevel
422 Client information clerks2.5278012.3007696sector and edulevel
242 Organisation analysts, policy administrators and human resource specialists1.6129001.9599904sector and edulevel
351 ICT operations and user support technicians2.4745491.5903279sector and edulevel
819 Process control technicians2.2508951.5586112sector and edulevel
341 Social work and religious associate professionals2.3577871.3263497sector and edulevel
611 Market gardeners and crop growers2.0163451.2719035sector and edulevel
541 Other surveillance and security workers2.4601301.0672924sector and edulevel
411 Office assistants and other secretaries2.2272351.0114046sector and edulevel
515 Building caretakers and related workers2.5261000.8254389sector and edulevel
342 Athletes, fitness instructors and recreational workers1.5409520.8230839sector and edulevel
531 Child care workers and teachers aides1.8978630.7969406sector and edulevel
533 Health care assistants2.1573790.5425248sector and edulevel
911 Cleaners and helpers1.9383660.0965584sector and edulevel
merge(summary_table, anova_table, c("ssyk", "interaction"), all = TRUE) %>%
  filter (term.x == "year_n") %>%
  filter (contcol.y > 0) %>%   
  filter (interaction == "sector and year") %>%
  mutate (estimate = (exp(estimate) - 1) * 100) %>%  
  select (ssyk, estimate, statistic.y, interaction) %>%
  rename (`F-value` = statistic.y) %>%
  rename (`Increase in salary` = estimate) %>%
  arrange (desc (`F-value`)) %>%
  knitr::kable(
    booktabs = TRUE,
    caption = 'Correlation for F-value (sector and year) and the yearly increase in salaries')
Table 5: Correlation for F-value (sector and year) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
129 Administration and service managers not elsewhere classified5.852818717.1667457sector and year
351 ICT operations and user support technicians3.245536216.6101284sector and year
334 Administrative and specialized secretaries1.067277514.9508269sector and year
534 Attendants, personal assistants and related workers2.276947712.4036331sector and year
422 Client information clerks3.273348311.6812523sector and year
962 Newspaper distributors, janitors and other service workers2.490734611.5673142sector and year
264 Authors, journalists and linguists2.990512110.5945994sector and year
531 Child care workers and teachers aides2.45102869.5936100sector and year
242 Organisation analysts, policy administrators and human resource specialists2.33558267.7816291sector and year
432 Stores and transport clerks0.53325677.4196762sector and year
243 Marketing and public relations professionals2.18280575.5660180sector and year
732 Printing trades workers2.88253804.3716553sector and year
213 Biologists, pharmacologists and specialists in agriculture and forestry2.80997833.6786224sector and year
611 Market gardeners and crop growers2.31612383.3017939sector and year
131 Information and communications technology service managers3.35049302.8750373sector and year
532 Personal care workers in health services2.74110302.8290655sector and year
235 Teaching professionals not elsewhere classified1.80475712.7841902sector and year
311 Physical and engineering science technicians2.86087412.6173373sector and year
533 Health care assistants1.99201132.2486864sector and year
214 Engineering professionals3.02099632.0446973sector and year
723 Machinery mechanics and fitters2.62588641.4272778sector and year
515 Building caretakers and related workers2.34233571.3492650sector and year
321 Medical and pharmaceutical technicians2.13763341.2494762sector and year
941 Fast-food workers, food preparation assistants2.19063121.1458297sector and year
234 Primary- and pre-school teachers3.15228490.8075167sector and year
411 Office assistants and other secretaries2.42174470.7799156sector and year
241 Accountants, financial analysts and fund managers2.26256630.7751592sector and year
541 Other surveillance and security workers2.30187470.6646888sector and year
134 Architectural and engineering managers3.38118210.5852232sector and year
333 Business services agents3.25200120.5424390sector and year
335 Tax and related government associate professionals2.39862330.3139375sector and year
123 Administration and planning managers4.09458840.2682143sector and year
911 Cleaners and helpers2.00828730.2021948sector and year
341 Social work and religious associate professionals2.39942920.0754320sector and year
342 Athletes, fitness instructors and recreational workers1.66738960.0633281sector and year
512 Cooks and cold-buffet managers2.42496310.0494622sector and year
819 Process control technicians2.22258730.0378303sector and year
331 Financial and accounting associate professionals2.05575050.0377336sector and year
251 ICT architects, systems analysts and test managers2.25361380.0294035sector and year
332 Insurance advisers, sales and purchasing agents2.60156640.0125275sector and year
159 Other social services managers2.54877580.0013436sector and year
merge(summary_table, anova_table, c("ssyk", "interaction"), all = TRUE) %>%
  filter (term.x == "year_n") %>%
  filter (contcol.y > 1) %>%   
  filter (interaction == "sector, year, edulevel and sex") %>%
  filter (!(contcol.y < 3 & interaction == "sector, year, edulevel and sex")) %>%  
  mutate (estimate = (exp(estimate) - 1) * 100) %>%  
  select (ssyk, estimate, statistic.y, interaction) %>%
  rename (`F-value` = statistic.y) %>%
  rename (`Increase in salary` = estimate) %>%
  arrange (desc (`F-value`)) %>%
  knitr::kable(
    booktabs = TRUE,
    caption = 'Correlation for F-value (sector, year, edulevel and sex) and the yearly increase in salaries')
Table 6: Correlation for F-value (sector, year, edulevel and sex) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
264 Authors, journalists and linguists2.07178715.0646298sector, year, edulevel and sex
311 Physical and engineering science technicians-1.93585963.3593399sector, year, edulevel and sex
159 Other social services managers2.13390492.5206357sector, year, edulevel and sex
134 Architectural and engineering managers-0.22217162.4150753sector, year, edulevel and sex
331 Financial and accounting associate professionals0.29897572.2892768sector, year, edulevel and sex
342 Athletes, fitness instructors and recreational workers2.77991672.1976399sector, year, edulevel and sex
214 Engineering professionals5.27329041.9988132sector, year, edulevel and sex
723 Machinery mechanics and fitters2.13349831.8843643sector, year, edulevel and sex
432 Stores and transport clerks-0.28837371.8215339sector, year, edulevel and sex
241 Accountants, financial analysts and fund managers2.62683771.8184489sector, year, edulevel and sex
533 Health care assistants1.31762801.6357939sector, year, edulevel and sex
911 Cleaners and helpers1.18756301.6319874sector, year, edulevel and sex
129 Administration and service managers not elsewhere classified16.09324031.5716145sector, year, edulevel and sex
512 Cooks and cold-buffet managers2.23356771.4882138sector, year, edulevel and sex
242 Organisation analysts, policy administrators and human resource specialists1.93778021.4494844sector, year, edulevel and sex
234 Primary- and pre-school teachers2.62862111.4408203sector, year, edulevel and sex
235 Teaching professionals not elsewhere classified1.48066491.4162230sector, year, edulevel and sex
532 Personal care workers in health services3.08097171.3439893sector, year, edulevel and sex
962 Newspaper distributors, janitors and other service workers1.72175341.3344044sector, year, edulevel and sex
332 Insurance advisers, sales and purchasing agents4.55151340.9604905sector, year, edulevel and sex
123 Administration and planning managers1.68604360.9155189sector, year, edulevel and sex
541 Other surveillance and security workers3.13725490.9113280sector, year, edulevel and sex
213 Biologists, pharmacologists and specialists in agriculture and forestry2.09567110.9044780sector, year, edulevel and sex
422 Client information clerks7.62311000.8611877sector, year, edulevel and sex
515 Building caretakers and related workers3.82842910.8343329sector, year, edulevel and sex
334 Administrative and specialized secretaries-1.80219420.7940149sector, year, edulevel and sex
531 Child care workers and teachers aides2.95562780.7580341sector, year, edulevel and sex
131 Information and communications technology service managers6.25364360.7429188sector, year, edulevel and sex
243 Marketing and public relations professionals-0.79390380.7338409sector, year, edulevel and sex
351 ICT operations and user support technicians3.23123020.7188959sector, year, edulevel and sex
732 Printing trades workers3.99938230.6905319sector, year, edulevel and sex
321 Medical and pharmaceutical technicians2.21646740.6326293sector, year, edulevel and sex
611 Market gardeners and crop growers2.27533480.6157880sector, year, edulevel and sex
341 Social work and religious associate professionals3.06666200.5266982sector, year, edulevel and sex
941 Fast-food workers, food preparation assistants2.79405680.4253642sector, year, edulevel and sex
335 Tax and related government associate professionals5.04704560.3217115sector, year, edulevel and sex
251 ICT architects, systems analysts and test managers2.90312560.2684425sector, year, edulevel and sex
819 Process control technicians1.67417170.2603997sector, year, edulevel and sex
333 Business services agents1.81433440.1540308sector, year, edulevel and sex
411 Office assistants and other secretaries5.52310190.0911334sector, year, edulevel and sex
534 Attendants, personal assistants and related workers2.69277190.0899580sector, year, edulevel and sex

Let’s check what we have found.

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "242 Organisation analysts, policy administrators and human resource specialists")
 
model <- lm (log(salary) ~ year_n + eduyears + sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "sector"))
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Highest F-value sector, Organisation analysts, policy administrators and human resource specialists

Figure 3: Highest F-value sector, Organisation analysts, policy administrators and human resource specialists

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "941 Fast-food workers, food preparation assistants")
 
model <-lm (log(salary) ~ year_n + eduyears + sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "sector"))
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Lowest F-value sector, Fast-food workers, food preparation assistants

Figure 4: Lowest F-value sector, Fast-food workers, food preparation assistants

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "911 Cleaners and helpers")
 
model <- lm (log(salary) ~ year_n + eduyears + sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "sex", "sector"))
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Highest F-value interaction sector and gender, Cleaners and helpers

Figure 5: Highest F-value interaction sector and gender, Cleaners and helpers

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "411 Office assistants and other secretaries")
 
model <- lm (log(salary) ~ year_n + eduyears + sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "sex", "sector"))
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Lowest F-value interaction sector and gender, Office assistants and other secretaries

Figure 6: Lowest F-value interaction sector and gender, Office assistants and other secretaries

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "335 Tax and related government associate professionals")
 
model <- lm (log(salary) ~ year_n + eduyears * sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "sector"))
## Warning in predict.lm(model, newdata = fitfram, type = "response", se.fit =
## se, : prediction from a rank-deficient fit may be misleading
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Highest F-value interaction sector and edulevel, Tax and related government associate professionals

Figure 7: Highest F-value interaction sector and edulevel, Tax and related government associate professionals

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "911 Cleaners and helpers")
 
model <- lm (log(salary) ~ year_n + eduyears * sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "sector"))
## Warning in predict.lm(model, newdata = fitfram, type = "response", se.fit =
## se, : prediction from a rank-deficient fit may be misleading
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Lowest F-value interaction sector and edulevel, Cleaners and helpers

Figure 8: Lowest F-value interaction sector and edulevel, Cleaners and helpers

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "129 Administration and service managers not elsewhere classified")
 
model <- lm (log(salary) ~ year_n * sector + eduyears + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "year_n", "sector"))
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Highest F-value interaction sector and year, Administration and service managers not elsewhere classified

Figure 9: Highest F-value interaction sector and year, Administration and service managers not elsewhere classified

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "159 Other social services managers")
 
model <- lm (log(salary) ~ year_n * sector + eduyears + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "year_n", "sector"))
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Lowest F-value interaction sector and year, Other social services managers

Figure 10: Lowest F-value interaction sector and year, Other social services managers

temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "264 Authors, journalists and linguists")
 
model <- lm (log(salary) ~ year_n * eduyears * sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "year_n", "sex", "sector"))
## Warning in predict.lm(model, newdata = fitfram, type = "response", se.fit =
## se, : prediction from a rank-deficient fit may be misleading
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Highest F-value interaction sector, edulevel, year and gender, Authors, journalists and linguists

Figure 11: Highest F-value interaction sector, edulevel, year and gender, Authors, journalists and linguists

## TableGrob (2 x 1) "arrange": 2 grobs
##   z     cells    name           grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (2-2,1-1) arrange gtable[layout]
temp <- tbnum %>%
  filter(`occuptional  (SSYK 2012)` == "534 Attendants, personal assistants and related workers")
 
model <- lm (log(salary) ~ year_n * eduyears * sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("eduyears", "year_n", "sex", "sector"))
## Warning in predict.lm(model, newdata = fitfram, type = "response", se.fit =
## se, : prediction from a rank-deficient fit may be misleading
## Model has log-transformed response. Back-transforming predictions to original response scale. Standard errors are still on the log-scale.

Lowest F-value interaction sector, edulevel, year and gender, Attendants, personal assistants and related workers

Figure 12: Lowest F-value interaction sector, edulevel, year and gender, Attendants, personal assistants and related workers

## TableGrob (2 x 1) "arrange": 2 grobs
##   z     cells    name           grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (2-2,1-1) arrange gtable[layout]

To leave a comment for the author, please follow the link and comment on their blog: R Analystatistics Sweden .

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)