make.merge | R Documentation |
Make an aggregation matrix to perform mergers of firms. The matrix can be post multiplied (matrix multiplication) to input and output matrices to make merged input and output matrices.
make.merge(grp, nFirm = NULL, X = NULL, names = NULL)
grp |
Either a list of length Kg for Kg firms after mergers; each component of the list is a (named) list with the firm numbers or names going into this merger. Or a factor of length K with Kg levels where each level determines a merger; to exclude firms for mergers set the factor value to NA. |
nFirm |
Number of firms before the mergers |
X |
A matrix of inputs or outputs where the rows corresponds to the number of original (starting) firms |
names |
A list with names of all firms, only needed if the
mergers are given as a list of names, i.e. |
Either nFirm
or X
must be present; if both are present
then nFirm
must be equal to the number of rows in X
, the
number of firms.
When X
is an input matrix of dimension K x m
, K
firms and m
inputs, and M <- make.merge(gr,K)
then
M %*% X
is the input matrix for the merged firms.
Returns an aggregation matrix of dimension Kg times K where rows corresponds to new merged firms and columns are 1 for firms to be included and 0 for firms to be excluded in the given merger as defined by the row.
The argument TRANSPOSE
has not been implemented for this
function. If you need transposed matrices you must transpose the
merger matrix yourself. If you define mergers via factors there is no
need to transpose in the arguments; just do not use X
in the
arguments.
Peter Bogetoft and Lars Otto larsot23@gmail.com
dea.merge
# To merge firms 1,3, and 5; and 2 and 4 of 7 firms into 2 new firms
# the aggregation matrix is M; not all firms are involved in a merger.
M <- make.merge(list(c(1,3,5), c(2,4)),7)
print(M)
# Merge 1 and 2, and 4 and 5, and leave 3 alone, total of 5 firms.
# Using a list
M1 <- make.merge(list(c(1,2), c(4,5)), nFirm=5)
print(M1)
# Using a factor
fgr <- factor(c("en","en",NA,"to","to"))
M2 <- make.merge(fgr)
print(M2)
# Name of mergers
M3 <- make.merge(list(AB=c("A","B"), DE=c("D","E")), names=LETTERS[1:5])
print(M3)
# No name of mergers
M4 <- make.merge(list(c("A","B"), c("D","E")), names=LETTERS[1:5])
print(M4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.