weighted.avg: Compute a weighted average of regions or industries from...

Description Usage Arguments Author(s) See Also Examples

View source: R/weighted.avg.r

Description

This function computes a weighted average of regions or industries from (incidence) regions - industries matrices.

Usage

1
weighted.avg(mat, vec, reg = T)

Arguments

mat

An incidence matrix with regions in rows and industries in columns

vec

A vector that will be used to compute the weighted average for each industry/region

reg

Logical; Shall the weighted average for regions be returned? Default to TRUE (requires a vector of industry value) but can be set to FALSE (requires a vector of region value) if the weighted average for industries should be returned

Author(s)

Pierre-Alexandre Balland p.balland@uu.nl

See Also

location.quotient

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## generate a region - industry matrix
set.seed(31)
mat <- matrix(sample(0:100,20,replace=T), ncol = 4)
rownames(mat) <- c ("R1", "R2", "R3", "R4", "R5")
colnames(mat) <- c ("I1", "I2", "I3", "I4")

## a vector for regions will be used to computed the weighted average of industries
vec <- c (5, 10, 15, 25, 50)
## run the function
weighted.avg (mat, vec, reg = F)

## a vector for industries will be used to computed the weighted average of regions
vec <- c (5, 10, 15, 25)
## run the function
weighted.avg (mat, vec, reg = T)

PABalland/EconGeo documentation built on Nov. 13, 2020, 2:50 a.m.