I am trying forecast forward 5 years and understand if there is a reason that the percentage of people in the workforce in the US with an advanced degree is declining. I am attempting to do so with hierarchical time series so that I can compare the total labor force, the percentage of those with advanced degrees and then splitting that into male and female.
I am new to R and need some help setting this up so that I can acquire some forecast data on the subject at hand.
The data set I am using has been cleaned up in Excel as can be seen here:
All help is welcome, and more info can be provided, thank you.
I am trying to recreate something similar to this book example My current work is majorly from the provided book that is linked above:
title: "Final Notebook"
output: html_notebook
Created a working directory to import the dataset,
setwd("C:/Users/carso/OneDrive/Documents/03 Junior/Forecasting")
View(LaborForceFinal)
import.package('fpp2')
import.package('hts')
import.package('dplyr')
import.package('stringr')
import.package('tidyr')
LaborForce.hts <- hts(LaborForceFinal,characters = c())
LaborForce.hts %>% aggts(levels=0:1) %>%
autoplot(facet=TRUE) +
xlab("Year") + ylab("millions") + ggtitle("Labor Force")
p1 <- prison.gts %>% aggts(level=0) %>%
autoplot() + ggtitle("Australian prison population") +
xlab("Year") + ylab("Total number of prisoners ('000)")
groups <- aggts(prison.gts, level=1:3)
cols <- sample(scales::hue_pal(h=c(15,375),
c=100,l=65,h.start=0,direction = 1)(NCOL(groups)))
p2 <- as_tibble(groups) %>%
gather(Series) %>%
mutate(Date = rep(time(groups), NCOL(groups)),
Group = str_extract(Series, "([A-Za-z ]*)")) %>%
ggplot(aes(x=Date, y=value, group=Series, colour=Series)) +
geom_line() +
xlab("Year") + ylab("Number of prisoners ('000)") +
scale_colour_manual(values = cols) +
facet_grid(.~Group, scales="free_y") +
scale_x_continuous(breaks=seq(2006,2016,by=2)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
gridExtra::grid.arrange(p1, p2, ncol=1)