get_var_names_by_index: Variables corresponding to given indices

Description Usage Arguments Details Value Examples

View source: R/class_model_var.R

Description

The get_var_names_by_index function allows to retrieve the names of variables with given indices.

Usage

1
get_var_names_by_index(model, index_names)

Arguments

model

an object of gecon_model class.

index_names

a character vector of indices.

Details

Cf. gEcon users' guide, chapter ‘Templates’.

Value

The function returns a character vector of relevant variables' names.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# copy the example to the current working directory
file.copy(from = file.path(system.file("examples", package = "gEcon"),
          "pure_exchange.gcn"), to = getwd())

# make and load the model
pure_exchange_t <- make_model("pure_exchange.gcn")

# model calibration
pure_exchange_t <- set_free_par(pure_exchange_t,
                                free_par = c("alpha__A__1" = 0.3, "alpha__A__2" = 0.4,
                                             "alpha__A__3" = 0.3, "alpha__B__1" = 0.3,
                                             "alpha__B__2" = 0.4, "alpha__B__3" = 0.3,
                                             "e_calibr__A__1" = 3, "e_calibr__B__1" = 1,
                                             "e_calibr__A__2" = 2, "e_calibr__B__2" = 1,
                                             "e_calibr__A__3" = 1, "e_calibr__B__3" = 3))

# find the equilibrium
pure_exchange_t <- steady_state(pure_exchange_t)

# get all variables' names associated with agent A
var_names_A <- get_var_names_by_index(pure_exchange_t, index_names = "A")


# get all variables' names associated with agent B
var_names_B <- get_var_names_by_index(pure_exchange_t, index_names = "B")

# compare equilibrium allocations
get_ss_values(pure_exchange_t, var_names_A)
get_ss_values(pure_exchange_t, var_names_B)

gEcon documentation built on May 2, 2019, 6:52 p.m.