IRIS-Solutions-Team / IRIS-Toolbox

[IrisToolbox] for Macroeconomic Modeling
Other
92 stars 42 forks source link

System priors on correlations and autocorrelations #250

Open pfjulio opened 4 years ago

pfjulio commented 4 years ago

Dear Jeromir,

How do I introduce a system prior on the correlation between two innovations, say e1 and e2? And on the autocorrelation of some variable, say x1?

Best, Paulo Júlio

jaromir-benes commented 4 years ago

Hi Paulo

First note that you do not create system priors for the correlation between two innovations - you simply create plain vanilla priors because the correlation coefficient is a plain parameter, and not a system property of the model. You simply treat the corr coefficient, which is automatically created as a parameter in the model for each pair of shocks and named corr_shock1__shock2 (mind the double underscore between the names of the shocks) as any other parameter (or, e.g., a standard error, std_shock), and hence assign a value to it or impose priors the normal kind of way.

Second, this is a snippet of code to create a system prior for the correlation

% Create a SystemPriorWrapper object, a container for system priors
spw = SystemPriorWrapper.forModel(m);

% Create a SystemProperty object on which you wish to impose a system

prior % Here, the system property is the autocorrelation function % Call the acf( ) function as if you wanted to simply calculate % the ACF for the model up to order 1, but you use the option 'SystemProperty=' % (which means no actual ACF will be calculated, and only a SystemProperty and assign names to the two outputs of the ACF (any names you wish); % these names will be then used to refer to the desired system property % values p = acf(m, 'Order=', 1, 'SystemProperty=', {'Cov', 'Corr'});

% Add the SystemProperty to the SystemPrior Wrapper
spw.addSystemProperty(p);

% Now, add a system prior referring to the system property names
% you defined earlier. The ACF function returns (auto)covariance and
% (auto)correlation matrices N-by-N-by-K where N is the number of

variables % (including auxiliary lags and leads) and K is the the f = distribution.Normal.fromMeanStd(0.5, 0.1); spw.addSystemPrior('Corr(Infl, Infl, 2)', f);

On Mon, May 11, 2020 at 11:47 AM pfjulio notifications@github.com wrote:

Dear Jeromir,

How do I introduce a system prior on the correlation between two innovations, say e1 and e2? And on the autocorrelation of some variable, say x1?

Best, Paulo Júlio

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/IRIS-Solutions-Team/IRIS-Toolbox/issues/250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCVKKUNPJSNJZXAFUY24MTRQ7CS5ANCNFSM4M5YDDVQ .

jaromir-benes commented 4 years ago

Hi Paulo

Sorry - the previous message was sent unfinished...

First note that you do not create system priors for the correlation between two innovations - you simply create plain vanilla priors because the correlation coefficient is a plain parameter, and not a system property of the model. You simply treat the corr coefficient, which is automatically created as a parameter in the model for each pair of shocks and named corr_shock1__shock2 (mind the double underscore between the names of the shocks) as any other parameter (or, e.g., a standard error, std_shock), and hence assign a value to it or impose priors the normal kind of way.

Second, this is a snippet of code to create a system prior for the correlation

% Create a SystemPriorWrapper object, a container for system priors
spw = SystemPriorWrapper.forModel(m);

% Create a SystemProperty object on which you wish to impose a system

prior % Here, the system property is the autocorrelation function % Call the acf( ) function as if you wanted to simply calculate % the ACF for the model up to order 1, but you use the option 'SystemProperty=' % (which means no actual ACF will be calculated, and only a SystemProperty % will be created for future evaluation) and assign names to the two % outputs of the ACF (any names you wish); % these names will be then used to refer to the desired system property % values... % Note that you would otherwise call e.g. [C, R] = acf(m, 'Order=', 1); p = acf(m, 'Order=', 1, 'SystemProperty=', {'C', 'R'});

% Add the SystemProperty to the SystemPrior Wrapper
spw.addSystemProperty(p);

% Now, add a system prior referring to the system property names
% you defined earlier. The ACF function returns (auto)covariance and
% (auto)correlation matrices N-by-N-by-K where N is the number of

variables % (including auxiliary lags and leads) and K is the the number of lags (order) % plus one, depending on the option 'Order='. % You can extract the desired number from the matrices by using the names % of variables instead of row numbers and column numbers. Here, we e.g. % have a variable named Infl. % Note that if a variable is a log-variable, the ACF is always % computed for the log of that variable, and needs to be referred % as log_XXX in the matrix below where XXX is the name of the varible % (remember there's no variable named log_XXX in the model, only XXX). distributionFunction = distribution.Normal.fromMeanStd(0.5, 0.1); spw.addSystemPrior('R(Infl, Infl, 2)', distributionFunction);

Finally, you add the spw object as the fifth input argument to the estimate( ) function.

Hope this helps. Let me know it needs some more clarification...

Best Jaromir

On Sat, May 16, 2020 at 7:31 PM Jaromir Benes jaromir.benes@gmail.com wrote:

Hi Paulo

First note that you do not create system priors for the correlation between two innovations - you simply create plain vanilla priors because the correlation coefficient is a plain parameter, and not a system property of the model. You simply treat the corr coefficient, which is automatically created as a parameter in the model for each pair of shocks and named corr_shock1__shock2 (mind the double underscore between the names of the shocks) as any other parameter (or, e.g., a standard error, std_shock), and hence assign a value to it or impose priors the normal kind of way.

Second, this is a snippet of code to create a system prior for the correlation

% Create a SystemPriorWrapper object, a container for system priors
spw = SystemPriorWrapper.forModel(m);

% Create a SystemProperty object on which you wish to impose a system

prior % Here, the system property is the autocorrelation function % Call the acf( ) function as if you wanted to simply calculate % the ACF for the model up to order 1, but you use the option 'SystemProperty=' % (which means no actual ACF will be calculated, and only a SystemProperty and assign names to the two outputs of the ACF (any names you wish); % these names will be then used to refer to the desired system property % values p = acf(m, 'Order=', 1, 'SystemProperty=', {'Cov', 'Corr'});

% Add the SystemProperty to the SystemPrior Wrapper
spw.addSystemProperty(p);

% Now, add a system prior referring to the system property names
% you defined earlier. The ACF function returns (auto)covariance and
% (auto)correlation matrices N-by-N-by-K where N is the number of

variables % (including auxiliary lags and leads) and K is the the f = distribution.Normal.fromMeanStd(0.5, 0.1); spw.addSystemPrior('Corr(Infl, Infl, 2)', f);

On Mon, May 11, 2020 at 11:47 AM pfjulio notifications@github.com wrote:

Dear Jeromir,

How do I introduce a system prior on the correlation between two innovations, say e1 and e2? And on the autocorrelation of some variable, say x1?

Best, Paulo Júlio

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/IRIS-Solutions-Team/IRIS-Toolbox/issues/250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCVKKUNPJSNJZXAFUY24MTRQ7CS5ANCNFSM4M5YDDVQ .