필터 지우기
필터 지우기

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

조회 수: 9 (최근 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