Learn R Programming

StablePopulation (version 1.0.3)

alpha_objective: Objective Function for uniroot: Finds the Difference Between Births and 1

Description

This function calculates the difference between the number of births, as calculated with the given values of alpha, beta, and fertility_rates, and the target value of 1.

Usage

alpha_objective(alpha, beta, fertility_rates)

Value

A numeric value giving the difference between the number of births (as calculated) and 1.

Arguments

alpha

A numeric value representing the alpha parameter.

beta

A numeric value representing the beta parameter.

fertility_rates

A numeric vector containing the fertility rates.

Details

Typically used as the objective function in root-finding algorithms such as uniroot, to determine the value of alpha that results in exactly one birth.

This function depends on calculate_population, which must be available in your package namespace.

See Also

Examples

Run this code
# Basic usage
alpha_objective(0.5, 1.2, c(0.2, 0.3, 0.5, 0.4))

# Example with uniroot:
fertility_rates <- c(0.2, 0.3, 0.5, 0.4)
beta <- 1.2
res <- uniroot(
  alpha_objective,
  interval = c(0.000001, 100),
  beta = beta,
  fertility_rates = fertility_rates
)
res$root

Run the code above in your browser using DataLab