gdrsclib
Data Structures | Macros | Functions
gdrs.h File Reference
#include "mainpage.h"
#include "datastruct.h"
#include "blockmath.h"
#include "sqlite3/sqlite3.h"

Go to the source code of this file.

Data Structures

struct  tax_entry
 The tax table has a dynamically allocated array of entries of this form. More...
 
struct  gdrs_struct
 This is the main struct that contains data from the sqlite3 database and calculated values. More...
 

Macros

#define GDRS_OK   0
 
#define GDRS_CFGREADERROR   255
 
#define GDRS_CFGCLOSEERROR   256
 
#define GDRS_FREADERROR   258
 
#define GDRS_FCLOSEERROR   259
 
#define GDRS_NOMEM   260
 
#define GDRS_DIDNOTRUN   261
 
#define GDRS_TOO_MANY_TAX_ENTRIES   262
 
#define GDRS_ID_TABLE   "id='gdrstable'"
 
#define GDRS_ROW_ID   "calcrow"
 
#define GDRS_CLASS_REGION   "class='gdrsregion'"
 
#define GDRS_ID_WORLD   "class='gdrsregion' id='gdrsworld'"
 
#define GDRS_TEXT_COL   "class='gdrstextcol'"
 
#define GDRS_SQLITE_OFFSET   1024
 
#define GDRS_SQLITE_CANTDELETEDB   1023
 
#define GDRS_SQLITE_BUFSIZE   2048
 
#define GDRS_SQLITE_HALFBUFSIZE   1024
 
#define GDRS_NUM_PARAMS   12
 
#define GDRS_NUM_TAX_PARAMS   6
 
#define EPS_NEWTON   1.0e-9
 
#define INIT_Y   500
 
#define PER_BEFORE_EP   0
 
#define PER_SEQUENCE   1
 
#define PER_GDRS   2
 
#define ANNEX1   1
 
#define ANNEX2   2
 
#define XR_PPP   0
 
#define XR_MER   1
 
#define TAX_MAX_ENTRIES   100
 
#define TAX_TYPE_VALUE   0
 
#define TAX_TYPE_NATL_QUINTILE   1
 
#define TAX_TYPE_GLOBAL_QUINTILE   2
 
#define GAP_COMBINE_NONE   0
 
#define GAP_COMBINE_ADD   1
 
#define GAP_COMBINE_MAX   2
 
#define GAP_COMBINE_MIN   3
 

Functions

void handle_sql3error (sqlite3 *db, sqlite3_stmt *stmt)
 Function that wraps repetitive code for SQLite3 errors. More...
 
int loadgdrs (struct gdrs_struct *gdrs, const char *fname)
 Function to translate from SQLite3 database to internal data structures. More...
 
int readtable (sqlite3 *db, const char *column, struct datablock *table, struct appdata ad)
 Helper function to read a column from the "core" table into a datablock. More...
 
void cleargdrs (struct gdrs_struct gdrs)
 Clear out the GDRs data structure. More...
 
void nextrci (int year, struct gdrs_struct *gdrs)
 Calculate the GDRs Responsibility-Capacity Indicator for a particular year. More...
 
double luxcap (int year, struct gdrs_struct *gdrs)
 If calculating luxury-capped baselines adjust the luxury threshold if needed to stay above emergency pathway. More...
 
void combine_gap (struct fixedfactor *gap, int i, double newgap, int combine)
 Calculate and store luxury emissions. More...
 
void calc_luxemiss (struct fixedfactor *gap, double *totgap, int year, int period, int combine, struct gdrs_struct *gdrs)
 Calculate and store luxury emissions. More...
 
void calc_kab (struct fixedfactor *gap, double *totgap, int year, int period, int combine, struct gdrs_struct *gdrs)
 Calculate and store "Kyoto gap" for Kyoto-adjusted baselines. More...
 
void calcallocs (struct gdrs_struct *gdrs)
 Calculate allocations for all years. More...
 
void calcybar (struct gdrs_struct *gdrs)
 Calculate mean income from GDP and population. More...
 
struct datablock z (double y, struct gdrs_struct *gdrs, int ppp_or_mer)
 Calculate the "z" transformed version of an income level for all countries and years. More...
 
double M (double a, double zc, double ybar, double sigma)
 Calculate a function \(M_a(y_c,\bar{y},\sigma)\) that is repeatedly used in calculations. More...
 
double globaldist (double y, int year, struct gdrs_struct *gdrs, int ppp_or_mer, double *dist_deriv)
 Calculate the fraction of global population below a specified income level in the given year. More...
 
double globalquintile (double q, int year, struct gdrs_struct *gdrs, int ppp_or_mer)
 Calculate the income at a given quintile for the world as a whole. More...
 
double a_gamma (double gamma, double y, double a, double b)
 Calculate the \(a_\gamma(y;a,b)\) function. More...
 
double b_gamma (double gamma, double y, double b)
 Calculate the \(b_\gamma(y;b)\) function. More...
 
double A_gamma (double gamma, double za, double zb, double yl, double yu, double ybar, double sigma)
 Calculate the \(A_\gamma(a,b;y_l,y_u/\pi_i,\bar{y}_i,\sigma_i)\) function. More...
 
double B_gamma (double gamma, double za, double zb, double yu, double ybar, double sigma)
 Calculate the \(B_\gamma(a,b;y_u/\pi_i,\bar{y}_i,\sigma_i)\) function. More...
 
double capbetween (double za, double zb, double zl, double zu, double yl, double yu_ppp, double ybar, double sigma, double pi, double luxmult)
 Calculate capacity per capita between two income limits. More...
 
double respbetween (double gamma, double za, double zb, double zl, double zu, double yl, double yu_ppp, double ybar, double sigma, double A)
 Calculate responsibility between two income limits. More...
 
double rhat (double E, double gamma, double sigma, double ybar)
 Calculate the factor \(\hat{r}_i\) for a country. More...
 
double c_indiv (double y, double yl, double yu, int do_interp)
 Calculate individual per capita capacity \(c_i(y)\) at a specified income level. More...
 
double r_indiv (double gamma, double y, double yl, double yu, double A, int do_interp)
 Calculate individual per capita annual responsibility \(r_i(y)\) at a specified income level. More...
 
int dump2sql3 (const char *fname, struct gdrs_struct gdrs)
 After the calculation, write all results to the SQLite3 database. More...
 

Macro Definition Documentation

◆ ANNEX1

#define ANNEX1   1

Definition at line 58 of file gdrs.h.

◆ ANNEX2

#define ANNEX2   2

Definition at line 59 of file gdrs.h.

◆ EPS_NEWTON

#define EPS_NEWTON   1.0e-9

Definition at line 51 of file gdrs.h.

◆ GAP_COMBINE_ADD

#define GAP_COMBINE_ADD   1

Definition at line 70 of file gdrs.h.

◆ GAP_COMBINE_MAX

#define GAP_COMBINE_MAX   2

Definition at line 71 of file gdrs.h.

◆ GAP_COMBINE_MIN

#define GAP_COMBINE_MIN   3

Definition at line 72 of file gdrs.h.

◆ GAP_COMBINE_NONE

#define GAP_COMBINE_NONE   0

Definition at line 69 of file gdrs.h.

◆ GDRS_CFGCLOSEERROR

#define GDRS_CFGCLOSEERROR   256

Definition at line 31 of file gdrs.h.

◆ GDRS_CFGREADERROR

#define GDRS_CFGREADERROR   255

Definition at line 30 of file gdrs.h.

◆ GDRS_CLASS_REGION

#define GDRS_CLASS_REGION   "class='gdrsregion'"

Definition at line 40 of file gdrs.h.

◆ GDRS_DIDNOTRUN

#define GDRS_DIDNOTRUN   261

Definition at line 35 of file gdrs.h.

◆ GDRS_FCLOSEERROR

#define GDRS_FCLOSEERROR   259

Definition at line 33 of file gdrs.h.

◆ GDRS_FREADERROR

#define GDRS_FREADERROR   258

Definition at line 32 of file gdrs.h.

◆ GDRS_ID_TABLE

#define GDRS_ID_TABLE   "id='gdrstable'"

Definition at line 38 of file gdrs.h.

◆ GDRS_ID_WORLD

#define GDRS_ID_WORLD   "class='gdrsregion' id='gdrsworld'"

Definition at line 41 of file gdrs.h.

◆ GDRS_NOMEM

#define GDRS_NOMEM   260

Definition at line 34 of file gdrs.h.

◆ GDRS_NUM_PARAMS

#define GDRS_NUM_PARAMS   12

Definition at line 48 of file gdrs.h.

◆ GDRS_NUM_TAX_PARAMS

#define GDRS_NUM_TAX_PARAMS   6

Definition at line 49 of file gdrs.h.

◆ GDRS_OK

#define GDRS_OK   0

Definition at line 29 of file gdrs.h.

◆ GDRS_ROW_ID

#define GDRS_ROW_ID   "calcrow"

Definition at line 39 of file gdrs.h.

◆ GDRS_SQLITE_BUFSIZE

#define GDRS_SQLITE_BUFSIZE   2048

Definition at line 46 of file gdrs.h.

◆ GDRS_SQLITE_CANTDELETEDB

#define GDRS_SQLITE_CANTDELETEDB   1023

Definition at line 45 of file gdrs.h.

◆ GDRS_SQLITE_HALFBUFSIZE

#define GDRS_SQLITE_HALFBUFSIZE   1024

Definition at line 47 of file gdrs.h.

◆ GDRS_SQLITE_OFFSET

#define GDRS_SQLITE_OFFSET   1024

Definition at line 44 of file gdrs.h.

◆ GDRS_TEXT_COL

#define GDRS_TEXT_COL   "class='gdrstextcol'"

Definition at line 42 of file gdrs.h.

◆ GDRS_TOO_MANY_TAX_ENTRIES

#define GDRS_TOO_MANY_TAX_ENTRIES   262

Definition at line 36 of file gdrs.h.

◆ INIT_Y

#define INIT_Y   500

Definition at line 53 of file gdrs.h.

◆ PER_BEFORE_EP

#define PER_BEFORE_EP   0

Definition at line 55 of file gdrs.h.

◆ PER_GDRS

#define PER_GDRS   2

Definition at line 57 of file gdrs.h.

◆ PER_SEQUENCE

#define PER_SEQUENCE   1

Definition at line 56 of file gdrs.h.

◆ TAX_MAX_ENTRIES

#define TAX_MAX_ENTRIES   100

Definition at line 64 of file gdrs.h.

◆ TAX_TYPE_GLOBAL_QUINTILE

#define TAX_TYPE_GLOBAL_QUINTILE   2

Definition at line 67 of file gdrs.h.

◆ TAX_TYPE_NATL_QUINTILE

#define TAX_TYPE_NATL_QUINTILE   1

Definition at line 66 of file gdrs.h.

◆ TAX_TYPE_VALUE

#define TAX_TYPE_VALUE   0

Definition at line 65 of file gdrs.h.

◆ XR_MER

#define XR_MER   1

Definition at line 62 of file gdrs.h.

◆ XR_PPP

#define XR_PPP   0

Definition at line 61 of file gdrs.h.

Function Documentation

◆ a_gamma()

double a_gamma ( double  gamma,
double  y,
double  a,
double  b 
)

Calculate the \(a_\gamma(y;a,b)\) function.

Parameters
gammaElasticity
yIncome (PPP) at which to evaluate the function
aLower income limit
bUpper income limit
Returns

\[0 \mbox{ if } |a - b| < \epsilon\]

or

\[a_\gamma(y;a,b) = \frac{1}{b - a}\left[\frac{\gamma}{\gamma +1}\left(y^{\gamma+1}-a^{\gamma+1}\right)-a\left(y^\gamma - a^\gamma\right)\right],\]

Note
See Technical report.
All incomes are assumed to be in PPP terms.
Todo:
Check input values

Definition at line 1299 of file gdrs.c.

◆ A_gamma()

double A_gamma ( double  gamma,
double  za,
double  zb,
double  yl,
double  yu,
double  ybar,
double  sigma 
)

Calculate the \(A_\gamma(a,b;y_l,y_u/\pi_i,\bar{y}_i,\sigma_i)\) function.

Parameters
gammaElasticity
zaLower income limit (transformed variable)
zbUpper income limit (transformed variable)
ylDevelopment threshold
yuLuxury threshold
ybarMean income for the country
sigmaStandard deviation of log income for the country
Returns

\[0 \mbox{ if } |y_u - y_l| < \epsilon\]

or

\[A_\gamma(a,b) = \frac{1}{y/\pi_i-y_l}\left[ \frac{\gamma}{\gamma+1}\left(M_{\gamma+1}(a) - M_{\gamma+1}(b)\right) - y_l\left(M_\gamma(a) - M_\gamma(b)\right) + \frac{y_l^{\gamma+1}}{\gamma+1} \left(M_0(b) - M_0(a)\right)\right],\]

Note
See Technical report.
All incomes are assumed to be in PPP terms; this means that the luxury threshold has already been converted to PPP terms.
Values for z's and y's can be positive infinity, and z's can be negative infinity.
Todo:
Check input values

Definition at line 1347 of file gdrs.c.

◆ b_gamma()

double b_gamma ( double  gamma,
double  y,
double  b 
)

Calculate the \(b_\gamma(y;b)\) function.

Parameters
gammaElasticity
yIncome (PPP) at which to evaluate the function
bUpper income limit
Returns

\[b_\gamma(y;b) = y^\gamma - b^\gamma.\]

Note
See Technical report.
All incomes are assumed to be in PPP terms.
Todo:
Check input values

Definition at line 1325 of file gdrs.c.

◆ B_gamma()

double B_gamma ( double  gamma,
double  za,
double  zb,
double  yu,
double  ybar,
double  sigma 
)

Calculate the \(B_\gamma(a,b;y_u/\pi_i,\bar{y}_i,\sigma_i)\) function.

Parameters
gammaElasticity
zaLower income limit (transformed variable)
zbUpper income limit (transformed variable)
yuLuxury threshold
ybarMean income for the country
sigmaStandard deviation of log income for the country
Returns

\[B_\gamma(a,b) = \left(M_\gamma(a)-M_\gamma(b)\right) - \left(\frac{y_u}{\pi_i}\right)^\gamma\left(M_0(a) - M_0(b)\right),\]

Note
See Technical report.
All incomes are assumed to be in PPP terms; this means that the luxury threshold has already been converted to PPP terms.
Values for z's and y's can be positive infinity, and z's can be negative infinity.
Todo:
Check input values

Definition at line 1379 of file gdrs.c.

◆ c_indiv()

double c_indiv ( double  y,
double  yl,
double  yu,
int  do_interp 
)

Calculate individual per capita capacity \(c_i(y)\) at a specified income level.

Parameters
yIncome at which to calculate c_indiv
ylDevelopment threshold
yuLuxury threshold
do_interpBoolean: are we interpolating between thresholds?
Returns
Individual capacity per capita at income $y$
Note
All incomes are in MER terms.

Definition at line 1519 of file gdrs.c.

◆ calc_kab()

void calc_kab ( struct fixedfactor gap,
double *  totgap,
int  year,
int  period,
int  combine,
struct gdrs_struct gdrs 
)

Calculate and store "Kyoto gap" for Kyoto-adjusted baselines.

Parameters
gapDifference between nominal baseline and luxury-adjusted baseline (if doing luxury-capping)
totgapSum of gaps across all countries
yearCurrent year for the calculation
periodFor sequencing: PER_BEFORE_EP, PER_SEQUENCE, or PER_GDRS
combineIf more than one gap, how are they being combined? GAP_COMBINE_NONE, GAP_COMBINE_ADD, GAP_COMBINE_MAX, GAP_COMBINE_MIN
gdrsThe global data structure for the GDRs calculation

Definition at line 812 of file gdrs.c.

◆ calc_luxemiss()

void calc_luxemiss ( struct fixedfactor gap,
double *  totgap,
int  year,
int  period,
int  combine,
struct gdrs_struct gdrs 
)

Calculate and store luxury emissions.

Parameters
gapDifference between nominal baseline and luxury-adjusted baseline (if doing luxury-capping)
totgapSum of gaps across all countries
yearCurrent year for the calculation
periodFor sequencing: PER_BEFORE_EP, PER_SEQUENCE, or PER_GDRS
combineIf more than one gap, how are they being combined? GAP_COMBINE_NONE, GAP_COMBINE_ADD, GAP_COMBINE_MAX, GAP_COMBINE_MIN
gdrsThe global data structure for the GDRs calculation

Set gdrs.lux_emiss, gdrs.lux_emiss_applied

Definition at line 892 of file gdrs.c.

◆ calcallocs()

void calcallocs ( struct gdrs_struct gdrs)

Calculate allocations for all years.

Parameters
gdrsThe global data structure for the GDRs calculation Set gdrs.a1domrdxn, gdrs.alloc_gdrs

Definition at line 947 of file gdrs.c.

◆ calcybar()

void calcybar ( struct gdrs_struct gdrs)

Calculate mean income from GDP and population.

Parameters
gdrsGlobal data structure with data, parameters, etc. Set gdrs.ybar_ppp

Definition at line 1714 of file gdrs.c.

◆ capbetween()

double capbetween ( double  za,
double  zb,
double  zl,
double  zu,
double  yl,
double  yu_ppp,
double  ybar,
double  sigma,
double  pi,
double  luxmult 
)

Calculate capacity per capita between two income limits.

Parameters
zaLower income limit (transformed variable)
zbUpper income limit (transformed variable)
zlDevelopment threshold (transformed variable)
zuLuxury threshold (transformed variable)
ylDevelopment threshold
yu_pppLuxury threshold in PPP terms
ybarMean income for the country
sigmaStandard deviation of log income for the country
piInverse of ppp2mer ratio
luxmultTax multiplier on high incomes
Returns
Average per capita contribution to national capacity from those with incomes between the income limits
Note
All incomes are assumed to be in PPP terms.
The return value must be multiplied by national population.
There is a lot of redundancy in the passed parameters, but for speed these are calculated once in function next_rci.
Values for z's and y's can be positive infinity, and z's can be negative infinity.

Definition at line 1408 of file gdrs.c.

◆ cleargdrs()

void cleargdrs ( struct gdrs_struct  gdrs)

Clear out the GDRs data structure.

Parameters
gdrsThe main data structure, containing data, information, and calculated outputs

Definition at line 621 of file gdrs.c.

◆ combine_gap()

void combine_gap ( struct fixedfactor gap,
int  i,
double  newgap,
int  combine 
)

Calculate and store luxury emissions.

Parameters
gapDifference between nominal baseline and luxury-adjusted baseline (if doing luxury-capping)
iValue in gap to set
newgapNew value for entry i
combineIf more than one gap, how are they being combined? GAP_COMBINE_NONE, GAP_COMBINE_ADD, GAP_COMBINE_MAX, GAP_COMBINE_MIN

Definition at line 782 of file gdrs.c.

◆ dump2sql3()

int dump2sql3 ( const char *  fname,
struct gdrs_struct  gdrs 
)

After the calculation, write all results to the SQLite3 database.

Parameters
fnameFilename for the SQLite3 database
gdrsGlobal structure with data and parameters
Returns
Success code Add the table "gdrs" to the SQLite3 database

Definition at line 1800 of file gdrs.c.

◆ globaldist()

double globaldist ( double  y,
int  year,
struct gdrs_struct gdrs,
int  ppp_or_mer,
double *  dist_deriv 
)

Calculate the fraction of global population below a specified income level in the given year.

Parameters
yIncome level below which to calculate the share of the global population
yearYear to report population share
gdrsThe global data structure for the GDRs calculation
ppp_or_merWhether using PPP or MER conversion rates
dist_derivPointer to a variable to store the derivative of the function (for finding quintiles) or NULL
Returns
Fraction of the population below the specified income level
Note
Before this is run, ybar, sigma, and scalpop should be calculated.

Definition at line 687 of file gdrs.c.

◆ globalquintile()

double globalquintile ( double  q,
int  year,
struct gdrs_struct gdrs,
int  ppp_or_mer 
)

Calculate the income at a given quintile for the world as a whole.

Parameters
qThe quintile (e.g., 0.5 for the median)
yearThe year in which to calculate the quintile
gdrsThe global data structure for the GDRs calculation
ppp_or_merWhether using PPP or MER conversion rates
Returns
The PPP income level for the corresponding global quintile
Note
Use Newton's method.

Definition at line 739 of file gdrs.c.

◆ handle_sql3error()

void handle_sql3error ( sqlite3 db,
sqlite3_stmt stmt 
)

Function that wraps repetitive code for SQLite3 errors.

This file handles the implementation of the GDRs algorithms

Parameters
dbAn sqlite3 database handle
stmtThe return value from an SQL3 call

Definition at line 38 of file gdrs.c.

◆ loadgdrs()

int loadgdrs ( struct gdrs_struct gdrs,
const char *  fname 
)

Function to translate from SQLite3 database to internal data structures.

Parameters
gdrsThe data structure to fill
fnameFile name of the SQLite3 database
Returns
Success code Set most values in the gdrs structure
Todo:
Implement percentiles

Definition at line 54 of file gdrs.c.

◆ luxcap()

double luxcap ( int  year,
struct gdrs_struct gdrs 
)

If calculating luxury-capped baselines adjust the luxury threshold if needed to stay above emergency pathway.

Parameters
yearYear for calculating the adjusted luxury cutoff
gdrsGlobal data structure containing parameters and data for all calculations
Returns
Value of the luxury-capped baseline, or NaN Set gdrs.yu_adj and gdrs.zu_adj

Definition at line 1572 of file gdrs.c.

◆ M()

double M ( double  a,
double  zc,
double  ybar,
double  sigma 
)

Calculate a function \(M_a(y_c,\bar{y},\sigma)\) that is repeatedly used in calculations.

Parameters
aElasticity
zcIncome cutoff, transformed into "z" variable \( z = \frac{1}{\sigma} \ln\left(y/\bar y\right) + \frac{1}{2}\sigma\)
ybarMean income
sigmaStandard deviation of log income
Returns

\[M_a(y_c,\sigma,\bar y) = \bar{y}^a e^{\frac{\sigma^2}{2} a (a - 1)} \left[1 - N(z_c - a \sigma)\right],\]

where \(N(\cdot)\) is the cumulative standardized normal distribution.
Note
See Equation (7) in the technical report

\[M_a(k y_c,\sigma, k\bar y) = k^aM_a(y_c, \sigma, \bar y)\]

Definition at line 1270 of file gdrs.c.

◆ nextrci()

void nextrci ( int  year,
struct gdrs_struct gdrs 
)

Calculate the GDRs Responsibility-Capacity Indicator for a particular year.

Parameters
yearYear for which to calculate RCI
gdrsGlobal data structure containing parameters and data Set gdrs.c, gdrs.r, gdrs.pop_above_dl, gdrs.pop_above_lux, gdrs.rci, gdrs.tax_revenue_mer_dens, tax_revenue_ppp_dens, gdrs.tax_pop_dens, gdrs.tax_income_mer_dens, tax_income_ppp_dens, gdrs.tax_pop_below
Note
IMPORTANT: alloc_gdrs for prev year is expected to be set by the calling function unless it is the first year

Definition at line 1107 of file gdrs.c.

◆ r_indiv()

double r_indiv ( double  gamma,
double  y,
double  yl,
double  yu,
double  A,
int  do_interp 
)

Calculate individual per capita annual responsibility \(r_i(y)\) at a specified income level.

Parameters
gammaEmissions elasticity
yIncome at which to calculate r_indiv
ylDevelopment threshold
yuLuxury threshold
AOverall coefficient (factor \(\hat{r}_i\))
Returns
Individual annual responsibility per capita at income \(y\)
Note
All incomes are in PPP terms

Definition at line 1546 of file gdrs.c.

◆ readtable()

int readtable ( sqlite3 db,
const char *  column,
struct datablock table,
struct appdata  ad 
)

Helper function to read a column from the "core" table into a datablock.

Parameters
dbHandle for the SQLite3 database
columnName of the column in the core table of the database
tableInternal data representation
adappdata structure with dimensions
Returns
Success code

Definition at line 576 of file gdrs.c.

◆ respbetween()

double respbetween ( double  gamma,
double  za,
double  zb,
double  zl,
double  zu,
double  yl,
double  yu_ppp,
double  ybar,
double  sigma,
double  A 
)

Calculate responsibility between two income limits.

Parameters
gammaEmissions elasticity
zaLower income limit (transformed variable)
zbUpper income limit (transformed variable)
zlDevelopment threshold (transformed variable)
zuLuxury threshold (transformed variable)
ylDevelopment threshold
yu_pppLuxury threshold in PPP terms
ybarMean income for the country
sigmaStandard deviation of log income for the country
AOverall multiplicative constant to convert to emissions
Returns
Contribution to national responsibility from those with incomes between the income limits
Note
All incomes are assumed to be in PPP terms.
There is a lot of redundancy in the passed parameters, but for speed these are calculated once in function next_rci.
Values for z's and y's can be positive infinity, and z's can be negative infinity.

Definition at line 1459 of file gdrs.c.

◆ rhat()

double rhat ( double  E,
double  gamma,
double  sigma,
double  ybar 
)

Calculate the factor \(\hat{r}_i\) for a country.

Parameters
EAnnual emissions
gammaEmissions elasticity
sigmaStandard deviation of the log of income
ybarMean income
Returns
The factor

\[\hat{r}_i=\frac{E_{i}}{{\bar{y}_{i}}^{\gamma }}e^{-{\frac{\sigma _{i}^{2}}{\;2}}\gamma (\gamma -1)}\]

Note
Mean income ybar is assumed to be in PPP terms where this factor appears in formulas.

Definition at line 1503 of file gdrs.c.

◆ z()

struct datablock z ( double  y,
struct gdrs_struct gdrs,
int  ppp_or_mer 
)

Calculate the "z" transformed version of an income level for all countries and years.

Parameters
yThe income at which to calculate z
gdrsGlobal data structure with variables and parameters
ppp_or_merWhether using PPP or MER conversion rates
Returns
Value of z
Note
\( z = \frac{1}{\sigma} \ln\left(y/\bar y\right) + \frac{1}{2}\sigma\)

Definition at line 1754 of file gdrs.c.