get.res {BGVAR}R Documentation

Calculate residuals of the global and the country models

Description

This function calculates residuals of the global and the country models based on a gvar object. Country models' residuals are equivalent to output generated by the print.bgvar function in case no trimming has been used. If trimming was invoked to discard unstable draws output of both functions might differ since print.bgvar calculates residuals as a running mean to save storage which is based on the whole set of posterior draws (including discarded draws). In this case it is recommended to recalculate the residuals with get.res and re-do the serial autocorrelation or average pairwise cross-correlation analysis using functions resid.corr.test and avg.pair.cc

Usage

get.res(gvar.obj)

Arguments

gvar.obj

A fitted gvar object.

Value

res.array.global

A (T-p) times K times saves*save_thin array containing the residuals of the global model.

res.array.country

A (T-p) times K times saves*save_thin array containing the residuals of the country models.

Author(s)

Martin Feldkircher

See Also

print.bgvar, resid.corr.test, avg.pair.cc

Examples

# This example demonstrates the equivalence of the cross-country residuals that are returned from the gvar object
# and the get.res residulas if no trimming is invoked for the SIMS, SSVS and NG priors.
library(BGVAR)

data(monthlyData)
model.sims<-bgvar(Data=new.data,W=W,saves=100,burns=100,plag=1,hyperparm=NULL,Cpu=1,prior="SIMS",save_thin=1,eigen=TRUE,logfile=FALSE,stats=TRUE)
aa=get.res(model.sims)

#calculate "running mean" as in bgvar function
aa=apply(aa$res.array.country,c(1:2),sum)/100
matplot(cbind(aa[,1],model.sims$country.res[,1]),type="l")

model.ssvs<-bgvar(Data=new.data,W=W,saves=100,burns=100,plag=1,hyperparm=NULL,Cpu=1,prior="SSVS",save_thin=1,eigen=TRUE,logfile=FALSE,stats=TRUE)
aa=get.res(model.ssvs)

#calculate "running mean" as in bgvar function
aa=apply(aa$res.array.country,c(1:2),sum)/100
matplot(cbind(aa[,1],model.ssvs$country.res[,1]),type="l")

model.NG<-bgvar(Data=new.data,W=W,saves=100,burns=100,plag=1,hyperparm=NULL,Cpu=1,prior="NG",save_thin=1,eigen=TRUE,logfile=FALSE,stats=TRUE,ea.weights=EA.weights)
aa=get.res(model.NG)

#calculate "running mean" as in bgvar function
aa=apply(aa$res.array.country,c(1:2),sum)/100
matplot(cbind(aa[,1],model.NG$country.res[,1]),type="l")

[Package BGVAR version 1.1.3 Index]