Type: | Package |
Title: | Solves a Generic Stochastic Growth Model with a Representative Agent |
Version: | 0.1.2 |
Author: | Thomas Vigie <vigiethomas@gmail.com> |
Maintainer: | Thomas Vigie <vigiethomas@gmail.com> |
Description: | It computes the solutions to a generic stochastic growth model for a given set of user supplied parameters. It includes the solutions to the model, plots of the solution, a summary of the features of the model, a function that covers different types of consumption preferences, and a function that computes the moments of a Markov process. Merton, Robert C (1971) <doi:10.1016/0022-0531(71)90038-X>, Tauchen, George (1986) <doi:10.1016/0165-1765(86)90168-0>, Wickham, Hadley (2009, ISBN:978-0-387-98140-6 ). |
License: | GPL-3 |
Encoding: | UTF-8 |
Suggests: | knitr, rmarkdown, testthat |
Imports: | ggplot2, ramify, Rtauchen |
VignetteBuilder: | knitr |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | no |
Packaged: | 2024-01-24 21:41:44 UTC; vigie |
Repository: | CRAN |
Date/Publication: | 2024-01-24 22:00:02 UTC |
sgmodel: A package for computating the solutions to a generic stochastic growth model.
Description
The sgmodel package provides three important functions:
sgmod
, util
and Markovmoments
.
The sgmodel
function
The sgmodel
function solves a standard stochastic growth model using value function iteration. The stochastic component follows an autoregressive process of order one, and is discretized by a finite state Markov process.
The util
function
It computes values for various uility functions encountered in economic theory.
The Markovmoments
function
It computes the four moments of a finite state Markov chain: expectation, variance, autocovariance and autocorrelation.
Markovmoments
Description
The function Markovmoments
computes the expectation, variance, autocovariance and autocorrelation of a Markov process.
Usage
Markovmoments(states, ptm, ...)
Arguments
states |
A numerical vector with the states of the Markov process. |
ptm |
The probability transition matrix, a square matrix of dimension length(states) whose columns sum to one. |
... |
Additional arguments. |
Value
It returns a list containing:
Expectation |
The mean of the process. |
Variance |
The variance of the process. |
Autocovariance |
The autocovariance of the process. |
Autocorrelation |
The autocorrelation of the process. |
Stationary distribution |
The stationary distribution of the process, used for the computation of the moments. |
Examples
a <- c(-1, 1)
A <- matrix(c(0.5, 0.6,
0.5, 0.4), 2, 2)
Markovmoments(a, A)
plot_sgmod
Description
The function plot_sgmod
returns a plot of the Savings
value of a sgmodel
object on the Capital grid
value.
Usage
plot_sgmod(x, ...)
Arguments
x |
A |
... |
Additional arguments. |
Value
It returns a plot using ggplot
that graphs the Savings
decisions from the sgmodel
object on the Capital grid
. The plot shows as many facets as length(Z)
where Z
is the vector of states of the TFP process.
References
Wickham H (2009), ggplot2: Elegant Graphics for Data Analysis.
Examples
model <- sgmodel( grid = 100, rho = 0.2, sigma = 0.02)
plot_sgmod(model)
grid <- 200
utiltype <- "CRRA"
utilparam <- 4
A <- 1
depre <- 0.03
discount <- 0.95
prod <- 0.3
states <- 5
m <- 2
rho <- 0.2
sigma <- 0.02
model <- sgmodel(grid, utiltype, utilparam, A, depre, discount, prod, states, m, rho, sigma)
plot_sgmod(model)
print.summary_sgmod
Description
The function print.summary_sgmod
prints a summary for a sgmodel
object.
Usage
## S3 method for class 'summary_sgmod'
print(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments. |
Value
It returns a list with the model parameters. It includes:
Utility function |
The type of utility function. See the details of |
Capital share |
The exponent on capital in the Cobb-Douglas production function. |
Discount factor |
The discount factor used in the model. |
Depreciation |
The depreciation rate of capital used in the model. |
Rho |
Autocorrelation of the TFP AR(1) process. |
Sigma |
Standard deviation of the white noise in the TFP process. |
Number of TFP states |
Number of states of the TFP process. |
Examples
grid <- 200
utiltype <- "CRRA"
utilparam <- 4
A <- 1
depre <- 0.03
discount <- 0.95
prod <- 0.3
states <- 3
m <- 4
rho <- 0.2
sigma <- 0.02
model <- sgmodel(grid, utiltype, utilparam, A, depre, discount, prod, states, m, rho, sigma)
summary_sgmod(model)
print_sgmod
Description
The function print_sgmod
prints results of the sgmodel
function.
Usage
print_sgmod(x, ...)
Arguments
x |
A |
... |
Additional arguments. |
Value
The function prints the call of the function, the Savings, Consumption and Capital grid vectors from sgmodel
.
Examples
grid <- 200
utiltype <- "CRRA"
utilparam <- 4
A <- 1
depre <- 0.03
discount <- 0.95
prod <- 0.3
states <- 3
m <- 5
rho <- 0.2
sigma <- 0.02
model <- sgmodel(grid, utiltype, utilparam, A, depre, discount, prod, states, m, rho, sigma)
print_sgmod(model)
Sgmodel
Description
The function sgmodel
computes the solutions to a generic stochastic growth model after discretizing the distribution of the stochastic element.
Usage
sgmodel(grid, utiltype, utilparam, A, depre, discount, prod, states, m, rho,
sigma, ...)
Arguments
grid |
A numerical value, the number of capital grid points to consider for k (t). Default value set to 1000. |
utiltype |
The type of preference for the |
utilparam |
Numerical value, preference parameter for the |
A |
Numerical value, preference parameter for the |
depre |
Numerical value for the depreciation parameter. Must be between 0 and 1. Default value set to 1. |
discount |
Numerical value for the discount factor. Must be (strictly) between 0 and 1. Default value set to 0.95. |
prod |
Numerical value for the Cobb-Douglas production function. Must be (strictly) between 0 and 1. Default value set to 0.3. |
states |
umerical value for the number of states of the Markov process approximating the TFP process. Default value set to 2. |
m |
Numerical value for the |
rho |
Autocorrelation of the TFP AR(1) process, used to approximate the process with a Markov process. |
sigma |
Standard deviation of the white noise in the TFP process, used to approximate the process with a Markov process. |
... |
Additional arguments. |
Value
The function returns a list containing:
Capital grid |
Vector of values for capital. |
Savings |
Vector of size ( |
Consumption |
Vector of size ( |
Z |
States of the TFP process. |
PTM |
The probability transition matrix of the process. |
Production parameter |
The exponent on capital in the Cobb-Douglas production function. |
Utility type |
The type of utility function. See the details of "util" for the available types |
Discount factor |
The discount factor used in the model. |
Depreciation |
The depreciation rate of capital used in the model. |
Rho |
Autocorrelation of the TFP AR(1) process. |
Sigma |
Standard deviation of the white noise in the TFP process. |
References
Tauchen G (1986), Finite state markov-chain approximations to univariate and vector autoregressions. Economics letters, 20(2), 177–181.
Merton R. C (1971), Optimum consumption and portfolio rules in a continuous-time model. Journal of Economic Theory, 3(4), 373–413. URL https://www.sciencedirect.com/science/article/pii/002205317190038X
Examples
model <- sgmodel(grid= 100, rho = 0.2, sigma = 0.02)
grid <- 200
utiltype <- "CRRA"
utilparam <- 4
A <- 1
depre <- 0.03
discount <- 0.95
prod <- 0.3
states <- 5
m <- 10
rho <- 0.2
sigma <- 0.02
model <- sgmodel(grid, utiltype, utilparam, A, depre, discount, prod, states, m, rho, sigma)
summary_sgmod
Description
The function summary_sgmod
prints a summary for results of the sgmodel
function.
Usage
summary_sgmod(object, ...)
Arguments
object |
A |
... |
Additional arguments. |
Value
It returns a list with the model parameters. It includes:
Utility function |
The type of utility function. See the details of |
Capital share |
The exponent on capital in the Cobb-Douglas production function. |
Discount factor |
The discount factor used in the model. |
Depreciation |
The depreciation rate of capital used in the model. |
Rho |
Autocorrelation of the TFP AR(1) process. |
Sigma |
Standard deviation of the white noise in the TFP process. |
Number of TFP states |
Number of states of the TFP process. |
Examples
grid <- 200
utiltype <- "CRRA"
utilparam <- 4
A <- 1
depre <- 0.03
discount <- 0.95
prod <- 0.3
states <- 3
m <- 3
rho <- 0.2
sigma <- 0.02
model <- sgmodel(grid, utiltype, utilparam, A, depre, discount, prod, states, m, rho, sigma)
summary_sgmod(model)
Util
Description
The function util
computes values for different types of utility functions and different parameters. See sgmodel_vignette
for detailed functional forms.
Usage
util(x, A, prefparam, type = c("log", "CRRA", "CARA", "Cobb-Douglas", "CES"),
ngoods, ...)
Arguments
x |
A numeric vector of length ngoods with values to compute utility for. |
A |
A numerical value that will premultiply the utility function. Default value set to 1. |
prefparam |
A numerical value, the preference parameter applied to the utility function depending on type. |
type |
A character for the Type of utility function. Can be "log", "CRRA", "CARA", "Cobb-Douglas", "CES". Default type set to "log". |
ngoods |
Numerical value for the number of goods to consider. Default value set to 1. |
... |
Additional arguments. |
Value
A numerical value, the utility function evaluated at the arguments.
References
Merton R. C (1971), Optimum consumption and portfolio rules in a continuous-time model. Journal of Economic Theory, 3(4), 373–413. URL https://www.sciencedirect.com/science/article/pii/002205317190038X.
Examples
x <- c(exp(1), exp(1))
A <- 2
type <- "log"
ngoods <- 2
util(x = x, A = A, type = type, ngoods = ngoods)