2012-08-23 4 views
1

나는 거시 경제 데이터 시리즈를 가지고 있으며 매주 (매주 월요일) 회귀 분석을 위해 이들을 사용할 계획입니다. 새 포인트 릴리스 이후 한 달에 한 번 릴리스되는 데이터 포인트를 내 날짜 템플릿 (해당 월 중 4 회)과 어떻게 일치시킬 수 있습니까?Matlab을 사용하여 매월 매일 데이터를 일치시키는 방법은 무엇입니까?

for u=2:size(daily,1) 
    l=find(dailytemplate(u)==monthly) 

    %# when the monthly date is not equal to my daily template 
    if isempty(l) 
     %# I need a clearver code for this part to find the previous release 
     dailyclose(u)=dailyclose(u-1) 
    else 
     dailyclose(u)=monthlyclose(l) 
    end 
end 

나는 다음과 같은 월 매크로 데이터가

코멘트

에서 UPDATE. 나는 그들을 주간 날짜를 먹이기 위해 사용하고 싶다. 예를 들어 2012 년 3 월 31 일의 M-input2.7입니다. 따라서 해당 날짜 이후의 주간 날짜는

W_output=2.7 

이어야합니다 (2012 년 4 월 30 일까지). 그런 다음 주간 W_output2.3이고 새로운 월별 포인트는 M_input입니다. 다음 표는 매주 W_ouput 및 월별 M_Input에 대한 예제를 제공합니다 :

08/06/2012 1.7 
30/06/2012 1.7 
01/06/2012 1.7 
31/05/2012 1.7 
25/05/2012 2.3 
30/04/2012 2.3 
18/05/2012 2.3 
31/03/2012 2.7 
11/05/2012 2.3 
29/02/2012 2.9 
04/05/2012 2.3 
31/01/2012 2.9 
27/04/2012 2.7 
31/12/2011 3 
20/04/2012 2.7 

답변

0
format long g 

%Create a vector of dates (what I am assuming your date template looks like, this is march 31 and the next 9 mondays that follow it) 
datetemplate = [datenum('2012/03/31')]; 
for i = 1:10 
    datetemplate(i + 1) = datetemplate(i) + 7; 
end 
datetemplate'; 

%Your macro ecos input and dates 
macrochangedate = [datenum('2012/03/31');datenum('2012/04/30')] 
macrochangedate = [macrochangedate [2.7; 2.3]] 

for i = 1:size(macrochangedate,1) 
    result(datetemplate >= macrochangedate(i,1)) = macrochangedate(i,2); 
end 

결과 :

result = 
      2.7 
      2.7 
      2.7 
      2.7 
      2.7 
      2.3 
      2.3 
      2.3 
      2.3 
      2.3 
      2.3 

datestr(datetemplate) 

ans = 

31-Mar-2012 
07-Apr-2012 
14-Apr-2012 
21-Apr-2012 
28-Apr-2012 
05-May-2012 
12-May-2012 
19-May-2012 
26-May-2012 
02-Jun-2012 
09-Jun-2012 
관련 문제