# feedback.loop: Feedback Loop Analysis In ioanalysis: Input Output Analysis

## Description

Calculates the complete hierarchical feedback loop as described in Sonis et al. (1995). A feed back loop is complete if it contains all region-sector pairs. Much like a sudoku puzzle, there may only be one identified cell in each row and one identified cell in each column per loop. The loops are hierarchical in the sense that first loop maximizes the intermediate transactions given the aforementioned constraints.

There are TWO functions for RAM concerns. A singular function storing all feedback loop matrices grows at rate n^3. Alternatively, constructing feedback loop matrices one at a time translates to the output of `feedback.loop` growth rate of roughly 2n^2.

Note: A feedback loop solves the Linear Programming Assignment problem.

Warning: Computation time depends on size of the system. A progress bar is printed.

## Usage

 ```1 2``` ```feedback.loop(io, agg.sectors, agg.regions, n.loops) feedback.loop.matrix(fl, loop) ```

## Arguments

 `io` An object of class `InputOutput` calculated from `as.inputoutput` `agg.sectors` An option to aggregate the sectors to compare regions only. Default is `FALSE`. `agg.regions` An option to aggregate the regions to compare sectors only. Default is `FALSE`. `n.loops` The number of loops you wish to calculate. The default is `"all"`. Must either be an integer or `"all"` `fl` An object of class `FeedbackLoop` created from `feedback.loop` `loop` The loop from which you want the selector matrix.

## Details

The feedback loop solves the following optimization problem:

max_S vec(Z)'vec(S)

such that:

i) A_{col}vec(S) = vec(1)

ii) A_{row}vec(S) = vec(1)

iii) vec(0) ≤ vec(S) ≤ vec(1)

where Z is the intermediate transaction matrix from `io`, S is a selctor matrix of the cells in Z, A_{col} is a constraint matrix to ensure only one cell per column is selected, A_{row} is a constraint matrix to ensure only one cell per row is selected, and constraint iii) ensures the values in the selector matrix are either one or zero.

After each loop, the selected cells are set to an extremely negative number to prevent selection in the next loop.

See the documentation on http://www.real.illinois.edu/ for more details and interpretation of the loops.

## Value

Produces a nested list: `fl`

 `fl` Contains `"value"`, `"loop_1"`, `"loop_2"`, ..., and `"loop_n"` `value` Contains a vector of the total value of intermediate transactions for each loop. `loop_i` Contains a list over each loop's subloops. Retrieve by calling `fl\$loop_i\$subloop_j`. Note each loop will likely have a different number of subloops.

## Author(s)

John J. P. Wade, Xiuli Liu

## References

Sonis, M., Hewings, G. J., & Gazel, R (1995). The structure of multi-regional trade flows: hierarchy, feedbacks and spatial linkages. The Annals of Regional Science, 29(4) 409-430.

## See Also

`as.inputoutput`

## 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 30``` ```########################## # The base feedback loop # ########################## data(toy.IO) class(toy.IO) fbl = feedback.loop(toy.IO) fbl\$loop_1 fl_3 = feedback.loop.matrix(fbl, 3) heatmap.io(fl_3, RS_label = toy.IO\$RS_label) fbl\$value fbl\$per = fbl\$value / sum(fbl\$value) * 100 obj = data.frame(x = 1:length(fbl\$per), y = fbl\$per) ggplot(obj, aes(x = x, y = y)) + geom_line() + geom_point() + labs(x = 'Loop', y = 'Percent', title = 'Proportion of Total Intermediate Transactions per Loop') ############################### # An aggregated feedback loop # ############################### fbl_agg = feedback.loop(toy.IO, agg.regions = TRUE) io_agg = agg.region(toy.IO, regions = 'all', newname = 'magic') fl_agg_1 = feedback.loop.matrix(fbl_agg, loop = 1) heatmap.io(fl_agg_1, RS_label = io_agg\$RS_label) ```

ioanalysis documentation built on Jan. 13, 2021, 5:16 p.m.