ffp_opt_anlyz_rhgin_bin: Theorem 1, Binary Optimal Allocation solution, loop along a...

Description Usage Arguments Value Author(s) References Examples

View source: R/ffp_opt_anlyz.R

Description

Works with binary allocation problems. The function invokes ffp_opt_sobin_target_row. The example tests think of as bottled protein.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ffp_opt_anlyz_rhgin_bin(
  df,
  svr_id_i,
  svr_A_i = "A",
  svr_alpha_i = "alpha",
  svr_beta_i = "beta",
  ar_rho = c(0.5, 0.1, -1, -20),
  svr_rho = "rho",
  svr_rho_val = "rho_val",
  svr_inpalc = "rank",
  svr_expout = "opti_exp_outcome",
  verbose = FALSE
)

Arguments

df

tibble data table including variables using svr names below each row is potentially an individual who will receive alternative allocations

svr_id_i

string name of the identify key for each i, to make sure merging happens properly

svr_A_i

string name of the A_i variable, dot product of covariates and coefficients

svr_alpha_i

string name of the alpha_i variable, individual specific elasticity information

svr_beta_i

string name of the beta_i variable, relative preference weight for each child

ar_rho

array preferences for equality for the planner, each value from negative infinity to 1

svr_rho

string variable name for the index planner inequality aversion variable, initially rho, then called rho, this is the index variable, index for each one of the rho values

svr_rho_val

string variable name for the value of the planner inequality aversion variable

svr_inpalc

string variable name for newly generated input optimal allocation

svr_expout

string variable name for newly generated expected outcome

verbose

boolean print out intermediary function outputs

Value

a list with a dataframe and an array

Author(s)

Fan Wang, http://fanwangecon.github.io

References

https://fanwangecon.github.io/PrjOptiAlloc/reference/ffp_opt_anlyz_rhgin_bin.html https://fanwangecon.github.io/PrjOptiAlloc/articles/ffv_opt_sobin_rkone_allrw_car.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(dplyr)
data(df_opt_dtgch_cbem4)
df <- df_opt_dtgch_cbem4
svr_id_i <- 'indi.id'
svr_A_i <- 'A_lin'
svr_alpha_i <- 'alpha_lin'
svr_beta_i <- 'beta'
ar_rho = c(-50, -10, -0.1, 0.1, 0.5, 0.7)
ls_bin_solu_all_rhos <- ffp_opt_anlyz_rhgin_bin(df, svr_id_i, svr_A_i, svr_alpha_i, svr_beta_i, ar_rho)
df_all_rho <- ls_bin_solu_all_rhos$df_all_rho
head(df_all_rho %>% select(svr_id_i, svr_A_i, svr_alpha_i, starts_with("rho")), 30)
head(df_all_rho, 15)
summary(df_all_rho)
df_all_rho_long <- ls_bin_solu_all_rhos$df_all_rho_long
head(df_all_rho_long, 15)
summary(df_all_rho_long)

FanWangEcon/PrjOptiAlloc documentation built on Jan. 25, 2022, 6:55 a.m.