Economics Trend Analysis (Visualisation)

Author

Pranish

Economics Trend Analysis (Visualisation)

Unemployment trend over time

library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.5.2
data("economics")
View(economics)
summary(economics)
      date                 pce               pop            psavert      
 Min.   :1967-07-01   Min.   :  506.7   Min.   :198712   Min.   : 2.200  
 1st Qu.:1979-06-08   1st Qu.: 1578.3   1st Qu.:224896   1st Qu.: 6.400  
 Median :1991-05-16   Median : 3936.8   Median :253060   Median : 8.400  
 Mean   :1991-05-17   Mean   : 4820.1   Mean   :257160   Mean   : 8.567  
 3rd Qu.:2003-04-23   3rd Qu.: 7626.3   3rd Qu.:290291   3rd Qu.:11.100  
 Max.   :2015-04-01   Max.   :12193.8   Max.   :320402   Max.   :17.300  
    uempmed          unemploy    
 Min.   : 4.000   Min.   : 2685  
 1st Qu.: 6.000   1st Qu.: 6284  
 Median : 7.500   Median : 7494  
 Mean   : 8.609   Mean   : 7771  
 3rd Qu.: 9.100   3rd Qu.: 8686  
 Max.   :25.200   Max.   :15352  
ggplot(economics, aes(x = date, y = unemploy)) +
  geom_line(color = "steelblue") +
  labs(title = "US Unemployment Trend (1967–2015)",
       x = "Year", y = "Number of Unemployed (thousands)") +
  theme_minimal()

Personal saving rate trend

ggplot(economics, aes(x = date, y = psavert)) +
  geom_line(color = "darkgreen") +
  labs(title = "US Personal Savings Rate Trend",
       x = "Year", y = "Savings Rate (%)") +
  theme_minimal()

Time Series Forecasting

library(forecast)
Warning: package 'forecast' was built under R version 4.5.2
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
# Convert unemployment series to time series object
unemp_ts <- ts(economics$unemploy, start = c(1967, 7), frequency = 12)

# Plot the time series
plot(unemp_ts, main = "Monthly Unemployment (Thousands)", ylab = "Unemployed", xlab = "Year")

# Fit ARIMA model
fit <- auto.arima(unemp_ts)

# Forecast next 5 years (60 months)
forecast_unemp <- forecast(fit, h = 60)

# Plot forecast
plot(forecast_unemp, main = "Forecast of US Unemployment")

Trend Composition (Seasonal + Trend + Residuals)

Decompose unemployment time series

decomp <- stl(unemp_ts, s.window = "periodic")
plot(decomp)