Compute Share of Outside Good and Nest Shares

create_shares(df, market_id, mkt_share, outside_share = NULL,
  nest_id = NULL, subnest_id = NULL)

Arguments

df

Dataframe to work with

market_id

List of variables contaning market identifiers

mkt_share

Variable containing product market shares, as a character string.

outside_share

Variable outside shares, as a character string.

nest_id

Variable contaning first level nest, as a character string.

subnest_id

Variable contaning second level nest, as a character string.

Value

A dataframe with the outside- and nest-shares added.

Examples

# Add Outside Share and Nest Share for two Level Nest mkts <- create_markets(geog_id = "market_id", time_id = "year") df <- mkt_share_from_sales(eurocars, quantity = 'qty_sold', population = 'population') df2 <- create_shares(df, market_id = mkts, mkt_share = 'mkt_share', nest_id = 'class_id', subnest_id = 'domestic')
#> [1] "Creating Outside Share..." #> [1] "Done!" #> [1] "Working with two layers of nests..." #> [1] "Nest ID is: class_id" #> [1] "Sub-Nest ID is: domestic"
# Add Outside Share and Nest Share for One Level Nest mkts <- create_markets(geog_id = "market_id", time_id = "year") df <- mkt_share_from_sales(eurocars, quantity = 'qty_sold', population = 'population') df2 <- create_shares(df, market_id = mkts, mkt_share = 'mkt_share', nest_id = 'class_id')
#> [1] "Creating Outside Share..." #> [1] "Done!" #> [1] "Working with one layer of nests..." #> [1] "Nest ID is: class_id"
# Add Nest Share for two Level Nest when outside share already computed mkts <- create_markets(geog_id = "market_id", time_id = "year") df <- mkt_share_from_sales(eurocars, quantity = 'qty_sold', population = 'population') df2 <- compute_outside_share(df, mkt_share = 'mkt_share', market_id = mkts) df3 <- create_shares(df2, market_id = mkts, mkt_share = 'mkt_share', outside_share = 'outside_share', nest_id = 'class_id')
#> [1] "Working with one layer of nests..." #> [1] "Nest ID is: class_id"