HARK.FashionVictim.FashionVictimModel¶

Specifies a dynamic model of fashion selection in a world with only two styles: jock and punk. Forward-looking agents receive utility from the style they choose based on the proportion of the population with the same style (as well as direct preferences each style), and pay switching costs if they change.

Functions

 calcFashionEvoFunc(pNow) Calculates a new approximate dynamic rule for the evolution of the proportion of punks as a linear function and a “shock width”. calcPunkProp(sNow) Calculates the proportion of punks in the population, given data from each type. main() solveFashion(solution_next, DiscFac, …) Solves a single period of the fashion victim model.

Classes

 FashionEvoFunc([pNextIntercept, pNextSlope, …]) A class for representing a dynamic fashion rule in the FashionVictim model. FashionMarketInfo(pNow) A class for representing the current distribution of styles in the population. FashionSolution([VfuncJock, VfuncPunk, …]) A class for representing the single period solution to a FashionVictim problem. FashionVictimType(**kwds) A class for representing types of agents in the fashion victim model.
class HARK.FashionVictim.FashionVictimModel.FashionEvoFunc(pNextIntercept=None, pNextSlope=None, pNextWidth=None)

A class for representing a dynamic fashion rule in the FashionVictim model. Fashion victims believe that the proportion of punks evolves according to a uniform distribution around a linear function of the previous state.

Methods

 __call__(self, \*\*kwds) Assign an arbitrary number of attributes to this agent, as a convenience. assignParameters(self, \*\*kwds) Assign an arbitrary number of attributes to this agent. distance(self, other) A generic distance method, which requires the existence of an attribute called distance_criteria, giving a list of strings naming the attributes to be considered by the distance metric. getAvg(self, varname, \*\*kwds) Calculates the average of an attribute of this instance.
class HARK.FashionVictim.FashionVictimModel.FashionMarketInfo(pNow)

A class for representing the current distribution of styles in the population.

class HARK.FashionVictim.FashionVictimModel.FashionSolution(VfuncJock=None, VfuncPunk=None, switchFuncJock=None, switchFuncPunk=None)

A class for representing the single period solution to a FashionVictim problem.

Methods

 __call__(self, \*\*kwds) Assign an arbitrary number of attributes to this agent, as a convenience. assignParameters(self, \*\*kwds) Assign an arbitrary number of attributes to this agent. distance(self, other) A generic distance method, which requires the existence of an attribute called distance_criteria, giving a list of strings naming the attributes to be considered by the distance metric. getAvg(self, varname, \*\*kwds) Calculates the average of an attribute of this instance.
class HARK.FashionVictim.FashionVictimModel.FashionVictimType(**kwds)

A class for representing types of agents in the fashion victim model. Agents make a binary decision over which style to wear (jock or punk), subject to switching costs. They receive utility directly from their chosen style and from the proportion of the population that wears the same style.

Methods

 __call__(self, \*\*kwds) Assign an arbitrary number of attributes to this agent, as a convenience. addToTimeInv(self, \*params) Adds any number of parameters to time_inv for this instance. addToTimeVary(self, \*params) Adds any number of parameters to time_vary for this instance. assignParameters(self, \*\*kwds) Assign an arbitrary number of attributes to this agent. checkElementsOfTimeVaryAreLists(self) A method to check that elements of time_vary are lists. checkRestrictions(self) A method to check that various restrictions are met for the model class. clearHistory(self) Clears the histories of the attributes named in self.track_vars. delFromTimeInv(self, \*params) Removes any number of parameters from time_inv for this instance. delFromTimeVary(self, \*params) Removes any number of parameters from time_vary for this instance. distance(self, other) A generic distance method, which requires the existence of an attribute called distance_criteria, giving a list of strings naming the attributes to be considered by the distance metric. getAvg(self, varname, \*\*kwds) Calculates the average of an attribute of this instance. getControls(self) Gets values of control variables for the current period, probably by using current states. getMortality(self) Simulates mortality or agent turnover according to some model-specific rules named simDeath and simBirth (methods of an AgentType subclass). getPostStates(self) Gets values of post-decision state variables for the current period, probably by current states and controls and maybe market-level events or shock variables. getShocks(self) Gets values of shock variables for the current period. getStates(self) Gets values of state variables for the current period, probably by using post-decision states from last period, current period shocks, and maybe market-level events. initializeSim(self) Prepares this AgentType for a new simulation. makeShockHistory(self) Makes a pre-specified history of shocks for the simulation. marketAction(self) The “market action” for a FashionType in the general equilibrium setting. postSolve(self) Unpack the behavioral and value functions for more parsimonious access. preSolve(self) Updates the punk proportion evolution array by calling self.updateEvolution(). readShocks(self) Reads values of shock variables for the current period from history arrays. reset(self) Resets this agent type to prepare it for a new simulation run. resetRNG(self) Reset the random number generator for this type. simBirth(self, which_agents) Makes new agents for the simulation. simDeath(self) Determines which agents in the current population “die” or should be replaced. simOnePeriod(self) Simulates one period for this type. simOnePrd(self) Simulate one period of the fashion victom model for this type. simulate(self[, sim_periods]) Simulates this agent type for a given number of periods (defaults to self.T_sim if no input). solve(self[, verbose]) Solve the model for this instance of an agent type by backward induction. timeFlip(self) Reverse the flow of time for this instance. timeFwd(self) Make time flow forward for this instance. timeReport(self) Report to the user the direction that time is currently “flowing” for this instance. timeRev(self) Make time flow backward for this instance. update(self) Updates the non-primitive objects needed for solution, using primitive attributes. updateEvolution(self) Updates the “population punk proportion” evolution array.
marketAction(self)

The “market action” for a FashionType in the general equilibrium setting. Simulates a single period using self.simOnePrd().

Parameters: none none
postSolve(self)

Unpack the behavioral and value functions for more parsimonious access.

Parameters: none none
preSolve(self)

Updates the punk proportion evolution array by calling self.updateEvolution().

Parameters: none none
reset(self)

Resets this agent type to prepare it for a new simulation run. This includes resetting the random number generator and initializing the style of each agent of this type.

simOnePrd(self)

Simulate one period of the fashion victom model for this type. Each agent receives an idiosyncratic preference shock and chooses whether to change styles (using the optimal decision rule).

Parameters: none none
update(self)

Updates the non-primitive objects needed for solution, using primitive attributes. This includes defining a “utility from conformity” function conformUtilityFunc, a grid of population punk proportions, and an array of future punk proportions (for each value in the grid). Results are stored as attributes of self.

Parameters: none none
updateEvolution(self)

Updates the “population punk proportion” evolution array. Fasion victims believe that the proportion of punks in the subsequent period is a linear function of the proportion of punks this period, subject to a uniform shock. Given attributes of self pNextIntercept, pNextSlope, pNextCount, pNextWidth, and pGrid, this method generates a new array for the attri- bute pEvolution, representing a discrete approximation of next period states for each current period state in pGrid.

Parameters: none none
HARK.FashionVictim.FashionVictimModel.calcFashionEvoFunc(pNow)

Calculates a new approximate dynamic rule for the evolution of the proportion of punks as a linear function and a “shock width”.

Parameters: pNow : [float] List describing the history of the proportion of punks in the population. (unnamed) : FashionEvoFunc A new rule for the evolution of the population punk proportion, based on the history in input pNow.
HARK.FashionVictim.FashionVictimModel.calcPunkProp(sNow)

Calculates the proportion of punks in the population, given data from each type.

Parameters: pNow : [np.array] List of arrays of binary data, representing the fashion choice of each agent in each type of this market (0=jock, 1=punk). pop_size : [int] List with the number of agents of each type in the market. Unused.
HARK.FashionVictim.FashionVictimModel.solveFashion(solution_next, DiscFac, conformUtilityFunc, punk_utility, jock_utility, switchcost_J2P, switchcost_P2J, pGrid, pEvolution, pref_shock_mag)

Solves a single period of the fashion victim model.

Parameters: solution_next: FashionSolution A representation of the solution to the subsequent period’s problem. DiscFac: float The intertemporal discount factor. conformUtilityFunc: function Utility as a function of the proportion of the population who wears the same style as the agent. punk_utility: float Direct utility from wearing the punk style this period. jock_utility: float Direct utility from wearing the jock style this period. switchcost_J2P: float Utility cost of switching from jock to punk this period. switchcost_P2J: float Utility cost of switching from punk to jock this period. pGrid: np.array 1D array of “proportion of punks” states spanning [0,1], representing the fraction of agents currently wearing punk style. pEvolution: np.array 2D array representing the distribution of next period’s “proportion of punks”. The pEvolution[i,:] contains equiprobable values of p for next period if p = pGrid[i] today. pref_shock_mag: float Standard deviation of T1EV preference shocks over style. solution_now: FashionSolution A representation of the solution to this period’s problem.