• No results found

Package DynareR. August 11, 2020

N/A
N/A
Protected

Academic year: 2021

Share "Package DynareR. August 11, 2020"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

Package ‘DynareR’

August 11, 2020

Type Package

Title A Seamless Integration of 'R' and 'Dynare' Version 0.1.1

Author Sagiru Mati [aut, cre]

Maintainer Sagiru Mati<[email protected]>

Description It allows running 'Dynare' program from R Markdown. 'Dynare' is a software plat-form for handling a wide class of economic models, in particular dynamic stochastic gen-eral equilibrium ('DSGE') and overlapping generations ('OLG') models. This pack-age serves as a 'Dynare' Knit-Engine for 'knitr' packpack-age. The packpack-age

re-quires 'Dynare' 4.6.1 (<https://www.dynare.org/>) and

'Oc-tave' 5.2.0 (<https://www.gnu.org/software/octave/download.html>). Write all your 'Dynare' com-mands in R Markdown chunk.

Depends R (>= 3.2.3) Imports knitr (>= 1.20)

SystemRequirements Dynare (>= 4.6.1), Octave (=5.2.0) Suggests rmarkdown License GPL URL https://github.com/sagirumati/DynareR/ BugReports https://github.com/sagirumati/DynareR/issues Encoding UTF-8 VignetteBuilder knitr RoxygenNote 7.1.1 NeedsCompilation no Repository CRAN LazyData true Date/Publication 2020-08-11 16:02:14 UTC 1

(2)

2 eng_dynare

R topics documented:

eng_dynare . . . 2 include_IRF . . . 3 run_dynare . . . 4 run_model . . . 6 run_models . . . 7 write_dyn . . . 8 write_mod . . . 10 Index 12

eng_dynare DynareR: A Seamless Integration of R and Dynare

Description

This package runs on top of knitr to facilitate communication with Dynare. Run Dynare scripts from R Markdown document.

Usage

eng_dynare(options) Arguments

options Chunk options, as provided byknitr during chunk execution. Chunk option for this isdynare

Details

Thedynare engine can be activated via

knitr::knit_engines$set(dynare = DynareR::eng_dynare) This will be set within an R Markdown document’s setup chunk. Value

Set ofDynare (open-source software for DSGE modelling) codes Author(s)

Sagiru Mati, ORCID: 0000-0003-1413-3974, https://smati.com.ng • Yusuf Maitama Sule (Northwest) University Kano, Nigeria • SMATI Academy

(3)

include_IRF 3 References

Bob Rudis (2015).Running Go language chunks in R Markdown (Rmd) files. Available at: https://gist.github.com/hrbrmstr/9accf90e63d852337cb7 Yihui Xie (2019). knitr: A General-Purpose Package for Dynamic Report Generation in R. R

package version 1.24.

Yihui Xie (2015) Dynamic Documents with R and knitr. 2nd edition. Chapman and Hall/CRC. ISBN 978-1498716963

Yihui Xie (2014) knitr: A Comprehensive Tool for Reproducible Research in R. In Victoria Stodden, Friedrich Leisch and Roger D. Peng, editors, Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN 978-1466561595

See Also

write_mod write_dynare run_model run_dynare Examples

knitr::knit_engines$set(dynare = DynareR::eng_dynare) library(DynareR)

include_IRF Embed the graphs Impulse Response Function (IRF) in R Markdown document

Description

Use this function to includeDynare IRF into the R Markdown document Usage

include_IRF(model="",IRF="",path="") Arguments

model Object or a character string representing the name of the model excluding.mod or.dyn file extension

IRF A character string for the name of the Impulse Response Function as defined in theDynare codes.

path Object or a character string representing the path to the folder for theDynare file. The current working directory is the defaultpath. Specify the path only if theDynare files live in different path from the current working directory. Value

(4)

4 run_dynare Author(s)

Sagiru Mati, ORCID: 0000-0003-1413-3974, https://smati.com.ng • Yusuf Maitama Sule (Northwest) University Kano, Nigeria • SMATI Academy

References

Bob Rudis (2015).Running Go language chunks in R Markdown (Rmd) files. Available at: https://gist.github.com/hrbrmstr/9accf90e63d852337cb7 Yihui Xie (2019). knitr: A General-Purpose Package for Dynamic Report Generation in R. R

package version 1.24.

Yihui Xie (2015) Dynamic Documents with R and knitr. 2nd edition. Chapman and Hall/CRC. ISBN 978-1498716963

Yihui Xie (2014) knitr: A Comprehensive Tool for Reproducible Research in R. In Victoria Stodden, Friedrich Leisch and Roger D. Peng, editors, Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN 978-1466561595

See Also

write_mod write_dynare run_model run_dynare Examples

knitr::knit_engines$set(dynare = DynareR::eng_dynare) library(DynareR)

run_dynare Create and runDynare mod file

Description

Use this function to create and runDynare mod file. Use run_dynare(model,code) if you want theDynare files to live in the current working directory. Use run_dynare(model,code,path) if you want theDynare files to live in the path different from the current working directory.

Usage

run_dynare(model,code,path) Arguments

model Object or a character string representing the name of the model excluding.mod or.dyn file extension

code Object or a character string representing the set ofDynare codes

path Object or a character string representing the path to the folder for theDynare file. The current working directory is the defaultpath. Specify the path only if theDynare files live in different path from the current working directory.

(5)

run_dynare 5 Value

Set ofDynare (open-source software for DSGE modelling) outputs See Also

write_mod write_dyn eng_dynare run_model Examples

library(DynareR) ## Not run:

DynareCodes='var y, c, k, a, h, b; varexo e, u;

parameters beta, rho, alpha, delta, theta, psi, tau; alpha = 0.36; rho = 0.95; tau = 0.025; beta = 0.99; delta = 0.025; psi = 0; theta = 2.95; phi = 0.1; model; c*theta*h^(1+psi)=(1-alpha)*y; k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1))) *(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); y = exp(a)*(k(-1)^alpha)*(h^(1-alpha)); k = exp(b)*(y-c)+(1-delta)*k(-1); a = rho*a(-1)+tau*b(-1) + e; b = tau*a(-1)+rho*b(-1) + u; end; initval; y = 1.08068253095672; c = 0.80359242014163; h = 0.29175631001732; k = 11.08360443260358; a = 0; b = 0; e = 0; u = 0; end; shocks; var e; stderr 0.009; var u; stderr 0.009; var e, u = phi*0.009*0.009; end; stoch_simul;'

model<-"example1" # This is "example1" of the `Dynare` example files code<-DynareCodes

(6)

6 run_model

## End(Not run)

run_model Run a singleexistingmod or dyn file.

Description

Userun_model(model) if the Dynare files live in the current working directory. Use run_model(model,path) if theDynare files live in the path different from the current working directory.

Usage

run_model(model, path = "") Arguments

model Object or a character string representing the name of the model excluding.mod or.dyn file extension

path Object or a character string representing the path to the folder for theDynare file. The current working directory is the defaultpath. Specify the path only if theDynare files live in different path from the current working directory. Value

Set ofDynare (open-source software for DSGE modelling) outputs See Also

write_mod write_dynare eng_dynare run_dynare Examples

library(DynareR) ## Not run:

DynareCodes='var y, c, k, a, h, b; varexo e, u;

parameters beta, rho, alpha, delta, theta, psi, tau; alpha = 0.36; rho = 0.95; tau = 0.025; beta = 0.99; delta = 0.025; psi = 0; theta = 2.95; phi = 0.1; model; c*theta*h^(1+psi)=(1-alpha)*y; k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))

(7)

run_models 7 *(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); y = exp(a)*(k(-1)^alpha)*(h^(1-alpha)); k = exp(b)*(y-c)+(1-delta)*k(-1); a = rho*a(-1)+tau*b(-1) + e; b = tau*a(-1)+rho*b(-1) + u; end; initval; y = 1.08068253095672; c = 0.80359242014163; h = 0.29175631001732; k = 11.08360443260358; a = 0; b = 0; e = 0; u = 0; end; shocks; var e; stderr 0.009; var u; stderr 0.009; var e, u = phi*0.009*0.009; end; stoch_simul;'

model<-"example1" # This is "example1" of the `Dynare` example files code<-DynareCodes

write_mod(model,code) run_model(model) ## End(Not run)

run_models Run multipleexistingmod or dyn files.

Description

Use this function to execute multiple existingDynare files. Use run_models(file) if the Dynare files live in the current working directory. Userun_models(file,path) if the Dynare files live in the path different from the current working directory.

Usage

run_models(model, path = "") Arguments

model Object or a vector of character strings representing the names of theDynare model files excluding.mod or .dyn file extension

(8)

8 write_dyn path Object or a character string representing the path to the folder for theDynare file. The current working directory is the defaultpath. Specify the path only if theDynare files live in different path from the current working directory. Value

Set ofDynare (open-source software for DSGE modelling) outputs See Also

write_mod write_dynare eng_dynare run_dynare Examples

library(DynareR)

# Provide the list of the `Dynare` files in a vector model=c("example1","example2","agtrend","bkk") ## Not run:

run_models(model) ## End(Not run)

write_dyn write a newdyn file.

Description

Usewrite_dyn(model,code) if you want the Dynare file to live in the current working directory. Usewrite_dyn(model,code,path) if you want the Dynare file to live in the path different from the current working directory.

Usage

write_dyn(model, code, path = "") Arguments

model Object or a character string representing the name of the model excluding.mod or.dyn file extension

code Object or a character string representing the set ofDynare codes

path Object or a character string representing the path to the folder for theDynare file. The current working directory is the defaultpath. Specify the path only if theDynare files live in different path from the current working directory. Value

(9)

write_dyn 9 See Also

write_mod eng_dynare run_model run_dynare

Examples

library(DynareR) ## Not run:

DynareCodes='var y, c, k, a, h, b; varexo e, u;

parameters beta, rho, alpha, delta, theta, psi, tau; alpha = 0.36; rho = 0.95; tau = 0.025; beta = 0.99; delta = 0.025; psi = 0; theta = 2.95; phi = 0.1; model; c*theta*h^(1+psi)=(1-alpha)*y; k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1))) *(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); y = exp(a)*(k(-1)^alpha)*(h^(1-alpha)); k = exp(b)*(y-c)+(1-delta)*k(-1); a = rho*a(-1)+tau*b(-1) + e; b = tau*a(-1)+rho*b(-1) + u; end; initval; y = 1.08068253095672; c = 0.80359242014163; h = 0.29175631001732; k = 11.08360443260358; a = 0; b = 0; e = 0; u = 0; end; shocks; var e; stderr 0.009; var u; stderr 0.009; var e, u = phi*0.009*0.009; end; stoch_simul;'

model<-"example1" # This is "example1" of the `Dynare` example files code<-DynareCodes

write_dyn(model,code) ## End(Not run)

(10)

10 write_mod

write_mod Write a newmod file.

Description

Usewrite_mod(model,code) if you want the Dynare file to live in the current working directory. Usewrite_mod(model,code,path) if you want the Dynare file to live in the path different from the current working directory.

Usage

write_mod(model, code, path = "") Arguments

model Object or a character string representing the name of the model excluding.mod or.dyn file extension

code Object or a character string representing the set ofDynare codes

path Object or a character string representing the path to the folder for theDynare file. The current working directory is the defaultpath. Specify the path only if theDynare files live in different path from the current working directory. Value

Set ofDynare (open-source software for DSGE modelling) outputs See Also

write_dynare eng_dynare run_model run_dynare Examples

library(DynareR) ## Not run:

DynareCodes='var y, c, k, a, h, b; varexo e, u;

parameters beta, rho, alpha, delta, theta, psi, tau; alpha = 0.36; rho = 0.95; tau = 0.025; beta = 0.99; delta = 0.025; psi = 0; theta = 2.95; phi = 0.1; model; c*theta*h^(1+psi)=(1-alpha)*y; k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))

(11)

write_mod 11 *(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); y = exp(a)*(k(-1)^alpha)*(h^(1-alpha)); k = exp(b)*(y-c)+(1-delta)*k(-1); a = rho*a(-1)+tau*b(-1) + e; b = tau*a(-1)+rho*b(-1) + u; end; initval; y = 1.08068253095672; c = 0.80359242014163; h = 0.29175631001732; k = 11.08360443260358; a = 0; b = 0; e = 0; u = 0; end; shocks; var e; stderr 0.009; var u; stderr 0.009; var e, u = phi*0.009*0.009; end; stoch_simul;'

model<-"example1" # This is "example1" of the `Dynare` example files code<-DynareCodes

write_mod(model,code) ## End(Not run)

(12)

Index

∗ documentation eng_dynare,2 include_IRF,3 run_dynare,4 run_model,6 run_models,7 write_dyn,8 write_mod,10 eng_dynare,2 include_IRF,3 run_dynare,4 run_model,6 run_models,7 write_dyn,8 write_mod,10 12

References

Related documents

if the input argument is a character vector of the file path of input BED files, the default value of the keep argument is TRUE.

We now discuss another kind of vector multiplication called the vector or cross product, which is a vector quantity that is a maximum when the two vectors are normal to each other

conn an Elasticsearch connection object, see connect() x A list, data.frame, or character path to a

In less than three weeks of using the lead management solution, Sharp generated, qualified and distributed 96 percent of the entire previous year’s leads to our top dealers

Moreover, the share of jobs created by establishment births in small firms (1 to 19 employees) was much higher in the services industry than in manufacturing.. The following

– object typically a character string (error message) or class object – if exception handler exists, exception caught and handled.. – otherwise,

Although rural households remain far more likely to have income levels below the poverty threshold than those in urban areas, those households with access to higher

row.names NULL or a single integer or character string specifying a column to be used as row names, or a character or integer vector giving the row names for the data frame..