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

2 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2014-9-23
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by