| Title: | Agricultural Policy Analysis Matrix Toolkit |
|---|---|
| Description: | Builds and analyses Policy Analysis Matrices ('PAMs') for agricultural production systems. Computes private and social profitability, policy transfers, the domestic resource cost ratio, nominal protection coefficients for outputs and inputs, the effective protection coefficient, the private cost ratio, the profitability coefficient, subsidy ratios, and social cost-benefit ratios. Supports itemised farm budgets, parity prices, grouped analysis, deterministic sensitivity analysis, switching values, and correlated Monte Carlo simulation. Methods follow Monke and Pearson (1989, ISBN:0801419530) and the Food and Agriculture Organization of the United Nations (2007, ISBN:9789251057476). |
| Authors: | Chiranjit Mazumder [aut, cre], Himadri Sekhar Roy [aut], Utkarsh Tiwari [aut], Pramit Pandit [aut], Bikramjeet Ghose [aut] |
| Maintainer: | Chiranjit Mazumder <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-11 10:06:43 UTC |
| Source: | https://github.com/cran/agriPAM |
Build, inspect, and stress-test Policy Analysis Matrices (PAMs) for agricultural production systems. The package implements private, social, and transfer accounts and standard competitiveness, comparative-advantage, and policy-protection indicators.
Create a matrix with pam() or pam_from_budget(), inspect it with
pam_matrix(), pam_transfers(), and pam_indicators(), and
then examine uncertainty with pam_sensitivity(),
switching_value(), or pam_monte_carlo().
Monke, E. A. and Pearson, S. R. (1989). The Policy Analysis Matrix for Agricultural Development. Cornell University Press. ISBN 0801419530.
Food and Agriculture Organization of the United Nations (2007). Agricultural Trade Policy and Food Security in the Caribbean. ISBN 9789251057476.
pam, pam_from_budget,
pam_monte_carlo
Return an itemised, synthetic crop budget or the corresponding Policy Analysis Matrix. Values are for examples and teaching, not policy inference.
agri_pam_example(type = c("pam", "budget"))agri_pam_example(type = c("pam", "budget"))
type |
Either |
An agri_pam object for type = "pam"; otherwise a data frame
with 28 itemised budget rows.
x <- agri_pam_example() pam_indicators(x) head(agri_pam_example("budget"))x <- agri_pam_example() pam_indicators(x) head(agri_pam_example("budget"))
Test whether an object inherits from class agri_pam.
is_agri_pam(x)is_agri_pam(x)
x |
An object. |
A single logical value.
is_agri_pam(agri_pam_example()) is_agri_pam(data.frame())is_agri_pam(agri_pam_example()) is_agri_pam(data.frame())
Construct one or more agricultural Policy Analysis Matrices from private and social revenues and costs, directly or from columns in a data frame.
pam( private_revenue, private_tradable_inputs, private_domestic_factors, social_revenue, social_tradable_inputs, social_domestic_factors, id = NULL, unit = NULL, currency = NULL ) pam_from_data( data, private_revenue, private_tradable_inputs, private_domestic_factors, social_revenue, social_tradable_inputs, social_domestic_factors, id = NULL, unit = NULL, currency = NULL )pam( private_revenue, private_tradable_inputs, private_domestic_factors, social_revenue, social_tradable_inputs, social_domestic_factors, id = NULL, unit = NULL, currency = NULL ) pam_from_data( data, private_revenue, private_tradable_inputs, private_domestic_factors, social_revenue, social_tradable_inputs, social_domestic_factors, id = NULL, unit = NULL, currency = NULL )
private_revenue, private_tradable_inputs, private_domestic_factors
|
For |
social_revenue, social_tradable_inputs, social_domestic_factors
|
For |
id |
For |
unit |
Optional character label for the activity unit, such as
|
currency |
Optional character label for the currency, such as
|
data |
A non-empty data frame containing PAM component columns. |
Every component vector must be non-negative and finite. Scalars are recycled to the common length. Private and social profits are revenue minus tradable-input cost minus domestic-factor cost.
An object of class agri_pam.
x <- pam( private_revenue = 150000, private_tradable_inputs = 42000, private_domestic_factors = 61000, social_revenue = 140000, social_tradable_inputs = 46000, social_domestic_factors = 55000, id = "Paddy", unit = "ha", currency = "INR" ) x pam_matrix(x) dat <- data.frame( crop = c("Paddy", "Wheat"), pr = c(150000, 110000), pt = c(42000, 31000), pd = c(61000, 44000), sr = c(140000, 116000), st = c(46000, 34000), sd = c(55000, 46000) ) pam_from_data(dat, "pr", "pt", "pd", "sr", "st", "sd", id = "crop")x <- pam( private_revenue = 150000, private_tradable_inputs = 42000, private_domestic_factors = 61000, social_revenue = 140000, social_tradable_inputs = 46000, social_domestic_factors = 55000, id = "Paddy", unit = "ha", currency = "INR" ) x pam_matrix(x) dat <- data.frame( crop = c("Paddy", "Wheat"), pr = c(150000, 110000), pt = c(42000, 31000), pd = c(61000, 44000), sr = c(140000, 116000), st = c(46000, 34000), sd = c(55000, 46000) ) pam_from_data(dat, "pr", "pt", "pd", "sr", "st", "sd", id = "crop")
Sum the six additive PAM accounts within groups and recalculate profits, transfers, and ratios from the totals.
pam_aggregate(x, group = NULL, id = "All")pam_aggregate(x, group = NULL, id = "All")
x |
An |
group |
|
id |
Label used when |
An agri_pam object with one row per group.
x <- agri_pam_example() pam_aggregate(x) pam_aggregate(x, c("Cereal", "Cereal", "Pulse", "Oilseed"))x <- agri_pam_example() pam_aggregate(x) pam_aggregate(x, c("Cereal", "Cereal", "Pulse", "Oilseed"))
Convert item quantities and private/social prices into revenue, tradable-input, and domestic-factor accounts, optionally for several production systems.
pam_from_budget( data, quantity, private_price, social_price, category, id = NULL, unit = NULL, currency = NULL )pam_from_budget( data, quantity, private_price, social_price, category, id = NULL, unit = NULL, currency = NULL )
data |
A non-empty data frame containing budget items. |
quantity, private_price, social_price, category
|
Character strings naming the quantity, private-price, social-price, and category columns. |
id |
|
unit, currency
|
Optional labels passed to |
Categories are normalised without regard to case, spaces, or hyphens. Accepted
categories are output, tradable_input, and
domestic_factor; documented aliases are also accepted. Values are
quantity multiplied by price and summed within production system and category.
An agri_pam object.
budget <- agri_pam_example("budget") x <- pam_from_budget( budget, "quantity", "private_price", "social_price", "category", id = "crop", unit = "ha", currency = "INR" ) pam_matrix(x, "Paddy")budget <- agri_pam_example("budget") x <- pam_from_budget( budget, "quantity", "private_price", "social_price", "category", id = "crop", unit = "ha", currency = "INR" ) pam_matrix(x, "Paddy")
Simulate uncertainty in the six additive PAM components using correlated lognormal or non-negative normal draws, then summarise policy indicators and decision probabilities.
pam_monte_carlo( x, cv = 0.1, n = 10000L, distribution = c("lognormal", "normal"), correlation = NULL, seed = NULL, index = 1L, probs = c(0.025, 0.5, 0.975) ) ## S3 method for class 'agri_pam_mc' print(x, ...) ## S3 method for class 'agri_pam_mc' summary(object, ...) ## S3 method for class 'agri_pam_mc' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'agri_pam_mc' plot(x, metric = "drc", breaks = "FD", ...)pam_monte_carlo( x, cv = 0.1, n = 10000L, distribution = c("lognormal", "normal"), correlation = NULL, seed = NULL, index = 1L, probs = c(0.025, 0.5, 0.975) ) ## S3 method for class 'agri_pam_mc' print(x, ...) ## S3 method for class 'agri_pam_mc' summary(object, ...) ## S3 method for class 'agri_pam_mc' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'agri_pam_mc' plot(x, metric = "drc", breaks = "FD", ...)
x |
An |
cv |
Coefficients of variation: one value, six unnamed values in standard component order, or a named subset. Named omitted components are fixed. |
n |
Number of Monte Carlo draws. |
distribution |
Either |
correlation |
Optional six-by-six correlation matrix for latent normal shocks. |
seed |
Optional integer seed. The caller's random-number state is restored on exit when a seed is supplied. |
index |
One numeric row number or character analysis identifier. |
probs |
Quantile probabilities used in the summary. |
object |
An |
row.names, optional
|
Arguments for the data-frame method. |
metric |
Metric whose simulated distribution is plotted. |
breaks |
Histogram breaks passed to |
... |
Additional arguments passed to the underlying method. |
pam_monte_carlo() returns an agri_pam_mc object containing
draws, summary, and probabilities data frames.
summary() returns the latter two tables, as.data.frame() returns
the draws, and the other methods return x invisibly.
x <- agri_pam_example() mc <- pam_monte_carlo( x, cv = 0.10, n = 500, seed = 123, index = "Paddy" ) mc summary(mc) plot(mc, metric = "drc") cvs <- c(social_revenue = 0.15, social_tradable_inputs = 0.08) pam_monte_carlo(x, cv = cvs, n = 250, seed = 42, index = "Wheat")x <- agri_pam_example() mc <- pam_monte_carlo( x, cv = 0.10, n = 500, seed = 123, index = "Paddy" ) mc summary(mc) plot(mc, metric = "drc") cvs <- c(social_revenue = 0.15, social_tradable_inputs = 0.08) pam_monte_carlo(x, cv = cvs, n = 250, seed = 42, index = "Wheat")
Vary one PAM component by specified proportional changes and recalculate all profits, transfers, and policy indicators.
pam_sensitivity( x, parameter, changes = seq(-0.2, 0.2, by = 0.05), index = 1L ) ## S3 method for class 'agri_pam_sensitivity' print(x, ...) ## S3 method for class 'agri_pam_sensitivity' plot(x, metric = "drc", ...)pam_sensitivity( x, parameter, changes = seq(-0.2, 0.2, by = 0.05), index = 1L ) ## S3 method for class 'agri_pam_sensitivity' print(x, ...) ## S3 method for class 'agri_pam_sensitivity' plot(x, metric = "drc", ...)
x |
An |
parameter |
One of the six private or social revenue, tradable-input, or domestic-factor component names. |
changes |
Numeric proportional changes; |
index |
One numeric row number or character analysis identifier. |
metric |
Metric to plot. |
... |
Additional arguments passed to the underlying method. |
pam_sensitivity() returns an object of class
agri_pam_sensitivity containing a results data frame. Methods
return x invisibly.
x <- agri_pam_example() s <- pam_sensitivity( x, "social_revenue", changes = seq(-0.2, 0.2, by = 0.1), index = "Paddy" ) s plot(s, metric = "drc")x <- agri_pam_example() s <- pam_sensitivity( x, "social_revenue", changes = seq(-0.2, 0.2, by = 0.1), index = "Paddy" ) s plot(s, metric = "drc")
Expose value accounts, policy transfers, standard indicators, qualitative classifications, or the conventional three-by-four PAM table.
pam_values(x) pam_transfers(x) pam_indicators(x) pam_classify(x) pam_matrix(x, index = 1L)pam_values(x) pam_transfers(x) pam_indicators(x) pam_classify(x) pam_matrix(x, index = 1L)
x |
An |
index |
Numeric row numbers or character analysis identifiers. |
For the conventional matrix, private values are denoted by A–D, social values by E–H, and transfers by I–L:
The indicator columns are:
npco: nominal protection coefficient on output, A/E;
npci: nominal protection coefficient on tradable inputs, B/F;
epc: effective protection coefficient, (A-B)/(E-F);
pcr: private cost ratio, C/(A-B);
drc: domestic resource cost ratio, G/(E-F);
pc: profitability coefficient, D/H;
srp: subsidy ratio to producers, L/E;
scb: social cost-benefit ratio, (F+G)/E.
A ratio is NA when its denominator is zero.
pam_values(), pam_transfers(), pam_indicators(), and
pam_classify() return data frames. pam_matrix() returns one
numeric matrix, or a named list of matrices if multiple analyses are selected.
x <- agri_pam_example() pam_values(x) pam_transfers(x) pam_indicators(x) pam_classify(x) pam_matrix(x, "Paddy")x <- agri_pam_example() pam_values(x) pam_transfers(x) pam_indicators(x) pam_classify(x) pam_matrix(x, "Paddy")
Calculate import- or export-parity prices for social valuation.
parity_price( border_price, exchange_rate = 1, transport = 0, handling = 0, other_costs = 0, quality_adjustment = 1, direction = c("import", "export") )parity_price( border_price, exchange_rate = 1, transport = 0, handling = 0, other_costs = 0, quality_adjustment = 1, direction = c("import", "export") )
border_price |
Border price in international currency per unit. |
exchange_rate |
Domestic currency units per international currency unit. |
transport, handling, other_costs
|
Domestic marketing costs per unit. |
quality_adjustment |
Multiplicative adjustment for quality differences. |
direction |
Either |
Import parity adds domestic transfer costs to the quality-adjusted border value. Export parity subtracts them. Taxes and subsidies should not be included when constructing an undistorted social price.
A numeric vector of parity prices in domestic currency per unit.
parity_price(300, exchange_rate = 83, transport = 1200, handling = 300, direction = "import") parity_price(300, exchange_rate = 83, transport = 1200, handling = 300, direction = "export")parity_price(300, exchange_rate = 83, transport = 1200, handling = 300, direction = "import") parity_price(300, exchange_rate = 83, transport = 1200, handling = 300, direction = "export")
Print, summarise, plot, or coerce Policy Analysis Matrices.
## S3 method for class 'agri_pam' print(x, ...) ## S3 method for class 'agri_pam' summary(object, ...) ## S3 method for class 'summary_agri_pam' print(x, ...) ## S3 method for class 'agri_pam' plot( x, type = c("profits", "coefficients", "transfers"), index = NULL, main = NULL, ... ) ## S3 method for class 'agri_pam' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'agri_pam' print(x, ...) ## S3 method for class 'agri_pam' summary(object, ...) ## S3 method for class 'summary_agri_pam' print(x, ...) ## S3 method for class 'agri_pam' plot( x, type = c("profits", "coefficients", "transfers"), index = NULL, main = NULL, ... ) ## S3 method for class 'agri_pam' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x, object
|
An |
type |
Plot type: profits, coefficients, or transfers. |
index |
Optional numeric row numbers or character analysis identifiers. |
main |
Optional plot title. |
row.names, optional
|
Arguments for the data-frame method. |
... |
Additional arguments passed to the underlying method. |
Print and plot methods return x invisibly. summary() returns a
summary_agri_pam object containing an overview data frame.
as.data.frame() returns a combined results data frame.
x <- agri_pam_example() print(x) summary(x) as.data.frame(x) plot(x, type = "coefficients")x <- agri_pam_example() print(x) summary(x) as.data.frame(x) plot(x, type = "coefficients")
Find the nearest proportional change in one PAM component that makes a selected profit, transfer, or ratio reach a target.
switching_value( x, parameter, metric = "drc", target = NULL, interval = c(-0.95, 3), index = 1L, tol = 1e-08 ) ## S3 method for class 'agri_pam_switch' print(x, ...)switching_value( x, parameter, metric = "drc", target = NULL, interval = c(-0.95, 3), index = 1L, tol = 1e-08 ) ## S3 method for class 'agri_pam_switch' print(x, ...)
x |
An |
parameter |
One of the six private or social revenue, tradable-input, or domestic-factor component names. |
metric |
A profit, transfer, or indicator name. |
target |
Numeric target. If |
interval |
Two proportional changes defining the search interval. |
index |
One numeric row number or character analysis identifier. |
tol |
Numeric root-finding tolerance. |
... |
Additional arguments passed to the print method. |
A one-row data frame of class agri_pam_switch. The found column
is FALSE when the target is not reached inside interval.
x <- agri_pam_example() switching_value(x, "social_revenue", metric = "drc", index = "Paddy") switching_value( x, "private_revenue", metric = "private_profit", index = "Paddy" )x <- agri_pam_example() switching_value(x, "social_revenue", metric = "drc", index = "Paddy") switching_value( x, "private_revenue", metric = "private_profit", index = "Paddy" )