Borrar filtros
Borrar filtros

How to calculate linear regression between two time series and remove?

9 visualizaciones (últimos 30 días)
I want to calculate the following between two time series:
R^2, slope, intercept , p, q,
and if possible q^hat
I know how to get r^2 for the whole timeseries but I would like to get this as a timeseries of coefficients.
I need the slope, P and the intercept in order to calculate q^hat (if it is not possible to get directly using a function) so that I can remove the relationship trend between two time series from one timeseries, like what is done using FERRET here: http://ferret.pmel.noaa.gov/static/FAQ/analysis/regressions.html
So far, I only know of 'corrcoef' which I can use to get R^2 and 'regression' to get the slope.
Can anyone help me?
thanks, Michael

Respuesta aceptada

Star Strider
Star Strider el 23 de Sept. de 2014
The easiest way is to use polyfit and polyval:
b = polyfit(p, q, 1); % Choose Degree ‘1’ for Linear Regression, b(1)=slope, b(2)=intercept
qhat = polyval(b, p);
Using corrcoef will give you the ‘R’ values, and you can get their statistical significance if you ask for ‘P’ as well.

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics 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