The sfcr_expand() function is a s3 generic that takes
a list of external objects and returns a expanded set of these lists.
It has methods for sfcr_set objects and for sfcr_shock objects.
sfcr_expand(x, variable, values)
| x | A external set created with |
|---|---|
| variable | the name of variable to be expanded. |
| values | a vector containing the new values of the external or shock variable. |
There are two available methods for the sfcr_expand() function:
sfcr_set:
Takes a sfcr_set object with external variables and creates
a list of sets that inherits all the aspects of the x set supplied
but set the values of the variable to the each element of value.
The output is a sfcr_mlt_set object.
sfcr_shock:
Takes a sfcr_shock object and creates a list of shocks that inherits
all the aspects of the x shock but set the values of the
variable to each element of value. The output of this
method is a sfcr_mlt_shock object.
João Macalós
# 1. Expand a external set: external <- sfcr_set(G_d ~ 20, W ~ 1, alpha1 ~ 0.6, alpha2 ~ 0.4, theta ~ 0.2) sfcr_expand(external, alpha2, c(0.1, 0.2))#> [[1]] #> [[1]][[1]] #> G_d ~ 20 #> <environment: 0xe0b7410> #> #> [[1]][[2]] #> W ~ 1 #> <environment: 0xe0b7410> #> #> [[1]][[3]] #> alpha1 ~ 0.6 #> <environment: 0xe0b7410> #> #> [[1]][[4]] #> theta ~ 0.2 #> <environment: 0xe0b7410> #> #> [[1]][[5]] #> alpha2 ~ 0.1 #> <environment: 0xe2facc8> #> #> #> [[2]] #> [[2]][[1]] #> G_d ~ 20 #> <environment: 0xe0b7410> #> #> [[2]][[2]] #> W ~ 1 #> <environment: 0xe0b7410> #> #> [[2]][[3]] #> alpha1 ~ 0.6 #> <environment: 0xe0b7410> #> #> [[2]][[4]] #> theta ~ 0.2 #> <environment: 0xe0b7410> #> #> [[2]][[5]] #> alpha2 ~ 0.2 #> <environment: 0xe300a60> #> #> #> attr(,"class") #> [1] "sfcr_mlt_set" "list" #> attr(,"original") #> [[1]] #> G_d ~ 20 #> <environment: 0xe0b7410> #> #> [[2]] #> W ~ 1 #> <environment: 0xe0b7410> #> #> [[3]] #> alpha1 ~ 0.6 #> <environment: 0xe0b7410> #> #> [[4]] #> alpha2 ~ 0.4 #> <environment: 0xe0b7410> #> #> [[5]] #> theta ~ 0.2 #> <environment: 0xe0b7410> #> #> attr(,"class") #> [1] "sfcr_set" "list"# 2. Expand a shock: shock <- sfcr_shock(variables = sfcr_set(alpha1 ~ 0.8), start = 5, end = 50) sfcr_expand(shock, alpha1, c(0.7, 0.8, 0.9))#> [[1]] #> $variables #> $variables[[1]] #> alpha1 ~ 0.7 #> <environment: 0xe618050> #> #> #> $start #> [1] 5 #> #> $end #> [1] 50 #> #> attr(,"class") #> [1] "sfcr_shock" "list" #> #> [[2]] #> $variables #> $variables[[1]] #> alpha1 ~ 0.8 #> <environment: 0xe61a9f0> #> #> #> $start #> [1] 5 #> #> $end #> [1] 50 #> #> attr(,"class") #> [1] "sfcr_shock" "list" #> #> [[3]] #> $variables #> $variables[[1]] #> alpha1 ~ 0.9 #> <environment: 0xe619560> #> #> #> $start #> [1] 5 #> #> $end #> [1] 50 #> #> attr(,"class") #> [1] "sfcr_shock" "list" #> #> attr(,"class") #> [1] "sfcr_mlt_shock" "list" #> attr(,"original") #> $variables #> list() #> #> $start #> [1] 5 #> #> $end #> [1] 50 #> #> attr(,"class") #> [1] "sfcr_shock" "list"