creativity
v1.3.0
Agent-based model of creativity and piracy
|
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... | |
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.
|
inline |
Default constructor: note that unlike a default-constructed BayesianLinear model, this default constructed object is a usable (but noninformative) model.
|
inlineexplicit |
Constructs a demand model with the given prior information.
This forwards arguments to the BayesianLinearRestricted constructor, but also adds the model's restrictions.
args | prior arguments to forward to the base BayesianLinearRestricted constructor. |
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).
draws | the number of draws to use for prediction |
q | the quality of the book |
s | prior book sales |
z | book pirated copies |
n | simulation readers size (including the author) |
nosales | the number of periods the book has gone without sales (age is used if this is > age). |
age | the age of the book, in simulation periods |
otherBooks | the number of other books created by this book's author. This parameter also determines the onlyBook dummy (= 1 iff otherBooks == 0 ). |
marketBooks | the number of books on the market in the last pre-prediction period (including this book, if this book was on the market) |
c | the per-unit cost of copies. |
max_price | the maximum price to set (if optimum is predicted above this, reduce to this) |
.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.std::domain_error | if c < 0 or q < 0 |
|
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.
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.
draws | the number of draws to use for prediction |
P | the price of a copy of the book |
q | the quality of the book |
S | prior book sales |
nosales | the 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) |
age | of the book |
otherBooks | the number of other books created by this book's author. This parameter also determines the onlyBook dummy (= 1 iff otherBooks == 0 ). |
lag_marketBooks | the number of books on the market in the previous period |
std::domain_error | if P < 0 or q < 0 . |
|
static |
Given various information about a book, returns an X matrix row of data representing that information.
P | the price of a copy of the book |
q | the quality of the book |
S | prior book sales |
nosales | the 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) |
age | of the book |
otherBooks | the number of other books created by this book's author. This parameter also determines the onlyBook dummy (= 1 iff otherBooks == 0 ). |
lag_marketBooks | the number of books on the market in the previous period |