Package AMA. October 27, 2010

Similar documents
Package RootsExtremaInflections

Package BayesNI. February 19, 2015

Package ShrinkCovMat

Package robustrao. August 14, 2017

Package factorqr. R topics documented: February 19, 2015

Package rnmf. February 20, 2015

Package gtheory. October 30, 2016

Package SEMModComp. R topics documented: February 19, Type Package Title Model Comparisons for SEM Version 1.0 Date Author Roy Levy

Package jmcm. November 25, 2017

Package symmoments. R topics documented: February 20, Type Package

Package scio. February 20, 2015

Package LIStest. February 19, 2015

Package depth.plot. December 20, 2015

Package pssm. March 1, 2017

Package denseflmm. R topics documented: March 17, 2017

Package goftest. R topics documented: April 3, Type Package

Package NlinTS. September 10, 2018

Package Tcomp. June 6, 2018

Package coop. November 14, 2017

Package noise. July 29, 2016

Package darts. February 19, 2015

Package ResistorArray

Package bigtime. November 9, 2017

Package CCP. R topics documented: December 17, Type Package. Title Significance Tests for Canonical Correlation Analysis (CCA) Version 0.

Package RTransferEntropy

Package dhsic. R topics documented: July 27, 2017

Package R1magic. April 9, 2013

Package ProbForecastGOP

Package REGARMA. R topics documented: October 1, Type Package. Title Regularized estimation of Lasso, adaptive lasso, elastic net and REGARMA

Package idmtpreg. February 27, 2018

Package unbalhaar. February 20, 2015

Package RI2by2. October 21, 2016

Package MAPA. R topics documented: January 5, Type Package Title Multiple Aggregation Prediction Algorithm Version 2.0.4

Package mpmcorrelogram

Package mixture. R topics documented: February 13, 2018

Package milineage. October 20, 2017

Package R1magic. August 29, 2016

Package CEC. R topics documented: August 29, Title Cross-Entropy Clustering Version Date

7.5 Operations with Matrices. Copyright Cengage Learning. All rights reserved.

Package mistwosources

Package ltsbase. R topics documented: February 20, 2015

Package covsep. May 6, 2018

Package Blendstat. February 21, 2018

Package rela. R topics documented: February 20, Version 4.1 Date Title Item Analysis Package with Standard Errors

Package ChIPtest. July 20, 2016

Package geoscale. R topics documented: May 14, 2015

Package spcov. R topics documented: February 20, 2015

Package BNN. February 2, 2018

Package plspolychaos

Package magma. February 15, 2013

Package effectfusion

Package polypoly. R topics documented: May 27, 2017

Package QuantifQuantile

Package MultisiteMediation

Package flexcwm. R topics documented: July 11, Type Package. Title Flexible Cluster-Weighted Modeling. Version 1.0.

Package IUPS. February 19, 2015

Package condmixt. R topics documented: February 19, Type Package

Package rarpack. August 29, 2016

Package severity. February 20, 2015

Package vhica. April 5, 2016

Package Select. May 11, 2018

Package breakaway. R topics documented: March 30, 2016

Package LCAextend. August 29, 2013

Package Rarity. December 23, 2016

Package ENA. February 15, 2013

Package DTK. February 15, Type Package

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University

Package gma. September 19, 2017

Package flexcwm. R topics documented: July 2, Type Package. Title Flexible Cluster-Weighted Modeling. Version 1.1.

Package aspi. R topics documented: September 20, 2016

Package EMMIX. November 8, 2013

Package spthin. February 20, 2015

Package varband. November 7, 2016

Lab 6: Linear Algebra

'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ. EGR 53L Fall Test I. Rebecca A. Simmons & Michael R. Gustafson II

Lab Objective: Introduce some of the basic optimization functions available in the CVXOPT package

Package sscor. January 28, 2016

Package threg. August 10, 2015

Package EMVS. April 24, 2018

Package EnergyOnlineCPM

Tests for Two Coefficient Alphas

Package SK. May 16, 2018

The nltm Package. July 24, 2006

Package gsarima. February 20, 2015

Package TSF. July 15, 2017

Package spatial.gev.bma

Package msbp. December 13, 2018

Package mlmmm. February 20, 2015

(Linear equations) Applied Linear Algebra in Geoscience Using MATLAB

Package alabama. March 6, 2015

Package tspi. August 7, 2017

Package invgamma. May 7, 2017

Package sindyr. September 10, 2018

Package nardl. R topics documented: May 7, Type Package

Package dlagm. January 17, 2018

Package sbgcop. May 29, 2018

Package abundant. January 1, 2017

Package OUwie. August 29, 2013

Solving Deterministic Models

Package Delaporte. August 13, 2017

Transcription:

Package AMA October 27, 2010 Type Package Title Anderson-Moore Algorithm Version 1.0.8 Depends rjava Date 2010-10-13 Author Gary Anderson, Aneesh Raghunandan Maintainer Gary Anderson <gary.anderson@frb.gov> Implements Anderson-Moore algorithm for solving linear rational expectations models. For information about the algorithm and its uses, please see http://www.federalreserve.gov/pubs/oss/oss4/aimindex.html. This version works on both Unix and Windows. For questions about the algorithm and its implementation/applications, please contact gary.anderson@frb.gov. If you are having technical issues with the package, please contact aneesh.raghunandan@yale.edu. License GPL-2 Copyright The C code, sparseaim.c, implementing the basic algorithm is in the public domain and may be used freely. However, the authors would appreciate acknowledgement of the source by citation of any of the following papers: Anderson, G. and Moore, G. A Linear Algebraic Procedure For Solving Linear Perfect Foresight Models. Economics Letters, 17, 1985. Anderson, G. Solving Linear Rational Expectations Models: A Horse Race. Computational Economics, 2008, vol. 31, issue 2, pp. 95-113 Anderson, G. A Reliable and Computationally Efficient Algorithm for Imposing the Saddle Point Property in Dynamic Models. Journal of Economic Dynamics and Control, 2010, vol 34, issue 3, pp. 472-489. \{}n SystemRequirements Java LazyLoad yes Repository CRAN Date/Publication 2010-10-27 19:18:40 1

2 callama R topics documented: callama.......................................... 2 example7.......................................... 4 example7params...................................... 4 genbmat........................................... 5 genhmat........................................... 6 genhmatrixscripts..................................... 7 genqmat........................................... 8 genscof........................................... 9 getfactormatrices...................................... 10 getreturncode....................................... 11 getstochtrans........................................ 12 Lcofbob2.cof........................................ 14 Index 15 callama Anderson-Moore Algorithm Calls the Anderson-Moore Algorithm for the given inputs. callsparseaim is a wrapper to the C and FORTRAN functions which carry out the computation. callama(cofh, neq, leads, lags, qmax) cofh Full H matrix, passed to R columnwise. The H matrix is the matrix [H_-T... H_0... H_theta]. Must have neq rows and neq*(leads+lags+1) columns. neq Details leads lags qmax Number of equations in the model. Must equal number of rows in H matrix. Number of leads in the model. Must be a positive integer. Number of lags in the model. Must be a positive integer. Number of elements to allocate for sparse matrix storage. Optional input. Default is neq * leads * neq * (leads + lags). Note: for details about what the H, B, Q, S, script A, script B etc. matrices are, please see [Anderson 2010]. You will need to separately load in the data file in the form of the "H" matrix that is, the matrix [H_-T... H_0... H_theta]. For details on how to obtain this matrix given a model and data, see the papers referenced and use the genhmat function. This utility may be added to this R package in the future. Output will be a list of "list" objects i.e. the B, S, etc. matrices will be returned as one-dimensional list objects, embedded within a list. It is pretty straightforward to get

callama 3 Note these into matrix form (use outobject[k][[1]] to get the kth output where outobject is the result of callsparseaim). This applies to the B (structural coefficients) and Q (asymptotic linear constraints) matrices. Alternatively, you can also use the genbmat and genqmat functions to get these matrices directly, as matrix objects. You can also obtain the S (observable structure) matrix as well as the stochastic transition matrices, labelled script A and script B in [Anderson 2010]. The following list object: [cofh, hrows, hcols, neq, leads, lags, nstate, qmax, ptr,cofb, qmat] Where: The first six elements (cofh,..., lags) are the same as the inputs nstate = leads + lags + 1 qmax is same as on input ptr is a pointer to the integer corresponding to the error code; 0 denotes successful output. See getreturncode() to "translate". cofb = reduced form coefficients matrix qmat = asymptotic linear constraints matrix It is preferable to ensure that the matrix H is as you want it before passing it as an argument to this function (and to genbmat, genqmat, etc.) However, if you wish to simply load the matrix H from a text file with neq*(nlag+nlead+1) lines, make sure to store the entries column-wise as this is R s default method of storage. If you are only interested in, for example, the B matrix or the S matrix, then it is not necessary to call this function. Use genbmat or genscof instead both call this function as well. To extract a matrix from the jth element of the list returned by this function, use result[j][[1]] (where result is the name of the list). Author(s) Gary Anderson and Aneesh Raghunandan genbmat, genscof, genqmat, genhmat, getstochtrans, getfactormatrices hmat = read.table(system.file("extdata/lcofbob2.cof",package="ama")) hrows = 4 hcols = 12 neq = 4 leads = 1 lags = 1 output <- callama(hmat, neq, leads, lags)

4 example7params example7 example7.mod Text input for example Contains model definition example7.mod Format Uses modelez format hmat<-genhmat(system.file("extdata/example7.mod",package="ama"),system.file("extdata/example bmat<-genbmat(hmat,4,1,1) example7params example7params.txt Text input for example Contains parameter assignments for the example7 matrix assignments. Format Rows of assignment statements for model parameters. hmat<-genhmat(system.file("extdata/example7.mod",package="ama"),system.file("extdata/example bmat<-genbmat(hmat,4,1,1)

genbmat 5 genbmat Reduced-Form Coefficients Matrix Computes the reduced-form coefficients matrix ("B") output by the Anderson-Moore Algorithm. are identical to those passed to callsparseaim. genbmat(cofh, neq, leads, lags, qmax) cofh Full H matrix, passed to R columnwise. The H matrix is the matrix [H_-T... H_0... H_theta]. Must have neq rows and neq*(leads+lags+1) columns. neq leads lags qmax Number of equations in the model. Must equal number of rows in H matrix. Number of leads in the model. Must be a positive integer. Number of lags in the model. Must be a positive integer. Number of elements to allocate for sparse matrix storage. Optional input. Default is neq * leads * neq * (leads + lags). cofb ("B" matrix) Note Alternatively, can be called from the object that callama returns; i.e. callama, then use "bmat = res[10][[1]]". if res is the output of callama

6 genhmat hmat <- read.table(system.file("extdata/lcofbob2.cof",package="ama")) bmat <- genbmat(hmat, 4, 1, 1) hmat<-genhmat(system.file("extdata/example7.mod",package="ama"),system.file("extdata/example bmat<-genbmat(hmat,4,1,1) genhmat Structural Coefficients Matrix Scripts Creates the structural coefficients matrix H, given the model file and parameter values as inputs. genhmat(modelfilenamefull, params, wantparamvec = FALSE) modelfilenamefull String object containing the name of the model file. Model file must be in MOD- ELEZ syntax. params Either: -A string object containing the name of the parameters file (One parameter per line, with each line in the format "param = <value>") OR: -A vector containing the parameters. Vector must have names associated with each entry (i.e. names(params) should be correct and complete) wantparamvec If TRUE, then the output of the function is a list object containing as its first element the H matrix and as its second element the vector of parameters. Default is FALSE. You should probably set this to TRUE if you re reading in from a parameter file, and leave it as FALSE if you already have a parameter vector. Details Model input file must be in MODELEZ syntax. Structural coefficients matrix H.

genhmatrixscripts 7 For the details of MODELEZ syntax, see for example http://www.federalreserve.gov/ pubs/oss/oss4/papers/habitmatlab/habitmatlab.html For details about the algorithm: callama hmat<-genhmat(system.file("extdata/example7.mod",package="ama"),system.file("extdata/example bmat<-genbmat(hmat,4,1,1) genhmatrixscripts Structural Coefficients Matrix Scripts Creates an R file in the present working directory which, when run, creates the matrix H. genhmatrixscripts(modelfilenamefull) modelfilenamefull String object containing the name of the model file. Model file must be in MOD- ELEZ syntax. Details Model input file must be in MODELEZ syntax. An R script, in the current directory, called "<model name>_sparseaimmatrices.r", which when run generates the matrix H.

8 genqmat For the details of MODELEZ syntax, see for example http://www.federalreserve.gov/ pubs/oss/oss4/papers/habitmatlab/habitmatlab.html callama genhmatrixscripts(system.file("extdata/example7.mod",package="ama")) genqmat Asymptotic Linear Constraints Computes the asymptotic linear constraints matrix ("Q") used by the Anderson-Moore Algorithm. are identical to those passed to callsparseaim. genqmat(cofh, neq, leads, lags, qmax) Note cofh Full H matrix, passed to R columnwise. The H matrix is the matrix [H_-T... H_0... H_theta]. Must have neq rows and neq*(leads+lags+1) columns. neq leads lags qmax Number of equations in the model. Must equal number of rows in H matrix. Number of leads in the model. Must be a positive integer. Number of lags in the model. Must be a positive integer. Number of elements to allocate for sparse matrix storage. Optional input. Default is neq * leads * neq * (leads + lags). qmat (asymptotic linear constraints matrix) Alternatively, can be called from the object that callama returns; i.e. callama, then use "qmat = res[11][[1]]". if res is the output of

genscof 9 callama hmat = read.table(system.file("extdata/lcofbob2.cof",package="ama")) hrows = 4 hcols = 12 neq = 4 leads = 1 lags = 1 Qmatrix <- genqmat(hmat, neq, leads, lags) genscof Observable Structure Matrix Computes the observable structure matrix ("S") using outputs from the Anderson-Moore Algorithm. genscof(hmat, bmat, neq, leads, lags) hmat Full H matrix, passed to R columnwise. The H matrix is the matrix [H_-T... H_0... H_theta]. bmat neq leads lags The B (reduced-form coefficients) matrix. Number of equations in the model. Number of leads in the model. Must be a positive integer. Number of lags in the model. Must be a positive integer. cofs (observable structure matrix)

10 getfactormatrices Note Alternatively, can be called from the object that callama returns; i.e. callama, then use "bmat = res[10][[1]]". if res is the output of callama, genbmat hmat = read.table(system.file("extdata/lcofbob2.cof",package="ama")) hrows = 4 hcols = 12 neq = 4 leads = 1 lags = 1 qmax = 150000 bmat <- genbmat(hmat, neq, leads, lags) Scoef <- genscof(hmat, bmat, neq, leads, lags) getfactormatrices Shock Factor Matrices for Inhomogeneous Solutions Computes the exogenous shock scaling (phi) and transfer (F) matrices used in the inhomogeneous case (i.e. getfactormatrices(hmat, bmat, neq, leads, lags) hmat Full H matrix, passed to R columnwise. The H matrix is the matrix [H_-T... H_0... H_theta]. Must have neq rows and neq*(leads+lags+1) columns. bmat neq leads lags Full B matrix, as generated either by callsparseaim or genbmat. Number of equations in the model. Must equal number of rows in H matrix. Number of leads in the model. Must be a positive integer. Number of lags in the model. Must be a positive integer.

getreturncode 11 Details [to be filled in] list object containing phi as first element and F as second element. callama, genbmat hmat = read.table(system.file("extdata/lcofbob2.cof",package="ama")) hrows = 4 hcols = 12 neq = 4 leads = 1 lags = 1 bmat <- genbmat(hmat, neq, leads, lags) hmat = matrix(as.matrix(hmat), neq) factormats <- getfactormatrices(hmat, bmat, neq, leads, lags) phi = factormats[1][[1]] F = factormats[2][[1]] getreturncode Return Code Computes the asymptotic linear constraints matrix ("Q") used by the Anderson-Moore Algorithm. are identical to those passed to callsparseaim. getreturncode(sparseaimobject) sparseaimobject Output object from callsparseaim.

12 getstochtrans Details [to be filled in] Return code (corresponds to 0 if call to SparseAIM is successful; prints error message otherwise) Note Integer corresponding to error code can be extracted directly from the object that callsparseaim returns; i.e. if res is the output of callsparseaim, then use "returncode = res[9][[1]]". callama hmat = read.table(system.file("extdata/lcofbob2.cof",package="ama")) hrows = 4 hcols = 12 neq = 4 leads = 1 lags = 1 output <- callama(hmat, neq, leads, lags) errormsg = getreturncode(output) getstochtrans Stochastic Transition Matrices Computes the stochastic transition matrices ("script A" and "script B") used by the Anderson-Moore Algorithm. Matrices H and S must already be matrix objects of proper dimension. getstochtrans(hmat, scof)

getstochtrans 13 hmat Full H matrix object. The H matrix is the matrix [H_-T... H_0... H_theta]. (i.e. T lags and theta leads) scof Matrix S ("observable structure"). Details A and B are the solution to [x_t-t+1... x_t] = A[x_t-T...xt-1] + B[e_t + psi*(e[z_t I_t] - E[z_t I_t- 1)] A, B (returned as a "list" object; the first element is A and the second is B.) callama, genscof, genbmat hmat = read.table(system.file("extdata/lcofbob2.cof",package="ama")) hrows = 4 hcols = 12 neq = 4 hmatrix = matrix((as.matrix(hmat)), neq) leads = 1 lags = 1 bmat <- genbmat(hmat, neq, leads, lags) Scoef <- genscof(hmat, bmat, neq, leads, lags) stochmatrices <- getstochtrans(hmatrix, Scoef) scripta = stochmatrices[1][[1]] scriptb = stochmatrices[2][[1]]

14 Lcofbob2.cof Lcofbob2.cof Lcofbob2.cof Example Input data Format Input matrix for example Lcofbob2.cof Matrix elements columnwise. hmat = read.table(system.file("extdata/lcofbob2.cof",package="ama")) hrows = 4 hcols = 12 neq = 4 leads = 1 lags = 1 output <- callama(hmat, neq, leads, lags)

Index Topic datasets example7, 3 example7params, 4 Lcofbob2.cof, 13 callama, 2, 5 8, 10 13 example7, 3 example7params, 4 genbmat, 3, 4, 10, 11, 13 genhmat, 3, 5 genhmatrixscripts, 7 genqmat, 3, 8 genscof, 3, 9, 13 getfactormatrices, 3, 10 getreturncode, 11 getstochtrans, 3, 12 Lcofbob2.cof, 13 15