# Analyst Cheat Sheet

## Goal

This guide covers the basic workflow:

    deal_spec() -> analyze_deal() -> summary() -> deal_cashflows()

## The 5 functions to know

- `deal_spec()`: define the deal
- `debt_terms()`: define the debt
- `analyze_deal()`: run the model
- `summary()`: read key metrics
- `deal_cashflows()`: extract tables

## The 10 variables that matter most

Variable | Meaning
--- | ---
`price` | all-in acquisition price
`horizon_years` | holding period
`entry_yield` | entry cap rate
`noi_y1` | year-1 NOI if already known
`rent_sqm` | rent per sqm
`area_sqm` | lettable area
`vacancy_rate` | average vacancy
`discount_rate` | discount rate
`ltv` | initial leverage
`rate` | debt interest rate

Use exactly one income mode:

- `entry_yield`
- or `noi_y1`
- or `rent_sqm + area_sqm`

## Quick Start

    library(cre.dcf)

    deal <- deal_spec(
      price = 10e6,
      entry_yield = 0.055,
      horizon_years = 10,
      debt = debt_terms(
        ltv = 0.60,
        rate = 0.045,
        type = "bullet"
      )
    )

    res <- analyze_deal(deal)

    summary(res)
    #> # A tibble: 1 × 25
    #>   income_mode purchase_year  price horizon_years area_sqm price_per_sqm rent_sqm
    #>   <chr>               <dbl>  <dbl>         <int>    <dbl>         <dbl>    <dbl>
    #> 1 entry_yield          2026    1e7            10       NA            NA       NA
    #> # ℹ 18 more variables: vacancy_rate <dbl>, opex_sqm <dbl>,
    #> #   gross_potential_rent_y1 <dbl>, gei_y1 <dbl>, noi_y1 <dbl>, pbtcf_y1 <dbl>,
    #> #   entry_yield <dbl>, index_rate <dbl>, discount_rate <dbl>, debt_type <chr>,
    #> #   debt_ltv <dbl>, debt_rate <dbl>, irr_project <dbl>, irr_equity <dbl>,
    #> #   dscr_min <dbl>, ltv_max_forward <dbl>, ops_share <dbl>, tv_share <dbl>

## Typical Workflow

### 1. Define the deal

    deal <- deal_spec(
      price = 12e6,
      rent_sqm = 240,
      area_sqm = 4000,
      vacancy_rate = 0.08,
      opex_sqm = 15,
      horizon_years = 7,
      discount_rate = 0.08,
      debt = debt_terms(
        ltv = 0.55,
        rate = 0.043,
        type = "amort",
        maturity = 7
      )
    )

    deal
    #> <cre_deal_spec>
    #> price_di: 12000000.00
    #> asset: 4,000.00 sqm | rent 240.00/sqm | vacancy 8.0% | opex 15.00/sqm | price 3,000.00/sqm
    #> year-1: GEI 883,200.00 | NOI 823,200.00 | PBTCF 823,200.00 | entry yield 6.86%
    #> horizon: 7 years
    #> income mode: 4000.00 sqm x 240.00 rent/sqm
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: amort, LTV 55.0%, rate 4.30%

### 2. Run the deal

    res <- analyze_deal(deal)
    res
    #> <cre_deal_result>
    #> # A tibble: 1 × 25
    #>   income_mode purchase_year  price horizon_years area_sqm price_per_sqm rent_sqm
    #>   <chr>               <dbl>  <dbl>         <int>    <dbl>         <dbl>    <dbl>
    #> 1 rent_roll            2026 1.20e7             7     4000          3000      240
    #> # ℹ 18 more variables: vacancy_rate <dbl>, opex_sqm <dbl>,
    #> #   gross_potential_rent_y1 <dbl>, gei_y1 <dbl>, noi_y1 <dbl>, pbtcf_y1 <dbl>,
    #> #   entry_yield <dbl>, index_rate <dbl>, discount_rate <dbl>, debt_type <chr>,
    #> #   debt_ltv <dbl>, debt_rate <dbl>, irr_project <dbl>, irr_equity <dbl>,
    #> #   dscr_min <dbl>, ltv_max_forward <dbl>, ops_share <dbl>, tv_share <dbl>

### 3. Read the key metrics

    summary(res)
    #> # A tibble: 1 × 25
    #>   income_mode purchase_year  price horizon_years area_sqm price_per_sqm rent_sqm
    #>   <chr>               <dbl>  <dbl>         <int>    <dbl>         <dbl>    <dbl>
    #> 1 rent_roll            2026 1.20e7             7     4000          3000      240
    #> # ℹ 18 more variables: vacancy_rate <dbl>, opex_sqm <dbl>,
    #> #   gross_potential_rent_y1 <dbl>, gei_y1 <dbl>, noi_y1 <dbl>, pbtcf_y1 <dbl>,
    #> #   entry_yield <dbl>, index_rate <dbl>, discount_rate <dbl>, debt_type <chr>,
    #> #   debt_ltv <dbl>, debt_rate <dbl>, irr_project <dbl>, irr_equity <dbl>,
    #> #   dscr_min <dbl>, ltv_max_forward <dbl>, ops_share <dbl>, tv_share <dbl>

Key fields:

- `irr_project`: project return before leverage
- `irr_equity`: return to equity
- `dscr_min`: minimum debt-service coverage ratio
- `ltv_max_forward`: maximum forward LTV
- `ops_share`: share of present value coming from operating cash flows
- `tv_share`: share of present value coming from terminal value

### 4. Extract the tables

    deal_cashflows(res, "comparison")
    #> # A tibble: 3 × 9
    #>   scenario    irr_equity npv_equity irr_project npv_project min_dscr
    #>   <chr>            <dbl>      <dbl>       <dbl>       <dbl>    <dbl>
    #> 1 all_equity       0.100   1353712.       0.100    1353712.   NA
    #> 2 debt_bullet      0.161   2625108.       0.100    1353712.    3.11
    #> 3 debt_amort       0.130   2165030.       0.100    1353712.    0.794
    #> # ℹ 3 more variables: max_ltv_forward <dbl>, ops_share <dbl>, tv_share <dbl>
    deal_cashflows(res, "full")
    #> # A tibble: 8 × 36
    #>    year      gei     noi   pbtcf net_operating_income capex  opex free_cash_flow
    #>   <int>    <dbl>   <dbl>   <dbl>                <dbl> <dbl> <dbl>          <dbl>
    #> 1     0       0       0       0                    0      0    0      -12000000
    #> 2     1  888000  883200  883200               888000      0 4800         883200
    #> 3     2  905760  900864  900864               905760      0 4896         900864
    #> 4     3  923875. 918881. 918881.              923875.     0 4994.        918881.
    #> 5     4  942353. 937259. 937259.              942353.     0 5094.        937259.
    #> 6     5  961200. 956004. 956004.              961200.     0 5196.        956004.
    #> 7     6  980424. 975124. 975124.              980424.     0 5300.        975124.
    #> 8     7 1000032. 994627. 994627.             1000032.     0 5406.      15561702.
    #> # ℹ 28 more variables: sale_proceeds <dbl>, discount_factor <dbl>,
    #> #   discounted_cash_flow <dbl>, asset_value <dbl>, acquisition_price <dbl>,
    #> #   discounted_cf <dbl>, debt_draw <dbl>, interest <dbl>, amortization <dbl>,
    #> #   payment <dbl>, arrangement_fee <dbl>, outstanding_debt <dbl>,
    #> #   loan_init <dbl>, df <dbl>, cf_pre_debt <dbl>, cf_post_debt <dbl>,
    #> #   equity_flow <dbl>, equity_disc <dbl>, noi_fwd <dbl>, value_forward <dbl>,
    #> #   dscr <dbl>, interest_cover_ratio <dbl>, debt_yield_init <dbl>, …

Use:

- `"full"` for the merged operating and debt cash flows
- `"all_equity"` for the unlevered table
- `"leveraged"` for the equity cash-flow view
- `"comparison"` for the summary by financing structure

## Three Common Input Styles

### Entry yield known

    deal_spec(price = 10e6, entry_yield = 0.055)
    #> <cre_deal_spec>
    #> price_di: 10000000.00
    #> asset: aggregated inputs (entry_yield)
    #> year-1: GEI NA | NOI 550,000.00 | PBTCF 550,000.00 | entry yield 5.50%
    #> horizon: 10 years
    #> income mode: entry yield 5.50%
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: bullet, LTV 55.0%, rate 4.50%

### NOI already known

    deal_spec(price = 10e6, noi_y1 = 550000)
    #> <cre_deal_spec>
    #> price_di: 10000000.00
    #> asset: aggregated inputs (noi_y1)
    #> year-1: GEI 550,000.00 | NOI 550,000.00 | PBTCF 550,000.00 | entry yield 5.50%
    #> horizon: 10 years
    #> income mode: NOI_y1 550000.00
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: bullet, LTV 55.0%, rate 4.50%

### Rent roll style input

    deal_spec(
      price = 10e6,
      rent_sqm = 220,
      area_sqm = 3000,
      vacancy_rate = 0.05,
      opex_sqm = 12
    )
    #> <cre_deal_spec>
    #> price_di: 10000000.00
    #> asset: 3,000.00 sqm | rent 220.00/sqm | vacancy 5.0% | opex 12.00/sqm | price 3,333.33/sqm
    #> year-1: GEI 627,000.00 | NOI 591,000.00 | PBTCF 591,000.00 | entry yield 5.91%
    #> horizon: 10 years
    #> income mode: 3000.00 sqm x 220.00 rent/sqm
    #> growth/discount: indexation 2.00% | discount rate 8.00%
    #> debt: bullet, LTV 55.0%, rate 4.50%

## Common Mistakes

- Do not provide more than one income mode.
- `price` is always the all-in acquisition price in the simplified API.
- If you use `rent_sqm + area_sqm`, the package derives year-1 NOI for you.
- If you want a quick first pass, start with `debt_terms()` defaults and only change `ltv`, `rate`, and `type`.

## When to move to the advanced API

Use the advanced API only if you need:

- YAML-based workflows,
- explicit lease-event structures,
- direct access to normalization helpers,
- custom scenario tooling built around `run_case()`.