create_shares: Compute Share of Outside Good and Nest Shares

Description Usage Arguments Value Examples

View source: R/create_shares.R

Description

Compute Share of Outside Good and Nest Shares

Usage

1
2
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

 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')

lachlandeer/demandr documentation built on May 21, 2019, 12:04 p.m.