0

I am struggling to compile and use X-13ARIMA-SEAT on a Mac with an m3 chip, and called it using sm.tsa.x13_arima_analysis(s, x12path='/usr/local/bin/x13as') in statsmodels. Finally, I succeeded and now share the method step by step.

In addition, I would like to know how to use Python libraries such as statsmodels or other seasonal adjustment tools using tramo-seats to seasonally adjust data?

1 Answer 1

2

Firstly we can download the X-13ARIMA-SEATS binary from the link SourceForge for macOS Apple Silicon (ARM64) and install it. Here are the detailed steps:

Step 1: Download X-13ARIMA-SEATS for macOS Apple Silicon

Download the X-13ARIMA-SEATS binary for macOS Apple Silicon from SourceForge:

curl -L -o x13as-mac-arm64.tar.gz https://sourceforge.net/projects/gretl/files/x13as/x13as-mac-arm64.tar.gz/download

Step 2: Unzip the downloaded file

Unzip the downloaded tar.gz file:

Bash:

tar -xzvf x13as-mac-arm64.tar.gz

Step 3: Move the executable to the system path

Move the unzipped x13as executable to the /usr/local/bin directory and make sure it has execute permissions:

Bash:

sudo mv x13as /usr/local/bin/x13as
sudo chmod +x /usr/local/bin/x13as

Step 4: Test the installation

Test that x13as was installed successfully:

Bash:

x13as

If everything went well, we should see the following error message, indicating that the binary worked properly:

enter image description here

information on how to run X-13ARIMA-SEATS.
X-13ARIMA-SEATS Seasonal Adjustment Program
Version Number 1.1 Build 61
Execution began Jul 14, 2022 19.38.34
ERROR: Must specify either an input specification file name
(-i infile or infile) or an input metafile name (-m metafile).
See Section 2 of the X-13ARIMA-SEATS Reference Manual for more
information on how to run X-13ARIMA-SEATS.

Step 5: Use X-13ARIMA-SEATS in Python

We can use the statsmodels library to call X-13ARIMA-SEATS in Python:

import statsmodels.api as sm
import pandas as pd
import numpy as np

# Generate test data
np.random.seed(0)
n_periods = 120 # 10 years, 12 months per year
date_range = pd.date_range(start='2010-01-01', periods=n_periods, freq='M')
seasonal_pattern = np.sin(2 * np.pi * date_range.month / 12)
trend = np.linspace(0, 10, n_periods)
noise = np.random.normal(0, 0.5, n_periods)
data = 10 + trend + seasonal_pattern + noise

# Create time series data
s = pd.Series(data, index=date_range)

# Seasonal Adjustment using X-13ARIMA-SEATS
res = sm.tsa.x13_arima_analysis(s, x12path='/usr/local/bin/x13as')

# Print Results
print(res.summary())

# Plot the Original Data and Seasonally Adjusted Data
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(12, 8))
s.plot(ax=ax, label='Original Data')
res.seasadj.plot(ax=ax, label='Seasonally Adjusted Data')
plt.legend()
plt.title('Seasonal Adjustment using X-13ARIMA-SEATS')
plt.show()

Out:

enter image description here

With these steps, we should be able to successfully install and use X-13ARIMA-SEATS on macOS.

References:

https://github.com/jmarbet/x13-compilation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.