creativity  v1.3.0
Agent-based model of creativity and piracy
Public Member Functions | Static Public Member Functions | List of all members
creativity::belief::Demand Class Reference

This class represents an author's belief about the per-period demand for books. More...

#include <creativity/belief/Demand.hpp>

Public Member Functions

 Demand ()
 Default constructor: note that unlike a default-constructed BayesianLinear model, this default constructed object is a usable (but noninformative) model. More...
 
template<typename ... Args>
 Demand (Args &&...args)
 Constructs a demand model with the given prior information. More...
 
virtual unsigned int fixedModelSize () const override
 This model always has exactly parameters() parameters.
 
double predict (unsigned int draws, double P, double q, unsigned int S, unsigned int nosales, unsigned int age, unsigned int otherBooks, unsigned int lag_marketBooks)
 Given a set of model parameters, this returns an expected value \(Q_b\), the number of sales. More...
 
std::pair< double, double > argmaxP (unsigned int draws, double q, unsigned int s, unsigned int z, unsigned int n, unsigned int nosales, unsigned int age, unsigned int otherBooks, unsigned int marketBooks, double c, double max_price)
 Given a set of model parameters (other than \(P_b\)) and a per-unit cost this returns the \(P_b\) value that maximizes expected total profits: More...
 
virtual std::string display_name () const override
 Returns "Demand", the name of this model.
 

Static Public Member Functions

static unsigned int parameters ()
 Returns the number of parameters of this model (5)
 
static Eigen::RowVectorXd row (double P, double q, unsigned S, unsigned nosales, unsigned age, unsigned otherBooks, unsigned lag_marketBooks)
 Given various information about a book, returns an X matrix row of data representing that information. More...
 
static Eigen::RowVectorXd bookRow (eris::SharedMember< Book > book, double quality, unsigned int lag_market_books)
 Given a book and perceived quality, this builds an X matrix row of data representing that book. More...
 

Detailed Description

This class represents an author's belief about the per-period demand for books.

The model is of the form:

\(Q_b = \beta_0 + \beta_1 P_b + \beta_2 q_b + \beta_3 prevSales + \beta_4 nosales + u\) where:

The following restrictions are imposed on beliefs:

These constraints are combined with a natural conjugate prior for the purposes of updating the beliefs via Bayesian econometrics.

Additionally, when predicting, readers know that Q can never be larger than the number of readers in the world minus the copies already sold, and incorporate this limitation into predictions.

Constructor & Destructor Documentation

§ Demand() [1/2]

creativity::belief::Demand::Demand ( )
inline

Default constructor: note that unlike a default-constructed BayesianLinear model, this default constructed object is a usable (but noninformative) model.

See also
eris::learning::BayesianLinear::BayesianLinear()

§ Demand() [2/2]

template<typename ... Args>
creativity::belief::Demand::Demand ( Args &&...  args)
inlineexplicit

Constructs a demand model with the given prior information.

This forwards arguments to the BayesianLinearRestricted constructor, but also adds the model's restrictions.

Parameters
argsprior arguments to forward to the base BayesianLinearRestricted constructor.
See also
eris::learning::BayesianLinear::BayesianLinear

Member Function Documentation

§ argmaxP()

std::pair<double, double> creativity::belief::Demand::argmaxP ( unsigned int  draws,
double  q,
unsigned int  s,
unsigned int  z,
unsigned int  n,
unsigned int  nosales,
unsigned int  age,
unsigned int  otherBooks,
unsigned int  marketBooks,
double  c,
double  max_price 
)

Given a set of model parameters (other than \(P_b\)) and a per-unit cost this returns the \(P_b\) value that maximizes expected total profits:

\[ P_b Q_b(P_b, \ldots) - c_b Q_b(P_b, \ldots) \]

which, due to the linearity of P_b in Q_b, has a maximum at:

\[ P_b^* = \frac{X\beta_{-1}}{-2\beta_1} + \frac{c_b}{2} \]

where \(X\) is all of the model terms that do not depend on \(P_b\) and \(\beta_{-1}\) are the associated coefficients.

Note, however, that there is a limit to Q: it can never be larger than the number of readers in the world who haven't read the book, in other words, the population minus the copies previously sold minus the copies pirated minus 1 (an author doesn't buy his own book).

Parameters
drawsthe number of draws to use for prediction
qthe quality of the book
sprior book sales
zbook pirated copies
nsimulation readers size (including the author)
nosalesthe number of periods the book has gone without sales (age is used if this is > age).
agethe age of the book, in simulation periods
otherBooksthe number of other books created by this book's author. This parameter also determines the onlyBook dummy (= 1 iff otherBooks == 0).
marketBooksthe number of books on the market in the last pre-prediction period (including this book, if this book was on the market)
cthe per-unit cost of copies.
max_pricethe maximum price to set (if optimum is predicted above this, reduce to this)
Returns
a std::pair of double values where .first is the maximizing price and .second is the quantity predicted at that price. If optimal price is below c (i.e. demand is 0 or negative at a price of c), 0 is returned for both fields.
Exceptions
std::domain_errorif c < 0 or q < 0

§ bookRow()

static Eigen::RowVectorXd creativity::belief::Demand::bookRow ( eris::SharedMember< Book book,
double  quality,
unsigned int  lag_market_books 
)
static

Given a book and perceived quality, this builds an X matrix row of data representing that book.

This method may only be called in the inter-period optimization stage, after t has been incremented but before new books/markets have been created. The book must still be on the market: its current market price is used to build the row.

Note that this method typically should only be used beginning in t=3: before that, lag_market_books would be 0.

§ predict()

double creativity::belief::Demand::predict ( unsigned int  draws,
double  P,
double  q,
unsigned int  S,
unsigned int  nosales,
unsigned int  age,
unsigned int  otherBooks,
unsigned int  lag_marketBooks 
)

Given a set of model parameters, this returns an expected value \(Q_b\), the number of sales.

Parameters
drawsthe number of draws to use for prediction
Pthe price of a copy of the book
qthe quality of the book
Sprior book sales
nosalesthe number of time periods since the book last had a sale; if greater than age, age is used (so that sim->t() - book->lastSale() can be passed)
ageof the book
otherBooksthe number of other books created by this book's author. This parameter also determines the onlyBook dummy (= 1 iff otherBooks == 0).
lag_marketBooksthe number of books on the market in the previous period
Exceptions
std::domain_errorif P < 0 or q < 0.

§ row()

static Eigen::RowVectorXd creativity::belief::Demand::row ( double  P,
double  q,
unsigned  S,
unsigned  nosales,
unsigned  age,
unsigned  otherBooks,
unsigned  lag_marketBooks 
)
static

Given various information about a book, returns an X matrix row of data representing that information.

Parameters
Pthe price of a copy of the book
qthe quality of the book
Sprior book sales
nosalesthe number of time periods since the book last had a sale; if greater than age, age is used (so that sim->t() - book->lastSale() can be passed)
ageof the book
otherBooksthe number of other books created by this book's author. This parameter also determines the onlyBook dummy (= 1 iff otherBooks == 0).
lag_marketBooksthe number of books on the market in the previous period
Inheritance diagram for creativity::belief::Demand:
[legend]
Collaboration diagram for creativity::belief::Demand:
[legend]

The documentation for this class was generated from the following file: