Package 'PolicyPortfolios'

Title: Tools for Managing, Measuring and Visualizing Policy Portfolios
Description: Tools for simplifying the creation and management of data structures suitable for dealing with policy portfolios, that is, two-dimensional spaces of policy instruments and policy targets. The package also allows to generate measures of portfolio characteristics and facilitates their visualization.
Authors: Xavier Fernández i Marín [aut, cre]
Maintainer: Xavier Fernández i Marín <[email protected]>
License: GPL-3
Version: 0.4
Built: 2025-01-25 03:34:36 UTC
Source: https://github.com/xfim/policyportfolios

Help Index


Calculate burden based on how different learning assumptions affect portfolio size

Description

Internal function to calculate a transformation of portfolio size based on a non-regular assumption of how policy learning works at the instrument level. This generates a weighted portfolio size that can be understood as the "burden" of its size.

Usage

burden(M, nI, nT, learning, weight_by = "instrument")

Arguments

M

Matrix with the policy portfolio, where the first dimension contains instruments and the second contains targets.

nI

Integer with the number of Instruments.

nT

Integer with the number of Targets.

learning

The assumption of the decay of learning. It is either "continuous" (arithmetical decay), "steep" (geometrical decay) or "capped" (sudden decay and constant hereafter).

weight_by

By default learning assumptions are done on different instrument levels ("instrument"). But it is also possible to use Target levels when using "target".

Details

- Arithmetical: assumes a continuous learning. - Geometrical: assumes steep learning. - Radical: assumes capped learning.

This contrasts with the regular portfolio size that assumes no learning is produced between policy instruments.

Value

A value of burden (portfolio size using a different learning assumption).


Calculate a configuration of instruments

Description

Internal function used to assess the number of configurations of instruments. Configurations are specific combinations of instruments thay may appear in different targets.

Usage

configurations(M)

Arguments

M

Matrix with the policy portfolio, where the first dimension contains instruments and the second contains targets.

Value

Vector with the distribution of configurations


Policy portfolios for the dataset of the CONSENSUS research project.

Description

A tidy dataset of a policy portfolios in social and environmental policies for the CONSENSUS research project.

Usage

data(consensus)

Format

A data frame (tibble) containing the coverage of state intervention in a specific policy space (presence = 1 or absence = 0) for the CONSENSUS research project (). It covers 23 countries in two sectors (Environmental, with 49 Targets and 11 Instruments; and Social, with X Targets and X Instruments) between 1976 and 2005.

Details

When using the dataset, please cite:

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Knill, C., Schulze, K. & Tosun, J. (2012). Regulatory Policy Outputs and Impacts. Exploring a Complex Relationship. _Regulation & Governance_, 5(4), 427-444. doi:10.1111/j.1748-5991.2012.01150.x.

Source

Consensus research project (217239): https://cordis.europa.eu/project/id/217239

References

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Knill, C., Schulze, K. & Tosun, J. (2012). Regulatory Policy Outputs and Impacts. Exploring a Complex Relationship. _Regulation & Governance_, 5(4), 427-444. doi:10.1111/j.1748-5991.2012.01150.x.

See Also

consensus.instruments and consensus.targets for meta data about Instrument id and types, and Target id and Subsector.

Examples

data(consensus)
str(consensus)

Meta-data on Instruments for the dataset of the CONSENSUS research project.

Description

A tidy dataset of the characteristics of Instruments in social and environmental policies for the CONSENSUS research project.

Usage

data(consensus.instruments)

Format

A data frame (tibble) containing the characteristics of Instruments, namely the Sector, the type of Instrument and the internal id in the original coding manual.

Details

When using the dataset, please cite:

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Knill, C., Schulze, K. & Tosun, J. (2012). Regulatory Policy Outputs and Impacts. Exploring a Complex Relationship. _Regulation & Governance_, 5(4), 427-444. doi:10.1111/j.1748-5991.2012.01150.x.

Source

Consensus research project (217239): https://cordis.europa.eu/project/id/217239

References

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Knill, C., Schulze, K. & Tosun, J. (2012). Regulatory Policy Outputs and Impacts. Exploring a Complex Relationship. _Regulation & Governance_, 5(4), 427-444. doi:10.1111/j.1748-5991.2012.01150.x.

See Also

consensus for the full dataset and consensus.targets for meta data about Target id and Subsector.

Examples

data(consensus.instruments)
str(consensus.instruments)

Meta-data on Targets for the dataset of the CONSENSUS research project.

Description

A tidy dataset of the characteristics of Targets in social and environmental policies for the CONSENSUS research project.

Usage

data(consensus.targets)

Format

A data frame (tibble) containing the characteristics of Targets, namely the Subsector and the internal id in the original coding manual.

Details

When using the dataset, please cite:

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Knill, C., Schulze, K. & Tosun, J. (2012). Regulatory Policy Outputs and Impacts. Exploring a Complex Relationship. _Regulation & Governance_, 5(4), 427-444. doi:10.1111/j.1748-5991.2012.01150.x.

Source

Consensus research project (217239): https://cordis.europa.eu/project/id/217239

References

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Knill, C., Schulze, K. & Tosun, J. (2012). Regulatory Policy Outputs and Impacts. Exploring a Complex Relationship. _Regulation & Governance_, 5(4), 427-444. doi:10.1111/j.1748-5991.2012.01150.x.

See Also

consensus for the full dataset and consensus.instruments for meta data about Instrument id and instrument type.

Examples

data(consensus.targets)
str(consensus.targets)

Calculate portfolio diversity (Average Instrument Diversity)

Description

Function used to calculate the diversity of a portfolio (Average Instrument Diversity, AID). It is adapted from the idea of a Gini-Simpson diversity index. The measure can be interpreted as the average probability that picking two policy spaces from different Targets, they use a different Instrument.

Usage

diversity_aid(M)

Arguments

M

Matrix with two dimensions (Instrument, Target) containing absence (0) or presence (1) of policy intervention.

Value

A value of the portfolio diversity.

Details

t=1..T,i=1..Ic=1Cct,i=c!t,!iC\forall_{t=1..T}, \forall_{i=1..I} \sum_{c=1}^{C} \frac{c_{t,i} = c_{!t,!i}}{C}

where:

T are the targets covered by at least one policy instrument I are the instruments addressing at least one policy target C are the entirety of target-instrument-constellations

It is applied only to matrices, not to tidy objects in a proper policy portfolio. For a proper treatment using tidy data, use it through pp_measures().

References

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Examples

data(consensus)
consensus %>%
  filter(Sector == "Environmental") %>%
  filter(Country %in% c("France", "United States")) %>%
  filter(Year %in% c(1976, 2005)) %>%
  pp_array() %>%
  apply(., c(1, 2, 3), diversity_aid) %>%
  as.vector() %>%
  round(digits = 3)
# 1976 (FR, US), 2005 (FR, US)

Simulated policy portfolio with fake data for the education sector.

Description

A tidy dataset of a policy portfolio in an imaginary sector (education), containing 3 countries, 10 Instruments and 15 Targets, for 11 years.

Usage

data(P.education)

Format

A data frame (tibble) containing the coverage of state intervention in a specific policy space (presence = 1 or absence = 0).

Examples

data(P.education)
str(P.education)

Simulated policy portfolio with fake data for the energy sector.

Description

A tidy dataset of a policy portfolio in an imaginary sector (energy), containing 3 countries, 15 Instruments and 25 Targets, for 11 years.

Usage

data(P.energy)

Format

A data frame (tibble) containing the coverage of state intervention in a specific policy space (presence = 1 or absence = 0).

Examples

data(P.energy)
str(P.energy)

Subset a full dataset with only certain cases (Country / Year)

Description

Internal function used to select a subset of cases (Country / Sector / Year) from a tidy dataset with portfolio data. When subsetting a sector, the remaining object limits the results to the available Instruments and Sectors found in the original object.

Usage

pass.id(D, id = NULL)

Arguments

D

Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors.

id

A list with up to three elements, namely "Country", "Sector" and "Year" indicating the specific identification characteristics of the portfolio(s) that must be processed; and optionally "clean" (logical, FALSE by default) to remove non observed factor levels in Instruments, Targets, Country, Sector and Year.

Value

A Data frame (tibble) with a part of the original input, defined by id.


Tools for managing, measuring and visualizing policy portfolios

Description

Tools for simplifying the creation and management of data structures suitable for dealing with policy portfolios, that is, two-dimensional spaces of of policy instruments and policy targets. It allows to generate measures of portfolio characteristics and facilitates their visualization.

References

http://xavier-fim.net/packages/PolicyPortfolios/.

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first.

Knill, C., Schulze, K. & Tosun, J. (2012). Regulatory Policy Outputs and Impacts. Exploring a Complex Relationship. _Regulation & Governance_, 5(4), 427-444. doi:10.1111/j.1748-5991.2012.01150.x.


Convert a tidy dataset into a matrix of policy portfolios

Description

Take a tidy dataset containing one or several policy portfolios and convert it into a matrix or an array.

Usage

pp_array(D, return_matrix = FALSE)

Arguments

D

Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors.

return_matrix

Logical value indicating whether the output must be in the form of an array with Country, Sector and Year dimensions present (although equal to one), or a simplified matrix of Instruments and Targets. Defaults to FALSE.

Value

An array when return_single is FALSE (the default), or a two-dimensional matrix with Instruments and Targets as first and second dimensions, respectively.

Examples

data(P.education)
# Returns an array
A <- pp_array(P.education)
dim(A)

# Returns a matrix
M <- pp_array(subset(P.education, Country == "Syldavia" & Year == 2022),
  return_matrix = TRUE)
dim(M)

Tidy a dataset with a "long" policy portfolio structure

Description

Clean a policy portfolio dataset into a tidy object.

Usage

pp_clean(
  d,
  Sector = NULL,
  Country.name = "Country",
  Year.name = "Year",
  Instrument.name = "Instrument",
  Target.name = "Target",
  coding.category.name = "Coding category",
  coding.category = 2,
  Direction.name = "Direction",
  directions = c(0, 1, -1),
  associated.vars = NULL,
  date = FALSE,
  setting.direction = FALSE,
  debug = FALSE
)

Arguments

d

Data frame in an uncleaned and untidy structure containing data from a policy portfolio.

Sector

Character vector with the Sector of the dataset.

Country.name

Character vector of length one with the name of the variable that contains the country name.

Year.name

Character vector of length one with the name of the variable that contains the year.

Instrument.name

Character vector of length one with the name of the variable that contains the instruments.

Target.name

Character vector of length one with the name of the variable that contains the targets.

coding.category.name

Character vector of length one with the name of the variable that contains the coding category.

coding.category

Numerical value with the level of the category that captures the combination of instrument and target.

Direction.name

Character vector of length one with the name of the variable that contains the direction of the policy change.

directions

Numerical vector with the numeric values of the direction of the policy changes, namely "Status quo", "Expansion" and "Dismantling". Defaults to, 0, 1 and -1, respectively.

associated.vars

Character vector indicating variables that contain characteristics of the policy space.

date

By default, return Year as the only time indicator. If TRUE, return the full date with dd-mm-YYYY.

setting.direction

Logical. When TRUE, returns not a tidy object with the portfolio, but a summary of changes in the Setting (Level/Scope) and in the Direction (Expansion/Dismantling). Defaults to FALSE.

debug

Logical value. When TRUE, print more verbose information about the cleaning process.

Value

D Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors. When setting.direction = TRUE it returns a summary of changes in the Setting (Level/Scope) and in the Direction (Expansion/Dismantling).

Examples

## Not run: 
X <- read.table("raw_data.csv", header = TRUE)
D <- pp_clean(X, Sector = "Education")

# Now 'D' is a tidy dataset suitable for being used in the context of the 'PolicyPortfolio' package.

## End(Not run)

Complete a policy portfolio

Description

Complete an already tidy dataset with the full set of instruments, targets and years. Used also to specify the order of instruments and targets.

Usage

pp_complete(
  D,
  year.range = NULL,
  Instrument.set = NULL,
  Target.set = NULL,
  date = FALSE
)

Arguments

D

Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors.

year.range

Numerical vector of length two with the initial and final value of the years considered

Instrument.set

Ordered factor with the full set of values of Instruments, to be combined with the already existing Instruments.

Target.set

Ordered factor with the full set of values of Targets, to be combined with the already existing Targets.

date

By default a portfolio by every year is employed. Otherwise, use a full date (DD-MM-YYYY).

Value

D Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors. It differs from the input in that this one includes the full set of pre-specified Instruments, Targets and temporal range.

Examples

data(P.education)
range(P.education$Year)

P.education.full <- pp_complete(P.education, year.range = c(2000, 2035))
range(P.education.full$Year)

Measures of interest of a policy portfolio

Description

Calculate measures of interest of a policy portfolio.

Usage

pp_measures(D, id = NULL)

Arguments

D

Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors.

id

A list with up to two elements, namely "Country", and "Year" indicating the specific identification characteristics of the portfolio(s) that must be processed. Defaults to NULL to process all portfolios.

Value

A tidy dataset containing the portfolio identificators (Country, Sector and Year) plus the Measure identificators (Measure and Measure.label) and the value of the portfolio characteristic.

References

Fernández-i-Marín, X., Knill, C. & Steinebach, Y. (2021). Studying Policy Design Quality in Comparative Perspective. _American Political Science Review_, online first. For Average Instrument Diversity.

Adam, C., Knill, C. & Fernández-i-Marín, X. (2016). Rule growth and government effectiveness: why it takes the capacity to learn and coordinate to constrain rule growth. _Policy Sciences_, 50, 241–268. doi:10.1007/s11077-016-9265-x. For portfolio size.

See Also

diversity for Average Instrument Diversity, Gini, diversity configurations.

Examples

data(P.education)
m.education <- pp_measures(P.education)
m.education

# Calculate portfolio measures for a restricted set of portfolios defined by a list.
data(P.energy)
m.energy <- pp_measures(P.energy, id = list(Country = "Borduria", Year = 2022))
m.energy

Plot a policy portfolio

Description

Plot a policy portfolio.

Usage

pp_plot(D, id = NULL, spacing = FALSE, subtitle = TRUE, caption = NULL)

Arguments

D

Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors.

id

A list with up to two elements, namely "Country", and "Year" indicating the specific identification characteristics of the portfolio(s) that must be processed.

spacing

Logical value. When TRUE, some space is added between tiles to help distinguish adjacent spaces. Defaults to FALSE.

subtitle

Logical value. When TRUE (the default), a subtitle with the measures of the portfolio is included.

caption

A character vector to overimpose the Source of the data. For the CONSENSUS dataset, please use "citation(PolicyPortfolios)" to properly cite its source.

Value

A tidy dataset containing the portfolio identificators (Country, Sector and Year) plus the Measure identificators (Measure and Measure.label) and the value of the portfolio characteristic.

Examples

data(P.education)
pp_plot(P.education, id = list(Country = "Borduria", Year = 2025))

Produce a report of policy portfolios

Description

Produce a report of policy portfolios.

Usage

pp_report(
  D,
  id = NULL,
  file = NULL,
  title = NULL,
  plot = c("single", "comparative"),
  text = TRUE,
  width = 12,
  height = 7,
  comparative = c("temporal", "static"),
  between = "",
  within = "",
  dev_type_html = "svg",
  ...
)

Arguments

D

Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors.

id

A list with up to two elements, namely "Country", and "Year" indicating the specific identification characteristics of the portfolio(s) that must be processed. Defaults to NULL to process all portfolios.

file

Character vector with the name of the file to create. Defaults to a combination of the date and time of production and policy portfolio report.

title

A character vector with the title of the report. If no title is passed, the default (NULL) is to use the id, or a generic title with the date and time of its production.

plot

A character vector with the types of plot to perform. If no plot is desired, set it to NULL. By default it plots individual portfolios ("single") as well as comparative figures with portfolio measures ("comparative").

text

A logical vector of whether in the case of single portfolios a textual report should be included.

width

A number with the width of the device for individual portfolio figures. Defaults to 12 for the svg device.

height

A number with the width of the device for individual portfolio figures. Defaults to 7 for the svg device.

comparative

A character vector with the types of comparative plots to perform. If no comparative plot is desired, set it to NULL. Valid types of comparative plots are "temporal" (for showing time series of measures of portfolios) or "static" (for dotplots with the values of a single time period. If multiple years are passed and "static" is set, then the last year is used.

between

A character vector indicating the variable to which the between-comparison must be performed. Defaults to "Sector". Not yet implemented.

within

A character vector indicating the variable to which the between-comparison must be performed. Defaults to "Country". Not yet implemented.

dev_type_html

Character. Character vector indicating the type of graphical device for the html output. By default, svg. See RMarkdown.

...

Other options passed to intermediate functions.

Value

An html report.

Examples

## Not run: 
data(P.education)
pp_report(P.education)

pp_report(P.education, id = list(Country = "Borduria", Year = 2025))

## End(Not run)

Calculate the similarity between different portfolios

Description

Calculate similarity between portfolios.

Usage

pp_similarity(D, id = NULL, method = "all", return_all = TRUE)

Arguments

D

Data frame in a tidy format with the following columns: "Country", "Sector", "Year", "Instrument", "Target" and "covered". "covered" is a binary identificator of whether the portfolio space is covered by policy intervention (1) or not (0). The remaining columns identify the case. Notice that "Year" is a numeric value, while the remaining 4 case identifiers are factors.

id

A list with up to two elements, namely "Country", and "Year" indicating the specific identification characteristics of the portfolio(s) that must be processed. Defaults to NULL to process all portfolios.

method

A character vector containing the indices of similarity requested. Defaults to "all". The implemented indices of binary similarity are "jaccard" (), "

return_all

Logical indicating whether all possible combinations (countries and years of origin and destination) must be returned or only when they are different. Defaults to TRUE.

Value

A tidy dataset containing the portfolio identificators (Country, Sector and Year) plus the similarity measures and their values.

Examples

## Not run: 
data(P.education)
pp_similarity(P.education, id = list(Year = 2025))

## End(Not run)