Generate periodic moving average lag 1 autoregressive model

7 views (last 30 days)
Hi Matlab community,
I am working on a river basin simulation model for a reservoir (dam) to test it under different conditions.
The observed data of streamflow that fed the reservoir are short (less than 30 years of monthly data. I want to creat 50,000 years of stochastically generated monthly streamflow to the reservoir system.
Can you help to model my streamflow with a periodic moving average lag 1 autoregressive model, to generate 50,000 years of monthly data.
Many thanks.

Answers (1)

Drishti
Drishti on 12 Mar 2025
To generate 50,000 years of monthly streamflow data with a periodic moving average lag 1 autoregressive model in MATLAB, you can utilize a custom method which takes into consideration the periodicity of the available data.
You can refer to the below given code snippet to get better understanding:
% Generate synthetic data
for year = 1:nYears
for month = 1:12
idx = (year-1)*12 + month;
if year == 1
% For the first year, initialize using observed data or available data
generatedStreamflow(idx) = observedStreamflow(month);
else
% Generate using AR(1) model
prevValue = generatedStreamflow(idx - 12);
noise = residuals{month}(randi(length(residuals{month})));
generatedStreamflow(idx) = monthlyMeans(month) + ...
phi(month) * (prevValue - monthlyMeans(month)) + noise;
end
end
end
In the provided code, for the years that come after the first one, the autoregressive model is used to create new data points. Further, the 'prevValue' variable stores the value from the same month in the previous year.
In addition, you can modify the parameters as per the requirement.
I hope this helps in getting started.
Thank you

Categories

Find more on Conditional Mean Models in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!