Description Usage Arguments Value Examples
View source: R/create_shares.R
Compute Share of Outside Good and Nest Shares
1 2 | create_shares(df, market_id, mkt_share, outside_share = NULL,
nest_id = NULL, subnest_id = NULL)
|
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. |
A dataframe with the outside- and nest-shares added.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # 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')
# 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')
# 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')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.