R/impulseResponseVAR1.r

Defines functions impulseResponseVAR1

Documented in impulseResponseVAR1

impulseResponseVAR1 <- function(A, 
				T){

	########################################################################
	#
	# DESCRIPTION:
	# Calculate impulse response for VAR(1) model. MA representation of the 
	# VAR(1) model dictates that these are given by powers of A.
	#
	# ARGUMENTS:
	# -> A       : Matrix A of regression parameters.
	# -> T       : Time point for which the impulse response is to be 
	#              evaluated.
	#
	# DEPENDENCIES:
	# library(expm)	    # functions: %^% 
	#
	# NOTES:
	# ...
	# 
	########################################################################

	# input checks
	if (!is(A, "matrix")){ 
		stop("Input (A) is of wrong class.") 
	}
	if (nrow(A) != ncol(A)){ 
		stop("Matrix A is not square.") 
	}
	if (!is(T, "numeric")){ 
		stop("Input (T) is of wrong class.") 
	}
	if (length(T) != 1){ 
		stop("Input (T) is of wrong length.") 
	}
	if (is.na(T)){ 
		stop("Input (T) is not a positive integer.") 
	}
	if (T < 1){ 
		stop("Input (T) should be an integer larger than one.") 
	}

	# calculate impulse responses
	return(A %^% T)   
}

Try the ragt2ridges package in your browser

Any scripts or data that you put into this service are public.

ragt2ridges documentation built on Jan. 28, 2020, 5:08 p.m.