필터 지우기
필터 지우기

How to skip NaN values in cross correlation between 2 time series datasets.

조회 수: 18 (최근 30일)
Chalita
Chalita 2019년 8월 1일
댓글: Chalita 2019년 8월 1일
Hi. I need to conduct cross correlation analysis between 2 time series datasets. Both datasets contain NaN values. In matlab, xcorr wouldn't skip wherever NaN values occurred in the time series. Please help.
~Thanks
My data look like this:
Soil moisture (SM):
SM = [ay1-1, ay1-2, ay1-3, ay1-4, NaN, NaN, NaN, NaN, ay2-1, ay2-2, ay2-3, NaN, NaN, NaN,....]
Plant growth (PG):
PG = [by1-1, by1-2, by1-3, by1-4, NaN, NaN, NaN, NaN, by2-1, by2-2, by2-3, NaN, NaN, NaN....]
NaN values in both vectors only occurred outside growing season; and that wherever there is NaN in SM, there is NaN in PG.
I want to see if there is any delayed responses in PG to changes in SM within growing season (lag analysis).
  댓글 수: 6
Guillaume
Guillaume 2019년 8월 1일
편집: Guillaume 2019년 8월 1일
Depends by what you mean by not affecting the correlation. It would mean that the matching non-nan element in the other vector wouldn't be taken into account for that particular shift, since the result of the multiplication would be 0. That may indeed be useful to do that as long as there aren't too many NaNs, but it will definitively affect the correlation values.
Replacing the NaNs by interpolated values may be more useful though. It's probably what Joe suggests doing with fillmissing (if he meant to use the 'linear' method).
Chalita
Chalita 2019년 8월 1일
Thank you for the explanation. You're right that replacing NaNs with zeros would affect the correlation in the way you've explained. What I meant by not affecting the correlation was that the matching NaN/ non-NaN element in the other vector wouldn't be taken into account for that particular shift.
I added more details about my data and what I'm trying to do above.
~Thank you so much for your help.

댓글을 달려면 로그인하십시오.

답변 (1개)

Joe Vinciguerra
Joe Vinciguerra 2019년 8월 1일
편집: Joe Vinciguerra 2019년 8월 1일
I encountered this same issue a few weeks ago. My solution was to use fillmissing() to patch up the NaN's.
I also used resample() to make sure my time vector was evenly distributed, but I suppose you could delete your NaN's all together, then resample.
  댓글 수: 1
Chalita
Chalita 2019년 8월 1일
Thank you for your suggestion. "Fillmissing()" might not work in my case because my data are ranked.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by