Time Series: China Export Commodities

Eduardo Ramirez

Introduction

Objective

In today’s global economy, analyzing time series data is essential for predicting trends, understanding seasonality, and identifying unexpected shocks. The objective of this analysis is to explore China’s export commodities over time, using time series analysis techniques to gain insights that can aid in strategic planning and effective decision-making.

Why Time Series Analysis?

Time series analysis involves collecting and interpreting data recorded over time. By examining China’s export data from early 1990 to the present, we can observe trends, seasonality, and irregular movements that are crucial for understanding the dynamics of international trade.

Data Preparation

Show the code
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse, tsibble, fable, feasts, tsibbledata, fable.prophet, patchwork, lubridate, rio, ggplot2, kableExtra, data.table, plotly)

# Data Import and Preparation
cexports_ts <- rio::import("data/CHNXTEXVA01NCMLM.csv") |> 
  mutate(
    CHNXTEXVA01NCMLM = as.numeric(gsub(",", "", CHNXTEXVA01NCMLM)), # Remove commas and convert to numeric
    dates = mdy(date),
    year = lubridate::year(dates), 
    month = lubridate::month(dates), 
    value = as.numeric(CHNXTEXVA01NCMLM)
  ) |>
  dplyr::select(dates, year, month, value)  |>
  arrange(dates) |>
  mutate(index = tsibble::yearmonth(dates)) |>
  as_tsibble(index = index) |>
  dplyr::select(index, dates, year, month, value) |>
  rename(exports_commodities = value) |>
  mutate(exports_commodities = exports_commodities / 1000) 

China’s Export Trade Commodities Time Series Plot

Show the code
plain_plot <- ggplot(cexports_ts, aes(x = dates, y = exports_commodities)) +
  geom_rect(aes(xmin = as.Date("2008-01-01"), xmax = as.Date("2010-01-01"), ymin = -Inf, ymax = Inf), fill = "firebrick", alpha = 0.2) +
  geom_rect(aes(xmin = as.Date("2020-02-01"), xmax = as.Date("2020-04-01"), ymin = -Inf, ymax = Inf), fill = "firebrick", alpha = 0.2) +
  geom_line() +
  geom_rect(aes(xmin = as.Date("2015-04-10"), xmax = as.Date("2015-04-28"), ymin = -Inf, ymax = Inf), fill = "firebrick", alpha = 0.2) +
  geom_line() +
  labs(x = "", y = "Exports Commodities (Billions)", title = "Fig 1 - China: Exports Commodities Time Series") +
  scale_y_continuous(limits = range(cexports_ts$exports_commodities, na.rm = TRUE)) +
    scale_x_yearmonth(
    labels = scales::label_date("%Y %b"),  # Format labels as "Jan 2020"
    breaks = "36 months"                    # Show labels every 8 months
  ) + 
  theme(plot.title = element_text(hjust = 0.5))

plain_plot

Fig 1 - China’s Exports Commodities Time Series
Show the code
# Save the plot as a PNG file
#ggsave("fig1_exports_commodities_plot.png", plot = plain_plot, width = 12, height = 6, dpi = 300)

Time Series Decomposition

Understanding Decomposition

Time series decomposition breaks down data into three components: trend, seasonality, and irregularities. This helps us understand underlying patterns and make better forecasts.

Why Use a Multiplicative Decomposition?

The upward trend in China’s export data suggests that fluctuations in seasonality and irregularities increase in magnitude as exports grow. That’s why we use a multiplicative classical decomposition model, where the data is broken down into:

  1. Trend Component: Captures the long-term growth pattern. Here, we observe steady growth in exports.

  2. Seasonal Component: Identifies repeating patterns within a year. Exports peak in December (possibly driven by holiday demand, especially in the US) and dip to their lowest in February (likely due to the Chinese New Year and post-holiday slowdowns).

  3. Random Component: Captures what’s left after accounting for the trend and seasonal components. It represents what the model cannot explain. These unexpected changes often correlate with macroeconomic events like the 2008 Global Financial Crisis, but not all irregular variations can be directly linked to specific events.

Multiplicative Classical Decomposition Model

Show the code
china_decompose_mult <- cexports_ts |>
  model(feasts::classical_decomposition(exports_commodities, type = "mult"))  |>
  components()

decompose_plot <- autoplot(china_decompose_mult) +
  ggtitle("Fig 2 - Classical Multiplicative Decomposition of China's Exports") +
  labs(subtitle = "Export commodities = trend (billions) * seasonal * random")

decompose_plot

Fig 2 - Classical Multiplicative Decomposition of China’s Exports
Show the code
# Save the plot as a PNG file
#ggsave("fig2_mult_decomposition.png", plot = decompose_plot, width = 12, height = 6, dpi = 300)

Seasonal Component

Show the code
plot_decomp_seasonal <- ggplot(china_decompose_mult %>% filter(index >= yearmonth('2019 Dec') & index <= yearmonth('2021 Jan')), aes(x = index, y = seasonal)) +
  geom_line(group = 1, color = "blue") +
  geom_point(color = "blue") +
  labs(title = "Fig 3 - China: Exports Commodities Seasonal Component",
       x = "Month",
       y = "Seasonal") +
  scale_x_yearmonth(
    labels = scales::label_date("%b"),  
    breaks = "1 months"                    
  )  + 
  theme(plot.title = element_text(hjust = 0.5))

plot_decomp_seasonal

Fig 3 - China’s Exports Commodities Seasonal Component
Show the code
# Save the plot as a PNG file
#ggsave("fig3_seasonal_component.png", plot = plot_decomp_seasonal, width = 12, height = 6, dpi = 300)

Random Component and Macroeconomic Events

These unexpected changes often correlate with macroeconomic events like the 2008 Global Financial Crisis. For example, in response to a slowdown (random shock), China increased export tax rebates in March 2015 to stimulate exports, showing how responses can occur after the initial shock. This randomness highlights inherent uncertainties—macroeconomic disruptions may explain some shocks, but many remain unpredictable. Understanding the random component helps us see where patterns could align—but also where uncertainties remain.

Show the code
highlight_months <- c("1992 Oct", "1994 Jan", "1994 Apr", "1994 Sep", 
                      "1995 Dec", "1997 Jul", "1998 Jan", "1999 Apr", 
                      "1999 Nov", "2001 Dec", "2003 Apr", "2004 Jul", 
                      "2005 Jul", "2008 Sep", "2008 Nov", "2009 Jun", 
                      "2010 May", "2010 Dec", "2015 Mar", "2017 Jan", 
                      "2018 Jul", "2019 Oct", "2019 Dec", "2020 Jan", 
                      "2020 Mar")

highlight_dates <- tsibble::yearmonth(highlight_months)

plot_random_component <- ggplot(china_decompose_mult %>% 
                                  filter(index >= yearmonth('1992 Jul') & 
                                         index <= yearmonth('2023 Dec')), 
                                aes(x = index, y = random)) +
  geom_line(group = 1, color = "blue") +
  geom_point(data = china_decompose_mult %>% filter(index %in% highlight_dates),
             aes(x = index, y = random),
             shape = 24, color = "red", fill = "red", size = 4) + 
  labs(title = "Fig 4 - Exports Commodities Random Component vs Macroeconomic Events",
       x = "",
       y = "Random") +
  scale_x_yearmonth(
    labels = scales::label_date("%Y %b"),  
    breaks = "36 months"                    
  )

plot_random_component

Fig 4 - Exports Commodities Random Component vs Macroeconomic Events
Show the code
# Save the plot as a PNG file
#ggsave("fig4_random_vs_macroeventns.png", plot = plot_random_component, width = 12, height = 6, dpi = 300)

Why a Multiplicative Decomposition Model Fits

The multiplicative model is particularly suitable because the amplitude of seasonal changes and irregular fluctuations increases along with the trend. In China’s export data, as exports grow, the seasonal variations and irregularities also become more pronounced. A multiplicative model accounts for this proportionality, making it appropriate for capturing the dynamics of the data.

Why an Additive Decomposition Model Would Not Work

An additive model assumes that the size of seasonal and irregular variations remains constant regardless of the trend. However, the data shows that fluctuations grow as the trend grows. Therefore, an additive model would fail to accurately represent the increasing variability linked to higher export levels.

Additive Classical Decomposition Model Plot

Show the code
china_decompose_add <- cexports_ts |>
  model(feasts::classical_decomposition(exports_commodities, type = "add"))  |>
  components()

autoplot(china_decompose_add) +
  ggtitle("Fig 5 - Classical Additive Decomposition of China's Exports")

Fig 5 - Classical Additive Decomposition of China’s Exports

Key Takeaways

  • Seasonal Patterns: Understanding these can help companies optimize their supply chains, especially during high-demand months.

  • Economic Resilience: The trend shows that China’s export sector has consistently been increasing over time.

  • Strategic Planning: By anticipating seasonal lows (like in February) and leveraging peaks (in December), businesses can better align their operations with demand cycles.

Recommendations

Given the observed seasonality, trend, and irregular components of China’s export data, it is important to prepare for upcoming political events that could potentially lead to a temporary fall in exports. However, based on historical patterns, China has demonstrated resilience and the ability to recover fairly quickly from these disruptions. Therefore, we recommend the following actionable items:

  • Diversify Supply Chains: Identify and establish relationships with alternative suppliers and markets to reduce dependence on China during potential disruptions.

  • Increase Inventory Buffer: Build up inventory reserves during periods of high export activity to prepare for potential downturns caused by political events.

  • Monitor Key Indicators: Closely monitor geopolitical developments and economic indicators to respond proactively to any signals of impending disruptions.

  • Establish Contingency Plans: Develop and maintain contingency plans to address short-term declines in supply, including logistical adjustments and finding new suppliers.

  • Communicate with Partners: Maintain open communication with Chinese suppliers and partners for early warnings of potential issues.

  • Leverage Seasonal Patterns: Use the identified seasonal peaks to strategically schedule production and export needs, ensuring that reserves are built up during times of predictable high export activity.

Conclusion

The decomposition of China’s export data reveals a strong upward trend, along with predictable seasonal fluctuations and irregular disruptions. While upcoming political events may lead to short-term declines, historical data shows that these are typically followed by rapid recovery. By understanding these trends, seasonality, and random components, businesses can better prepare for potential disruptions without significant long-term impacts.

The key insight is that while risks are present, proactive preparation can mitigate their effects. By leveraging strategic planning, maintaining communication, and building contingency buffers, companies can continue to operate smoothly and minimize disruptions. This approach ensures resilience in the face of political uncertainties, relying on the observed adaptability of China’s export capabilities.

What’s Next? I’ll continue refining the analysis and exploring potential forecast models to enhance predictive capabilities.

Back to top