Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/feedback.loop.R

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.

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

`io` |
An object of class |

`agg.sectors` |
An option to aggregate the sectors to compare regions only. Default is |

`agg.regions` |
An option to aggregate the regions to compare sectors only. Default is |

`n.loops` |
The number of loops you wish to calculate. The default is |

`fl` |
An object of class |

`loop` |
The loop from which you want the selector matrix. |

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.

Produces a nested list: `fl`

`fl` |
Contains |

`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 |

John J. P. Wade, Xiuli Liu

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.

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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.