Effacer les filtres
Effacer les filtres

Quadratic time detrending. Any help or code ???

2 vues (au cours des 30 derniers jours)
Panty
Panty le 15 Juil 2014
Commenté : Panty le 15 Juil 2014
Hi guys!! I have a question.
For linearly detrending a time-series you can use the detrend(..) function.
If you want to extract the quadratic time trend?? Any function or code you could share??
I have found this code in the 'Parametric Trend Estimation' Mathworks page, but I want to make sure whether it works or not and you opinion.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
load(fullfile(matlabroot,'examples','econ','Data_Accidental.mat')); t = [1:N]'; X = [ones(N,1) t t.^2];
B = X\Y;
Th = X*B;
h = plot(Th/1000,'r','LineWidth',2);
legend(h,'Quadratic Trend Estimate');
hold off
Y = Dataset.NUMD;
N = length(Y);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Many thanks

Réponse acceptée

Alfonso Nieto-Castanon
Alfonso Nieto-Castanon le 15 Juil 2014
Yes, that should work, you just need to define:
Ynew = Y - Th;
to get the new "detrended" timeseries.
  7 commentaires
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon le 15 Juil 2014
Yes, ordinary least squares, linear regression, general linear model, the X\Y part would do just that.
Panty
Panty le 15 Juil 2014
Thats perfect. Thank you very much Alfonso. Much appreciated.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Signal Generation and Preprocessing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by