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

[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.

In my last post, I examined the significance of the sector on the salary for different occupational groups using statistics from different regions. In previous posts I have shown a correlation between the salary and experience and also salary and education, In this post, I will examine the correlation between salary and sector using statistics for age.

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
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, 000000D2.csv, http://www.statistikdatabasen.scb.se/pxweb/en/ssd/.

I have renamed the file to 000000D2_sector.csv because the filename 000000D2.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 age. 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("000000D2_sector.csv") %>%
  rowwise() %>%
  mutate(age_l = unlist(lapply(strsplit(substr(age, 1, 5), "-"), strtoi))[1]) %>%
  rowwise() %>%
  mutate(age_h = unlist(lapply(strsplit(substr(age, 1, 5), "-"), strtoi))[2]) %>%
  mutate(age_n = (age_l + age_h) / 2)

summary_table = 0
anova_table = 0

for (i in unique(tb$`occuptional  (SSYK 2012)`)){
  temp <- filter(tb, `occuptional  (SSYK 2012)` == i)
  if (dim(temp)[1] > 90){
    model <- lm(log(salary) ~ poly(age_n, 3) + 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) ~ poly(age_n, 3) * sector + sex + year_n, data = temp)
    summary_table <- rbind (summary_table, mutate (tidy (summary (model)), ssyk = i, interaction = "sector and age"))
    anova_table <- rbind (anova_table, mutate (tidy (Anova (model, type = 2)), ssyk = i, interaction = "sector and age"))  
    
    model <- lm(log(salary) ~ poly(age_n, 3) + 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) ~ poly(age_n, 3) +  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) ~ poly(age_n, 3) * sector * sex * year_n, data = temp)
    summary_table <- rbind (summary_table, mutate (tidy (summary (model)), ssyk = i, interaction = "sector, year, age and sex"))
    anova_table <- rbind (anova_table, mutate (tidy (Anova (model, type = 2)), ssyk = i, interaction = "sector, year, age 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
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, age and sex
  filter (!(contcol.y < 3 & interaction == "sector, year, age 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, age, 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, age, 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 1: Correlation for F-value (sector) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
218 Specialists within environmental and health protection2.3966875456.4704739none
261 Legal professionals2.6130221304.1919940none
411 Office assistants and other secretaries2.3419860285.0349753none
222 Nursing professionals4.6578230280.4433905none
515 Building caretakers and related workers2.2146338270.0075297none
819 Process control technicians2.5350438268.3445857none
242 Organisation analysts, policy administrators and human resource specialists2.0523696259.5458010none
251 ICT architects, systems analysts and test managers2.3512692241.0997355none
321 Medical and pharmaceutical technicians2.5801263237.2341857none
333 Business services agents2.3936321218.8431989none
334 Administrative and specialized secretaries2.0432078197.0091850none
243 Marketing and public relations professionals1.7547524188.6715597none
335 Tax and related government associate professionals2.4477931179.6275210none
342 Athletes, fitness instructors and recreational workers1.8086152178.9426205none
962 Newspaper distributors, janitors and other service workers1.9900356178.5334093none
213 Biologists, pharmacologists and specialists in agriculture and forestry1.8912397161.3670379none
265 Creative and performing artists2.0992262156.9400225none
241 Accountants, financial analysts and fund managers2.4619072134.7081954none
351 ICT operations and user support technicians2.7045039117.0092304none
331 Financial and accounting associate professionals2.1803329111.0703889none
264 Authors, journalists and linguists2.286542993.9690111none
211 Physicists and chemists2.001043865.4196943none
911 Cleaners and helpers1.930675764.9465316none
231 University and higher education teachers2.398735858.9926983none
541 Other surveillance and security workers2.250032654.4430468none
815 Machine operators, textile, fur and leather products1.351741948.6411876none
723 Machinery mechanics and fitters2.425175148.2416487none
233 Secondary education teachers3.039016538.5627689none
422 Client information clerks2.468674437.8718779none
228 Specialists in health care not elsewhere classified2.158984436.5601628none
941 Fast-food workers, food preparation assistants1.996052718.6514673none
216 Architects and surveyors2.832355615.8227312none
235 Teaching professionals not elsewhere classified1.658282414.3745577none
532 Personal care workers in health services3.007607312.2147525none
311 Physical and engineering science technicians2.770414512.1641422none
234 Primary- and pre-school teachers3.47749837.3900661none
511 Cabin crew, guides and related workers-0.34434276.9533625none
534 Attendants, personal assistants and related workers2.02334195.1208491none
533 Health care assistants2.22717204.8058895none
332 Insurance advisers, sales and purchasing agents2.20446764.2832833none
531 Child care workers and teachers aides1.91056374.0479235none
214 Engineering professionals2.79957422.1850611none
341 Social work and religious associate professionals2.56514582.1164875none
432 Stores and transport clerks1.93373540.7577500none
611 Market gardeners and crop growers1.80417430.0643998none
512 Cooks and cold-buffet managers2.79429440.0197082none
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 2: Correlation for F-value (sector and sex) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
911 Cleaners and helpers1.9306757109.1411280sector and sex
335 Tax and related government associate professionals2.447793170.7824355sector and sex
815 Machine operators, textile, fur and leather products1.356328931.8117555sector and sex
333 Business services agents2.289985330.4752880sector and sex
331 Financial and accounting associate professionals2.202360025.9296892sector and sex
342 Athletes, fitness instructors and recreational workers1.808615225.0203935sector and sex
241 Accountants, financial analysts and fund managers2.478635824.2528951sector and sex
264 Authors, journalists and linguists2.245361921.8740576sector and sex
533 Health care assistants2.227172021.5539071sector and sex
243 Marketing and public relations professionals1.726344219.6730093sector and sex
332 Insurance advisers, sales and purchasing agents2.204467619.3664844sector and sex
611 Market gardeners and crop growers1.754284915.6290927sector and sex
532 Personal care workers in health services3.007607312.5499477sector and sex
213 Biologists, pharmacologists and specialists in agriculture and forestry1.897384711.5413223sector and sex
321 Medical and pharmaceutical technicians2.56366369.5201918sector and sex
242 Organisation analysts, policy administrators and human resource specialists2.03885257.8030347sector and sex
351 ICT operations and user support technicians2.70450397.5568275sector and sex
211 Physicists and chemists1.99262647.5217104sector and sex
235 Teaching professionals not elsewhere classified1.62284165.7033533sector and sex
512 Cooks and cold-buffet managers2.79429445.4926902sector and sex
941 Fast-food workers, food preparation assistants1.99605273.8523689sector and sex
432 Stores and transport clerks1.92479043.3361868sector and sex
218 Specialists within environmental and health protection2.39029203.2726896sector and sex
231 University and higher education teachers2.40494293.1968905sector and sex
222 Nursing professionals4.65279742.8848508sector and sex
265 Creative and performing artists2.09082312.4335097sector and sex
962 Newspaper distributors, janitors and other service workers1.99003562.3091055sector and sex
233 Secondary education teachers3.04788121.6616950sector and sex
228 Specialists in health care not elsewhere classified2.22714101.4295653sector and sex
819 Process control technicians2.53504381.1646979sector and sex
541 Other surveillance and security workers2.25003261.1488532sector and sex
534 Attendants, personal assistants and related workers2.02334191.1344410sector and sex
261 Legal professionals2.60149001.1208624sector and sex
531 Child care workers and teachers aides1.90342891.0441681sector and sex
411 Office assistants and other secretaries2.34198600.8053533sector and sex
214 Engineering professionals2.79383300.7610648sector and sex
341 Social work and religious associate professionals2.56665410.6898733sector and sex
422 Client information clerks2.47072550.4188795sector and sex
251 ICT architects, systems analysts and test managers2.35126920.2019761sector and sex
234 Primary- and pre-school teachers3.47749830.1910697sector and sex
334 Administrative and specialized secretaries2.04739360.1673844sector and sex
723 Machinery mechanics and fitters2.42700250.0946975sector and sex
216 Architects and surveyors2.83233700.0480519sector and sex
515 Building caretakers and related workers2.21487110.0466927sector and sex
311 Physical and engineering science technicians2.76957810.0317138sector and sex
511 Cabin crew, guides and related workers-0.34526680.0263848sector 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 age") %>%
  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 age) and the yearly increase in salaries')
Table 3: Correlation for F-value (sector and age) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
251 ICT architects, systems analysts and test managers2.351269281.293931sector and age
534 Attendants, personal assistants and related workers2.023341974.994233sector and age
234 Primary- and pre-school teachers3.477498350.554556sector and age
511 Cabin crew, guides and related workers-0.321470349.726047sector and age
331 Financial and accounting associate professionals2.176011543.716282sector and age
432 Stores and transport clerks1.937226841.355837sector and age
351 ICT operations and user support technicians2.704503937.992660sector and age
241 Accountants, financial analysts and fund managers2.492508131.914364sector and age
242 Organisation analysts, policy administrators and human resource specialists2.098454831.372391sector and age
422 Client information clerks2.476353024.396462sector and age
342 Athletes, fitness instructors and recreational workers1.808615221.878170sector and age
332 Insurance advisers, sales and purchasing agents2.204467620.887588sector and age
333 Business services agents2.571178220.728956sector and age
261 Legal professionals2.654214519.114710sector and age
233 Secondary education teachers3.108961118.460571sector and age
541 Other surveillance and security workers2.250032618.166197sector and age
243 Marketing and public relations professionals1.829873916.372110sector and age
231 University and higher education teachers2.500021615.799814sector and age
411 Office assistants and other secretaries2.341986015.436701sector and age
235 Teaching professionals not elsewhere classified1.846733115.280487sector and age
211 Physicists and chemists1.994935411.545117sector and age
213 Biologists, pharmacologists and specialists in agriculture and forestry1.883576711.142152sector and age
228 Specialists in health care not elsewhere classified2.024367910.920972sector and age
335 Tax and related government associate professionals2.447793110.914843sector and age
941 Fast-food workers, food preparation assistants1.996052710.718505sector and age
341 Social work and religious associate professionals2.58162959.475763sector and age
216 Architects and surveyors2.78725559.229637sector and age
321 Medical and pharmaceutical technicians2.58727478.122166sector and age
911 Cleaners and helpers1.93067578.084293sector and age
815 Machine operators, textile, fur and leather products1.37511337.636766sector and age
334 Administrative and specialized secretaries2.13558837.153296sector and age
218 Specialists within environmental and health protection2.46203576.994422sector and age
962 Newspaper distributors, janitors and other service workers1.99003566.838603sector and age
531 Child care workers and teachers aides1.92261266.070516sector and age
515 Building caretakers and related workers2.21927606.005165sector and age
311 Physical and engineering science technicians2.78753165.421210sector and age
723 Machinery mechanics and fitters2.43606825.406378sector and age
819 Process control technicians2.53504385.043236sector and age
264 Authors, journalists and linguists2.22475054.044872sector and age
512 Cooks and cold-buffet managers2.79429443.928362sector and age
533 Health care assistants2.22717203.673529sector and age
265 Creative and performing artists2.07869062.538964sector and age
214 Engineering professionals2.78631372.497814sector and age
532 Personal care workers in health services3.00760732.339712sector and age
222 Nursing professionals4.62628272.287950sector and age
611 Market gardeners and crop growers1.80421071.716068sector and age
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 4: Correlation for F-value (sector and year) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
222 Nursing professionals3.282162352.9080079sector and year
235 Teaching professionals not elsewhere classified2.710281524.3392922sector and year
334 Administrative and specialized secretaries0.682470415.9484068sector and year
531 Child care workers and teachers aides2.370446213.8844930sector and year
422 Client information clerks3.222693912.4412439sector and year
962 Newspaper distributors, janitors and other service workers2.546582910.9472608sector and year
534 Attendants, personal assistants and related workers2.371931110.1007673sector and year
532 Personal care workers in health services2.75909889.0616925sector and year
611 Market gardeners and crop growers2.42858819.0355793sector and year
233 Secondary education teachers3.46811598.2187247sector and year
264 Authors, journalists and linguists3.24881086.2777560sector and year
351 ICT operations and user support technicians3.42725764.8822064sector and year
214 Engineering professionals3.44752154.3685520sector and year
723 Machinery mechanics and fitters2.77268004.0300820sector and year
511 Cabin crew, guides and related workers-1.46366153.9854827sector and year
243 Marketing and public relations professionals2.41743093.9092911sector and year
311 Physical and engineering science technicians3.29751813.6534643sector and year
533 Health care assistants2.02029983.4258034sector and year
216 Architects and surveyors3.27663213.0286083sector and year
512 Cooks and cold-buffet managers2.47617962.1189296sector and year
231 University and higher education teachers2.75641491.9590690sector and year
911 Cleaners and helpers2.10801131.3375758sector and year
265 Creative and performing artists1.82521021.3073089sector and year
341 Social work and religious associate professionals2.71797801.1525106sector and year
332 Insurance advisers, sales and purchasing agents2.46984200.8846941sector and year
515 Building caretakers and related workers2.08964860.8721029sector and year
251 ICT architects, systems analysts and test managers2.10709690.8453000sector and year
242 Organisation analysts, policy administrators and human resource specialists2.30748100.7627131sector and year
213 Biologists, pharmacologists and specialists in agriculture and forestry2.15158400.7217108sector and year
815 Machine operators, textile, fur and leather products1.51692160.7021796sector and year
333 Business services agents2.67709840.6948266sector and year
411 Office assistants and other secretaries2.49611110.6866667sector and year
261 Legal professionals2.90248570.6474976sector and year
342 Athletes, fitness instructors and recreational workers2.03569520.5210552sector and year
541 Other surveillance and security workers2.13193480.4764820sector and year
941 Fast-food workers, food preparation assistants2.10300850.4107102sector and year
241 Accountants, financial analysts and fund managers2.18377200.3653365sector and year
335 Tax and related government associate professionals2.24763510.3329319sector and year
228 Specialists in health care not elsewhere classified2.02159850.1994037sector and year
321 Medical and pharmaceutical technicians2.49865100.1694097sector and year
234 Primary- and pre-school teachers3.52270870.0566620sector and year
211 Physicists and chemists2.05092880.0256116sector and year
819 Process control technicians2.55253880.0089722sector and year
432 Stores and transport clerks1.95792840.0058151sector and year
331 Financial and accounting associate professionals2.14713900.0023497sector and year
218 Specialists within environmental and health protection2.38969460.0012880sector 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, age and sex") %>%
  filter (!(contcol.y < 3 & interaction == "sector, year, age 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, age and sex) and the yearly increase in salaries')
Table 5: Correlation for F-value (sector, year, age and sex) and the yearly increase in salaries
ssykIncrease in salaryF-valueinteraction
214 Engineering professionals2.464885511.6391393sector, year, age and sex
342 Athletes, fitness instructors and recreational workers2.09916708.9098726sector, year, age and sex
216 Architects and surveyors3.23014667.6322806sector, year, age and sex
228 Specialists in health care not elsewhere classified1.51767474.1043437sector, year, age and sex
321 Medical and pharmaceutical technicians2.26419783.9184148sector, year, age and sex
218 Specialists within environmental and health protection2.45737893.6168903sector, year, age and sex
261 Legal professionals2.75817523.2902539sector, year, age and sex
235 Teaching professionals not elsewhere classified2.40115133.0277439sector, year, age and sex
335 Tax and related government associate professionals2.02928742.6128635sector, year, age and sex
341 Social work and religious associate professionals2.63190842.6004044sector, year, age and sex
233 Secondary education teachers3.52731562.2615012sector, year, age and sex
331 Financial and accounting associate professionals2.46628601.9867325sector, year, age and sex
941 Fast-food workers, food preparation assistants1.99001781.9221016sector, year, age and sex
512 Cooks and cold-buffet managers2.52222191.9206611sector, year, age and sex
962 Newspaper distributors, janitors and other service workers2.66039851.8150814sector, year, age and sex
213 Biologists, pharmacologists and specialists in agriculture and forestry2.39628411.7496638sector, year, age and sex
911 Cleaners and helpers2.11973501.5815397sector, year, age and sex
511 Cabin crew, guides and related workers-0.69574971.5410098sector, year, age and sex
211 Physicists and chemists2.33105091.5257771sector, year, age and sex
333 Business services agents2.93060661.5169994sector, year, age and sex
819 Process control technicians2.53943981.4148181sector, year, age and sex
723 Machinery mechanics and fitters2.91458831.2913243sector, year, age and sex
234 Primary- and pre-school teachers3.53732141.2588294sector, year, age and sex
533 Health care assistants2.05617641.1641262sector, year, age and sex
222 Nursing professionals3.31411751.1593790sector, year, age and sex
515 Building caretakers and related workers2.35543681.0916712sector, year, age and sex
334 Administrative and specialized secretaries-0.48411620.8627072sector, year, age and sex
264 Authors, journalists and linguists3.87663710.8178463sector, year, age and sex
541 Other surveillance and security workers2.19591430.8087407sector, year, age and sex
531 Child care workers and teachers aides2.46244350.6787061sector, year, age and sex
815 Machine operators, textile, fur and leather products1.25585000.6507638sector, year, age and sex
242 Organisation analysts, policy administrators and human resource specialists2.14125800.6425880sector, year, age and sex
411 Office assistants and other secretaries2.40637130.5077368sector, year, age and sex
432 Stores and transport clerks2.16184840.5005162sector, year, age and sex
422 Client information clerks3.38191830.4079113sector, year, age and sex
265 Creative and performing artists1.71710840.4046591sector, year, age and sex
241 Accountants, financial analysts and fund managers1.96503320.3867492sector, year, age and sex
311 Physical and engineering science technicians3.06617050.3303477sector, year, age and sex
611 Market gardeners and crop growers2.17588450.1794678sector, year, age and sex
351 ICT operations and user support technicians3.34724780.1238188sector, year, age and sex
332 Insurance advisers, sales and purchasing agents2.21618560.1214610sector, year, age and sex
251 ICT architects, systems analysts and test managers2.13710360.1080593sector, year, age and sex
534 Attendants, personal assistants and related workers2.35764110.0748416sector, year, age and sex
532 Personal care workers in health services2.64485240.0675532sector, year, age and sex
231 University and higher education teachers2.52122520.0231719sector, year, age and sex
243 Marketing and public relations professionals2.16266400.0083390sector, year, age and sex

Let’s check what we have found.

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "218 Specialists within environmental and health protection")
 
model <- lm (log(salary) ~ year_n + poly(age_n, 3) + sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_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 sector, Specialists within environmental and health protection

Figure 3: Highest F-value sector, Specialists within environmental and health protection

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "512 Cooks and cold-buffet managers")
 
model <-lm (log(salary) ~ year_n + poly(age_n, 3) + sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_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 sector, Cooks and cold-buffet managers

Figure 4: Lowest F-value sector, Cooks and cold-buffet managers

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "911 Cleaners and helpers")
 
model <- lm (log(salary) ~ year_n + poly(age_n, 3) + sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_n", "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 <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "511 Cabin crew, guides and related workers")
 
model <- lm (log(salary) ~ year_n + poly(age_n, 3) + sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_n", "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, Cabin crew, guides and related workers

Figure 6: Lowest F-value interaction sector and gender, Cabin crew, guides and related workers

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "251 ICT architects, systems analysts and test managers")
 
model <- lm (log(salary) ~ year_n + poly(age_n, 3) * sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_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 age, ICT architects, systems analysts and test managers

Figure 7: Highest F-value interaction sector and age, ICT architects, systems analysts and test managers

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "611 Market gardeners and crop growers")
 
model <- lm (log(salary) ~ year_n + poly(age_n, 3) * sector + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_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 age, Market gardeners and crop growers

Figure 8: Lowest F-value interaction sector and age, Market gardeners and crop growers

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "222 Nursing professionals")
 
model <- lm (log(salary) ~ year_n * sector + poly(age_n, 3) + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_n", "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, Nursing professionals

Figure 9: Highest F-value interaction sector and year, Nursing professionals

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "218 Specialists within environmental and health protection")
 
model <- lm (log(salary) ~ year_n * sector + poly(age_n, 3) + sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_n", "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, Specialists within environmental and health protection

Figure 10: Lowest F-value interaction sector and year, Specialists within environmental and health protection

temp <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "214 Engineering professionals")
 
model <- lm (log(salary) ~ year_n * poly(age_n, 3) * sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_n", "year_n", "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, age, year and gender, Engineering professionals

Figure 11: Highest F-value interaction sector, age, year and gender, Engineering professionals

## 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 <- tb %>%
  filter(`occuptional  (SSYK 2012)` == "243 Marketing and public relations professionals")
 
model <- lm (log(salary) ~ year_n * poly(age_n, 3) * sector * sex, data = temp) 
 
plot_model(model, type = "pred", terms = c("age_n", "year_n", "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, age, year and gender, Marketing and public relations professionals

Figure 12: Lowest F-value interaction sector, age, year and gender, Marketing and public relations professionals

## 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)