Hodrick-Prescott filter with smoothing factor as parameter
Hi i’m trying to parametrize Hodrick-Prescott filter (HP) as a function of smoothing parameter. Simple xy plot with the smoothing factor as parameter. I post my code below
excel=readmatrix("COMEX_SIZ2024, 1D_1f4e1.csv");
price=excel(:,6);
lambda=500:500:5500;
>> for pp=1:length(lambda)
[Trend(length(price),pp),Cyclical(length(price),pp)]=hpfilter(price,Smoothing=lambda(pp));
end
ERROR: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
I’m using a for loop to impile the lambda on columns and calculation (x=price) on rows. However it doesnt seem to work.
Where is my error? ThanksHi i’m trying to parametrize Hodrick-Prescott filter (HP) as a function of smoothing parameter. Simple xy plot with the smoothing factor as parameter. I post my code below
excel=readmatrix("COMEX_SIZ2024, 1D_1f4e1.csv");
price=excel(:,6);
lambda=500:500:5500;
>> for pp=1:length(lambda)
[Trend(length(price),pp),Cyclical(length(price),pp)]=hpfilter(price,Smoothing=lambda(pp));
end
ERROR: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
I’m using a for loop to impile the lambda on columns and calculation (x=price) on rows. However it doesnt seem to work.
Where is my error? Thanks Hi i’m trying to parametrize Hodrick-Prescott filter (HP) as a function of smoothing parameter. Simple xy plot with the smoothing factor as parameter. I post my code below
excel=readmatrix("COMEX_SIZ2024, 1D_1f4e1.csv");
price=excel(:,6);
lambda=500:500:5500;
>> for pp=1:length(lambda)
[Trend(length(price),pp),Cyclical(length(price),pp)]=hpfilter(price,Smoothing=lambda(pp));
end
ERROR: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
I’m using a for loop to impile the lambda on columns and calculation (x=price) on rows. However it doesnt seem to work.
Where is my error? Thanks hp filter, parameter, for loop, cycle MATLAB Answers — New Questions