Menggunakan Darts untuk melihat bedanya prediksi harga beras domestik dan internasional sejak Neraca Komoditas

I’m one of the regular readers of tweets by Haryo Aswicahyono, who often talks about economics. Just the other day, he tweeted mainly about how rice prices remain high, even though there’s an abundant supply. Here’s the tweet:

At the time, I happened to be working on a paper about the Commodity Balance Sheet for the Center for Indonesian Policy Studies (CIPS), alongside Hasran and Rasya. Rice is one of the products covered by the Commodity Balance. So I was writing a bit about rice myself—and sure enough, I found the same thing: domestic rice prices remain high. The steep price stands in stark contrast to international rice prices, which have declined since early 2024.

20192020202120222023202420256k8k10k12k14k
jenisdomestikinternasionalharga beras bulanan (PIHPS)monthharga

Rice prices rose in mid-2023 due to climate conditions and India, a major exporter that banned its rice exports. But if we look at the trend, domestic and international rice prices had already started rising in mid-2022, around August. Both rose in parallel until early 2024, when they began to diverge. Domestic prices continued climbing, while international prices started falling. Interestingly, these persistently high domestic prices emerged at a time when domestic stock was abundant.

Given the surplus, the issue with high domestic rice prices might stem from distribution—from warehouses to markets—not moving quickly enough. I’m not too familiar with how the distribution chain works from Bulog to markets, such as how much rice is purchased from warehouses or the selling price determined by distributors. But if distribution were quicker, prices might better reflect the stock levels.

Commodity Balance Sheet

Part of the rice supply chain involves the Commodity Balance Sheet, a system designed to regulate imports. Rice may only be imported if forecast data suggests that domestic production will fall short of consumption. If a surplus is predicted, imports are halted. Imports can help lower domestic prices, since international rice prices are typically cheaper.

International prices often serve as reference points for analysts to track domestic trends. Broad factors affecting rice production, such as regional weather events, will influence both domestic and international prices. But if an event is isolated to Indonesia, only domestic prices will rise. That’s where imports become useful—if international prices remain stable while domestic supply is disrupted, imports help stabilize the market.

The speed of price stabilization depends on how fast imports can arrive. The Commodity Balance Sheet was reportedly designed to accelerate import decisions. Rice was added to this system in 2022. Before that, imports were still restricted but not using this mechanism. So—does the Commodity Balance Sheet actually work better?

In a paper co-written with Hasran and Rasya, I explored price movements in Indonesia without the Commodity Balance Sheet by estimating rice prices using other price indicators (a method called synthetic control). The results? You’ll have to wait until the paper’s out—lol.

In this blog post, let’s try a ‘lite’ version using forecasting. The premise: what would domestic rice prices look like if the Commodity Balance Sheet didn’t exist? We use Darts—specifically, Exponential Smoothing—to forecast post-2022 prices based on historical data, then compare those predictions to actual outcomes. The gap is attributed to the Commodity Balance Sheet. As a benchmark, we do the same for international rice prices, which weren’t affected by this system.

The time series is monthly. Domestic rice prices are sourced from PIHPS (Strategic Food Price Information Center), while international prices come from the IMF commodity market. I cut the data at August 2023, since prices start trending upward from then. A time series alone isn’t enough to capture all the dynamics at play.

#package
import pandas as pd
import plotly.express as px
from darts import TimeSeries
from darts.models import ExponentialSmoothing

# plot domestik vs internasional
df = pd.read_excel('beras.xlsx')
df['month'] = pd.Series(pd.date_range(start='2018-07-01', end='2025-05-10', freq='ME'))
dfl=df.melt(id_vars=['month'], var_name='jenis', value_name='harga')
fig = px.line(dfl, x="month", y="harga", title='harga beras bulanan (PIHPS)',color='jenis',
              color_discrete_sequence=px.colors.qualitative.G10,template='plotly_dark')
fig.update_layout(
        legend=dict(
            orientation="h",  # Horizontal orientation
            yanchor="bottom", # Anchor the legend's y-position to the bottom
            y=1.02,           # Adjust the y-position (can be slightly above the plot)
            xanchor="right",  # Anchor the legend's x-position to the right
            x=1               # Adjust the x-position (can be slightly to the right of the plot)
        )
    )
fig.write_html('wew.html', full_html=False, include_plotlyjs='cdn')
df2=df[:-32]
series = TimeSeries.from_dataframe(df2, "month", "domestik")
train,val=series[:-8],series[-8:]
model=ExponentialSmoothing()
model.fit(train)
prediction=model.predict(len(val),num_samples=1000)
series.plot()
prediction.plot(label='prediksi',low_quantile=.05,high_quantile=.95)
plt.title('Prediksi harga beras domestik')
plt.legend()

<matplotlib.legend.Legend at 0x1ea12e5bd90>

png

series = TimeSeries.from_dataframe(df2, "month", "internasional")
train,val=series[:-8],series[-8:]
model=ExponentialSmoothing()
model.fit(train)
prediction=model.predict(len(val),num_samples=1000)
series.plot()
prediction.plot(label='prediksi',low_quantile=.05,high_quantile=.95)
plt.title('Prediksi harga beras internasional')
plt.legend()
<matplotlib.legend.Legend at 0x1ea12ef4a50>

png

Lol look at that confidence interval! It’s so wide that it’s almost useless. Of course there’re structural stuff in the rice market and our series isnt that long anyway. For fun, still okay i supposoe. Just dont be too serious about it.

The forecasting results show that domestic rice prices should have either declined or at least flattened since the Commodity Balance Sheet was implemented. But in reality, domestic prices actually increased. Meanwhile, international rice prices don’t seem too far off from the forecast. Technically, the forecast still falls within the 95% confidence interval—though just barely, haha. Is this because of the Commodity Balance Sheet? Possibly, but we’d need further analysis to confirm. Again, this is just a playful experiment, not a definitive conclusion. Treat it as a light-hearted exploration of forecasting with Darts, not a rigorous analysis.

Alright, that’s it for today’s post. Honestly, this entry is half a soft promo for the paper and half a playful experiment with Darts. Next time, we’ll try another, more exciting forecasting model!

Krisna Gupta
Krisna Gupta
Lecturer

Research mainly on international trade and investment policy and its impact on firms. Indonesia in particular is my main geographical focus. I also write at East Asia Forum and The Conversation Indonesia

Related