INF11198: Data-driven Business and Behaviour Analytics Coursework 2 : Agent Based Modelling 1 Introduction The objective of this assignment is to help you understand the various steps involved while working with Agent-based Model. You will submit two files: • Jupyter Notebook: Submit your ipynb file showing your analysis. Please annotate your code with comments. • A PDF titled s
-answers.pdf. You will write all your answers that do not require coding into this file. You are free to use any text-editor you like (e.g. Latex, Word,...). Please do not use scans of your handwriting. There are no restrictions on the number of pages for the report. Please read the entire question and then attempt answering them. Writing a pseudo code is strongly recommended for the implementation part (the pseudo code wont be marked). Deadline : 5pm 04/12/2020 2 Prediction markets Prediction markets are speculative markets which bet on the occurrence of events in the future. They are powerful forecasting tools which use the idea of the wisdom of the crowd to make predictions about the future value of an asset by using the aggregate values of individual’s expectations. The price in a prediction market is a bet that a particular event will occur and it represents an estimated value that the person placing the bet assigns to the parameters considered in the bet. Individuals bet on a piece of information that they believe is valuable. In this exercise, you will develop an agent-based model for prediction markets. 2.1 Opinion dynamics (23%) Consider a social network of agents, each possessing an opinion about the prob- ability of a given event occurring. They buy or sell contracts on a prediction market exchange based on their opinion. 1 De↵uant model: The bounded confidence model of opinion dynamics, is a stochastic model for the evolution of continuous-valued opinions within a finite group of peers. Consider a population of N agents in a network G. Each agent i has an opinion oi which changes upon interaction with other agents. Each agent is initiated with a random opinion in the interval (0, 1). At each time step, a random agent i is chosen from the network and it is allowed to interact with another agent j chosen randomly from agent i’s neighbours. If the opinions of agents oi and oj at time t meet the condition: |oi oj | < ✏, their opinions are updated as: oi(t+ 1) = oi(t) + µ[oj(t) oi(t)] oj(t+ 1) = oj(t) + µ[oi(t) oj(t)] Here, ✏ is the threshold and µ is the convergence parameter. Questions 1. Implement the de↵uant model to study the opinion di↵usion process on a Barabasi Albert network (G) for 1000 agents. Set m (the number of edges to attach from a new node to existing nodes) as 4 . (10) 2. Give time charts of the opinions for the two cases given below and explain the curve. (3 +3 + 2) (a) ✏ = 0.5 and µ = 0.5 (b) ✏ = 0.2 and µ = 0.5 3. What happens when ✏ is increased from 0 to 1 for a constant value of µ = 0.5. Use plots to explain the answer. (5) 2.2 ABM for prediction markets (32%) Prediction markets are time-limited markets in which contracts are traded based on the outcome of a given event E 2 {0, 1} where E = 1 if event occurs and 0 otherwise. Similarly, the payo↵ for the contract on the event is 1 if it occurs, and 0 otherwise. Let ⇡ be the normalised price of the contract. If a prediction market is com- pletely e cient, the normalized prices reflect the probability that the corre- sponding outcome occurs! 2 Consider the de↵uant model for opinion di↵usion in the previous model. Now, each agent participates in the market with a probability, P = (T ⌧) Here T is the duration of the market and ⌧ is the time left until the end of market both in days. is a scaling parameter and should be fixed at 2.44 Each agent believes that the probability of the event occurring, i.e, P (E = 1) = oi, so they will buy the contract if the current price ⇡ < oi and sell it if ⇡ > oi. Set the initial price as 0.5. The demand of an agent i is the di↵erence between its opinion and the price, which is calculated as: Di = oi(t) ⇡(t) We define the excess demand (ED) as: ED(t) = |v| X i Di(t) where v is a noise term drawn from the distribution N(0, ) with 2 = 0.05 The price is updated at each time step depending only on ED(t) as: ⇡(t+ 1) = ( min{1,⇡(t) + ED(t)} ED(t) 0 max{0,⇡(t) + ED(t)} ED(t) < 0 ) Questions 1. Incorporate prediction markets into the de↵uant model from the previous question for 1000 agents. (10) 2. What happens when the scaling parameter is increased? Using a time plot study the e↵ects of the scaling parameter on the price for the cases : (3 + 3 + 3 + 3) (a) = 1 (b) = 2.44 (c) = 3 Set the parameters at ✏ = 0.5 and µ = 0.5 for this question. 3. Sample the model 100 times with = 2.44 for T = 100. How does the price at the end of the market change with each iteration? Why is iterating an ABM for the same set of parameters necessary? If you wanted to get the same exact trend-line over multiple iterations for an agent based model given a set of parameters, what would you do? (5 + 3 +2) 3 ~ 2.3 Validation (30%) The daily price change often called as return at time t is rt = Price(t) Price(t 1) Kurtosis is a statistical measure that is used to describe a distribution, it mea- sures the tailedness of the probability distribution. To validate the simulations with empirical data, we define a objective function, f as : f = |ksim kemp| where ksim kurtosis of the distribution of returns from the simulations and kemp is the kurtosis of the distribution of returns from the empirical data. Hint :You may use the scipy function : scipy stats.kurtosis() for calculating the kurtosis. The file 0data prediction.csv0 is a data-set for multiple events from a prediction market platform. The dataset contains the following: • id : unique for a market • date : date stamps • CloseSharePrice : The closing prices on each day for the corresponding market id. The aggregate values calculated from a sample data set for the given data-set are kemp = 39.31. Questions 1. From the data-set, extract the following information: (a) Total number of unique markets, Q. (3) (b) Duration of the market for each market. (3) 2. Simulate the prediction market ABM model for 1000 agents for all values of ✏ in the interval (0, 1) and µ in the interval (0, 0.5) with a step size of 0.1. Iterate the simulations Q number of times for each parameter set. For each of simulation, draw the market duration time (T) randomly from the set of market duration’s calculated from the data in the previous question. Set the scaling parameter at = 2.44. 4 (a) Calculate the return rt for each simulation. (4) (b) Calculate the kurtosis ksim of the distribution of returns from the simulations for each combination of parameters. Plot a heat map of averaged ksim with respect to the two parameters ✏ and µ. (4 + 4) (c) Calculate the objective function of the returns for all the simulations. (4) (d) Plot a heat map of the objective function f for all values of ✏ and µ and explain the plot. (4) (e) How can you improve the objective function to validate the simulated data with the empirical data? (4) 3 Cryptocurrency market (15%) Cryptocurrencies are digital currencies that are secured using cryptography, making it it nearly impossible to counterfeit or double-spend. There are plenty of cryptocurrencies today, like Bitcoin, Ethereum, XRP ,Tether etc. Using your experience with building an Agent-based model for prediction mar- kets, come up with a model for the bitcoin market. Questions 1. What kind of agents will you use for this problem ? Explain the choice of agents. You can use the example agent types taught in class and/or modify them. (3 + 3) 2. How would you describe the interactions in the model? Give reasons to motivate the interactions that you use. (3 + 3) 3. What kind of data-sets will you use to validate the model? Are these open data sets? (3) 5 欢迎咨询51作业君