Question

I have montly macroeconomic data series and I am planning to use them for a weekly (every Monday) regression analysis. How can I match a data point which release once a month to my date template( 4 times during that month) since the new point release and so on.

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 from comment

I have the following monthly macro data. I want to use them to feed the weekly dates. For example, at March 31/03/2012 the M-input was 2.7. So any weekly date after that date should be

W_output=2.7

until the April 30/04/2012. Then the weekly W_output will be 2.3 which is the new monthly point, M_input. The following table provides examples for the weekly W_ouput and monthly 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
Était-ce utile?

La solution

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

Results:

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top