Package 'perfinr'

Title: Personal Finance Calculations for the Field Manual
Description: Small, tested functions for the calculations in the personal finance field manual: budgeting, savings, emergency funds, debt payoff, loans and mortgages, investing, retirement accounts, insurance, and federal income taxes.
Authors: Martin Frigaard [aut, cre]
Maintainer: Martin Frigaard <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9001
Built: 2026-12-04 20:13:10 UTC
Source: https://github.com/mjfrigaard/perfinr

Help Index


After tax value of a retirement contribution

Description

Taxes the contribution once at tax_rate (today for a Roth, in retirement for a traditional account) and grows it at rate. From the Retirement accounts chapter.

Usage

after_tax_value(contribution, tax_rate, rate, years)

Arguments

contribution

Amount contributed.

tax_rate

Tax rate applied, as a decimal.

rate

Yearly return, as a decimal.

years

Number of years.

Value

A numeric vector of after tax values.

See Also

Other retirement accounts: employer_match()

Examples

# Roth: taxed at today's 12% rate
after_tax_value(contribution = 1000, tax_rate = 0.12, rate = 0.07, years = 40)

# Traditional: taxed at a 22% rate in retirement
after_tax_value(contribution = 1000, tax_rate = 0.22, rate = 0.07, years = 40)

Categorize transactions with keyword rules

Description

Matches each rule's Pattern (a regular expression, case ignored) against the transaction Description. The first matching rule wins; unmatched rows get "Other". From the Tracking spending chapter.

Usage

apply_rules(df, rules)

Arguments

df

A data frame of transactions with a character Description column.

rules

A data frame with character Pattern and Category columns, in priority order.

Value

df with a Category column added (or replaced).

See Also

Other tracking spending: subscription_opportunity_cost()

Examples

transactions <- data.frame(
  Description = c("SAFEWAY #123", "NETFLIX.COM", "SHELL OIL", "ATM FEE")
)
rules <- data.frame(
  Pattern = c("safeway|trader joe", "netflix|spotify", "shell|chevron"),
  Category = c("Groceries", "Subscriptions", "Gas")
)
apply_rules(transactions, rules)

Convert an APR to an APY

Description

The effective yearly rate of an annual percentage rate (APR) compounded periods_per_year times. From the Managing debt chapter.

Usage

apr_to_apy(apr, periods_per_year = 365)

Arguments

apr

Annual percentage rate, as a decimal.

periods_per_year

Compounding periods per year. Defaults to 365 (daily, as most credit cards compound). Must be greater than 0.

Value

A numeric vector of APYs, as decimals.

See Also

Other managing debt: credit_utilization(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

# 24% APR compounded daily
apr_to_apy(apr = 0.24)

Share of assets with a named beneficiary

Description

From the Estate planning chapter.

Usage

beneficiary_share(with_beneficiary, without_beneficiary)

Arguments

with_beneficiary

Numeric vector of asset values that name a beneficiary (or pay on death).

without_beneficiary

Numeric vector of asset values that do not.

Value

A single number between 0 and 1.

See Also

Other estate planning: net_worth()

Examples

with_beneficiary <- c(k401 = 12000, roth_ira = 6000, life_insurance = 45000, savings_pod = 8000)
without_beneficiary <- c(car = 9000)
beneficiary_share(with_beneficiary, without_beneficiary)

Years for a higher deductible to pay off

Description

The extra deductible risk divided by the yearly premium savings. From the Insurance chapter.

Usage

break_even_years(high_deductible, low_deductible, yearly_savings)

Arguments

high_deductible

The higher deductible.

low_deductible

The lower deductible.

yearly_savings

Yearly premium savings from the higher deductible. Must be greater than 0.

Value

A numeric vector of years (not rounded).

See Also

Other insurance: plan_cost()

Examples

# $1,000 vs. $500 deductible, saving $150 a year
break_even_years(high_deductible = 1000, low_deductible = 500, yearly_savings = 150)

Credit utilization

Description

Card balance as a percent of the credit limit. From the Managing debt chapter.

Usage

credit_utilization(balance, credit_limit)

Arguments

balance

Card balance.

credit_limit

Credit limit. Must be greater than 0.

Value

A numeric vector of percentages.

See Also

Other managing debt: apr_to_apy(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

# $900 balance on a $3,000 limit
credit_utilization(balance = 900, credit_limit = 3000)

Debt to income (DTI) ratio

Description

Monthly debt payments as a percent of gross monthly income. From the Managing debt chapter.

Usage

dti_ratio(monthly_debt_payments, gross_monthly_income)

Arguments

monthly_debt_payments

Total monthly debt payments.

gross_monthly_income

Gross (before tax) monthly income. Must be greater than 0.

Value

A numeric vector of percentages.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

# $1,061 in debt payments on $3,750 gross income
dti_ratio(monthly_debt_payments = 1061, gross_monthly_income = 3750)

Emergency fund balance after interest

Description

Compounds a balance monthly at annual_rate / 12 for a number of months. From the Emergency fund chapter.

Usage

ef_growth(balance, annual_rate, months)

Arguments

balance

Starting balance.

annual_rate

Annual interest rate, as a decimal.

months

Number of months.

Value

A numeric vector of balances.

See Also

Other emergency fund: emergency_fund_target(), monthly_contribution_needed(), months_to_ef_goal()

Examples

# $9,600 at a 4% annual rate for 12 months
ef_growth(balance = 9600, annual_rate = 0.04, months = 12)

Emergency fund target

Description

Monthly essential expenses times the number of months to cover. From the Emergency fund chapter.

Usage

emergency_fund_target(monthly_expenses, months = 3)

Arguments

monthly_expenses

Essential expenses per month.

months

Months of expenses to cover. Defaults to 3.

Value

A numeric vector of target balances.

See Also

Other emergency fund: ef_growth(), monthly_contribution_needed(), months_to_ef_goal()

Examples

# $2,400/month in essential expenses, 3-month and 6-month targets
emergency_fund_target(monthly_expenses = 2400, months = 3)
emergency_fund_target(monthly_expenses = 2400, months = 6)

Yearly employer retirement match

Description

The employer matches match_rate of contributions up to match_limit_pct of salary. From the Retirement accounts chapter.

Usage

employer_match(salary, contribution_pct, match_limit_pct, match_rate)

Arguments

salary

Yearly salary.

contribution_pct

Share of salary you contribute, as a decimal.

match_limit_pct

Share of salary the employer will match, as a decimal.

match_rate

Employer match per dollar contributed, as a decimal (0.5 is 50 cents per dollar).

Value

A numeric vector of yearly match amounts.

See Also

Other retirement accounts: after_tax_value()

Examples

# $45,000 salary, 6% contribution, 50% match on the first 6%
employer_match(salary = 45000, contribution_pct = 0.06,
               match_limit_pct = 0.06, match_rate = 0.50)

# same job, but only contributing 3%
employer_match(salary = 45000, contribution_pct = 0.03,
               match_limit_pct = 0.06, match_rate = 0.50)

Interest and principal in the first loan payment

Description

From the Major purchases chapter.

Usage

first_payment_split(principal, annual_rate, years)

Arguments

principal

Loan amount (a single number).

annual_rate

Yearly interest rate, as a decimal (a single number).

years

Loan term in years (a single number).

Value

A one row data frame with columns payment, interest, principal, and pct_interest (the percent of the payment that is interest).

See Also

Other major purchases: mortgage_payment(), rent_buy_threshold()

Examples

# first payment on a $480,000 loan at 6% over 30 years
first_payment_split(principal = 480000, annual_rate = 0.06, years = 30)

Fixed costs as a percent of take home pay

Description

From the Income chapter.

Usage

fixed_cost_ratio(fixed_costs, take_home)

Arguments

fixed_costs

Monthly fixed costs (rent, insurance, loan payments).

take_home

Monthly take home pay. Must be greater than 0.

Value

A numeric vector of percentages.

See Also

Other income: pay_frequency_from_days(), pay_period_days(), pay_period_full_time_hours(), pay_periods_per_year(), raise_invested_value(), wealth_formula()

Examples

fixed_cost_ratio(fixed_costs = 1800, take_home = 3200)

Future value of a one time investment

Description

Compounds present_value once per year. From the Investing basics chapter.

Usage

future_value(present_value, rate, years)

Arguments

present_value

Amount invested today.

rate

Yearly return, as a decimal.

years

Number of years.

Value

A numeric vector of future values.

See Also

Other investing basics: future_value_series(), real_return(), rule_of_72()

Examples

# $10,000 at 7% for 10 years
future_value(present_value = 10000, rate = 0.07, years = 10)

# same $10,000 across several horizons
future_value(present_value = 10000, rate = 0.07, years = c(5, 10, 20, 30))

Future value of monthly contributions after fund fees

Description

Subtracts the expense ratio from the yearly return, then compounds monthly contributions. From the Index funds chapter.

Usage

future_value_after_fees(contribution, annual_return, expense_ratio, years)

Arguments

contribution

Monthly contribution.

annual_return

Yearly return before fees, as a decimal.

expense_ratio

Yearly expense ratio, as a decimal.

years

Number of years.

Value

A numeric vector of ending balances.

See Also

Other index funds: yearly_fee()

Examples

# $300/month for 40 years at 7%, index fund vs. active fund
index_fund <- future_value_after_fees(300, 0.07, 0.0004, 40)
active_fund <- future_value_after_fees(300, 0.07, 0.01, 40)
index_fund - active_fund

Future value of a series of equal contributions

Description

Contributions are made at the end of each period. rate is the rate per period, so use 0.07 / 12 for monthly contributions at 7% a year. At a 0% rate this is contribution * periods. From the Investing basics chapter.

Usage

future_value_series(contribution, rate, periods)

Arguments

contribution

Amount contributed each period.

rate

Return per period, as a decimal.

periods

Number of periods.

Value

A numeric vector of ending balances.

See Also

Other investing basics: future_value(), real_return(), rule_of_72()

Examples

# $500/month for 30 years at 7% a year
future_value_series(contribution = 500, rate = 0.07 / 12, periods = 30 * 12)

High yield savings account balance

Description

Grows a principal at an annual percentage yield (APY). From the High yield accounts chapter.

Usage

hysa_balance(principal, annual_apy, years = 1)

Arguments

principal

Starting balance.

annual_apy

Annual percentage yield, as a decimal.

years

Number of years. Defaults to 1.

Value

A numeric vector of balances.

Examples

# $9,600 at 4% APY after 1 year, then after 5 years
hysa_balance(principal = 9600, annual_apy = 0.04, years = 1)
hysa_balance(principal = 9600, annual_apy = 0.04, years = 5)

Income driven repayment (IDR) monthly payment

Description

Discretionary income is adjusted gross income (AGI) above threshold_pct times the poverty guideline. The yearly payment is payment_rate of that, split into 12 months and rounded to cents. From the Managing debt chapter.

Usage

idr_monthly_payment(
  agi,
  poverty_guideline = 15960,
  threshold_pct = 1.5,
  payment_rate = 0.1
)

Arguments

agi

Adjusted gross income.

poverty_guideline

Federal poverty guideline for the household size. Defaults to 15960 (one person).

threshold_pct

Multiple of the poverty guideline that is protected. Defaults to 1.5 (150%).

payment_rate

Share of discretionary income paid each year. Defaults to 0.10.

Value

A numeric vector of monthly payments.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

# IBR: $50,000 AGI, 150% threshold, 10% rate
idr_monthly_payment(agi = 50000)

# IBR for loans before July 2014: 15% rate
idr_monthly_payment(agi = 50000, payment_rate = 0.15)

Federal income tax for a single filer

Description

Applies the 2026 federal brackets for single filers to income after the standard deduction. From the Taxes chapter.

Usage

income_tax(income, deduction = 16100)

Arguments

income

Gross yearly income (a single number).

deduction

Deduction subtracted before the brackets apply. Defaults to the 2026 standard deduction, 16100.

Value

A single number: the yearly federal income tax.

See Also

Other taxes: raise_kept()

Examples

# 2026 federal income tax on a $45,000 salary
tax <- income_tax(income = 45000)
tax

# effective rate
tax / 45000

Student loan total relative to expected salary

Description

A ratio above 1 means you owe more than a year of starting pay. From the Managing debt chapter.

Usage

loan_income_ratio(loan_total, expected_salary)

Arguments

loan_total

Total student loan balance.

expected_salary

Expected yearly starting salary. Must be greater than 0.

Value

A numeric vector of ratios.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), idr_monthly_payment(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

# $45,000 in loans, $42,000 expected starting salary
loan_income_ratio(loan_total = 45000, expected_salary = 42000)

Monthly contribution needed to reach a target by a deadline

Description

Rounds up to whole dollars and returns 0 when the target is already met. From the Emergency fund chapter.

Usage

monthly_contribution_needed(target, current_balance, months)

Arguments

target

Target balance.

current_balance

Amount already saved.

months

Months until the deadline. Must be greater than 0.

Value

A numeric vector of whole dollar monthly contributions.

See Also

Other emergency fund: ef_growth(), emergency_fund_target(), months_to_ef_goal()

Examples

# $9,600 target, $1,200 saved, want to finish in 18 months
monthly_contribution_needed(target = 9600, current_balance = 1200, months = 18)

Monthly deposit needed to reach a savings goal

Description

The level monthly deposit that grows to goal in months at annual_rate, compounded monthly. At a 0% rate this is goal / months. From the Financial goals chapter.

Usage

monthly_for_goal(goal, annual_rate, months)

Arguments

goal

Target amount.

annual_rate

Yearly interest rate, as a decimal.

months

Number of monthly deposits. Must be greater than 0.

Value

A numeric vector of monthly deposits.

See Also

Other financial goals: months_to_fund()

Examples

# $15,000 in 5 years at 4%, compared to no interest
monthly_for_goal(goal = 15000, annual_rate = 0.04, months = 60)
monthly_for_goal(goal = 15000, annual_rate = 0, months = 60)

Monthly savings at a given savings rate

Description

The "pay yourself first" amount: gross monthly income times the savings rate. From the Automating savings chapter.

Usage

monthly_savings(gross_monthly_income, savings_rate)

Arguments

gross_monthly_income

Gross (before tax) monthly income.

savings_rate

Share of income to save, as a decimal.

Value

A numeric vector of monthly savings amounts.

Examples

# $4,000 gross monthly income, 20% savings rate
monthly_savings(gross_monthly_income = 4000, savings_rate = 0.20)

Monthly payment on a standard student loan plan

Description

mortgage_payment() with federal student loan defaults: 6.5% over 10 years. From the Managing debt chapter.

Usage

monthly_standard_payment(principal, annual_rate = 0.065, years = 10)

Arguments

principal

Loan amount.

annual_rate

Yearly interest rate, as a decimal. Defaults to 0.065.

years

Repayment term in years. Defaults to 10.

Value

A numeric vector of monthly payments.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), months_to_payoff(), order_avalanche(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

# standard 10-year monthly payment on $45,000
monthly_standard_payment(principal = 45000)

Months until an upfront cost pays for itself

Description

From the Budgeting chapter.

Usage

months_to_break_even(upfront_cost, monthly_savings)

Arguments

upfront_cost

One time cost.

monthly_savings

Amount saved each month because of the purchase. Must be greater than 0.

Value

A numeric vector of months (not rounded).

See Also

Other budgeting: opportunity_cost(), percent_of_income(), to_annual(), to_monthly()

Examples

# $600 upfront to save $50 a month
months_to_break_even(upfront_cost = 600, monthly_savings = 50)

Months to reach an emergency fund target

Description

Rounds up to whole months and returns 0 when the target is already met. From the Emergency fund chapter.

Usage

months_to_ef_goal(target, current_balance, monthly_contribution)

Arguments

target

Target balance.

current_balance

Amount already saved.

monthly_contribution

Amount added each month. Must be greater than 0.

Value

A numeric vector of whole months.

See Also

Other emergency fund: ef_growth(), emergency_fund_target(), monthly_contribution_needed()

Examples

# $9,600 target, $1,200 saved, $400/month contribution
months_to_ef_goal(target = 9600, current_balance = 1200, monthly_contribution = 400)

Months to fund a goal with a fixed monthly amount

Description

Rounds up to whole months and ignores interest. From the Financial goals chapter.

Usage

months_to_fund(goal, monthly)

Arguments

goal

Target amount.

monthly

Amount set aside each month. Must be greater than 0.

Value

A numeric vector of whole months.

See Also

Other financial goals: monthly_for_goal()

Examples

# one at a time: trip first, then car
months_to_fund(3000, 600)
months_to_fund(3000 + 9000, 600)

Months to pay off a balance with a fixed payment

Description

Interest compounds monthly at apr / 12. The result is not rounded; the last payment is a partial one. Errors when the payment does not cover the first month's interest, because the balance would never be paid off. From the Managing debt chapter.

Usage

months_to_payoff(balance, monthly_payment, apr)

Arguments

balance

Current balance. Must be greater than 0.

monthly_payment

Fixed monthly payment. Must be greater than 0.

apr

Annual percentage rate, as a decimal.

Value

A numeric vector of months.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), order_avalanche(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

# $5,000 balance, $100/month, 22% APR
months_to_payoff(balance = 5000, monthly_payment = 100, apr = 0.22)

Monthly payment on a fixed rate loan

Description

The standard amortization formula with monthly compounding. At a 0% rate this is principal / (years * 12). From the Major purchases chapter.

Usage

mortgage_payment(principal, annual_rate, years)

Arguments

principal

Loan amount.

annual_rate

Yearly interest rate, as a decimal.

years

Loan term in years. Must be greater than 0.

Value

A numeric vector of monthly payments.

See Also

Other major purchases: first_payment_split(), rent_buy_threshold()

Examples

# $480,000 loan at 6% over 30 years
mortgage_payment(principal = 480000, annual_rate = 0.06, years = 30)

Net worth

Description

Total assets minus total debts. From the Estate planning chapter.

Usage

net_worth(assets, debts)

Arguments

assets

Numeric vector of asset values.

debts

Numeric vector of debt balances.

Value

A single number.

See Also

Other estate planning: beneficiary_share()

Examples

assets <- c(k401 = 12000, roth_ira = 6000, savings = 8000, car = 9000)
debts <- c(car_loan = 6000, credit_card = 1000)
net_worth(assets, debts)

What money spent today could grow to

Description

The future value of a one time amount if it were invested instead of spent. From the Budgeting chapter.

Usage

opportunity_cost(amount, rate, years)

Arguments

amount

Amount spent today.

rate

Yearly return, as a decimal.

years

Number of years.

Value

A numeric vector of future values.

See Also

Other budgeting: months_to_break_even(), percent_of_income(), to_annual(), to_monthly()

Examples

# $1,000 invested at 7% for 30 years
opportunity_cost(amount = 1000, rate = 0.07, years = 30)

Order debts for the avalanche method

Description

Highest APR first. From the Managing debt chapter.

Usage

order_avalanche(debts)

Arguments

debts

A data frame with a numeric apr column.

Value

debts, reordered by apr from highest to lowest.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_snowball(), payoff_vs_invest(), total_interest()

Examples

debts <- data.frame(
  name = c("Card A", "Card B", "Card C"),
  balance = c(1000, 5000, 2000),
  apr = c(0.18, 0.24, 0.15)
)
order_avalanche(debts)

Order debts for the snowball method

Description

Smallest balance first. From the Managing debt chapter.

Usage

order_snowball(debts)

Arguments

debts

A data frame with a numeric balance column.

Value

debts, reordered by balance from smallest to largest.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), payoff_vs_invest(), total_interest()

Examples

debts <- data.frame(
  name = c("Card A", "Card B", "Card C"),
  balance = c(1000, 5000, 2000),
  apr = c(0.18, 0.24, 0.15)
)
order_snowball(debts)

The pay frequency for a period length in days

Description

The inverse of pay_period_days(). Each frequency has its own day count, so the match is never ambiguous.

Usage

pay_frequency_from_days(days)

Arguments

days

A day count, as pay_period_days() returns.

Value

The frequency, or NA_character_ when days is NA or matches none.

See Also

Other income: fixed_cost_ratio(), pay_period_days(), pay_period_full_time_hours(), pay_periods_per_year(), raise_invested_value(), wealth_formula()

Examples

pay_frequency_from_days(14)
pay_frequency_from_days(10)

Days in one pay period

Description

The nominal length of a pay period, for display. "semimonthly" (15) and "monthly" (30) are round numbers, so don't annualize with them; use pay_periods_per_year() instead.

Usage

pay_period_days(frequency)

Arguments

frequency

One of "weekly", "biweekly", "semimonthly", or "monthly".

Value

A number of days: 7, 14, 15, or 30.

See Also

Other income: fixed_cost_ratio(), pay_frequency_from_days(), pay_period_full_time_hours(), pay_periods_per_year(), raise_invested_value(), wealth_formula()

Examples

pay_period_days("biweekly")

Full-time hours in one pay period

Description

Assumes a 40-hour week, so the result depends on the frequency alone.

Usage

pay_period_full_time_hours(frequency)

Arguments

frequency

One of "weekly", "biweekly", "semimonthly", or "monthly".

Value

Hours: 40, 80, about 85.7, or about 171.4.

See Also

Other income: fixed_cost_ratio(), pay_frequency_from_days(), pay_period_days(), pay_periods_per_year(), raise_invested_value(), wealth_formula()

Examples

pay_period_full_time_hours("biweekly")

Paychecks in a year for a pay frequency

Description

A biweekly schedule pays 26 times a year, not 24, so two months a year bring a third paycheck. Use this count, not 365 / pay_period_days(), to turn one paycheck into a yearly figure.

Usage

pay_periods_per_year(frequency)

Arguments

frequency

One of "weekly", "biweekly", "semimonthly", or "monthly".

Value

An integer number of pay periods.

See Also

Other income: fixed_cost_ratio(), pay_frequency_from_days(), pay_period_days(), pay_period_full_time_hours(), raise_invested_value(), wealth_formula()

Examples

pay_periods_per_year("biweekly")
2500 * pay_periods_per_year("biweekly") # a year of $2,500 paychecks

Pay off a loan or invest the difference

Description

Compares a loan's interest rate to an expected investment return. From the Managing debt chapter.

Usage

payoff_vs_invest(loan_rate, expected_return)

Arguments

loan_rate

Loan interest rate, as a decimal (a single number).

expected_return

Expected yearly return, as a decimal (a single number).

Value

A single string: "Pay off the debt", "Invest the difference", or "Roughly a wash; do both".

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), order_snowball(), total_interest()

Examples

# 5% student loan vs. expected 7% return
payoff_vs_invest(loan_rate = 0.05, expected_return = 0.07)

Expense as a percent of income

Description

From the Budgeting chapter.

Usage

percent_of_income(expense, income)

Arguments

expense

Expense amount.

income

Income for the same period as expense. Must be greater than 0.

Value

A numeric vector of percentages (30 is 30%).

See Also

Other budgeting: months_to_break_even(), opportunity_cost(), to_annual(), to_monthly()

Examples

percent_of_income(expense = 1500, income = 5000)

Total yearly cost of a health plan

Description

Premiums for the year plus medical costs (capped at the out of pocket maximum), minus any employer HSA contribution. From the Insurance chapter.

Usage

plan_cost(monthly_premium, medical_cost, oop_max, employer_hsa = 0)

Arguments

monthly_premium

Monthly premium.

medical_cost

Medical costs for the year. Use Inf for a worst case year.

oop_max

Out of pocket maximum.

employer_hsa

Employer HSA contribution. Defaults to 0.

Value

A numeric vector of yearly costs.

See Also

Other insurance: break_even_years()

Examples

# Plan A vs. Plan B in a healthy year ($300 of care) and the worst year
plan_cost(100, c(300, Inf), oop_max = 3000)
plan_cost(40, c(300, Inf), oop_max = 5000, employer_hsa = 500)

Blended return of a stock and bond portfolio

Description

Weights the stock and bond returns by the share of the portfolio held in stocks. From the Asset allocation chapter.

Usage

portfolio_return(stock_pct, stock_return, bond_return)

Arguments

stock_pct

Share of the portfolio in stocks, as a decimal (0.8 is 80%). The rest is in bonds.

stock_return

Stock return for the period, as a decimal.

bond_return

Bond return for the period, as a decimal.

Value

A numeric vector of portfolio returns, as decimals.

See Also

Other asset allocation: rebalance_amount()

Examples

# 100/0, 80/20, and 60/40 in an average year and a bad year
splits <- c(1, 0.8, 0.6)
portfolio_return(splits, stock_return = 0.10, bond_return = 0.04)
portfolio_return(splits, stock_return = -0.40, bond_return = 0)

Future value of investing part of a raise

Description

Invests monthly_raise * invest_share every month, compounded monthly. From the Income chapter.

Usage

raise_invested_value(monthly_raise, invest_share, rate, years)

Arguments

monthly_raise

Monthly increase in take home pay.

invest_share

Share of the raise invested, as a decimal.

rate

Yearly return, as a decimal.

years

Number of years.

Value

A numeric vector of ending balances.

See Also

Other income: fixed_cost_ratio(), pay_frequency_from_days(), pay_period_days(), pay_period_full_time_hours(), pay_periods_per_year(), wealth_formula()

Examples

# invest half of a $200/month raise at 7% for 30 years
raise_invested_value(200, invest_share = 0.5, rate = 0.07, years = 30)

Part of a raise kept after federal income tax

Description

The raise minus the extra tax it causes, using income_tax(). From the Taxes chapter.

Usage

raise_kept(old_income, raise)

Arguments

old_income

Yearly income before the raise (a single number).

raise

Yearly raise amount (a single number).

Value

A single number: the raise after federal income tax.

See Also

Other taxes: income_tax()

Examples

# $2,000 raise on a $66,000 salary
raise_kept(old_income = 66000, raise = 2000)

Return after inflation

Description

The exact (Fisher) real return. From the Investing basics chapter.

Usage

real_return(nominal, inflation)

Arguments

nominal

Nominal yearly return, as a decimal.

inflation

Yearly inflation rate, as a decimal.

Value

A numeric vector of real returns, as decimals.

See Also

Other investing basics: future_value(), future_value_series(), rule_of_72()

Examples

# 7% nominal return against 3% inflation
real_return(nominal = 0.07, inflation = 0.03)

Amount to move to get back to a target allocation

Description

The difference between the target dollar amount for an asset class and the amount currently held. From the Asset allocation chapter.

Usage

rebalance_amount(target_pct, total, current_amount)

Arguments

target_pct

Target share of the portfolio, as a decimal.

total

Total portfolio value.

current_amount

Current value held in the asset class.

Value

A numeric vector. Positive values are amounts to buy; negative values are amounts to sell.

See Also

Other asset allocation: portfolio_return()

Examples

# $5,600 in stocks and $2,000 in bonds after a 30% stock drop
rebalance_amount(target_pct = 0.80, total = 5600 + 2000, current_amount = 5600)

Monthly rent that matches the unrecoverable cost of owning

Description

The 5% rule: yearly unrecoverable costs of owning (property tax, maintenance, cost of capital) are about 5% of the home value. Rent below this monthly amount favors renting. From the Major purchases chapter.

Usage

rent_buy_threshold(home_value, unrecoverable_rate = 0.05)

Arguments

home_value

Price of the home.

unrecoverable_rate

Yearly unrecoverable cost as a share of home value. Defaults to 0.05.

Value

A numeric vector of monthly rent thresholds.

See Also

Other major purchases: first_payment_split(), mortgage_payment()

Examples

# $500,000 home at the standard 5% rate
rent_buy_threshold(home_value = 500000)

Years for money to double (rule of 72)

Description

A quick estimate: 72 divided by the yearly return in percent. From the Investing basics chapter.

Usage

rule_of_72(annual_return_pct)

Arguments

annual_return_pct

Yearly return as a percent (7 is 7%), not a decimal. Must be greater than 0.

Value

A numeric vector of years.

See Also

Other investing basics: future_value(), future_value_series(), real_return()

Examples

rule_of_72(annual_return_pct = 7)

Savings rate

Description

Income left after spending, as a percent of income. From the Savings strategies chapter.

Usage

savings_rate(income, spending)

Arguments

income

Income for the period. Must be greater than 0.

spending

Spending for the same period.

Value

A numeric vector of percentages.

Examples

# $3,200 take home, $2,720 spent
savings_rate(income = 3200, spending = 2720)

What a subscription would grow to if invested instead

Description

Invests the yearly cost of a subscription at the end of each year. From the Tracking spending chapter.

Usage

subscription_opportunity_cost(monthly_cost, years, rate = 0.07)

Arguments

monthly_cost

Monthly subscription cost.

years

Number of years.

rate

Yearly return, as a decimal. Defaults to 0.07.

Value

A numeric vector of ending balances.

See Also

Other tracking spending: apply_rules()

Examples

# a $15/month subscription over 30 years
subscription_opportunity_cost(monthly_cost = 15, years = 30)

Convert a daily, weekly, or monthly amount to a yearly amount

Description

Uses 365 days, 52 weeks, and 12 months per year. From the Budgeting chapter.

Usage

to_annual(amount, period = c("daily", "weekly", "monthly"))

Arguments

amount

Amount per period.

period

One of "daily", "weekly", or "monthly".

Value

A numeric vector of yearly amounts.

See Also

Other budgeting: months_to_break_even(), opportunity_cost(), percent_of_income(), to_monthly()

Examples

to_annual(5, period = "daily")
to_annual(1500, period = "monthly")

Convert a daily, weekly, or yearly amount to a monthly amount

Description

Uses 30.44 days and 4.33 weeks per month. From the Budgeting chapter.

Usage

to_monthly(amount, period = c("daily", "weekly", "annual"))

Arguments

amount

Amount per period.

period

One of "daily", "weekly", or "annual".

Value

A numeric vector of monthly amounts.

See Also

Other budgeting: months_to_break_even(), opportunity_cost(), percent_of_income(), to_annual()

Examples

to_monthly(5, period = "daily")
to_monthly(60000, period = "annual")

Total interest paid over a loan

Description

All payments minus the amount borrowed. From the Managing debt chapter.

Usage

total_interest(monthly_payment, n_months, principal)

Arguments

monthly_payment

Monthly payment.

n_months

Number of payments.

principal

Amount borrowed.

Value

A numeric vector of total interest.

See Also

Other managing debt: apr_to_apy(), credit_utilization(), dti_ratio(), idr_monthly_payment(), loan_income_ratio(), monthly_standard_payment(), months_to_payoff(), order_avalanche(), order_snowball(), payoff_vs_invest()

Examples

# 6-year car loan vs. 4-year, $20,000 principal at 7%
total_interest(monthly_payment = 340.98, n_months = 72, principal = 20000)
total_interest(monthly_payment = 478.92, n_months = 48, principal = 20000)

Wealth from saving part of an income every year

Description

The future value of saving median_income * savings_rate at the end of each year (contributions plus growth). From the Income chapter.

Usage

wealth_formula(median_income, savings_rate, annual_return, years)

Arguments

median_income

Yearly income.

savings_rate

Share of income saved, as a decimal.

annual_return

Yearly return, as a decimal.

years

Number of years.

Value

A numeric vector of ending balances.

See Also

Other income: fixed_cost_ratio(), pay_frequency_from_days(), pay_period_days(), pay_period_full_time_hours(), pay_periods_per_year(), raise_invested_value()

Examples

# $45,000 income, 20% saved, 7% return, 30 years
wealth_formula(45000, savings_rate = 0.20, annual_return = 0.07, years = 30)

Yearly fund fee

Description

Balance times the fund's expense ratio. From the Index funds chapter.

Usage

yearly_fee(balance, expense_ratio)

Arguments

balance

Amount invested.

expense_ratio

Yearly expense ratio, as a decimal (0.0004 is 0.04%).

Value

A numeric vector of yearly fees.

See Also

Other index funds: future_value_after_fees()

Examples

# $10,000 in an index fund vs. an active fund
yearly_fee(balance = 10000, expense_ratio = c(0.0004, 0.01))