0% found this document useful (0 votes)
6 views

Package CGE': R Topics Documented

Uploaded by

Goldman Clarck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Package CGE': R Topics Documented

Uploaded by

Goldman Clarck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 77

Package ‘CGE’

October 12, 2022


Type Package
Title Computing General Equilibrium
Version 0.3.3
Author LI Wu <[email protected]>
Maintainer LI Wu <[email protected]>
Description Developing general equilibrium models, computing general equilibrium and simulat-
ing economic dynamics with structural dynamic mod-
els in LI (2019, ISBN: 9787521804225) ``General Equilibrium and Structural Dynamics: Per-
spectives of New Structural Economics. Beijing: Economic Science Press''. When develop-
ing complex general equilibrium models, GE package should be used in addition to this package.
License GPL-2 | GPL-3
Encoding UTF-8
LazyData true

BugReports https://github.com/LiWuR/CGE/issues
RoxygenNote 7.1.0
NeedsCompilation no
Repository CRAN
Date/Publication 2020-05-24 05:00:11 UTC

R topics documented:
CD_A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CD_mA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
CES_A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
CES_mA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
ChinaCGE2012 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
dg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Example.MWG.15.B.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Example.MWG.15.B.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Example.MWG.Exercise.15.B.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Example.MWG.Exercise.15.B.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

1
2 R topics documented:

Example.Section.3.1.2.corn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Example.Varian.Exercise.18.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Example.Varian.P352 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Example2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Example2.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Example3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Example3.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Example3.12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Example3.14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Example3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Example3.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Example3.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Example3.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Example4.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Example4.11.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Example4.11.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Example4.12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Example4.13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Example4.15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Example4.16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Example4.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Example4.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Example4.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Example5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Example5.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Example5.11.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Example5.11.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Example5.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Example5.3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Example5.3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Example5.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Example5.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Example5.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Example6.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Example6.11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Example6.13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Example6.2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Example6.2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Example6.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Example6.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Example6.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Example6.6.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Example6.6.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Example6.6.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Example6.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Example6.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Example7.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Example7.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
CD_A 3

Example7.10.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Example7.11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Example7.12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Example7.13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Example7.14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Example7.15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Example7.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Example7.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Example7.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Example7.5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Example7.5.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Example7.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Example7.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Example7.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Example7.9X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Example8.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Example8.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Example8.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Example8.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Example8.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Example9.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Example9.10.policy.deficit.fiscal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Example9.10.policy.deflation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Example9.10.policy.interest.rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Example9.10.policy.money.supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Example9.10.policy.quantitative.easing . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Example9.10.policy.tax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Example9.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Example9.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Example9.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Example9.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Example9.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
F_Z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
iep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Leontief_mA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
PF_eig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
sdm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Index 76

CD_A Cobb-Douglas Demand Structure Matrix

Description
This function computes the Cobb-Douglas demand structure matrix.
4 CD_mA

Usage
CD_A(alpha, Beta, p)

Arguments
alpha a nonnegative numeric m-vector or m-by-1 matrix.
Beta a nonnegative numeric n-by-m matrix whose each column sum equals 1.
p a nonnegative numeric n-vector or n-by-1 matrix.

Value
A demand coefficient n-by-m matrix is computed which indicates the demands of agents (firms or
consumers) for obtaining unit product or utility with Cobb-Douglas production functions or utility
functions under the price vector p.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
CD_A(1, c(0.5, 0.5), c(1, 2))

#####
alpha <- c(5, 3, 1)
Beta <- matrix(c(
0.6, 0.4, 0.2,
0.1, 0.4, 0.7,
0.3, 0.2, 0.1
), 3, 3, TRUE)
p <- 1:3
CD_A(alpha, Beta, p)

CD_mA Cobb-Douglas Monetary Demand Structure Matrix

Description
This function computes a Cobb-Douglas monetary demand structure matrix in a monetary economy.

Usage
CD_mA(alpha, Beta, p)
CES_A 5

Arguments
alpha a nonnegative numeric m-vector or m-by-1 matrix.
Beta nonnegative numeric n-by-m matrix whose each column sum equals 1.
p a nonnegative numeric n-vector or n-by-1 matrix.

Details
Some elements of Beta corresponding to money equal -1.

Value
A n-by-m matrix is computed which indicates the (monetary) demand structure of agents (firms or
consumers) with Cobb-Douglas production functions or utility functions under the price vector p.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
alpha <- c(1, 1, 1)
Beta <- matrix(c(
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-1, -1, -1
), 3, 3, TRUE)
p <- c(1, 2, 0.1)
CD_mA(alpha, Beta, p)

CES_A CES Demand Coefficient Matrix

Description
This function computes the CES demand coefficient matrix.

Usage
CES_A(sigma, alpha, Beta, p, Theta = NULL)
6 CES_A

Arguments
sigma a numeric m-vector or m-by-1 matrix.
alpha a nonnegative numeric m-vector or m-by-1 matrix.
Beta a nonnegative numeric n-by-m matrix.
p a nonnegative numeric n-vector or n-by-1 matrix.
Theta null or a positive numeric n-by-m matrix.

Value
A demand coefficient n-by-m matrix is computed which indicates the demands of agents (firms or
consumers) for obtaining unit product or utility with CES production functions or utility functions
(e.g. alpha*(beta1*x1^sigma+beta2*x2^sigma)^(1/sigma) or alpha*(beta1*(x1/theta1)^sigma+beta2*(x2/theta2)^sigma)^(1/
under the price vector p.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
CES_A(-1, 2, c(0.2, 0.1), c(1, 2))

#####
sigma <- c(-1, -1, -1)
alpha <- c(1, 1, 1)
Beta <- matrix(c(
0, 1, 1,
1, 0, 0,
1, 0, 0
), 3, 3, TRUE)
p <- 1:3
CES_A(sigma, alpha, Beta, p)

#####
sigma <- -1e-10
alpha <- 1
Beta <- c(0.8, 0.2)
Theta <- c(2, 1)
p <- c(1, 1)
CES_A(sigma, alpha, Beta, p, Theta)
CD_A(alpha * prod(Theta^(-Beta)), Beta, p)

CES_A(sigma, alpha, Beta, p, Beta)


CD_A(alpha * prod(Beta^(-Beta)), Beta, p)
CES_mA 7

CES_A(-1e5, alpha, Beta, p, Theta)

CES_mA CES Monetary Demand Coefficient Matrix

Description

This function computes a CES monetary demand coefficient matrix in a monetary economy.

Usage

CES_mA(sigma, alpha, Beta, p, Theta = NULL)

Arguments

sigma a numeric m-vector or m-by-1 matrix.


alpha a nonnegative numeric m-vector or m-by-1 matrix.
Beta a nonnegative numeric n-by-m matrix whose each column sum equals 1.
p a nonnegative numeric n-vector or n-by-1 matrix.
Theta null or a positive numeric n-by-m matrix.

Details

Some elements of Beta corresponding to money equal -1.

Value

A n-by-m matrix is computed which indicates the (monetary) demand structure of agents (firms or
consumers) with CES production functions or utility functions under the price vector p.

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
8 ChinaCGE2012

Examples
alpha <- matrix(1, 6, 1)
Beta <- matrix(c(
0, 1, 1, 0, 1, 1,
0.5, 0, 0, 0, 0, 0,
-1, -1, -1, 0, 0, 0,
0.5, 0, 0, 0.5, 0, 0,
0, 0, 0, 0.5, 0, 0,
0, 0, 0, -1, -1, -1
), 6, 6, TRUE)
p <- c(1, 2, 0.1, 4, 5, 0.1)
CES_mA(rep(-1, 6), alpha, Beta, p)

ChinaCGE2012 A CGE Model of China based on the Input-Output Table of 2012 (Unit:
Ten Thousand RMB)

Description
This data set gives parameters of a CGE model of China based on the input-output table of 2012.

Usage
ChinaCGE2012

Format
A list containing the following components:

A(state) function a function which returns a demand structure 41-by-38 matrix under a given price 41-vector.
B numeric a supply structure 41-by-38 matrix.
S0Exg numeric an exogenous supply 41-by-38 matrix.
z0 numeric an initial exchange levels (i.e. activity levels, production levels or utility levels) 38-vector.
subject.names character names of 41 subjects (or commodities).
sector.names character names of 38 sectors.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
dg 9

ChinaCGE2012$A(list(p = rep(1, 41)))

#####
cge <- function(GRExg = 0) {
sdm(
A = ChinaCGE2012$A,
B = ChinaCGE2012$B,
S0Exg = ChinaCGE2012$S0Exg,
GRExg = GRExg,
z0 = ChinaCGE2012$z0,
priceAdjustmentVelocity = 0.03
)
}

#####
ge0 <- cge()
names(ge0$p) <- ChinaCGE2012$subject.names
ge0$p

names(ge0$z) <- ChinaCGE2012$sector.names


ge0$z

#####
ge6 <- cge(GRExg = 0.06)
names(ge6$p) <- ChinaCGE2012$subject.names
ge6$p

names(ge6$z) <- ChinaCGE2012$sector.names


ge6$z

dg A Modified diag Function

Description
This function works in the way analogous to the diag function of Matlab.

Usage
dg(x)

Arguments
x a number, vector or square matrix.

Value
If x is a number, dg returns itself. If x is a vector, a one-row matrix or a one-column matrix, dg
returns a matrix with x as the main diagnol. Otherwise dg returns diag(x).
10 Example.MWG.15.B.1

Author(s)

LI Wu <[email protected]>

Examples
diag(matrix(2, 3))
dg(matrix(2, 3))

Example.MWG.15.B.1 Example 15.B.1 in MWG (1995)

Description

This is Example 15.B.1 in MWG (1995, P519), which is a pure exchange Cobb-Douglas 2-by-2
economy.

Usage

Example.MWG.15.B.1(
a = 0.1,
S0Exg = matrix(c(
1, 2,
2, 1
), 2, 2, TRUE)
)

Arguments

a Each consumer has the Cobb-Douglas utility function x1^a*x2^(1-a).


S0Exg exogenous supply matrix which will be passed to the function sdm.

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Mas-Colell, Andreu and Whinston, Michael Dennis and Green, Jerry R. (1995, ISBN: 0195073401)
Microeconomic Theory. Oxford University Press (New York).
Example.MWG.15.B.2 11

Examples
Example.MWG.15.B.1()

#####
Example.MWG.15.B.1(a = 0.2)

#####
S <- matrix(c(
18, 72,
40, 20
), 2, 2, TRUE)
ge <- Example.MWG.15.B.1(a = 0.2, S0Exg = S)
ge$p / ge$p[1]

Example.MWG.15.B.2 Example 15.B.2 in MWG (1995)

Description
This is Example 15.B.2 in MWG (1995, P521), which is a pure exchange 2-by-2 economy with
quasilinear utility functions.

Usage
Example.MWG.15.B.2(p0 = c(1, 0.3))

Arguments
p0 an initial price 2-vector, which will be passed to the function sdm.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Mas-Colell, Andreu and Whinston, Michael Dennis and Green, Jerry R. (1995, ISBN: 0195073401)
Microeconomic Theory. Oxford University Press (New York).

Examples

ge <- Example.MWG.15.B.2()
ge$p

#####
12 Example.MWG.Exercise.15.B.6

ge <- Example.MWG.15.B.2(p0 = c(0.3, 1))


ge$p

#####
ge <- Example.MWG.15.B.2(p0 = c(1, 1))
ge$p

Example.MWG.Exercise.15.B.6
Exercise 15.B.6 in MWG (1995)

Description
This is Exercise 15.B.6 in MWG (1995, P541), which is a pure exchange CES 2-by-2 economy.

Usage
Example.MWG.Exercise.15.B.6(p0 = c(1, 2))

Arguments
p0 an initial price 2-vector, which will be passed to the function sdm.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Mas-Colell, Andreu and Whinston, Michael Dennis and Green, Jerry R. (1995, ISBN: 0195073401)
Microeconomic Theory. Oxford University Press (New York).

Examples

ge <- Example.MWG.Exercise.15.B.6()
ge$p / ge$p[2] # (3/4)^3

#####
ge <- Example.MWG.Exercise.15.B.6(p0 = c(2, 1))
ge$p / ge$p[2] # (4/3)^3

#####
ge <- Example.MWG.Exercise.15.B.6(p0 = c(1, 1))
ge$p
Example.MWG.Exercise.15.B.9 13

Example.MWG.Exercise.15.B.9
Exercise 15.B.9 in MWG (1995)

Description

This is Exercise 15.B.9 in MWG (1995, P541), which is a pure exchange 2-by-2 economy.

Usage

Example.MWG.Exercise.15.B.9(
S0Exg = matrix(c(
30, 0,
0, 20
), 2, 2, TRUE)
)

Arguments

S0Exg an exogenous supply matrix, which will be passed to the function sdm.

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Mas-Colell, Andreu and Whinston, Michael Dennis and Green, Jerry R. (1995, ISBN: 0195073401)
Microeconomic Theory. Oxford University Press (New York).

Examples
Example.MWG.Exercise.15.B.9()

#####
S <- matrix(c(
5, 0,
0, 20
), 2, 2, TRUE)
Example.MWG.Exercise.15.B.9(S0Exg = S)
14 Example.Varian.Exercise.18.2

Example.Section.3.1.2.corn
Example in Section.3.1.2 of Li (2019)

Description
This is the example in Section.3.1.2 of Li (2019), which is a Leontief-type two-sector corn economy.

Usage
Example.Section.3.1.2.corn()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example.Varian.Exercise.18.2
Exercise 18.2 in Varian (1992)

Description
This is Exercise 18.2 in Varian (1992, P357), which is a Cobb-Douglas 3-by-4 economy.

Usage
Example.Varian.Exercise.18.2()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Varian, Hal R. (1992, ISBN: 0393957357) Microeconomic Analysis. W. W. Norton & Company.

Examples
ge <- Example.Varian.Exercise.18.2()
ge$A %*% diag(ge$z) #input matrix
Example.Varian.P352 15

Example.Varian.P352 Example on Page 352 in Varian (1992)

Description
This is the example on page 352 in Varian (1992) (see also Example 15.C.2. in MWG, 1995, P542),
which is a decreasing-returns-to-scale Cobb-Douglas 3-by-2 economy and can be transformed into
a constant-returns-to-scale 3-by-3 (or 3-by-2) economy.

Usage
Example.Varian.P352(agent.number = 3)

Arguments
agent.number agent.number can be set to 3 or 2.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Mas-Colell, Andreu and Whinston, Michael Dennis and Green, Jerry R. (1995, ISBN: 0195073401)
Microeconomic Theory. Oxford University Press (New York).
Varian, Hal R. (1992, ISBN: 0393957357) Microeconomic Analysis. W. W. Norton & Company.

Examples
Example.Varian.P352()

#####
Example.Varian.P352(agent.number = 2)

Example2.2 Example 2.2 in Li (2019)

Description
This is Example 2.2 in Li (2019), which is a Cobb-Douglas pure production economy.

Usage
Example2.2()
16 Example3.1

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example2.3 Example2.3 in Li (2019)

Description
This is Example 2.3 in Li (2019), which is a von Neumann economy.

Usage
Example2.3()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example3.1 Example 3.1 in Li (2019)

Description
This is Example 3.1 in Li (2019),which is a two-sector corn economy with a non-homothetic utility
function.

Usage
Example3.1()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example3.10 17

Example3.10 Example 3.10 in Li (2019)

Description

This is Example 3.10 in Li (2019),which is a Leontief corn economy with three primary factors.

Usage

Example3.10()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example3.12 Example 3.12 in Li (2019)

Description

This is Example 3.12 in Li (2019),which is an economy with decreasing returns to scale.

Usage

Example3.12()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
18 Example3.2

Example3.14 Example 3.14 in Li (2019)

Description
This is Example 3.14 in Li (2019),which illustrates the relationship between a regular economy and
a pure exchange economy.

Usage
Example3.14()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example3.2 Example 3.2 in Li (2019)

Description
This is Example 3.2 in Li (2019),which is a Cobb-Douglas two-sector corn economy.

Usage
Example3.2()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example3.4 19

Example3.4 Example 3.4 in Li (2019)

Description
This is Example 3.2 in Li (2019),which is a Lontief three-sector economy with one primary factor.

Usage
Example3.4()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example3.8 Example 3.8 in Li (2019)

Description
This is Example 3.8 in Li (2019),which is a Cobb-Douglas three-sector economy with one primary
factor.

Usage
Example3.8()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
20 Example4.10

Example3.9 Example 3.9 in Li (2019)

Description
This is Example 3.9 in Li (2019),which is a Cobb-Douglas three-sector economy with two primary
factors.

Usage
Example3.9()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example4.10 Example 4.10 in Li (2019)

Description
This is Example 4.10 in Li (2019),which illustrates the tax.

Usage
Example4.10()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example4.11.1 21

Example4.11.1 First Part of Example 4.11 in Li (2019)

Description

This is the first part of Example 4.11 in Li (2019),which illustrates the tax.

Usage

Example4.11.1()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example4.11.2 Second Part of Example 4.11 in Li (2019)

Description

This is the second part of Example 4.11 in Li (2019),which illustrates the tax.

Usage

Example4.11.2()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
22 Example4.13

Example4.12 Example 4.12 in Li (2019)

Description

This is Example 4.12 in Li (2019),which illustrates the tax.

Usage

Example4.12()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example4.13 Example 4.13 in Li (2019)

Description

This is Example 4.13 in Li (2019),which illustrates the divident.

Usage

Example4.13()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example4.15 23

Example4.15 Example 4.15 in Li (2019)

Description

This is Example 4.15 in Li (2019),which illustrates over-investment.

Usage

Example4.15()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example4.16 Example 4.16 in Li (2019)

Description

This is Example 4.16 in Li (2019),which illustrates technology monopoly.

Usage

Example4.16()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
24 Example4.8

Example4.2 Example 4.2 in Li (2019)

Description

This is Example 4.2 in Li (2019), which illustrates the non-sufficient supply of the primary factor.

Usage

Example4.2()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example4.8 Example 4.8 in Li (2019)

Description

This is Example 4.8 in Li (2019),which illustrates the increasing returns to scale.

Usage

Example4.8()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example4.9 25

Example4.9 Example 4.9 in Li (2019)

Description

This is Example 4.9 in Li (2019),which illustrates the price signal.

Usage

Example4.9()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example5.1 Example 5.1 in Li (2019)

Description

This is Example 5.1 in Li (2019),which illustrates fixed assets.

Usage

Example5.1()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
26 Example5.11.1

Example5.10 Example 5.10 in Li (2019)

Description

This is Example 5.10 in Li (2019),which illustrates pollution.

Usage

Example5.10()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example5.11.1 First Part of Example 5.11 in Li (2019)

Description

This is the first part of Example 5.11 in Li (2019),which illustrates pollution.

Usage

Example5.11.1()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example5.11.2 27

Example5.11.2 Second Part of Example 5.11 in Li (2019)

Description

This is the second part of Example 5.11 in Li (2019),which illustrates pollution.

Usage

Example5.11.2()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example5.2 Example 5.2 in Li (2019)

Description

This is Example 5.2 in Li (2019),which illustrates fixed assets.

Usage

Example5.2()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
28 Example5.3.2

Example5.3.1 First Part of Example 5.3 in Li (2019)

Description

This is the first part of Example 5.3 in Li (2019),which illustrates fixed assets.

Usage

Example5.3.1()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example5.3.2 Second Part of Example 5.3 in Li (2019)

Description

This is the second part of Example 5.3 in Li (2019),which illustrates fixed assets.

Usage

Example5.3.2()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example5.4 29

Example5.4 Example 5.4 in Li (2019)

Description

This is Example 5.4 in Li (2019),which illustrates fixed assets.

Usage

Example5.4()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example5.5 Example 5.5 in Li (2019)

Description

This is Example 5.5 in Li (2019),which illustrates fixed assets.

Usage

Example5.5()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
30 Example6.10

Example5.6 Example 5.6 in Li (2019)

Description

This is Example 5.6 in Li (2019),which illustrates fixed assets.

Usage

Example5.6()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example6.10 Example 6.10 in Li (2019)

Description

This is Example 6.10 in Li (2019),which illustrates a two-country economy.

Usage

Example6.10()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example6.11 31

Example6.11 Example 6.11 in Li (2019)

Description
This is Example 6.11 in Li (2019),which illustrates a two-country economy.

Usage
Example6.11()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example6.13 Example 6.13 in Li (2019)

Description
This is Example 6.13 in Li (2019),which illustrates a two-country economy.

Usage
Example6.13()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
ge <- Example6.13()
matplot(ge$ts.p, type = "l")
matplot(ge$ts.z, type = "l")
32 Example6.2.2

Example6.2.1 First Part of Example 6.2 in Li (2019)

Description

This is the first part of Example 6.2 in Li (2019),which illustrates a two-country economy.

Usage

Example6.2.1()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example6.2.2 Second Part of Example 6.2 in Li (2019)

Description

This is the second part of Example 6.2 in Li (2019),which illustrates a two-country economy.

Usage

Example6.2.2()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example6.3 33

Example6.3 Example 6.3 in Li (2019)

Description

This is Example 6.3 in Li (2019),which illustrates a two-country economy.

Usage

Example6.3()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example6.4 Example 6.4 in Li (2019)

Description

This is Example 6.4 in Li (2019),which illustrates a two-country economy.

Usage

Example6.4()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
34 Example6.6.1

Example6.5 Example 6.5 in Li (2019)

Description

This is Example 6.5 in Li (2019),which illustrates a two-country economy.

Usage

Example6.5()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example6.6.1 First Part of Example 6.6 in Li (2019)

Description

This is the first part of Example 6.6 in Li (2019),which illustrates a two-country economy.

Usage

Example6.6.1()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example6.6.2 35

Example6.6.2 Second Part of Example 6.6 in Li (2019)

Description
This is the second part of Example 6.6 in Li (2019),which illustrates the first country of a two-
country economy.

Usage
Example6.6.2()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example6.6.3 Third Part of Example 6.6 in Li (2019)

Description
This is the third part of Example 6.6 in Li (2019),which illustrates the second country of a two-
country economy.

Usage
Example6.6.3()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
36 Example6.9

Example6.7 Example 6.7 in Li (2019)

Description

This is Example 6.7 in Li (2019),which illustrates a two-country economy.

Usage

Example6.7()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example6.9 Example 6.9 in Li (2019)

Description

This is Example 6.9 in Li (2019),which illustrates a two-country economy.

Usage

Example6.9()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example7.1 37

Example7.1 Example 7.1 in Li (2019)

Description

This is Example 7.1 in Li (2019),which illustrates a monetary pure exchange economy.

Usage

Example7.1()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.10 Example 7.10 in Li (2019)

Description

This is Example 7.10 in Li (2019), which illustrates fiat money and representative money.

Usage

Example7.10()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019) General Equilibrium and Structural Dynamics: Perspectives of New Structural Eco-
nomics. Beijing: Economic Science Press. (In Chinese)
38 Example7.11

Example7.10.2 Extra Part of Example 7.10 in Li (2019)

Description
This is an extra part of Example 7.10 in Li (2019), which illustrates fiat money and representative
money.

Usage
Example7.10.2()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.11 Example 7.11 in Li (2019)

Description
This is Example 7.11 in Li (2019), which illustrates bond.

Usage
Example7.11()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example7.12 39

Example7.12 Example 7.12 in Li (2019)

Description
This is Example 7.12 in Li (2019), which illustrates the foreign exchange rate and international
credit.

Usage
Example7.12()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.13 Example 7.13 in Li (2019)

Description
This is Example 7.13 in Li (2019), which illustrates indirect financing based on commercial banks.

Usage
Example7.13()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
40 Example7.15

Example7.14 Example 7.14 in Li (2019)

Description

This is Example 7.14 in Li (2019), which illustrates shadow prices.

Usage

Example7.14()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.15 Example 7.15 in Li (2019)

Description

This is Example 7.15 in Li (2019), which illustrates shadow prices and international trade.

Usage

Example7.15()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example7.2 41

Example7.2 Example 7.2 in Li (2019)

Description
This is Example 7.2 in Li (2019),which illustrates a monetary Cobb-Douglas zero-growth corn
economy.

Usage
Example7.2()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
## Another way to compute this equilibrium, i.e. treating money as tax receipt.
r <- 0.25
ge <- sdm(
A = function(state) {
alpha <- rbind(1, 1, 1)
Beta <- matrix(c(
0.5, 0.5, 0.5,
0.5, 0.5, 0.5
), 2, 3, TRUE)
tmp.A <- CD_A(alpha, Beta, state$p[1:2])
tmp <- apply(tmp.A, 2, function(x) sum(x * state$p[1:2]))

rbind(tmp.A, r * tmp / state$p[3])


},
B = diag(3),
S0Exg = {
tmp <- matrix(NA, 3, 3)
tmp[2, 2] <- 100
tmp[3, 3] <- 100
tmp
}
)

ge$p / ge$p[3] * r

p <- ge$p
p[3] <- p[3] / r
42 Example7.4

p / p[3]

Example7.3 Example 7.3 in Li (2019)

Description
This is Example 7.3 in Li (2019),which illustrates a monetary Leontief corn economy.

Usage
Example7.3()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.4 Example 7.4 in Li (2019)

Description
This is Example 7.4 in Li (2019),which illustrates a monetary Cobb-Douglas positive-growth corn
economy.

Usage
Example7.4()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example7.5.1 43

Example7.5.1 First Part of Example 7.5 in Li (2019)

Description
This is the first part of Example 7.5 in Li (2019),which illustrates a monetary Cobb-Douglas corn
economy including dividend.

Usage
Example7.5.1()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.5.2 Second Part of Example 7.5 in Li (2019)

Description
This is the second part of Example 7.5 in Li (2019), which illustrates a monetary Cobb-Douglas
corn economy including dividend.

Usage
Example7.5.2()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019) General Equilibrium and Structural Dynamics: Perspectives of New Structural Eco-
nomics. Beijing: Economic Science Press. (In Chinese)
44 Example7.7

Example7.6 Example 7.6 in Li (2019)

Description

This is Example 7.6 in Li (2019), which illustrates foreign exchange rates.

Usage

Example7.6()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.7 Example 7.7 in Li (2019)

Description

This is Example 7.7 in Li (2019), which illustrates foreign exchange rates.

Usage

Example7.7()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example7.8 45

Example7.8 Example 7.8 in Li (2019)

Description

This is Example 7.8 in Li (2019), which illustrates commodity money.

Usage

Example7.8()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example7.9X Example 7.9 in Li (2019)

Description

This is Example 7.9 in Li (2019), which illustrates commodity money and representative money.

Usage

Example7.9X()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
46 Example8.2

Example8.1 Example 8.1 in Li (2019)

Description
This is Example 8.1 in Li (2019), which expounds the equilibrium coffee problem.

Usage
Example8.1()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Example8.2 Example 8.2 in Li (2019)

Description
This is Example 8.2 in Li (2019), which expounds a Cobb-Douglas market-clearing exchange pro-
cess.

Usage
Example8.2()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example8.7 47

Example8.7 Example 8.7 in Li (2019)

Description
This is Example 8.7 in Li (2019), which discusses price changes in the coffee economy.

Usage
Example8.7()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
ge <- Example8.7()
matplot(ge$ts.p, type = "l")
matplot(ge$ts.z, type = "l")

Example8.8 Example 8.8 in Li (2019)

Description
This is Example 8.8 in Li (2019), which illustrates a dynamic exchange model with one type of
money.

Usage
Example8.8()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
48 Example9.10

Examples
ge <- Example8.8()
matplot(ge$ts.p, type = "l")
matplot(ge$ts.z, type = "l")

Example8.9 Example 8.9 in Li (2019)

Description
This is Example 8.9 in Li (2019), which illustrates a dynamic exchange model with multiple types
of money.

Usage
Example8.9()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
ge <- Example8.9()
matplot(ge$ts.p, type = "l")
matplot(ge$ts.z, type = "l")

Example9.10 Example 9.10-9.14 in Li (2019)

Description
This is Example 9.10-14 in Li (2019), which illustrates economic cycles in a monetary economy
and economic policies ironing economic cycles.

Usage
Example9.10(
policy = NULL,
pExg = rbind(NA, NA, 0.25),
p0 = rbind(0.625, 0.375, 0.25),
priceAdjustmentVelocity = 0.3,
ts = TRUE
)
Example9.10 49

Arguments
Those arguments will be passed to the function sdm. See sdm.
a policy function
policy
pExg an n-vector indicating the exogenous prices (if any).
p0 an initial price n-vector.
priceAdjustmentVelocity
the price adjustment velocity.
ts if TRUE, the time series of the last iteration are returned.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

See Also
sdm; Example9.10.policy.interest.rate; Example9.10.policy.money.supply; Example9.10.policy.deflation;
Example9.10.policy.quantitative.easing; Example9.10.policy.tax; Example9.10.policy.deficit.fiscal

Examples

##### no policy
ge <- Example9.10()
matplot(ge$ts.p, type = "l")
matplot(ge$ts.z, type = "l")

##### interest rate policy (Fig. 9.12)


Example9.10(policy = Example9.10.policy.interest.rate)

##### monetary supply policy (Fig. 9.13)


Example9.10(policy = Example9.10.policy.money.supply)

##### deflation policy (Fig. 9.14)


ge <- Example9.10(
policy = Example9.10.policy.deflation,
pExg = rbind(NA, NA, 0),
p0 = rbind(0.625, 0.375, 0), ts = TRUE
)
plot(ge$ts.S[3, 3, ], type = "l")
plot(ge$ts.q[, 3], type = "l")

##### quantitative easing policy (Fig. 9.15)


ge <- Example9.10(
policy = Example9.10.policy.quantitative.easing,
pExg = rbind(NA, NA, 0),
50 Example9.10.policy.deficit.fiscal

p0 = rbind(0.625, 0.375, 0),


ts = TRUE
)
plot(log(ge$ts.S[3, 3, ]), type = "l")
plot(ge$ts.q[, 3], type = "l")
plot(log(ge$ts.p[, 1]), type = "l")
lines(log(ge$ts.p[, 2]), col = "blue")

##### deficit fiscal policy (Fig. 9.17; Fig. 9.18)


ge <- Example9.10(
policy = Example9.10.policy.deficit.fiscal,
priceAdjustmentVelocity = 0.5, ts = TRUE
)
plot(ge$ts.S[3, 3, ], type = "l")
plot(ge$ts.q[, 1], type = "l")

deficit.Example9.10 <- ge$policy.data


plot(deficit.Example9.10, type = "l")
plot(deficit.Example9.10[, 1], cumsum(deficit.Example9.10[, 2]), type = "l")
plot(deficit.Example9.10[, 1],
cumsum(deficit.Example9.10[, 2]) /
(tail(ge$ts.z[, 1] * ge$ts.p[, 1], -399)),
type = "l"
)

##### tax policy (Fig. 9.16)


ge <- Example9.10(policy = Example9.10.policy.tax)
plot(ge$policy.data, type = "l")

Example9.10.policy.deficit.fiscal
Deficit Fiscal Policy for Example 9.10 in Li (2019)

Description
This is the deficit fiscal policy for the economy of Example 9.10 in Li (2019), which is discussed in
Example 9.14.

Usage
Example9.10.policy.deficit.fiscal(time, state, state.history)

Arguments
time the current time.
state a list indicating the current economic state including prices, exchange levels (i.e.
activity levels, production levels or utility levels) and supplies.
state.history the history of economic states.
Example9.10.policy.deflation 51

Value
Example9.10.policy.deficit.fiscal returns a list indicating the modified current economic state in-
cluding prices, exchange levels (i.e. activity levels, production levels or utility levels), supplies and
current policy data.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

See Also
Example9.10; Example9.10.policy.interest.rate; Example9.10.policy.money.supply; Example9.10.policy.defl
Example9.10.policy.quantitative.easing; Example9.10.policy.tax

Example9.10.policy.deflation
Deflation Policy for Example9.10 in Li (2019)

Description
This is the deflation policy for the economy of Example 9.10 in Li (2019), which is discussed in
Example 9.12.

Usage
Example9.10.policy.deflation(time, state, state.history)

Arguments
time the current time.
state a list indicating the current economic state including prices, exchange levels (i.e.
activity levels, production levels or utility levels) and supplies.
state.history the history of economic states.

Value
Example9.10.policy.deflation returns a list indicating the modified current economic state including
prices, exchange levels (i.e. activity levels, production levels or utility levels) and supplies.

Author(s)
LI Wu <[email protected]>
52 Example9.10.policy.interest.rate

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

See Also
Example9.10; Example9.10.policy.interest.rate; Example9.10.policy.money.supply; Example9.10.policy.quan
Example9.10.policy.tax; Example9.10.policy.deficit.fiscal

Example9.10.policy.interest.rate
Interest Rate Policy for Example9.10 in Li (2019)

Description
This is the interest rate policy for the economy of Example 9.10 in Li (2019), which is discussed in
Example 9.11.

Usage
Example9.10.policy.interest.rate(time, state, state.history)

Arguments
time the current time.
state a list indicating the current economic state including prices, exchange levels (i.e.
activity levels, production levels or utility levels) and supplies.
state.history the history of economic states.

Value
Example9.10.policy.interest.rate returns a list indicating the modified current economic state in-
cluding prices, exchange levels (i.e. activity levels, production levels or utility levels) and supplies.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

See Also
Example9.10; Example9.10.policy.money.supply; Example9.10.policy.deflation; Example9.10.policy.quantit
Example9.10.policy.tax; Example9.10.policy.deficit.fiscal
Example9.10.policy.money.supply 53

Example9.10.policy.money.supply
Money Supply Policy for Example9.10 in Li (2019)

Description

This is the money supply policy for the economy of Example 9.10 in Li (2019), which is discussed
in Example 9.12.

Usage

Example9.10.policy.money.supply(time, state, state.history)

Arguments

time the current time.


state a list indicating the current economic state including prices, exchange levels (i.e.
activity levels, production levels or utility levels) and supplies.
state.history the history of economic states.

Value

Example9.10.policy.money.supply returns a list indicating the modified current economic state in-
cluding prices, exchange levels (i.e. activity levels, production levels or utility levels) and supplies.

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

See Also

Example9.10; Example9.10.policy.interest.rate; Example9.10.policy.deflation; Example9.10.policy.quantit


Example9.10.policy.tax; Example9.10.policy.deficit.fiscal
54 Example9.10.policy.quantitative.easing

Example9.10.policy.quantitative.easing
Quantitative Easing Policy for Example 9.10 in Li (2019)

Description

This is the deflation policy for the economy of Example 9.10 in Li (2019), which is discussed in
Example 9.12.

Usage

Example9.10.policy.quantitative.easing(time, state, state.history)

Arguments

time the current time.


state a list indicating the current economic state including prices, exchange levels (i.e.
activity levels, production levels or utility levels) and supplies.
state.history the history of economic states.

Value

Example9.10.policy.quantitative.easing returns a list indicating the modified current economic state


including prices, exchange levels (i.e. activity levels, production levels or utility levels) and sup-
plies.

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

See Also

Example9.10; Example9.10.policy.interest.rate; Example9.10.policy.money.supply; Example9.10.policy.defl


Example9.10.policy.tax; Example9.10.policy.deficit.fiscal
Example9.10.policy.tax 55

Example9.10.policy.tax
Tax Policy for Example9.10 in Li (2019)

Description

This is the tax policy for the economy of Example 9.10 in Li (2019), which is discussed in Example
9.13.

Usage

Example9.10.policy.tax(time, state, state.history)

Arguments

time the current time.


state a list indicating the current economic state including prices, exchange levels (i.e.
activity levels, production levels or utility levels) and supplies.
state.history the history of economic states.

Value

Example9.10.policy.tax returns a list indicating the modified current economic state including prices,
exchange levels (i.e. activity levels, production levels or utility levels), supplies and current policy
data.

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

See Also

Example9.10; Example9.10.policy.interest.rate; Example9.10.policy.money.supply; Example9.10.policy.defl


Example9.10.policy.quantitative.easing; Example9.10.policy.deficit.fiscal
56 Example9.4

Example9.3 Example 9.3 in Li (2019)

Description
This is Example 9.3 in Li (2019), which illustrates economic cycles in a pure production economy.

Usage
Example9.3()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
ge<-Example9.3()
matplot(ge$ts.p, type="l")
matplot(ge$ts.z, type="l")

Example9.4 Example 9.4 in Li (2019)

Description
This is Example 9.4 in Li (2019), which illustrates economic cycles in a corn economy.

Usage
Example9.4()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
Example9.5 57

Examples
ge<-Example9.4()
matplot(ge$ts.p, type="l")
matplot(ge$ts.z, type="l")

Example9.5 Example 9.5 in Li (2019)

Description
This is Example 9.5 in Li (2019), which illustrates the price-control equilibrium.

Usage
Example9.5()

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
ge<-Example9.5()
matplot(ge$ts.p, type="l")
matplot(ge$ts.z, type="l")

Example9.6 Example 9.6 in Li (2019)

Description
This is Example 9.6 in Li (2019), which illustrates the technological progress and capital accumu-
lation in the corn economy.

Usage
Example9.6()

Author(s)
LI Wu <[email protected]>
58 Example9.7

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples

ge<-Example9.6()
matplot(ge$ts.p, type="l")
matplot(ge$ts.z, type="l")

Example9.7 Example 9.7 in Li (2019)

Description

This is Example 9.7 in Li (2019), which illustrates fixed assets and economic cycles.

Usage

Example9.7()

Author(s)

LI Wu <[email protected]>

References

LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives


of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples

ge<-Example9.7()
matplot(ge$ts.p, type="l")
matplot(ge$ts.z, type="l")
F_Z 59

F_Z Exchange Function

Description
Given a price vector, a demand coefficient matrix and a supply matrix, this function computes the
(disequilibrium) exchange results of an exchange process. There are n commodities and m agents
in the exchange process.

Usage
F_Z(A, p, S)

Arguments
A a n-by-m demand coefficient matrix.
p a price n-vector.
S a n-by-m supply matrix.

Value
F_Z returns a list containing the following components:

z an exchange amount m-vector.


q a sales rate n-vector.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
A <- matrix(c(
0.05, 0.05, 0.1,
0.1, 0, 0.1,
0, 0.15, 0.05
), 3, 3, TRUE)
S <- diag(3)

# a market-clearing price vector


p <- c(0.6, 0.9, 1)
result <- F_Z(A, p, S)
# Each sales rate is equal to 1
60 iep

result$q
# the purchase matrix
A %*% diag(result$z)

# a non-market-clearing price vector


p <- c(1, 1, 1)
result <- F_Z(A, p, S)
# Some sales rates don't equal 1
result$q
# the purchase matrix
A %*% diag(result$z)

iep Compute Instantaneous Equilibrium Path (alias Market Clearing


Path)

Description
This function computes the instantaneous equilibrium path (alias market clearing path).

Usage
iep(A.iep = NULL, A = NULL, B.iep = NULL, B = NULL,
SExg.iep, InitialEndowments, nPeriods.iep, ...)

Arguments
A.iep A.iep(state.iep) is a function which returns a demand coefficient matrix or a
function A(state). state.iep is a list consisting of time (the iep time), p (the price
vector at the iep time), z (output and utility vector at the iep time).
A a demand coefficient matrix or a function A(state) which returns a demand co-
efficient matrix. If A.iep is not NULL, A will be ignored.
B.iep B.iep(state.iep) is a function which returns a supply coefficient matrix or a func-
tion B(state) at the iep time.
B a supply coefficient matrix or a function B(state) which returns a supply coeffi-
cient matrix. If B.iep is not NULL, B will be ignored.
SExg.iep an exogenous supply matrix or a function SExg.iep(state.iep) which returns an
exogenous supply matrix at the iep time.
InitialEndowments
a matrix indicating the initial endowments.
nPeriods.iep number of periods of the instantaneous equilibrium path.
... parameters of the function sdm.

Details
This function computes the instantaneous equilibrium path (alias market clearing path) of a dynamic
economy with the structural dynamic model (the sdm function).
iep 61

Value
a list of general equilibria.

Author(s)
LI Wu <[email protected]>

References
Acemoglu, D. (2009, ISBN: 9780691132921) Introduction to Modern Economic Growth. Princeton
University Press.
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
LI Wu (2010) A Structural Growth Model and its Applications to Sraffa’s System. http://www.iioa.org/conferences/18th/paper
Torres, Jose L. (2016, ISBN: 9781622730452). Introduction to Dynamic Macroeconomic General
Equilibrium Models (Second Edition). Vernon Press.

See Also
sdm; Example7.2

Examples

## example 6.4 of Acemoglu (2009, page 206)


discount.factor <- 0.97
return.rate <- 1 / discount.factor - 1

A <- function(state) {
a1 <- CD_A(
1, rbind(0.35, 0.65, 0),
c(state$p[1] * (1 + return.rate), state$p[2:3])
)
a2 <- c(1, 0, 0)
a1[3] <- state$p[1] * a1[1] * return.rate / state$p[3]
cbind(a1, a2)
}

B <- matrix(c(
1, 0,
0, 1,
0, 1
), 3, 2, TRUE)

SExg.iep <- {
tmp <- matrix(NA, 3, 2)
tmp[2, 2] <- tmp[3, 2] <- 1
tmp
}
62 iep

InitialEndowments <- {
tmp <- matrix(0, 3, 2)
tmp[1, 1] <- 0.01
tmp[2, 2] <- tmp[3, 2] <- 1
tmp
}

ge.list <- iep(


A = A, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = 50
)

z <- t(sapply(ge.list, function(x) x$z))


matplot(z, type = "l")

z[1:49, 1] * (1 - 0.97 * 0.35) # the same as z[-1,2] (i.e. consumption)

# stochastic (instantaneous) equilibrium path (SEP) in the economy above.


nPeriods.iep <- 150
set.seed(1)
alpha.SEP <- rep(1, 50)
for (t in 51:nPeriods.iep) {
alpha.SEP[t] <- exp(0.95 * log(alpha.SEP[t - 1]) +
rnorm(1, sd = 0.01))
}

A.iep <- function(state.iep) {


A <- function(state) {
a1 <- CD_A(
alpha.SEP[state.iep$time],
rbind(0.35, 0.65, 0),
c(state$p[1] * (1 + return.rate), state$p[2:3])
)
a2 <- c(1, 0, 0)
a1[3] <- state$p[1] * a1[1] * return.rate / state$p[3]
cbind(a1, a2)
}

return(A)
}

ge.list <- iep(


A.iep = A.iep, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = nPeriods.iep
)

z <- t(sapply(ge.list, function(x) x$z))


matplot(z, type = "l")

## an example with two firms


iep 63

sigma <- 0 # 0 implies Cobb-Douglas production functions


gamma1 <- 0.01
gamma2 <- 0.01
gamma3 <- 0.01
beta1 <- 0.35
beta2 <- 0.4

A.iep <- function(state.iep) {


A <- function(state) {
a1 <- CES_A(sigma, exp(gamma1 * (state.iep$time - 1)), rbind(beta1, 0, 1 - beta1), state$p)
a2 <- CES_A(sigma, exp(gamma2 * (state.iep$time - 1)), rbind(beta2, 0, 1 - beta2), state$p)
a3 <- c(0, 1, 0)
cbind(a1, a2, a3)
}

return(A)
}

B <- diag(3)

SExg.iep <- function(state.iep) {


tmp <- matrix(NA, 3, 3)
tmp[3, 3] <- exp(gamma3 * (state.iep$time - 1))
tmp
}

InitialEndowments <- {
tmp <- matrix(0, 3, 3)
tmp[1, 1] <- 0.01
tmp[2, 2] <- 0.02
tmp[3, 3] <- 1
tmp
}

ge.list <- iep(


A.iep = A.iep, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = 100, trace = FALSE
)

z <- t(sapply(ge.list, function(x) x$z)) # outputs and utility


matplot(z, type = "l")

diff(log(z)) # logarithmic growth rate

## an example with heterogeneous firms


A <- function(state) {
a1 <- CD_A(1, rbind(0.35, 0.65), state$p)
a2 <- CD_A(1.3, rbind(0.9, 0.1), state$p)
a3 <- c(1, 0)
cbind(a1, a2, a3)
}
64 iep

B <- matrix(c(
1, 1, 0,
0, 0, 1
), 2, 3, TRUE)

SExg.iep <- {
tmp <- matrix(NA, 2, 3)
tmp[2, 3] <- 1
tmp
}

InitialEndowments <- {
tmp <- matrix(0, 2, 3)
tmp[1, 1] <- tmp[1, 2] <- 0.01
tmp[2, 3] <- 1
tmp
}

ge.list <- iep(


A = A, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = 200, trace = FALSE
)

z <- t(sapply(ge.list, function(x) x$z))


matplot(z, type = "l")

## an iep of the example (see Table 2.1 and 2.2) of the canonical dynamic
## macroeconomic general equilibrium model in Torres (2016).
discount.factor <- 0.97
return.rate <- 1 / discount.factor - 1
depreciation.rate <- 0.06

A <- function(state) {
a1 <- CD_A(1, rbind(0, 0.65, 0.35, 0), state$p)
a2 <- CD_A(1, rbind(0.4, 1 - 0.4, 0, 0), state$p)
a3 <- c(1, 0, 0, state$p[1] * return.rate / state$p[4])
cbind(a1, a2, a3)
}

B <- matrix(c(
1, 0, 1 - depreciation.rate,
0, 1, 0,
0, 0, 1,
0, 1, 0
), 4, 3, TRUE)

SExg.iep <- {
tmp <- matrix(NA, 4, 3)
tmp[2, 2] <- tmp[4, 2] <- 1
tmp
}
iep 65

InitialEndowments <- {
tmp <- matrix(0, 4, 3)
tmp[1, 1] <- 0.01
tmp[2, 2] <- tmp[4, 2] <- 1
tmp[3, 3] <- 0.01
tmp
}

ge.list <- iep(


A = A, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = 200, trace = FALSE
)

z <- t(sapply(ge.list, function(x) x$z))


matplot(z, type = "l")

## another iep of the economy above


discount.factor <- 0.97
return.rate <- 1 / discount.factor - 1
depreciation.rate <- 0.06

A <- function(state) {
a1 <- CD_A(
1, rbind(0.35, 0.65, 0),
c(state$p[1] * (return.rate + depreciation.rate), state$p[2:3])
)
a2 <- CD_A(1, rbind(0.4, 1 - 0.4, 0), state$p)
a1[3] <- state$p[1] * a1[1] * return.rate / state$p[3]
cbind(a1, a2)
}

B <- function(state) {
tmp <- matrix(c(
1, 0,
0, 1,
0, 1
), 3, 2, TRUE)

tmp[1] <- tmp[1] + A(state)[1, 1] * (1 - depreciation.rate)


tmp
}

SExg.iep <- {
tmp <- matrix(NA, 3, 2)
tmp[2, 2] <- tmp[3, 2] <- 1
tmp
}

InitialEndowments <- {
tmp <- matrix(0, 3, 2)
tmp[1, 1] <- 0.01
tmp[2, 2] <- tmp[3, 2] <- 1
66 iep

tmp
}

ge.list <- iep(


A = A, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = 100, n = 3, m = 2, trace = FALSE
)

z <- t(sapply(ge.list, function(x) x$z))


matplot(z, type = "l")

## TFP shock in the economy above (see Torres, 2016, section 2.8).
nPeriods.iep <- 200

discount.factor <- 0.97


return.rate <- 1 / discount.factor - 1
depreciation.rate <- 0.06

set.seed(1)
alpha.shock <- rep(1, 100)
alpha.shock[101] <- exp(0.01)
for (t in 102:nPeriods.iep) {
alpha.shock[t] <- exp(0.95 * log(alpha.shock[t - 1]))
}

A.iep <- function(state.iep) {


A <- function(state) {
a1 <- CD_A(
alpha.shock[state.iep$time],
rbind(0.35, 0.65, 0),
c(state$p[1] * (return.rate + depreciation.rate), state$p[2:3])
)
a2 <- CD_A(1, rbind(0.4, 1 - 0.4, 0), state$p)
a1[3] <- state$p[1] * a1[1] * return.rate / state$p[3]
cbind(a1, a2)
}

return(A)
}

B.iep <- function(state.iep) {


B <- function(state) {
tmp <- matrix(c(
1, 0,
0, 1,
0, 1
), 3, 2, TRUE)

a1 <- CD_A(
alpha.shock[state.iep$time],
rbind(0.35, 0.65, 0),
c(state$p[1] * (return.rate + depreciation.rate), state$p[2:3])
iep 67

tmp[1] <- tmp[1] + a1[1] * (1 - depreciation.rate)


tmp
}

return(B)
}

SExg.iep <- {
tmp <- matrix(NA, 3, 2)
tmp[2, 2] <- tmp[3, 2] <- 1
tmp
}

InitialEndowments <- {
tmp <- matrix(0, 3, 2)
tmp[1, 1] <- tmp[2, 2] <- tmp[3, 2] <- 1
tmp
}

ge.list <- iep(


A.iep = A.iep, B.iep = B.iep, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = nPeriods.iep, n = 3, m = 2, trace = FALSE
)

z <- t(sapply(ge.list, function(x) x$z))


c <- sapply(ge.list, function(x) x$A[1,2]*x$z[2]) #consumption

par(mfrow = c(2, 2))


matplot(z, type = "l")
x <- 100:140
plot(x, z[x, 1] / z[x[1], 1], type = "b", pch = 20)
plot(x, z[x, 2] / z[x[1], 2], type = "b", pch = 20)
plot(x, c[x] / c[x[1]], type = "b", pch = 20)

## an iep of example 7.2 (a monetary economy) in Li (2019).


A <- function(state) {
alpha <- rbind(1, 1, 1)
Beta <- matrix(c(
0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-1, -1, -1
), 3, 3, TRUE)
CD_mA(alpha, Beta, state$p)
}

B <- diag(3)

SExg.iep <- {
tmp <- matrix(NA, 3, 3)
tmp[2, 2] <- 100
68 iep

tmp[3, 3] <- 100


tmp
}

InitialEndowments <- {
tmp <- matrix(0, 3, 3)
tmp[1, 1] <- 10
tmp[2, 2] <- tmp[3, 3] <- 100
tmp
}

ge.list <- iep(


A = A, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = 20,
moneyIndex = 3,
moneyOwnerIndex = 3,
pExg = rbind(NA, NA, 0.25)
)

par(mfrow = c(1, 2))


z <- t(sapply(ge.list, function(x) x$z))
matplot(z, type = "b", pch = 20)
p <- t(sapply(ge.list, function(x) x$p))
matplot(p, type = "b", pch = 20)

## an example of structural transition policy


A.iep <- function(state.iep) {
a <- 15
b <- 25
A <- function(state) {
alpha1 <- 5
alpha2 <- 15

if (state.iep$time == 1 || state.iep$z[1] <= a) {


alpha <- alpha1
} else if (state.iep$z[1] > b) {
alpha <- alpha2
} else {
alpha <- (b - state.iep$z[1]) / (b - a) * alpha1 +
(state.iep$z[1] - a) / (b - a) * alpha2
}

return(cbind(
CD_A(alpha, c(0.5, 0.5), state$p),
c(1, 0)
))
}

return(A)
}

B <- matrix(c(
Leontief_mA 69

1, 0,
0, 1
), 2, 2, TRUE)

SExg.iep <- function(state.iep) {


if (state.iep$time >= 15 && state.iep$z[1] < 30) {
result <- matrix(c(
NA, NA,
0.6, 0.4
), 2, 2, TRUE)
} else {
result <- matrix(c(
NA, NA,
0, 1
), 2, 2, TRUE)
}

return(result)
}

InitialEndowments <- {
tmp <- matrix(0, 2, 2)
tmp[1, 1] <- 1
tmp[2, 2] <- 1
tmp
}

ge.list <- iep(


A.iep = A.iep, B = B, SExg.iep = SExg.iep,
InitialEndowments = InitialEndowments,
nPeriods.iep = 30, trace = FALSE
)

z <- t(sapply(ge.list, function(x) x$z))


matplot(z, type = "b", pch = 20)

Leontief_mA Leontief Monetary Demand Coefficient Matrix

Description

This function computes a Leontief monetary demand coefficient matrix in a monetary economy.

Usage

Leontief_mA(A.pre, p)
70 PF_eig

Arguments
A.pre a numeric n-by-m matrix.
p a nonnegative numeric n-vector or n-by-1 matrix.

Details
Some elements of A corresponding to money equal -1.

Value
A n-by-m matrix is computed which indicates the (monetary) demand structure of agents (firms or
consumers) with Leontief production functions or utility functions under the price vector p.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)

Examples
A.pre <- matrix(c(
0.5, 1, 1,
0.1, 0, 0,
-1, -1, -1
), 3, 3, TRUE)
p <- c(1, 2, 0.1)
Leontief_mA(A.pre, p)

PF_eig P-F (i.e. Perron-Frobenius) Eigenvalue and Eigenvector

Description
This function computes the P-F (i.e. Perron-Frobenius) eigenvalue and eigenvector of an indecom-
posable nonnegative square matrix.

Usage
PF_eig(M)

Arguments
M an indecomposable nonnegative square matrix.
sdm 71

Value
PF_eig returns a list containing the following components:

val the P-F eigenvalue of M.


vec the normalized P-F eigenvector of M.

Author(s)
LI Wu <[email protected]>

References
Horn, R. A., Johnson, C. R. (2012, ISBN: 0521548233) Matrix Analysis. Cambridge University
Press.

Examples
M<-matrix(c(0.5,1,
1, 0),2,2,TRUE)
PF_eig(M)

sdm Structural Dynamic Model (alias Structural Growth Model)

Description
This function computes the general equilibrium and simulates the economic dynamics. The key
part of this function is an exchange function (see F_Z), which is expounded in Li (2010, 2019).

Usage
sdm(
A,
B = diag(nrow(A)),
n = nrow(B),
m = ncol(B),
S0Exg = matrix(NA, n, m),
p0 = matrix(1, nrow = n, ncol = 1),
z0 = matrix(100, nrow = m, ncol = 1),
GRExg = NA,
moneyOwnerIndex = NULL,
moneyIndex = NULL,
pExg = NULL,
tolCond = 1e-5,
maxIteration = 200,
numberOfPeriods = 300,
depreciationCoef = 0.8,
72 sdm

thresholdForPriceAdjustment = 0.99,
priceAdjustmentMethod = "variable",
priceAdjustmentVelocity = 0.15,
trace = TRUE,
ts = FALSE,
policy = NULL,
exchangeFunction = F_Z
)

Arguments
A a demand coefficient n-by-m matrix (alias demand structure matrix) or a func-
tion A(state) which returns an n-by-m matrix.
B a supply coefficient n-by-m matrix (alias supply structure matrix) or a function
which returns an n-by-m matrix. If (i,j)-th element of S0Exg is not NA, the value
of the (i,j)-th element of B will be useless and ignored.
n the number of commodities.
m the number of economic agents (or sectors).
S0Exg an initial exogenous supply n-by-m matrix. This matrix may contain NA, but
not zero.
p0 an initial price n-vector.
z0 an m-vector consisting of the initial exchange levels (i.e. activity levels, produc-
tion levels or utility levels).
GRExg an exogenous growth rate of the exogenous supplies in S0Exg. If GRExg is NA
and some commodities have exogenous supply, then GRExg will be set to 0.
moneyOwnerIndex
a vector consisting of the indices of agents supplying money.
moneyIndex a vector consisting of the commodity indices of all types of money.
pExg an n-vector indicating the exogenous prices (if any).
tolCond the tolerance condition.
maxIteration the maximum iteration count. If the main purpose of running this function is
to do simulation instead of calculating equilibrium, then maxIteration should be
set to 1.
numberOfPeriods
the period number in each iteration.
depreciationCoef
the depreciation coefficient (i.e. 1 minus the depreciation rate) of the unsold
products.
thresholdForPriceAdjustment
the threshold for the fixed percentage price adjustment method.
priceAdjustmentMethod
the price adjustment method. Normally it should be set to "variable". If it is set
to "fixed", a fixed percentage price adjustment method will be used.
priceAdjustmentVelocity
the price adjustment velocity.
sdm 73

trace if TRUE, information is printed during the running of sdm.


ts if TRUE, the time series of the last iteration are returned.
policy a policy function.
exchangeFunction
the exchange function.

Details
The parameters A may be a function A(state) wherein state is a list consisting of p (the price vector),
z (the output and utility vector), w (the wealth vector), t (the time) and e (the foreign exchange rate
vector if any). state indicates the states at time t.
The parameters B also may be a function B(state) wherein state is a list consisting of p (the price
vector), z (the output and utility vector) and t (the time).

Value
sdm returns a list containing the following components:
tolerance the tolerance of the results.
p equilibrium prices.
z equilibrium exchange levels (i.e. activity levels, output levels or utility levels).
S the equilibrium supply matrix at the initial period.
e equilibrium foreign exchange rates in a multi-money economy.
growthRate the endogenous equilibrium growth rate in a pure production economy.
A the equilibrium demand coefficient matrix.
B If B is a function, the equilibrium supply coefficient matrix is returned.
ts.p the time series of prices in the last iteration.
ts.z the time series of exchange levels (i.e. activity levels, production levels or utility
levels) in the last iteration.
ts.S the time series of supply matrix in the last iteration.
ts.q the time series of sales rates in the last iteration.
ts.e the time series of foreign exchange rates in the last iteration.
policy.data the policy data.

Author(s)
LI Wu <[email protected]>

References
LI Wu (2019, ISBN: 9787521804225) General Equilibrium and Structural Dynamics: Perspectives
of New Structural Economics. Beijing: Economic Science Press. (In Chinese)
LI Wu (2010) A Structural Growth Model and its Applications to Sraffa’s System. http://www.iioa.org/conferences/18th/paper
Torres, Jose L. (2016, ISBN: 9781622730452) Introduction to Dynamic Macroeconomic General
Equilibrium Models (Second Edition). Vernon Press.
Varian, Hal R. (1992, ISBN: 0393957357) Microeconomic Analysis. W. W. Norton & Company.
74 sdm

See Also
iep; Example2.2; Example2.3; Example.Section.3.1.2.corn; Example3.1; Example3.2; Example3.4;
Example3.8; Example3.9; Example3.10; Example3.12; Example3.14; Example4.2; Example4.8;
Example4.9; Example4.10; Example4.11.1; Example4.11.2; Example4.12; Example4.13; Example4.15;
Example4.16; Example5.1; Example5.2; Example5.3.2; Example5.4; Example5.5; Example5.6;
Example5.10; Example5.11.1; Example5.11.2; Example6.2.1; Example6.2.2; Example6.3;
Example6.4; Example6.5; Example6.6.1; Example6.6.2; Example6.6.3; Example6.7; Example6.9;
Example6.10; Example6.11; Example7.1; Example7.2; Example7.3; Example7.4; Example7.5.1;
Example7.5.2; Example7.6; Example7.7; Example7.8; Example7.9X; Example7.10; Example7.10.2;
Example7.11; Example7.12; Example7.13; Example7.14; Example7.15; Example8.1; Example8.2;
Example8.7; Example8.8; Example8.9; Example9.3; Example9.4; Example9.5; Example9.6;
Example9.7; Example9.10;

Examples
## the example on page 352 in Varian (1992)
ge <- sdm(
A = function(state) {
a <- 0.5

alpha <- rep(1, 3)


Beta <- matrix(c(0, a, a,
0.5, 0, 0,
0.5, 1 - a, 1 - a), 3, 3, TRUE)

#the demand coefficient matrix.


CD_A(alpha, Beta, state$p)
},
B = diag(3),
S0Exg = matrix(c(NA, NA, NA,
NA, 1, NA,
NA, NA, 1), 3, 3, TRUE),
GRExg = 0,
tolCond = 1e-10
)

ge$p/ge$p[1]

## the example (see Table 2.1 and 2.2) of the canonical dynamic
## macroeconomic general equilibrium model in Torres (2016).
discount.factor <- 0.97
return.rate <- 1 / discount.factor - 1
depreciation.rate <- 0.06

ge <- sdm(
n = 4, m = 3,
A = function(state) {
a1 <- CD_A(1, rbind(0, 0.65, 0.35, 0), state$p)
a2 <- CD_A(1, rbind(0.4, 1 - 0.4, 0, 0), state$p)
a3 <- c(1, 0, 0, state$p[1] * return.rate / state$p[4])
sdm 75

cbind(a1, a2, a3)


},
B = matrix(c(
1, 0, 1 - depreciation.rate,
0, 1, 0,
0, 0, 1,
0, 1, 0
), 4, 3, TRUE),
S0Exg = {
tmp <- matrix(NA, 4, 3)
tmp[2, 2] <- 1
tmp[4, 2] <- 1
tmp
},
priceAdjustmentVelocity = 0.03,
maxIteration = 1,
numberOfPeriods = 5000,
ts = TRUE
)

ge$A %*% diag(ge$z) # the demand matrix


ge$p / ge$p[1]

plot(ge$ts.z[, 1], type = "l")


Index

CD_A, 3 Example5.2, 27, 74


CD_mA, 4 Example5.3.1, 28
CES_A, 5 Example5.3.2, 28, 74
CES_mA, 7 Example5.4, 29, 74
CES_mA (CES_mA), 7 Example5.5, 29, 74
ChinaCGE2012, 8 Example5.6, 30, 74
Example6.10, 30, 74
dg, 9 Example6.11, 31, 74
Example6.13, 31
Example.MWG.15.B.1, 10 Example6.2.1, 32, 74
Example.MWG.15.B.2, 11
Example6.2.2, 32, 74
Example.MWG.Exercise.15.B.6, 12
Example6.3, 33, 74
Example.MWG.Exercise.15.B.9, 13
Example6.4, 33, 74
Example.Section.3.1.2.corn, 14, 74
Example6.5, 34, 74
Example.Varian.Exercise.18.2, 14
Example6.6.1, 34, 74
Example.Varian.P352, 15
Example6.6.2, 35, 74
Example2.2, 15, 74
Example6.6.3, 35, 74
Example2.3, 16, 74
Example6.7, 36, 74
Example3.1, 16, 74
Example3.10, 17, 74 Example6.9, 36, 74
Example3.12, 17, 74 Example7.1, 37, 74
Example3.14, 18, 74 Example7.10, 37, 74
Example3.2, 18, 74 Example7.10.2, 38, 74
Example3.4, 19, 74 Example7.11, 38, 74
Example3.8, 19, 74 Example7.12, 39, 74
Example3.9, 20, 74 Example7.13, 39, 74
Example4.10, 20, 74 Example7.14, 40, 74
Example4.11.1, 21, 74 Example7.15, 40, 74
Example4.11.2, 21, 74 Example7.2, 41, 61, 74
Example4.12, 22, 74 Example7.3, 42, 74
Example4.13, 22, 74 Example7.4, 42, 74
Example4.15, 23, 74 Example7.5.1, 43, 74
Example4.16, 23, 74 Example7.5.2, 43, 74
Example4.2, 24, 74 Example7.6, 44, 74
Example4.8, 24, 74 Example7.7, 44, 74
Example4.9, 25, 74 Example7.8, 45, 74
Example5.1, 25, 74 Example7.9X, 45, 74
Example5.10, 26, 74 Example8.1, 46, 74
Example5.11.1, 26, 74 Example8.2, 46, 74
Example5.11.2, 27, 74 Example8.7, 47, 74

76
INDEX 77

Example8.8, 47, 74
Example8.9, 48, 74
Example9.10, 48, 51–55, 74
Example9.10.policy.deficit.fiscal, 49,
50, 52–55
Example9.10.policy.deflation, 49, 51, 51,
52–55
Example9.10.policy.interest.rate, 49,
51, 52, 52, 53–55
Example9.10.policy.money.supply, 49, 51,
52, 53, 54, 55
Example9.10.policy.quantitative.easing,
49, 51–53, 54, 55
Example9.10.policy.tax, 49, 51–54, 55
Example9.3, 56, 74
Example9.4, 56, 74
Example9.5, 57, 74
Example9.6, 57, 74
Example9.7, 58, 74

F_Z, 59, 71

iep, 60, 74

Leontief_mA, 69
Leontief_mA (Leontief_mA), 69

PF_eig, 70

sdm, 49, 61, 71

You might also like