Giter Club home page Giter Club logo

frbca's Introduction

frbca

The goal of frbca is to conduct benefit-cost analysis (BCA) for buildings archetypes designed for functional recovery. The inputs include:

  • Expected Annualized Losses (EALs) for (i) a baseline (code-conforming) design and (ii) recovery-based design interventions
  • Structural and nonstructural costs for both (i) and (ii)
  • A list of analysis parameters, including discount rate, time horizon, and economic analysis parameters such as business income

Installation

You can install the development version of frbca like so:

You can install frbca from GitHub with:

devtools::install_github("juanfung/frbca")

Expected inputs

To run the analysis, provide two inputs in tabular (eg, data.frame) form:

Expected annualized losses (EALs) from a performance assessment

Each row is an archetype model. Expected (minimum) columns:

| variable                 | type  | description                        |
|--------------------------|-------|------------------------------------|
| model                    | <chr> | unique model name or id            |
| intervention             | {0,1} | baseline design = 0; otherwise = 1 |
| num_stories              | <dbl> | number of stories                  |
| loss_ratio               | <dbl> | loss ratio                         |
| repair_costs             | <dbl> | repair costs, in dollars           |
| re_occupancy_time        | <dbl> | re-occupancy time, in days         |
| functional_recovery_time | <dbl> | functional recovery time, in days  |

Construction costs

Each row is an archetype model. Expected (minimum) columns:

| variable     | type  | description                                  |
|--------------|-------|----------------------------------------------|
| model        | <chr> | unique model name or id                      |
| intervention | {0,1} | baseline design = 0; otherwise = 1           |
| num_stories  | <dbl> | number of stories                            |
| c_s          | <dbl> | structural construction costs, in dollars    |
| c_ns         | <dbl> | nonstructural construction costs, in dollars |

In addition, several parameters are required in list form. The following are the base parameters required under sub-list input_param$parameters$base:

| parameter    | type    | description                                        |
|--------------|---------|----------------------------------------------------|
| floor_area   | <dbl>   | total square footage per story                     |
| delta        | <delta> | discount rate                                      |
| T            | <dbl>   | planning horizon, in years                         |
| bi           | <dbl>   | business income                                    |
| ri           | <dbl>   | rental income                                      |
| displacement | <dbl>   | occupant-incurred costs of displacement            |
| tenant       | <dbl>   | number of tenants per square foot                  |
| recapture    | <dbl>   | recapture rate for rental income                   |
| sc           | <sc>    | supply-chain multiplier for business income losses |

In addition, parameter values for sensitivity analysis should be provided under the sub-list input_param$parameters$sensitivity. For example, sensitivity analysis for delta would be conducted based on provided values input_param$parameters$sensitivity$delta$low and input_param$parameters$sensitivity$delta$high.

Example

This is a basic example which shows you how to solve a common problem:

## NOT RUN
library(frbca)

## assuming input data is loaded and parameters are set...

## run analysis
output <- frbca::frbca(input_eal, input_cost, input_param)

## generate results plot with sensitivity analysis
frbca::plot_frbca(output, n_floors=4, system='RCMF')

frbca's People

Contributors

juanfung avatar

Watchers

 avatar

frbca's Issues

Allow variable economic parameters for BCA

Currently, loss computations for economic parameters provided via input list (ie, displacement, business_income, rental_income, and sc) are hard-coded:

pv_loss <- function(model, p) {
    ## Purpose:
    ## Calculate losses for each model
    return(
        model %>%
        ## NB: assumes total_area column has been created
        dplyr::mutate(
                   displacement=p$displacement*p$tenant*re_occupancy_time*total_area,
                   business_income=(1 - p$recapture)*p$bi*functional_recovery_time*total_area,
                   rental_income=p$ri*functional_recovery_time*total_area
               ) %>%
        dplyr::mutate(sc=(p$sc * business_income))
        )
}

To allow flexibility:

  1. the input list should include an econ sub-list with desired economic parameters
  2. the computations would iterate through the named econ sub-list and extract the names from the list

Decouple post-processing code from plot function

Current function plot_frbca includes code to post-process output to prepare for plotting. This could might be useful to have in a standalone function as it might help to have the output in a specific format for tables.

Add explicit guidance on expected input format

Currently, the package expects explicit input formats for two tables: one for EALs (e.g., eal.csv) and one for costs (e.g., cost.csv).

Not only do the expected input tables need to be added to documentation, but also the expected formats (minimum amount of information, column names, and format/types).

Improve/streamline plot functions

Current plot functions are kludgey. Needs

  • Wrapper to streamline plotting as inputs are the same (same goes for postprocessing code)
  • Global plot theme (so this isn't getting done ad hoc with each plot) #14
  • Plotting other metrics
  • EDIT: filtering by model list should actually be by design (intervention); need to update preprocessing to create this column, with plain english names, for easy plotting (as this is getting done ad hoc for plotting from the outputs)

Preprocessing nests systems within stories

Current preprocessing_model nests systems [j] within stories [i].

As a result, when running the analysis for multiple systems:

out <- frbca(eal_multiple_systems, cost_multiple_systems, params)

the output out is nested by stories rather than systems. In other words, out is a list with the length length(out) = number of unique story heights represented in the data.

It should be the other way around: nest stories within systems, so that length(out) = number of unique structural systems.

Add additional metrics

  1. In addition to BCR and NPV, add (a) AROI and (b) IRR
  2. Generalize NPV calculation to be reusable (ie, wrap in a function, parameterize, and use to calculate IRR)

Update input table formats for more explicit model information

Updating input schema to include:

  • system: structural system name (eg, RCMF)
  • num_stories: number of stories (eg, 4)
  • design_s: explicit designation of structural intervention (eg, RCIV)
  • design_ns: explicit designation of nonstructural intervention (eg, ns16 for the 16th nonstructural design iteration documented in the paper)
  • model: concatenation of system-num_stories-design_s-design_ns (eg, RCMF-4-RCIV-baseline)

Need to update:

  • preprocess_model function, which assumes a different schema
  • README

Need to decide if analyses will continue to be run for a fixed system (the current implicit assumption) or whether to add something to preprocessing to allow a single analysis of multiple systems:

  • This would likely necessitate preprocess_model creates nested submodels for analyses; currently submodels are separated by num_stories but can also nest that within system:
## OLD:
    stories <- dat |> dplyr::distinct(num_stories) |> pull()
    for (i in 1:length(stories)) {
        models[[i]] <- dat |>
            dplyr::filter(num_stories == stories[i])
    }

## NEW:
    systems <- dat |> dplyr::distinct(system) |> pull()
    stories <- dat |> dplyr::distinct(num_stories) |> pull()
    for (j in 1:length(systems)) {
        for (i in 1:length(stories)) {
            models[[j]][[i]] <- dat |>
                dplyr::filter(system == systems[j] & num_stories == stories[i])
        }
    }

Will need to check if any of the remaining functions assume a single-level submodel structure, in which case they will need to be modified to iterate through all levels, or whether they work as is (unlikely)

Add computation for value added losses

Related to #9, add computation for a new loss category (loss of value added, analogous to business income):

## old
  } else if (loss_name == 'loss_business_income') {

## new
  } else if (grepl('(business_income|value_added)', loss_name) {

Include example input data

Provide example input files (EALs and Costs), as well as reasonable defaults for parameters (see #4) in order to demonstrate use (either in README or in a vignette)

Loss calculations for rental income and displacement

Rental income depends on reoccupancy time (assuming owners can collect rent even if tenant has not returned) but displacement depends on recovery time (tenants likely won't return until building is functional). Currently it's reversed so it needs to be flipped.

PV Cost calculation is hard-coded

Nonstructural costs are discounted relative to base year, but this discounting is hard-coded:

pv_ns=c_ns*(1-p$delta)^(2018-2011)) %>%

Similarly, the total cost then adjusts nonstructural costs for maintenance over the life of the building...but again, this is hard-coded (it should be 0.5 * T):

dplyr::mutate(pv_total=pv_s+pv_ns+pv_ns/(1+p$delta)^25)

Create a vignette

Depends on #4 and #5. Create a vignette to provide more illustrative documentation of how an end-to-end analysis might look.

Model story height should be explicit input

Currently, model story height is pulled from the model_name column:

dplyr::mutate(total_floors=as.numeric(gsub('(.*-)(\\d{1,2})$', '\\2', model))) %>%

Input tables should have explicit story-height column and story height should be pulled from there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.