I'm working with time-series data and I'm trying to compute autocorrelation function, variance and the spread of Pt - Pt-1. I defined the following model:
Array
Pt is the transaction price, Mt is the value of a firm, S is the spread, that is the difference between the ask and bid prices and Qt is 1 if the investor buys or -1 if the investor sells (with the same probability and uncorrelated over time). I use the 'close' as the transaction price.
So my question is how can I compute the autocorrelation function, variance and spread of Pt - Pt-1 using the data below?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str10 date int time float(open high low close) long volume str9 ticker "09/15/2008" 930 33.31 33.31 33.31 33.31 2135 "zeus" "09/15/2008" 932 32.94 32.94 32.94 32.94 100 "zeus" "09/15/2008" 934 32.32 32.32 31.95 31.95 600 "zeus" "09/15/2008" 935 31.96 31.96 31.91 31.91 600 "zeus" "09/15/2008" 936 31.67 31.67 31.27 31.27 2380 "zeus" "09/15/2008" 937 31.27 31.27 30.4 30.44 1600 "zeus" "09/15/2008" 938 30.68 31.29 30.68 31.29 3200 "zeus" "09/15/2008" 939 31.17 31.23 31.03 31.08 700 "zeus" "09/15/2008" 941 31.35 31.78 31.14 31.46 1800 "zeus" "09/15/2008" 942 31.73 32.13 31.47 31.64 1100 "zeus" "09/15/2008" 943 31.65 31.66 31.48 31.49 2800 "zeus" "09/15/2008" 944 31.6 31.81 31.51 31.65 1900 "zeus" "09/15/2008" 945 31.68 31.68 31.68 31.68 200 "zeus" "09/15/2008" 946 31.71 31.8 31.68 31.77 700 "zeus" "09/15/2008" 947 32 32.14 32 32 600 "zeus" "09/15/2008" 948 32.04 32.06 32.04 32.06 200 "zeus" "09/15/2008" 949 32.06 32.18 32.01 32.18 700 "zeus" "09/15/2008" 950 32.17 32.18 32.06 32.18 2600 "zeus" "09/15/2008" 951 32.15 32.15 31.92 32 5976 "zeus" "09/15/2008" 952 32.06 32.11 31.63 31.63 3900 "zeus" "09/15/2008" 953 31.92 32.12 31.89 32.01 4100 "zeus" "09/15/2008" 954 32.01 32.03 31.92 31.99 3200 "zeus" "09/15/2008" 955 32.01 32.02 31.98 32.01 1500 "zeus" "09/15/2008" 956 31.99 32.14 31.99 32.14 1300 "zeus" "09/15/2008" 957 32.11 32.11 32.01 32.01 400 "zeus" "09/15/2008" 958 32.02 32.04 32.01 32.01 1200 "zeus" "09/15/2008" 959 32.03 32.11 31.98 32.11 1586 "zeus" "09/15/2008" 1000 32.06 32.16 32.06 32.11 300 "zeus" "09/15/2008" 1001 32.02 32.02 32.02 32.02 260 "zeus" "09/15/2008" 1002 32.01 32.01 31.92 31.92 5400 "zeus" "09/15/2008" 1003 31.92 32.08 31.89 32 800 "zeus" "09/15/2008" 1004 32.02 32.02 32.02 32.02 100 "zeus" "09/15/2008" 1005 31.92 32.04 31.82 31.94 3100 "zeus" "09/15/2008" 1006 31.94 32.04 31.94 32.04 400 "zeus" "09/15/2008" 1007 31.99 31.99 31.53 31.53 1300 "zeus" "09/15/2008" 1008 31.51 31.51 31.39 31.4 1100 "zeus" "09/15/2008" 1009 31.39 31.5 31.14 31.35 3200 "zeus" "09/15/2008" 1010 31.48 31.51 31.03 31.15 2000 "zeus"
Johnson
0 Response to Time-series computing autocorrelation function
Post a Comment