computeAvgTotCost: Calculate the cumulative and average annual cost over a...

View source: R/summarizeCosts.R

computeAvgTotCostR Documentation

Calculate the cumulative and average annual cost over a single period of time

Description

This simple function calculates the cumulative cost average annual cost of invasive alien species over a single period of time. It is used internally by summarizeCosts.

Usage

computeAvgTotCost(
  costdb,
  cost.column = "Cost_estimate_per_year_2017_USD_exchange_rate",
  year.column = "Impact_year",
  min.year = NULL,
  max.year = NULL
)

Arguments

costdb

The expanded 'InvaCost' database output from expandYearlyCosts, where annual costs occurring over several years are repeated for each year.

cost.column

Name of the cost column to use in costdb (usually, choose between the exchange rate (default) or Purchase Power Parity cost per year)

year.column

Name of the year column to use in costdb.

min.year

The minimum year of the period (specify only if different from the range of data)

max.year

The minimum year of the period (specify only if different from the range of data)

Value

a named list with 5 elements

  • initial_year: first year in the data

  • final_year: last year in the data

  • time_span: the difference between initial and final years.

  • total_cost: total cost.

  • annual.cost: cost per year

  • number_estimates: the number of cost estimates before expansion via expandYearlyCosts

  • number_year_values: the number of costs per year included

Note

Arguments min.year and max.year do not filter the data. Only specify them if you wish to change the interval over which averages are calculated. For example, if your data have values from 1960 to 1964 but you want to calculated the average value from 1960 to 1969, set min.year = 1960 and max.year = 1969.

However, if you want to calculate values for an interval narrower than your data, filter the data BEFORE running this function.

Author(s)

Boris Leroy leroy.boris@gmail.com, Andrew Kramer, Anne-Charlotte Vaissière, Christophe Diagne

References

https://github.com/Farewe/invacost

Leroy Boris, Kramer Andrew M, Vaissière Anne-Charlotte, Kourantidou Melina, Courchamp Franck & Diagne Christophe (2022). Analysing economic costs of invasive alien species with the invacost R package. Methods in Ecology and Evolution. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/2041-210X.13929")}

See Also

expandYearlyCosts to get the database in appropriate format.

Examples

data(invacost)

### Cleaning steps
# Eliminating data with no information on starting and ending years
invacost <- invacost[-which(is.na(invacost$Probable_starting_year_adjusted)), ]
invacost <- invacost[-which(is.na(invacost$Probable_ending_year_adjusted)), ]
# Keeping only observed and reliable costs
invacost <- invacost[invacost$Implementation == "Observed", ]
invacost <- invacost[which(invacost$Method_reliability == "High"), ]
# Eliminating data with no usable cost value
invacost <- invacost[-which(is.na(invacost$Cost_estimate_per_year_2017_USD_exchange_rate)), ]

### Expansion

db.over.time <- expandYearlyCosts(invacost,
                                  startcolumn = "Probable_starting_year_adjusted",
                                  endcolumn = "Probable_ending_year_adjusted")
                                  
### Analysis
res <- computeAvgTotCost(db.over.time,
                         min.year = 1960,
                         max.year = 2020) # Excluding data after 2020 (e.g. planned budgets)
res

invacost documentation built on May 29, 2024, 3:34 a.m.