ArmaUtils-package: Fast RcppArmadillo and RcppEigen Helper Functions for Dynamic...

Description Details Author(s) References Examples

Description

Implements several functions useful for discrete and continuous state dynamic programming. A prototypical problem would be to approximate V(S) = max_x u(S,x) + b * V(S'|S,x) where S stands for the state space, x for control variables, V() and u() are real valued functions. The package is useful if S is large. It has the following functionality:

compute u(c,h): utilfun computes u(c,h)
compute u(c,h): ufun_Atta computes u(c,h) after Wakefield et al.
compute u(c,l,h): ufun_Atta_L computes u(c,l,h) with continuous l
compute u(c,l,h): ufun_Atta_disc computes u(c,l,h) with discrete l
max u(S,x) + b * V(S'|S,x): armamax rowwise max
approximate V(S'): armakron obtain B-spline coefficients
evaluate approximations of V(S'): krons evaluate B-spline coeffs

Details

Package: ArmaUtils
Type: Package
Version: 1.0
Date: 2012-09-11
License: What license is it under?

Author(s)

florian.oswald@gmail.com

References

C. De Boor. Efficient computer manipulation of tensor products. ACM Transactions on Mathematical Software (TOMS), 5(2):173-182, 1979
M. Miranda and P. Fackler. Applied computational economics and finance. MIT Press, 2002
Orazio P. Attanasio, Renata Bottazzi, Hamish W. Low, Lars Nesheim, and Matthew Wakefield. Modelling the demand for housing over the life cycle. Review of Economic Dynamics, 15(1):1 – 18, 2012.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
x1 <- matrix(rnorm(25),nrow=5,ncol=5)
x2 <- matrix(rnorm(9),nrow=3,ncol=3)
x3 <- matrix(rnorm(4),nrow=2,ncol=2)
y  <- rnorm(5*3*2)

R.kron   <- kronecker(x3,kronecker(x2,x1))	# form R kronecker product. impossible beyond a certain size
R.result <- R.kron 

Arma.result <- armakron(y=y,list(x1,x2,x3))	# armakron() computes result directly without forming kronecker product

all.equal(R.result,Arma.result)		# TRUE

# armamax()
result <- armamax(x1)
all.equal(apply(x1,1,max),as.numeric(result$values))	# TRUE
all.equal(apply(x1,1,which.max),as.numeric(result$indices))	# TRUE

## End(Not run)

floswald/ArmaUtils documentation built on May 16, 2019, 1:23 p.m.