Borrar filtros
Borrar filtros

Data Seasonal Adjustment using Cubic Splines

9 visualizaciones (últimos 30 días)
Lu
Lu el 11 de Abr. de 2012
Hello everybody,
Im trying to calculate the intraday seasonal factor of my data set using a cubic spline. I have 90 days and each day has 24 observations, so in total I have 2160 observations.
My data for one day looks like this:
Hr Vol
00 880
01 950
02 789
03 680
.....
22 990
23 1000
24 890
I used a cubic spline to fit my data and try to get the seasonal factor, but after I do this I have no idea of how to seasonally adjust my dataset. I want to use a multiplicative model, so my adjusted data would have the form of y_adjusted = y / seasonal_factor.Do you have any suggestions of how could I do this? I have read that the seasonal factor should be the sum of the trading volumes from 00-24 hours, but when I divide my y by this total sum of trading volumes, it doesnt make sense because I get trading volumes of 0.6 or so.
clear all
clc
data = load('91days.txt');
buy90 = data ( 1 : 2160 , 1);
x = 1 : 1: 24; % Number of Knots
xx = linspace(1,24);
y = reshape( buy90, length(x), []);
for j = 1 : 1 : 75
a = y( : , j : j + 15);
mean_16d = mean ( a , 2 );
mean_day = mean(mean_16d);
pp_24 = spline(x,mean_16d);
v = ppval(pp_24,xx);
plot(x,mean_16d(x))
hold on
plot(xx,v,'r');
end
I hope you can give me a hint. Thank you and have a nice day,
Lu

Respuestas (1)

Thomas
Thomas el 11 de Abr. de 2012
I'm assuming this is what you are looking for
c=rand(2160,1); % random data 2160 observation
q=reshape(c,24,[]); % reshaping 24 observations for 90 days 24x90 matrix
out=spline(1:90,q,r); % this uses the matlab cubic spline fcn.
% any given hour to check the season variation
plot(1:24,q(:,1),'o',1:24,out(1,:)) % this plots the variation across the 90 days for hour 1 (00)
etc..
  1 comentario
Lu
Lu el 11 de Abr. de 2012
Dear Thomas,
Thank you for your answer. I tried your code and it plots the season variation as you said, but is there a way to save in a vector this season variation? because everytime I type for example a=out(1,:), it gives me back the electricity volumes of the first day. Also, is your r=1:24?
Thank you so much,
Lourdes

Iniciar sesión para comentar.

Categorías

Más información sobre Spline Postprocessing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by