(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 166483, 5833]*) (*NotebookOutlinePosition[ 173177, 6016]*) (* CellTagsIndexPosition[ 172315, 5989]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Markov Chain Monte Carlo Algorithms for Bayesian Estimation of Microstructure \ Models\ \>", "Subtitle"], Cell["\<\ Computational Appendix to \"Liquidity in the futures pits: Inferring market dynamics from incomplete data\"\ \>", "Subtitle"], Cell["\<\ Joel Hasbrouck May, 2002\ \>", "Subtitle"], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell["\<\ This appendix describes the Markov Chain Monte Carlo (MCMC) estimation of \ microstructure models with bid/ask spreads, discreteness, clustering and \ trade impacts. In all cases, the data are presumed to consist solely of trade \ prices and (optionally) trade volumes. The exposition discusses models of \ increasing complexity. The appendix is distributed in two forms: a text \ document, and a Mathematica notebook in which derivations are interspersed \ with the text.\ \>", "Text"], Cell["\<\ The appendix presumes some exposure to Bayesian MCMC techniques. Textbook \ level discussions are given in Carlin and Louis (1996), Tanner (1996), \ Gamerman (1997), and Kim and Nelson (2000). Casella and George (1992), Chib \ and Greenberg (1995), and Chib and Greenberg (1996) also provide useful \ expositions.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " initializations)" }], "Section", CellFrameLabels->{{None, Inherited}, {Inherited, Inherited}}, TextAlignment->Right, CounterIncrements->"None"], Cell["Evaluate this section first.", "Text"], Cell[CellGroupData[{ Cell["Miscellaneous intializations", "Subsection"], Cell["Standard packages", "Text"], Cell[BoxData[{ \(\(Needs["\"];\)\), "\n", \(\(Needs["\"];\)\)}], "InputOnly", CellLabel->"In[1]:="], Cell["Turn off spelling warnings.", "Text"], Cell[BoxData[{ \(\(Off[General::spell1];\)\ \), "\[IndentingNewLine]", \(\(Off[General::spell];\)\)}], "InputOnly", CellLabel->"In[3]:="], Cell[TextData[{ "The following defines a transormation that formats \"", Cell[BoxData[ \(TraditionalForm\` \[Rule] \)]], "\" as \"=\". (It just reworks the rule into a more familiar notation.)" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(RuleToEquals = Rule[a_, b_] :> HoldForm[ HoldForm[a] "\<=\>"\ HoldForm[b]];\)\[IndentingNewLine] (*\ For\ \(\(example\)\(:\)\)\ *) \), "\[IndentingNewLine]", \({c \[Rule] 4, d \[Rule] 3} /. RuleToEquals // TableForm\)}], "Input", CellLabel->"In[5]:="], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { TagBox[ RowBox[{ TagBox["c", HoldForm], " ", "\<\"=\"\>", " ", TagBox["4", HoldForm]}], HoldForm]}, { TagBox[ RowBox[{ TagBox["d", HoldForm], " ", "\<\"=\"\>", " ", TagBox["3", HoldForm]}], HoldForm]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ { HoldForm[ Times[ HoldForm[ c], "=", HoldForm[ 4]]], HoldForm[ Times[ HoldForm[ d], "=", HoldForm[ 3]]]}]], TraditionalForm]], "Output", CellLabel->"Out[6]//TableForm="] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Normal density and distribution functions", "Subsection"], Cell[TextData[{ "The expression ", Cell[BoxData[ \(TraditionalForm\`\[Phi][\[Mu], \[Sigma], x]\)]], " denotes the normal density function for random variable x, with mean \ \[Mu] and standard deviation ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\)]], ". The following rule expands this definition." }], "Text"], Cell[BoxData[ \(\(\[Phi]Def = \[Phi][\[Mu]_, \[Sigma]_, x_] :> PDF[NormalDistribution[\[Mu], \[Sigma]], x];\)\)], "InputOnly", CellLabel->"In[7]:="], Cell["For example, ", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\[Phi][m, s, z] /. \[Phi]Def\)], "Input", CellLabel->"In[8]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(-\(\((z - m)\)\^2\/\(2\ \ s\^2\)\)\)\/\(\@\(2\ \[Pi]\)\ s\)\)], "Output", CellLabel->"Out[8]="] }, Open ]], Cell[TextData[{ "Similarly, the expression ", Cell[BoxData[ \(TraditionalForm\`\[CapitalPhi][\[Mu], \[Sigma], a, b] \[Congruent] \[Integral]\_a\%b \[Phi][\[Mu], \[Sigma], x] \[DifferentialD]x\)]], " , i.e., the cumulative normal distribution function evaluated between ", Cell[BoxData[ \(TraditionalForm\`a\ and\ b\)]], ". The following rule replaces this with the formula:" }], "Text"], Cell[BoxData[ \(\(\[CapitalPhi]Def = \[CapitalPhi][\[Mu]_, \[Sigma]_, a_, b_] :> CDF[NormalDistribution[\[Mu], \[Sigma]], b] - CDF[NormalDistribution[\[Mu], \[Sigma]], a];\)\)], "InputOnly", CellLabel->"In[9]:="], Cell["For example,", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\[CapitalPhi][2, 1, 1.5, 1.8] /. \[CapitalPhi]Def\)], "Input", CellLabel->"In[10]:="], Cell[BoxData[ \(TraditionalForm\`0.11220275183491013`\)], "Output", CellLabel->"Out[10]="] }, Open ]], Cell[TextData[{ "The following rule is useful to tell ", "Mathematica", " that ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\)]], " is a real, positive number." }], "Text"], Cell[BoxData[ \(\(\[Sigma]uAssumptions = {Re[\[Sigma]\_u\%2] > 0, RealQ[\[Sigma]\_u], \[Sigma]\_u > 0};\)\)], "InputOnly", CellLabel->"In[11]:="] }, Open ]], Cell[CellGroupData[{ Cell["Finding the parameters of a normal density.", "Subsection"], Cell[TextData[{ "Sometimes we have a density that we know is proportional to a normal \ density, but working out the exact correspondence is algebraically tedious. \ In such situations, the following function (GetNormalForm) is useful. That \ is, given a random variable ", Cell[BoxData[ \(TraditionalForm\`v\)]], " and its density function ", Cell[BoxData[ \(TraditionalForm\`f\)]], " (which is assumed proportional to a normal density), GetNormalForm finds \ \[Mu] and ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\)]], " such that ", Cell[BoxData[ \(TraditionalForm\`v\)]], " is normal with mean \[Mu] and standard deviation \[Sigma]. Traditionally, \ this is done by \"completing the square\" of the exponent of ", Cell[BoxData[ \(TraditionalForm\`e\)]], ". Mathematica's symbolic equation solving makes the process easier." }], "Text"], Cell[BoxData[ \(GetNormalForm[f_, x_, \[Mu]Symbol_: \[Mu]New, \[Sigma]Symbol_: \[Sigma]New] := Module[{h, fexp, e, r}, \[IndentingNewLine]h = \[Kappa]New - \((x - \[Mu]New)\)\^2/\((2\ \ \[Sigma]New\^2)\); \[IndentingNewLine] (*\ Find\ the\ exponent\ of\ E\ in\ the\ supplied\ function\ \ *) \[IndentingNewLine]fexp\ = \ \(Cases[DummyFactor*f, E^a_ \[Rule] a, Infinity]\)[\([1]\)]; \[IndentingNewLine]e\ = \ MapThread[ Equal, {CoefficientList[fexp, x], CoefficientList[h, x]}]; \[IndentingNewLine]r = Simplify[ Solve[e, {\[Mu]New, \[Sigma]New, \[Kappa]New}]]; \ \[IndentingNewLine] (*\ Verify\ that\ the\ random\ variable\ does\ not\ appear\ in\ \(\(\ \[Kappa]New\)\(.\)\)\ *) \[IndentingNewLine]If[FreeQ[\[Kappa]New /. r, x], , Print["\"]]; \[IndentingNewLine] (*\ Eliminate\ references\ to\ \[Kappa]New\ *) \[IndentingNewLine]r = \ \(Select[#, FreeQ[#, \[Kappa]New] &] &\)\ /@ \ r; \[IndentingNewLine] (*\ Eliminate\ solutions\ with\ negative\ \[Sigma]New\ \ *) \[IndentingNewLine]r = Select[r, FreeQ[#, \[Sigma]New \[Rule] Times[\(-1\), _]]\ && \ FreeQ[#, \[Sigma]New \[Rule] \(-1\)] &] // Flatten; \[IndentingNewLine]r /. {\[Mu]New \[Rule] \[Mu]Symbol, \ \[Sigma]New \[Rule] \[Sigma]Symbol}]\)], "InputOnly", CellLabel->"In[12]:="], Cell[TextData[{ "For example suppose we know that a density ", Cell[BoxData[ \(TraditionalForm\`f(z)\)]], " is normal and proportional to ", Cell[BoxData[ \(TraditionalForm\`e\^\(\(-z\^2\)\/10 + z\/3\)\)]], ". Then" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(GetNormalForm[E\^\(\(-z\^2\)\/10 + z\/3\), z]\)], "Input", CellLabel->"In[13]:="], Cell[BoxData[ \(TraditionalForm\`{\[Mu]New \[Rule] 5\/3, \[Sigma]New \[Rule] \@5}\)], "Output", CellLabel->"Out[13]="] }, Open ]], Cell["or", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(GetNormalForm[E\^\(\(-z\^2\)\/10 + z\/3\), z, MyMean, MySD]\)], "Input",\ CellLabel->"In[14]:="], Cell[BoxData[ \(TraditionalForm\`{MyMean \[Rule] 5\/3, MySD \[Rule] \@5}\)], "Output", CellLabel->"Out[14]="] }, Open ]], Cell["\<\ gives the mean and standard deviation for the distribution. The implied \ density is\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\[Phi][MyMean, MySD, z] /. \[Phi]Def\) /. %\)], "Input", CellLabel->"In[15]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(\(-\(1\/10\)\)\ \((z - 5\/3)\)\^2\)\ \/\@\(10\ \[Pi]\)\)], "Output", CellLabel->"Out[15]="] }, Open ]] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Notation and conventions", "Section"], Cell[TextData[{ "A time-series variable written without a time subscript denotes the full \ sample, e.g., ", Cell[BoxData[ \(TraditionalForm\`q = {q\_1, q\_2, ... , q\_T}\)]], ". The subscript \"", Cell[BoxData[ \(TraditionalForm\`\(\(\\\)\(t\)\)\)]], "\" indicates the full sample except for the observation at time ", Cell[BoxData[ \(TraditionalForm\`t\)]], ", e.g., ", Cell[BoxData[ \(TraditionalForm\`q\_\(\(\\\)\(t\)\) = {q\_1, ... , q\_\(t - 1\), q\_\(t + 1\), ... , q\_T}\)]], ". " }], "Text"], Cell[TextData[{ "\"Draw ", Cell[BoxData[ \(TraditionalForm\`x | y, z\)]], "\" is shorthand for \"draw ", Cell[BoxData[ FormBox[ RowBox[{"x", Cell[""]}], TraditionalForm]]], " from ", Cell[BoxData[ \(TraditionalForm\`f(x | y, z)\)]], ".\"" }], "Text"], Cell[TextData[{ "The expression ", Cell[BoxData[ \(TraditionalForm\`\[Phi][\[Mu], \[Sigma], x]\)]], " denotes the normal density function for random variable x, with mean \ \[Mu] and standard deviation ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\)]], ". For example, we denote the normal density for a random variable ", Cell[BoxData[ \(TraditionalForm\`z\)]], " with mean ", Cell[BoxData[ \(TraditionalForm\`m\)]], " and standard deviation ", Cell[BoxData[ \(TraditionalForm\`s\)]], " as ", Cell[BoxData[ \(TraditionalForm\`\[Phi](m, \ s, \ z)\)]], ". Fully expanded," }], "Text"], Cell[TextData[{ " \t", Cell[BoxData[ FormBox[ RowBox[{\(\[Phi](m, s, z)\), "=", StyleBox[\(\[ExponentialE]\^\(-\(\((z - m)\)\^2\/\(2\ \ s\^2\)\)\)\/\(\@\(2\ \[Pi]\)\ s\)\), ScriptLevel->0]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "Similarly, the expression ", Cell[BoxData[ \(TraditionalForm\`\[CapitalPhi][\[Mu], \[Sigma], a, b] \[Congruent] \[Integral]\_a\%b \[Phi][\[Mu], \[Sigma], x] \[DifferentialD]x\)]], " , i.e., the cumulative normal distribution function evaluated between ", Cell[BoxData[ \(TraditionalForm\`a\ and\ b\)]], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Basic Roll model", "Section"], Cell[CellGroupData[{ Cell["Model description", "Subsection"], Cell["The basic Roll model is:", "Text"], Cell[TextData[{ Cell[BoxData[ \(TraditionalForm\`m\_t = m\_\(t - 1\) + u\_t\)]], " where ", Cell[BoxData[ FormBox[ RowBox[{\(u\_t\), " ", "is", " ", "distributed", " ", "as", " ", "N", Cell[TextData[{ "(0,", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2\)]], ")" }]]}], TraditionalForm]]], "\n", Cell[BoxData[ \(TraditionalForm\`p\_t = m\_t + c\ q\_t\)]] }], "NumberedEquation"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " is the log efficient price, ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " is the buy/sell (trade direction) indicator variable, ", Cell[BoxData[ \(TraditionalForm\`q\_t \[Element] {\(-1\), \(+1\)}\)]], ", ", Cell[BoxData[ \(TraditionalForm\`c\)]], " is the is the half-spread, and ", Cell[BoxData[ \(TraditionalForm\`p\_t\)]], " is the log transaction price. The increment to the log efficient price, \ ", Cell[BoxData[ \(TraditionalForm\`u\_t~\(N(0, \[Sigma]\_u\%2)\)\)]], "; ", Cell[BoxData[ \(TraditionalForm\`c\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2\)]], " are constant parameters. The ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " are independent of ", Cell[BoxData[ \(TraditionalForm\`u\_t = \[CapitalDelta]\[VeryThinSpace]m\_t\)]], ", so trade directions are not informative.\n\tThe data consist of a sample \ of (log) transaction prices ", Cell[BoxData[ \(TraditionalForm\`p = {p\_1, ... , p\_T}\)]], ". The Gibbs sampler iterates over parameter draws and latent data draws. \ There are two parameters in the model, ", Cell[BoxData[ \(TraditionalForm\`{\[Sigma]\_u, c}\)]], ". There are ", Cell[BoxData[ \(TraditionalForm\`2 T\)]], " latent data items, ", Cell[BoxData[ \(TraditionalForm\`{q, m}\)]], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Moment estimates", "Subsection"], Cell["The price difference is", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]p\_t = u\_t + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t\)]] }], "Text"], Cell["The variance and first-order autocovariance are:", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\[Gamma]\_0 \[Congruent] Var(\[CapitalDelta]\[VeryThinSpace]p\_t) = \(\[Sigma]\_u\%2 + \ \(c\^2\) \(Var(\[CapitalDelta]\[VeryThinSpace]q\_t)\) = \[Sigma]\_u\%2 + 2 c\^2\)\)]], "\n\t", Cell[BoxData[ \(TraditionalForm\`\[Gamma]\_1 \[Congruent] Cov(\[CapitalDelta]\[VeryThinSpace]p\_t, \[CapitalDelta]\ \[VeryThinSpace]p\_\(t - 1\)) = \(\(c\^2\) E\[CapitalDelta]\[VeryThinSpace]\(q\_t\) \[CapitalDelta]\ \[VeryThinSpace]q\_\(t - 1\) = \(-c\^2\)\)\)]] }], "Text"], Cell["Solving:", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2 = \[Gamma]\_0 + 2 \[Gamma]\_1\)]], " and ", Cell[BoxData[ \(TraditionalForm\`c = \@\(-\[Gamma]\_1\)\)]] }], "Text"], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " code)" }], "MathGroup"], Cell["Note that Mathematica returns complex solutions", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MomentSolutions = Solve[{\[Gamma]\_0 \[Equal] \[Sigma]\_u\%2 + 2 c\^2, \[Gamma]\_1 \[Equal] \(-c\^2\)}, {c, \[Sigma]\_u}]\)], \ "Input", CellLabel->"In[16]:="], Cell[BoxData[ \(TraditionalForm\`{{\[Sigma]\_u \[Rule] \(-\@\(\[Gamma]\_0 + 2\ \[Gamma]\ \_1\)\), c \[Rule] \(-\[ImaginaryI]\)\ \@\[Gamma]\_1}, {\[Sigma]\_u \[Rule] \ \(-\@\(\[Gamma]\_0 + 2\ \[Gamma]\_1\)\), c \[Rule] \[ImaginaryI]\ \@\[Gamma]\_1}, {\[Sigma]\_u \[Rule] \@\(\ \[Gamma]\_0 + 2\ \[Gamma]\_1\), c \[Rule] \(-\[ImaginaryI]\)\ \@\[Gamma]\_1}, {\[Sigma]\_u \[Rule] \@\ \(\[Gamma]\_0 + 2\ \[Gamma]\_1\), c \[Rule] \[ImaginaryI]\ \@\[Gamma]\_1}}\)], "Output", CellLabel->"Out[16]="] }, Open ]], Cell[TextData[{ "Here are the solutions for ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2\)]], " and ", Cell[BoxData[ \(TraditionalForm\`c\)]], ":" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Union[ Simplify[{\[Sigma]\_u\%2, c} /. MomentSolutions, {\[Gamma]\_1 \[Element] Reals, \[Gamma]\_1 < 0, c \[Element] Reals}]]\)], "Input", CellLabel->"In[17]:="], Cell[BoxData[ FormBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {\(\[Gamma]\_0 + 2\ \[Gamma]\_1\), \(\@\(-\[Gamma]\_1\)\)}, {\(\[Gamma]\_0 + 2\ \[Gamma]\_1\), \(\[ImaginaryI]\ \@\[Gamma]\_1\)} }], "\[NoBreak]", ")"}], TraditionalForm]], "Output", CellLabel->"Out[17]="] }, Open ]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Overview of the Bayesian sampler", "Subsection"], Cell[TextData[{ "In the Gibbs sampler, we start with any feasible set of values (a sample \ path) for ", Cell[BoxData[ \(TraditionalForm\`q\)]], ". We then iterate over" }], "Text"], Cell[TextData[{ "1. Parameter draw. Generate a random draw of ", Cell[BoxData[ \(TraditionalForm\`c, \[Sigma]\_u | p, m, q\)]], "." }], "Text"], Cell[TextData[{ "2. Latent data draw. Generate a random draw of ", Cell[BoxData[ \(TraditionalForm\`m, q | c, \[Sigma]\_u, p\)]], "." }], "Text"], Cell["\<\ In the parameter draw, we condition on the most-recently drawn values of the \ latent data; in the latent data draw, we condition on the most recent \ parameter draw. We now discuss each of these draws in greater detail.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Parameter draws", "Subsection"], Cell["\<\ The prior and posterior densities for the parameters are standard Bayesian \ results covered in most basic treatments, such as Carlin and Louis (1997), \ Tanner (1997). Kim and Nelson (2000) discuss these results in a state-space \ context.\ \>", "Text"], Cell[CellGroupData[{ Cell[TextData[{ "The draw for ", Cell[BoxData[ \(TraditionalForm\`c\)]], ".\[VeryThinSpace]" }], "Subsubsection"], Cell[TextData[{ "Given all of the other parameters and latent data ", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]p\_t = \ \[CapitalDelta]\[VeryThinSpace]m\_t + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t\)]], ". Therefore, ", Cell[BoxData[ \(TraditionalForm\`c\)]], " can be interpreted as the coefficient in the regression specification" }], "Text"], Cell[TextData[{ " ", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]p\_t = c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t + u\_t\)]], ". " }], "NumberedEquation", CellTags->"cRegression"], Cell["The classic Bayesian regression model is ", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`y = X\[Beta] + u\)]], ", where ", Cell[BoxData[ \(TraditionalForm\`E\[VeryThinSpace]u\[VeryThinSpace]u\^\[Prime] = \ \[CapitalOmega]\_u\)]], ". " }], "Text"], Cell[TextData[{ "If the prior distribution on the coefficients is normal: ", Cell[BoxData[ \(TraditionalForm\`\[Beta]~\(N(\[Mu]\_\[Beta]\%Prior, \[CapitalOmega]\_\ \[Beta]\%Prior)\)\)]], ", then the posterior distribution for the coefficients is ", Cell[BoxData[ \(TraditionalForm\`\[Beta] | y~\(N(\[Mu]\_\[Beta]\%Posterior, \[CapitalOmega]\_\[Beta]\%Posterior)\ \)\)]], ", where ", Cell[BoxData[ \(TraditionalForm\`\[Mu]\_\[Beta]\%Posterior = D\[VeryThinSpace]d\)]], ", ", Cell[BoxData[ \(TraditionalForm\`\[CapitalOmega]\_\[Beta]\%Posterior = D\^\(-1\)\)]], ", ", Cell[BoxData[ \(TraditionalForm\`D\^\(-1\) = \(X\^\[Prime]\) \ \(\[CapitalOmega]\_u\%\(-1\)\) X + \((\[CapitalOmega]\_\[Beta]\%Prior)\)\^\(-1\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`d = \(X\^\[Prime]\) \(\[CapitalOmega]\_u\%\(-1\)\) y + \(\((\[CapitalOmega]\_\[Beta]\%\(P rior\))\)\^\(-1\)\) \[Mu]\ \_\[Beta]\%Prior\)]], ". " }], "Text"], Cell[TextData[{ "In the present case, ", Cell[BoxData[ \(TraditionalForm\`y = \([\[CapitalDelta]\[VeryThinSpace]p\_t]\)\)]], ", the column vector of price changes, ", Cell[BoxData[ \(TraditionalForm\`X = \([\[CapitalDelta]\[VeryThinSpace]q\_t]\)\)]], ", and ", Cell[BoxData[ \(TraditionalForm\`\[CapitalOmega] = \[Sigma]\_u\%2\)]], ". We might take ", Cell[BoxData[ \(TraditionalForm\`\[Mu]\_\[Beta]\%Prior = 0\)]], ", and ", Cell[BoxData[ \(TraditionalForm\`\(\(\[CapitalOmega]\_\[Beta]\%Prior\)\(=\)\)\)]], "some large number like ", Cell[BoxData[ \(TraditionalForm\`\(\(10\^6\)\(.\)\)\)]], " We would then compute ", Cell[BoxData[ \(TraditionalForm\`\[Mu]\_\[Beta]\%Posterior\ and\ \[CapitalOmega]\_\ \[Beta]\%Posterior\)]], ", and make a random draw from the coefficient posterior." }], "Text"], Cell[TextData[{ "On economic grounds, it is sensible to impose a non-negativity restriction \ on ", Cell[BoxData[ \(TraditionalForm\`c\)]], ". The easiest way to do this is to let the prior be ", Cell[BoxData[ \(TraditionalForm\`c~\(\(N\^+\)(0, \[CapitalOmega]\_c\%Prior)\)\)]], ", where the \"+\" superscript denotes restriction of the density to ", Cell[BoxData[ \(TraditionalForm\`\(\([0, \(+\[Infinity]\)\)\()\)\)\)]], ". The posterior is then ", Cell[BoxData[ \(TraditionalForm\`\(N\^+\)(\[Mu]\_c\%Posterior, \ \[CapitalOmega]\_c\%Posterior)\)]], ", where the parameters are computed exactly as in the unrestricted case." }], "Text"], Cell[TextData[{ "(The nonnegativity restriction on ", Cell[BoxData[ \(TraditionalForm\`c\)]], " is attractive from an economic perspective. It is also necessary for \ identification. The regression in eq. (", CounterBox["None"], ") is observationally equivalent if ", Cell[BoxData[ FormBox[ RowBox[{Cell[TextData[StyleBox["c", FontSlant->"Italic"]]], " ", "and", " ", "q", Cell[""]}], TraditionalForm]]], " are replaced with ", Cell[BoxData[ \(TraditionalForm\`\(-c\)\ and\ - q\)]], ".)" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "The draw for ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\)]] }], "Subsubsection"], Cell[TextData[{ "With normal ", Cell[BoxData[ \(TraditionalForm\`u\_t\)]], ", a natural prior for ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2\)]], " is the inverted gamma distribution, denoted ", Cell[BoxData[ \(TraditionalForm\`IG[\[Alpha]\^Prior, \[Beta]\^Prior]\)]], ". Then, given ", Cell[BoxData[ \(TraditionalForm\`u = {u\_1, ... , u\_T}\)]], ", the posterior is ", Cell[BoxData[ \(TraditionalForm\`IG[\[Alpha]\^Posterior, \[Beta]\^Posterior]\)]], ", where ", Cell[BoxData[ \(TraditionalForm\`\[Alpha]\^Posterior = \[Alpha]\^Prior + T/2\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\[Beta]\^Posterior = \[Beta]\^Prior + \ \[CapitalSigma]\[VeryThinSpace]u\_t\%2/2\)]], "." }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Latent data draws", "Subsection"], Cell[TextData[{ "There are two latent series, ", Cell[BoxData[ \(TraditionalForm\`q\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\)]], ", but one of these is redundant. (The ", Cell[BoxData[ \(TraditionalForm\`p\)]], " are known, and ", Cell[BoxData[ \(TraditionalForm\`p = m + c\[VeryThinSpace]q\)]], ".) It suffices therefore to draw ", Cell[BoxData[ \(TraditionalForm\`q | p, c, \[Sigma]\_u\)]], ". At this stage, ", Cell[BoxData[ \(TraditionalForm\`c\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\)]], " are known, so for notational economy, these parameters will be dropped \ from the explicit conditioning set. To set up the draw:" }], "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{\(Pr(q | p)\), "=", RowBox[{\(f(p | q)\), "\[Times]", \(Pr(q)\), "\[Times]", StyleBox[\(1\/\(f(p)\)\), ScriptLevel->0]}]}], TraditionalForm]]]], "NumberedEquation", CellTags->"RollBayes0"], Cell[TextData[{ "Since the ", Cell[BoxData[ \(TraditionalForm\`q\)]], " are discrete random variables and the ", Cell[BoxData[ \(TraditionalForm\`p\)]], " are continuous, the joint distribution is written as ", Cell[BoxData[ \(TraditionalForm\`\(f(p | q)\)\[Times]\((Pr(q)\)\)]], " to avoid writing an improper density function like \"", Cell[BoxData[ \(TraditionalForm\`f(p, q)\)]], "\". In eq. (", CounterBox["NumberedEquation", "RollBayes0"], ") the last factor does not depend on ", Cell[BoxData[ \(TraditionalForm\`q\)]], ". Furthermore, since buys and sells are unconditionally equally probable, \ ", Cell[BoxData[ \(TraditionalForm\`Pr(q) = \((1/2)\)\^T\)]], ". Therefore:" }], "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{ RowBox[{\(Pr(q | p)\), "\[Proportional]", RowBox[{\(f(p | q)\), Cell[""]}]}], "=", \(\(f(m)\)\( | \_\(m = p - c\[VeryThinSpace]q\)\)\)}], TraditionalForm]]]], "NumberedEquation", CellTags->"qCondp"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`f(m)\)]], " is the unconditional distribution of the ", Cell[BoxData[ \(TraditionalForm\`m\)]], ". From the structure of the model, ", Cell[BoxData[ \(TraditionalForm\`f( m) = \(f(m\_1)\) \(\[Product]\+\(t = 2\)\%T f(u\_t)\)\)]], " where ", Cell[BoxData[ \(TraditionalForm\`u\_t = \[CapitalDelta]\[VeryThinSpace]m\_t\)]], ". The distribution of the initial realization of ", Cell[BoxData[ \(TraditionalForm\`m\)]], " is taken as uniform in the region of interest, so this can be impounded \ into the constant of proportionality." }], "Text"], Cell[TextData[{ "The direct approach to making the draw would be to enumerate all possible \ sample paths for ", Cell[BoxData[ \(TraditionalForm\`q\)]], ", compute the unnormalized (i.e., up to the factor of proportionality) \ probabilities; normalize. Finally, we'd make the draw on the resulting \ discrete probability space. Given that the number of sample paths is ", Cell[BoxData[ \(TraditionalForm\`2\^T\)]], ", the direct approach is not feasible." }], "Text"], Cell[TextData[{ "Fortunately, it is not necessary to fully characterize ", Cell[BoxData[ \(TraditionalForm\`Pr(q | p)\)]], " to make the draw. The next section describes a Gibbs sampler approach to \ the problem.\t" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["The Gibbs sampler", "Subsection"], Cell[TextData[{ "At this stage, we assume that ", Cell[BoxData[ \(TraditionalForm\`c\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\)]], " are known, so for notational economy, these parameters will be dropped \ from the explicit conditioning set. Furthermore, since the ", Cell[BoxData[ \(TraditionalForm\`p\)]], " are known, given ", Cell[BoxData[ \(TraditionalForm\`q\)]], ", the ", Cell[BoxData[ \(TraditionalForm\`m\)]], " are redundant. In the Gibbs sampler, ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " draws are made sequentially. To distinguish the newly drawn ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " from those left over from the previous draw, I denote the newly drawn \ values ", Cell[BoxData[ \(TraditionalForm\`\(q\_t\%*\)\)]], ". The steps are then:" }], "Text"], Cell[TextData[{ "1. ", Cell[BoxData[ \(TraditionalForm\`Draw\ \(q\_1\%*\) from\ \(Pr(q\_1 | p, q\_2, q\_3, ... , q\_T)\)\)]] }], "Text"], Cell[TextData[{ "2. ", Cell[BoxData[ \(TraditionalForm\`Draw\ \(q\_2\%*\) from\ \(Pr(q\_2 | p, \(q\_1\%*\), q\_3, ... , q\_T)\)\)]] }], "Text"], Cell["\t\[VerticalEllipsis]", "Text"], Cell[TextData[{ "3. ", Cell[BoxData[ \(TraditionalForm\`Draw\ \(q\_T\%*\)\ from\ \(Pr( q\_T | p, \(q\_1\%*\), \(q\_2\%*\), ... , \(q\_\(T - 1\)\%*\))\)\)]] }], "Text"], Cell[TextData[{ "Note that at each step, we use the fresh ", Cell[BoxData[ \(TraditionalForm\`\(q\_t\%*\)\)]], " as they become available. The individual draws all follow a similar \ pattern. We will first consider the general case, the draw for ", Cell[BoxData[ \(TraditionalForm\`q\_t | p, q\_\(\(\\\)\(t\)\)\)]], " for ", Cell[BoxData[ \(TraditionalForm\`1 < t < \(\(T\)\(.\)\)\)]], " The endpoint draws (at ", Cell[BoxData[ \(TraditionalForm\`t = 1\)]], " and ", Cell[BoxData[ \(TraditionalForm\`t = T\)]], ") follow as simple modifications. " }], "Text"], Cell[TextData[{ "Given the structure of the model, ", Cell[BoxData[ FormBox[ StyleBox[\(Pr(q\_t | p, q\_\(\(\\\)\(t\)\)) = Pr(q\_t | p\_t, m\_\(t - 1\), m\_\(t + 1\))\), ScriptSizeMultipliers->0.71], TraditionalForm]]], ". That is, once we know ", Cell[BoxData[ FormBox[ StyleBox[\(p\_t, m\_\(t - 1\), and\ m\_\(t + 1\)\), ScriptSizeMultipliers->0.71], TraditionalForm]]], ", the additional variables in the full conditioning set are not \ informative. To analyze ", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | p\_t, m\_\(t - 1\), m\_\(t + 1\))\)]], ", note that by conventional conditional probability calculations" }], "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_t | p\_t, m\_\(t - 1\), m\_\(t + 1\))\), "=", StyleBox[\(\(\(f(p\_t | q\_t, \ m\_\(t - 1\), \ m\_\(t + 1\))\)\ \[Times]\(Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\))\)\)\/\(f(p\_t | m\_\(t - 1\), m\_\(t + 1\))\)\), ScriptLevel->0]}], TraditionalForm]]]], "NumberedEquation", CellTags->"RollBayes"], Cell[TextData[{ "When we actually need to evaluate this, ", Cell[BoxData[ \(TraditionalForm\`p\_t\)]], " is known, so the denominator can be treated as a proportionality \ constant. Next, because the trade directions are independent of the efficient \ price evolution, ", Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\))\), "=", RowBox[{\(Pr(q\_t)\), "=", RowBox[{\(1/2\), Cell[""]}]}]}], TraditionalForm]]], ". Therefore, " }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | p\_t, m\_\(t - 1\), m\_\(t + 1\)) \[Proportional] f(p\_t | q\_t, m\_\(t - 1\), m\_\(t + 1\))\)]], ". " }], "Text"], Cell["To evaluate the r.h.s., note that ", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`f(m\_t | m\_\(t - 1\), m\_\(t + 1\)) \[Proportional] \(f(m\_\(t + 1\) | m\_t)\) \(f( m\_t | m\_\(t - 1\))\) = \(\[Phi](0, \[Sigma]\_u, m\_t - m\_\(t - 1\))\)\ \(\[Phi](0, \[Sigma]\_u, m\_\(t + 1\) - m\_t)\)\)]] }], "Text"], Cell["The last expression is:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ff = \(\[Phi][0, \[Sigma]\_u, u\_t] \[Phi][0, \[Sigma]\_u, u\_\(t + 1\)] /. u\_t_ \[Rule] m\_t - m\_\(t - 1\)\) /. \[Phi]Def\)], "Input", CellLabel->"In[18]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(\(-\(\((m\_t - m\_\(t - 1\))\)\^2\/\ \(2\ \[Sigma]\_u\%2\)\)\) - \((m\_\(t + 1\) - m\_t)\)\^2\/\(2\ \[Sigma]\_u\%2\ \)\)\/\(2\ \[Pi]\ \[Sigma]\_u\%2\)\)], "Output", CellLabel->"Out[18]="] }, Open ]], Cell["This implies ", "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`f(m\_t | m\_\(t - 1\), m\_\(t + 1\)) = \[Phi](\[Mu]\_t, \[Sigma]\_t, m\_t)\)]]], "NumberedEquation", CellTags->"RollDensity"], Cell["where", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(mParams = GetNormalForm[ff, m\_t, \[Mu]\_t, \[Sigma]\_t];\)\), "\[IndentingNewLine]", \(mParams /. RuleToEquals // TableForm\)}], "Input", CellLabel->"In[19]:="], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { TagBox[ RowBox[{ TagBox[\(\[Mu]\_t\), HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(1\/2\ \((m\_\(t - 1\) + m\_\(t + 1\))\)\), HoldForm], ")"}]}], HoldForm]}, { TagBox[ RowBox[{ TagBox[\(\[Sigma]\_t\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(\[Sigma]\_u\/\@2\), HoldForm]}], HoldForm]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ { HoldForm[ Times[ HoldForm[ Subscript[ \[Mu], t]], "=", HoldForm[ Times[ Rational[ 1, 2], Plus[ Subscript[ m, Plus[ -1, t]], Subscript[ m, Plus[ 1, t]]]]]]], HoldForm[ Times[ HoldForm[ Subscript[ \[Sigma], t]], "=", HoldForm[ Times[ Power[ 2, Rational[ -1, 2]], Subscript[ \[Sigma], u]]]]]}]], TraditionalForm]], "Output",\ CellLabel->"Out[20]//TableForm="] }, Open ]], Cell[TextData[{ "Since ", Cell[BoxData[ \(TraditionalForm\`p\_t = m\_t + c\[VeryThinSpace]q\_t\)]], ", " }], "Text"], Cell[TextData[Cell[BoxData[ FormBox[ StyleBox[\(f(p\_t | q\_t, m\_\(t - 1\), m\_\(t + 1\)) = \[Phi](\[Mu]\_t, \[Sigma]\_t, p\_t - c\[VeryThinSpace]q\_t)\), "Caption"], TraditionalForm]]]], "NumberedEquation", CellTags->"Rollfm"], Cell[CellGroupData[{ Cell[TextData[{ "The unnormalized probabilities of a buy and a sell are given by evaluating \ the above quantity at ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(+1\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(-1\)\)]], " respectively. The normalized probability of a buy is therefore" }], "TextGroup"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(PQ = \[Phi][\[Mu]\_t, \[Sigma]\_t, p\_t - c\ q\_t] /. mParams;\)\), "\[IndentingNewLine]", \(\(PQ /. q\_t \[Rule] \(+1\)\)\/\(\((PQ /. q\_t \[Rule] \(+1\))\) + \ \((PQ /. q\_t \[Rule] \(-1\))\)\)\)}], "Input", CellLabel->"In[21]:="], Cell[BoxData[ \(TraditionalForm\`\(\[Phi](1\/2\ \((m\_\(t - 1\) + m\_\(t + 1\))\), \ \[Sigma]\_u\/\@2, p\_t - c)\)\/\(\[Phi](1\/2\ \((m\_\(t - 1\) + m\_\(t + 1\))\ \), \[Sigma]\_u\/\@2, p\_t - c) + \[Phi](1\/2\ \((m\_\(t - 1\) + m\_\(t + \ 1\))\), \[Sigma]\_u\/\@2, c + p\_t)\)\)], "Output", CellLabel->"Out[22]="] }, Open ]], Cell["This simplifies to", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(% /. \[Phi]Def // Simplify\)], "Input", CellLabel->"In[23]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(\(4\ c\ \ p\_t\)\/\[Sigma]\_u\%2\)\/\(\[ExponentialE]\^\(\(2\ c\ \((m\_\(t - 1\) + \ m\_\(t + 1\))\)\)\/\[Sigma]\_u\%2\) + \[ExponentialE]\^\(\(4\ c\ p\_t\)\/\ \[Sigma]\_u\%2\)\)\)], "Output", CellLabel->"Out[23]="] }, Open ]], Cell[TextData[{ "Given ", Cell[BoxData[ \(TraditionalForm\`p\_t, \ m\_\(t - 1\), \ m\_\(t + 1\), \ c\ and\ \[Sigma]\_u\%2, \ we\ can\ compute\ this\ and\ make\ the\ \(\(draw\)\(.\)\)\)]], " For example, with ", Cell[BoxData[ \(TraditionalForm\`{m\_\(t - 1\) = 5, m\_\(t + 1\) = 5.1`, p\_t = 5.2`, c = 0.2, \[Sigma]\_u = 0.4`}\)], "Caption"], ", the probability of a buy is 0.679. Intuitively, we can rationalize this \ value in the following way. Given that ", Cell[BoxData[ \(TraditionalForm\`m\_\(t - 1\) = 5\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\_\(t + 1\) = 5.1\)]], ", ", Cell[BoxData[ \(TraditionalForm\`E\[VeryThinSpace]m\_t = 5.05\)]], ". That the transaction price lies above this makes it more likely that the \ trade was a \"buy\". " }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " code)" }], "MathGroup"], Cell[CellGroupData[{ Cell[BoxData[ \(%\ /. \ {m\_\(t - 1\) \[Rule] 5, m\_\(t + 1\) \[Rule] 5.1, p\_t \[Rule] 5.20, c \[Rule] 0.2, \[Sigma]\_u \[Rule] 0.4}\)], "Input",\ CellLabel->"In[24]:="], Cell[BoxData[ \(TraditionalForm\`0.6791786991753931`\)], "Output", CellLabel->"Out[24]="] }, Open ]], Cell[TextData[{ "We now consider the endpoint draws, ", Cell[BoxData[ \(TraditionalForm\`\((t = \(1\ and\ t = T\))\)\)]], ", which are slightly different." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell[TextData[Cell[BoxData[ \(TraditionalForm\`t = 1\)]]], "Subsubsection"], Cell[TextData[{ "At ", Cell[BoxData[ \(TraditionalForm\`t = 1\)]], ", the relevant conditional density is ", Cell[BoxData[ \(TraditionalForm\`f(m\_1 | m\_2)\)]], ", which is proportional to ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{\(f(m\_2 | m\_1)\), Cell[""]}], "=", \(\[Phi](0, \[Sigma]\_u, m\_2 - m\_1)\)}], TraditionalForm]]], ". Substituting in for ", Cell[BoxData[ \(TraditionalForm\`m\_1\)]], " gives ", Cell[BoxData[ \(TraditionalForm\`\[Phi](0, \[Sigma]\_u, m\_2 - p\_1 + c\ q\_1)\)], "Caption"], ". The unnormalized probabilities for a buy and sell are given by \ evaluating this at ", Cell[BoxData[ \(TraditionalForm\`q\_1 = \(+1\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`q\_1 = \(-1\)\)]], ". The normalized probability of a buy is:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(Clear[u, \[Sigma], m, c, p, q];\)\), "\[IndentingNewLine]", \(\(PQ = \(\[Phi][0, \[Sigma]\_u, u\_2] /. u\_2 \[Rule] m\_2 - m\_1\) /. m\_1 \[Rule] p\_1 - c\ q\_1;\)\), "\[IndentingNewLine]", \(\(PQ /. q\_1 \[Rule] \(+1\)\)\/\(\((PQ /. q\_1 \[Rule] \(+1\))\) + \ \((PQ /. q\_1 \[Rule] \(-1\))\)\)\)}], "Input", CellLabel->"In[25]:="], Cell[BoxData[ \(TraditionalForm\`\(\[Phi](0, \[Sigma]\_u, c + m\_2 - \ p\_1)\)\/\(\[Phi](0, \[Sigma]\_u, \(-c\) + m\_2 - p\_1) + \[Phi](0, \ \[Sigma]\_u, c + m\_2 - p\_1)\)\)], "Output", CellLabel->"Out[27]="] }, Open ]], Cell["This simplifies to:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(% /. \[Phi]Def // Simplify\)], "Input", CellLabel->"In[28]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(\(2\ c\ \ p\_1\)\/\[Sigma]\_u\%2\)\/\(\[ExponentialE]\^\(\(2\ c\ m\_2\)\/\[Sigma]\_u\%2\ \) + \[ExponentialE]\^\(\(2\ c\ p\_1\)\/\[Sigma]\_u\%2\)\)\)], "Output", CellLabel->"Out[28]="] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[Cell[BoxData[ \(TraditionalForm\`t = T\)]]], "Subsubsection"], Cell[TextData[{ "At time ", Cell[BoxData[ \(TraditionalForm\`T\)]], " we have ", Cell[BoxData[ \(TraditionalForm\`f(m\_T | m\_\(T - 1\)) = \[Phi](0, \[Sigma]\_u, m\_T - m\_\(T - 1\))\)], "Caption"], ". Evaluated at ", Cell[BoxData[ \(TraditionalForm\`m\_T = p\_T - c\[VeryThinSpace]q\_T\)], "Caption"], ",", " this becomes ", Cell[BoxData[ \(TraditionalForm\`\[Phi]( 0, \[Sigma]\_u, \(-m\_\(T - 1\)\) + p\_T - c\ q\_T)\)], "Caption"], ". The (unnormalized) probabilities for a buy and sell are given by \ evaluating this at ", Cell[BoxData[ \(TraditionalForm\`q\_T = \(+1\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`q\_T = \(-1\)\)]], ". The normalized probability of a buy is:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(PQ = \(\[Phi][0, \[Sigma]\_u, u\_T] /. u\_T \[Rule] m\_T - m\_\(T - 1\)\) /. m\_T \[Rule] p\_T - c\ q\_T;\)\), "\[IndentingNewLine]", \(\(PQ /. q\_T \[Rule] \(+1\)\)\/\(\((PQ /. q\_T \[Rule] \(+1\))\) + \ \((PQ /. q\_T \[Rule] \(-1\))\)\)\)}], "Input", CellLabel->"In[29]:="], Cell[BoxData[ \(TraditionalForm\`\(\[Phi](0, \[Sigma]\_u, \(-c\) - m\_\(T - 1\) + p\_T)\ \)\/\(\[Phi](0, \[Sigma]\_u, \(-c\) - m\_\(T - 1\) + p\_T) + \[Phi](0, \ \[Sigma]\_u, c - m\_\(T - 1\) + p\_T)\)\)], "Output", CellLabel->"Out[30]="] }, Open ]], Cell["This evaluates and simplies to:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(% /. \[Phi]Def // Simplify\)], "Input", CellLabel->"In[31]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(\(2\ c\ \ p\_T\)\/\[Sigma]\_u\%2\)\/\(\[ExponentialE]\^\(\(2\ c\ m\_\(T - 1\)\)\/\ \[Sigma]\_u\%2\) + \[ExponentialE]\^\(\(2\ c\ p\_T\)\/\[Sigma]\_u\%2\)\)\)], \ "Output", CellLabel->"Out[31]="] }, Open ]] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Contemporaneous trade impacts on the efficient price", "Section"], Cell[CellGroupData[{ Cell["Description", "Subsection"], Cell["\<\ This model incorporates trade impacts on the efficient price, which are \ presumed to reflect the informationcontent of the trades. The evolution of \ the efficient price is:\ \>", "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`m\_t = m\_\(t - 1\) + \(q\_t\) \(V\_t\) \[Lambda] + u\_t\)]]], "NumberedEquation", CellTags->"InformativeTradeModel"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`V\_t\)]], " is the volume of the trade, \[Lambda] is the impact coefficient, and ", Cell[BoxData[ \(TraditionalForm\`p\_t\)]], " is the observed log transaction price. The quantity ", Cell[BoxData[ \(TraditionalForm\`\(V\_t\) \[Lambda]\)]], " can be interpeted as a product of scalars, or a vector product, as in: ", Cell[BoxData[ \(TraditionalForm\`V\_t = \([1\(\(\ \)\(\ \)\) Vol\_t\ \ \ \@Vol\_t]\)\)]], " and \[Lambda] a 3\[Times]1 vector of coefficients. As in the basic model, \ ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " is the trade direction indicator, +1 for a buy and ", Cell[BoxData[ \(TraditionalForm\`\(-1\)\)]], " for a sell. Thus ", Cell[BoxData[ \(TraditionalForm\`\(q\_t\) V\_t\)]], " is the signed volume. The disturbance ", Cell[BoxData[ \(TraditionalForm\`u\_t\)]], " is public information, and ", Cell[BoxData[ \(TraditionalForm\`\(\(u\_t\)\(~\)\)\)]], Cell[BoxData[ FormBox[ RowBox[{"N", Cell[TextData[{ "(0,", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2\)]], ")" }]]}], TraditionalForm]]], ". The mapping to the observed price is the same as in the Roll model:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`p\_t = m\_t + c\ q\_t\)]] }], "Text"], Cell[TextData[{ "Relative to the basic Roll case discussed in the last section, this model \ is complicated by an additional parameter, \[Lambda], and dependence of the \ ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " on ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], ". " }], "Text"], Cell["\<\ The parameter draw is relatively straightforward, as the model implies\ \>", "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]p\_t = \ \(\[CapitalDelta]\[VeryThinSpace]m\_t + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t = \[Lambda]\ \[VeryThinSpace]\(q\_t\) V\_t + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t + u\_t\)\)]]], "NumberedEquation"], Cell[TextData[{ "At the parameter draw stage, ", Cell[BoxData[ \(TraditionalForm\`q\_t\[VeryThinSpace]V\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]q\_t\)]], " are known. This specification therefore fits in the regression framework, \ and \[Lambda] and ", Cell[BoxData[ \(TraditionalForm\`c\)]], " may be drawn from the regression coefficient posterior. " }], "Text"], Cell["\<\ The latent data draws are more complicated. Given the structure of the model, \ \ \>", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr[q\_t | m\_\(\(\\\)\(t\)\), q\_\(\(\\\)\(t\)\), p\_t] = Pr[q\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\), p\_t]\)]], ". " }], "Text"], Cell[TextData[{ "Analogous to eq. (", CounterBox["NumberedEquation", "RollBayes"], ")," }], "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_t | p\_t, m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\), "=", StyleBox[\(\(\(f(p\_t | q\_t, m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\)\ \[Times]\(Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), \ q\_\(t + 1\))\)\)\/\(f(p\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\)\), ScriptLevel->0]}], TraditionalForm]]]], "NumberedEquation", CellTags->"BayesContemporaneousImpact"], Cell[TextData[{ "As in the simple case, when we need to evaluate this, ", Cell[BoxData[ \(TraditionalForm\`p\_t\)]], " is known, and so the denominator can be treated as a proportionality \ factor. Here, however, and in contrast with the Roll case, ", Cell[BoxData[ FormBox[ RowBox[{\(f(q\_t | m\_\(t - 1\), m\_\(t + 1\)) \[NotEqual] f(q\_t)\), "=", RowBox[{\(1/2\), Cell[""]}]}], TraditionalForm]]], ". Intuitively, if ", Cell[BoxData[ \(TraditionalForm\`m\_\(t + 1\)\)]], "is relatively high, this implies that ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " is more likely to be +1 (a buy). Therefore, we need to compute both of \ the factors in the numerator of eq. (", CounterBox["NumberedEquation", "BayesContemporaneousImpact"], ")." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\)]]], "Subsection"], Cell[TextData[{ "The joint distribution of ", Cell[BoxData[ \(TraditionalForm\`u\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`u\_\(t + 1\)\)]], "is ", Cell[BoxData[ \(TraditionalForm\`\(\[Phi](0, \[Sigma]\_u, u\_t)\)\ \(\[Phi]( 0, \[Sigma]\_u, u\_\(t + 1\))\)\)], "Caption"], ". Substituting from (", CounterBox["NumberedEquation", "InformativeTradeModel"], ") gives: " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(TD = \[Phi][0, \[Sigma]\_u, u\_t] \[Phi][0, \[Sigma]\_u, u\_\(t + 1\)] /. u\_t_ \[Rule] m\_t - \((m\_\(t - 1\) + q\_t\ \[Lambda]\ V\_t)\)\)], "Input", CellLabel->"In[32]:="], Cell[BoxData[ \(TraditionalForm\`\(\[Phi]( 0, \[Sigma]\_u, \(-m\_\(t - 1\)\) + m\_t - \[Lambda]\ q\_t\ V\_t)\)\ \(\[Phi]( 0, \[Sigma]\_u, \(-m\_t\) + m\_\(t + 1\) - \[Lambda]\ q\_\(t + 1\)\ V\_\(t + 1\))\)\)], "Output",\ CellLabel->"Out[32]="] }, Open ]], Cell[TextData[{ "To compute ", Cell[BoxData[ \(TraditionalForm\`\(\(Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\)\(\ \)\)\)]], ", the dependence on ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " must be eliminated, which we do by integrating over ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], ". That is, " }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\)) \[Proportional] \[Integral]\_\(-\[Infinity]\)\%\(+\ \[Infinity]\)\(\[Phi]( 0, \[Sigma]\_u, \(-m\_\(t - 1\)\) + m\_t - \[Lambda]\ q\_t\ V\_t)\)\ \(\[Phi]( 0, \[Sigma]\_u, \(-m\_t\) + m\_\(t + 1\) - \[Lambda]\ q\_\(t + 1\)\ V\_\(t + 1\))\) \ \[DifferentialD]m\_t \[Congruent] Pr(q\_t)\)]] }], "Text"], Cell[TextData[{ "Evaluating the integral gives ", Cell[BoxData[ \(TraditionalForm\`\(\(Pr(q\_t)\)\(\[Congruent]\)\)\)]] }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(fI = Integrate[TD /. \[Phi]Def, {m\_t, \(-\[Infinity]\), \(+\[Infinity]\)}, Assumptions \[Rule] \[Sigma]uAssumptions]\)], "Input", CellLabel->"In[33]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(-\(\((m\_\(t - 1\) - m\_\(t + 1\) + \ \[Lambda]\ q\_t\ V\_t + \[Lambda]\ q\_\(t + 1\)\ V\_\(t + 1\))\)\^2\/\(4\ \ \[Sigma]\_u\%2\)\)\)\/\(2\ \@\[Pi]\ \[Sigma]\_u\)\)], "Output", CellLabel->"Out[33]="] }, Open ]], Cell["Performing the final normalization:", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\ = \(Pr(q\_t)\)\/\(Pr(\(+1\)) + Pr(\(-1\))\)\)]] }], "Text"], Cell[TextData[{ "Therefore, ", Cell[BoxData[ \(TraditionalForm\`\(\(Pr(q\_t = 1 | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\)\(=\)\)\)]] }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(PrBuy = Pr[1]\/\(Pr[\(+1\)] + Pr[\(-1\)]\) // Simplify\)], "Input", CellLabel->"In[34]:="], Cell[BoxData[ \(TraditionalForm\`\(Pr(1)\)\/\(Pr(\(-1\)) + Pr(1)\)\)], "Output", CellLabel->"Out[34]="] }, Open ]], Cell["For example, at the values", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(TrialValues = {m\_\(t - 1\) \[Rule] 5, m\_\(t + 1\) \[Rule] 5.2, V\_t \[Rule] 1, q\_\(t + 1\) -> 1, V\_\(t + 1\) \[Rule] 2, \[Lambda] \[Rule] 0.01, \[Sigma]\_u \[Rule] 0.05};\)\), "\[IndentingNewLine]", \(TrialValues /. RuleToEquals\)}], "Input", CellLabel->"In[35]:="], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ TagBox[ RowBox[{ TagBox[\(m\_\(t - 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["5", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(m\_\(t + 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["5.2`", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(V\_t\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["1", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(q\_\(t + 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["1", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(V\_\(t + 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["2", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox["\[Lambda]", HoldForm], " ", "\<\"=\"\>", " ", TagBox["0.01`", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(\[Sigma]\_u\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["0.05`", HoldForm]}], HoldForm]}], "}"}], TraditionalForm]], "Output", CellLabel->"Out[36]="] }, Open ]], Cell[TextData[{ "the probability of a buy is 0.673. Intuitively, given the increase in the \ efficient price between ", Cell[BoxData[ \(TraditionalForm\`m\_\(t - 1\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\_\(t + 1\)\)]], ", it is more likely that the trade at time ", Cell[BoxData[ \(TraditionalForm\`t\)]], " was a buy." }], "Text"], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " code)" }], "MathGroup"], Cell[CellGroupData[{ Cell[BoxData[ \(PrqBuy1 = PrBuy /. TrialValues\)], "Input", CellLabel->"In[37]:="], Cell[BoxData[ \(TraditionalForm\`\(Pr(1)\)\/\(Pr(\(-1\)) + Pr(1)\)\)], "Output", CellLabel->"Out[37]="] }, Open ]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[Cell[BoxData[ \(TraditionalForm\`f(p\_t | m\_\(t - 1\), q\_t, m\_\(t + 1\), m\_\(t + 1\), q\_\(t + 1\))\)]]], "Subsection"], Cell["As indicated above, the transition density is ", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\(\[Phi]( 0, \[Sigma]\_u, \(-m\_\(t - 1\)\) + m\_t - \[Lambda]\ q\_t\ V\_t)\)\ \(\[Phi]( 0, \[Sigma]\_u, \(-m\_t\) + m\_\(t + 1\) - \[Lambda]\ q\_\(t + 1\)\ V\_\(t + 1\))\)\)]], ". " }], "Text"], Cell["Expanding the normal densities and simplifying gives:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(TD2 = TD /. \[Phi]Def // Simplify\)], "Input", CellLabel->"In[38]:="], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(-\(\(\((m\_\(t - 1\) - m\_t + \ \[Lambda]\ q\_t\ V\_t)\)\^2 + \((m\_t - m\_\(t + 1\) + \[Lambda]\ q\_\(t + \ 1\)\ V\_\(t + 1\))\)\^2\)\/\(2\ \[Sigma]\_u\%2\)\)\)\/\(2\ \[Pi]\ \[Sigma]\_u\ \%2\)\)], "Output", CellLabel->"Out[38]="] }, Open ]], Cell[TextData[{ "Therefore, ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " is normal: ", Cell[BoxData[ \(TraditionalForm\`f(m\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, q\_\(t + 1\)) = \[Phi](\[Mu]\_t, \[Sigma]\_t, m\_t)\)]], " with parameters" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(mParams = GetNormalForm[TD2, m\_t, \[Mu]\_t, \[Sigma]\_t];\)\), "\[IndentingNewLine]", \(mParams /. RuleToEquals // TableForm\)}], "Input", CellLabel->"In[39]:="], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { TagBox[ RowBox[{ TagBox[\(\[Mu]\_t\), HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(1\/2\ \((m\_\(t - 1\) + m\_\(t + 1\) + \[Lambda]\ q\_t\ V\_t - \[Lambda]\ \ q\_\(t + 1\)\ V\_\(t + 1\))\)\), HoldForm], ")"}]}], HoldForm]}, { TagBox[ RowBox[{ TagBox[\(\[Sigma]\_t\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(\[Sigma]\_u\/\@2\), HoldForm]}], HoldForm]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ { HoldForm[ Times[ HoldForm[ Subscript[ \[Mu], t]], "=", HoldForm[ Times[ Rational[ 1, 2], Plus[ Subscript[ m, Plus[ -1, t]], Subscript[ m, Plus[ 1, t]], Times[ \[Lambda], Subscript[ q, t], Subscript[ V, t]], Times[ -1, \[Lambda], Subscript[ q, Plus[ 1, t]], Subscript[ V, Plus[ 1, t]]]]]]]], HoldForm[ Times[ HoldForm[ Subscript[ \[Sigma], t]], "=", HoldForm[ Times[ Power[ 2, Rational[ -1, 2]], Subscript[ \[Sigma], u]]]]]}]], TraditionalForm]], "Output", CellLabel->"Out[40]//TableForm="] }, Open ]], Cell[TextData[{ "Substituting in for ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " gives" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`f(p\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, q\_\(t + 1\)) = \[Phi](\[Mu]\_t, \[Sigma]\_t, p\_t - c\[VeryThinSpace]q\_t)\)]] }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Summary", "Subsection"], Cell["The draw is made in the following steps.", "Text"], Cell[TextData[{ "1. Compute the normalized probabilities ", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\)]], " for ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(\(-1\)\ and\ q\_t = \(+1\)\)\)]], "." }], "Text"], Cell[TextData[{ "2. Compute ", Cell[BoxData[ \(TraditionalForm\`\(\[Phi](\[Mu]\_t, \[Sigma]\_t, p\_t - c\[VeryThinSpace]q\_t)\) \(Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), q\_\(t + 1\))\)\)]], " for ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(\(-1\)\ and\ q\_t = \(+1\)\)\)]], "." }], "Text"], Cell["3. Normalize the probabilities from step 2.", "Text"], Cell["4. Make the draw.", "Text"], Cell["\<\ Note that the overall calculation requires two normalizations, at step 1 \ (done, above, for the trial values) and step 3.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Endpoint modifications", "Subsection"], Cell[CellGroupData[{ Cell[TextData[Cell[BoxData[ \(TraditionalForm\`t = 1\)]]], "Subsubsection"], Cell[TextData[{ "At ", Cell[BoxData[ \(TraditionalForm\`t = 1\)]], ", " }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(q\_1 | m\_\\1, q\_\\1, p\_1)\[IndentingNewLine] = Pr(q\_1 | m\_2, q\_2, p\_1)\[IndentingNewLine] \[Proportional] \(f(p\_1 | m\_2, q\_2, q\_1)\)\[Times]\(Pr(q\_1 | m\_2, q\_2)\)\)]], ". " }], "Text"], Cell[TextData[{ "Here, however, ", Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_1 | m\_2, q\_2)\), "=", RowBox[{\(Pr(q\_1)\), "=", RowBox[{\(1/2\), Cell[""]}]}]}], TraditionalForm]]], ". To compute the first term on the r.h.s., the relevant density is ", Cell[BoxData[ \(TraditionalForm\`f(u\_2) = \[Phi](0, \[Sigma]\_u, u\_2)\)]], ". Substituting in for ", Cell[BoxData[ \(TraditionalForm\`u\_2\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\_1\)]], "and solving indicates" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`f(m\_1 | m\_2, q\_2, q\_1) = \(f(m\_1 | m\_2, q\_2) = \[Phi](\[Mu]\_1, \[Sigma]\_1, m\_1)\)\)]] }], "Text"], Cell["where", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(m1Params = GetNormalForm[\(\[Phi][0, \[Sigma]\_u, u\_2] /. u\_2 \[Rule] m\_2 - \((m\_1 + q\_2\ \[Lambda]\[VeryThinSpace]V\_2)\)\) /. \[Phi]Def, m\_1, \[Mu]\_1, \[Sigma]\_1];\)\), "\[IndentingNewLine]", \(m1Params /. RuleToEquals // TableForm\)}], "Input", CellLabel->"In[41]:="], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { TagBox[ RowBox[{ TagBox[\(\[Mu]\_1\), HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(m\_2 - \[Lambda]\ q\_2\ V\_2\), HoldForm], ")"}]}], HoldForm]}, { TagBox[ RowBox[{ TagBox[\(\[Sigma]\_1\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(\[Sigma]\_u\), HoldForm]}], HoldForm]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ { HoldForm[ Times[ HoldForm[ Subscript[ \[Mu], 1]], "=", HoldForm[ Plus[ Subscript[ m, 2], Times[ -1, \[Lambda], Subscript[ q, 2], Subscript[ V, 2]]]]]], HoldForm[ Times[ HoldForm[ Subscript[ \[Sigma], 1]], "=", HoldForm[ Subscript[ \[Sigma], u]]]]}]], TraditionalForm]], "Output", CellLabel->"Out[42]//TableForm="] }, Open ]], Cell["Thus,", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`f(p\_1 | m\_2, q\_2, q\_1) = \[Phi](\[Mu]\_1, \[Sigma]\_1, p\_1 - c\[VeryThinSpace]q\_1)\)]] }], "Text"], Cell[TextData[{ "We evaluate this. for ", Cell[BoxData[ \(TraditionalForm\`q\_1 = \(\[PlusMinus]1\)\)]], ", normalize, and make the draw of ", Cell[BoxData[ \(TraditionalForm\`q\_1\)]], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[Cell[BoxData[ \(TraditionalForm\`t = T\)]]], "Subsubsection"], Cell[TextData[{ "At ", Cell[BoxData[ \(TraditionalForm\`t = T\)]], ", " }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(q\_T | m\_\(\(\\\)\(T\)\), q\_\(\(\\\)\(T\)\), p\_T)\[IndentingNewLine] = Pr(q\_T | m\_\(T - 1\), q\_\(T - 1\), p\_T)\[IndentingNewLine] \[Proportional] \(f(p\_T | m\_\(T - 1\), q\_\(T - 1\), q\_T)\)\[Times]\(Pr(q\_T | m\_\(T - 1\), q\_\(T - 1\))\)\)]], ". " }], "Text"], Cell[TextData[{ "Again, ", Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_T | m\_\(T - 1\), q\_\(T - 1\))\), "=", RowBox[{\(Pr(q\_\(T - 1\))\), "=", RowBox[{\(1/2\), Cell[""]}]}]}], TraditionalForm]]], ". To compute the first term on the r.h.s., the relevant density is ", Cell[BoxData[ \(TraditionalForm\`f(u\_T) = \[Phi](0, \[Sigma]\_u, u\_T)\)]], ". Substituting in for ", Cell[BoxData[ \(TraditionalForm\`u\_T\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\_T\)]], " gives:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`f(m\_T | m\_\(T - 1\), q\_\(T - 1\), q\_T) = \[Phi](\[Mu]\_T, \[Sigma]\_T, m\_T)\)]] }], "Text"], Cell["where", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(mTParams = GetNormalForm[\(\[Phi][0, \[Sigma]\_u, u\_T] /. u\_T \[Rule] m\_T - \((m\_\(T - 1\) + \(q\_T\) \[Lambda]\ V\_T)\)\) /. \ \[Phi]Def, m\_T, \[Mu]\_T, \[Sigma]\_T];\)\), "\[IndentingNewLine]", \(mTParams /. RuleToEquals // TableForm\)}], "Input", CellLabel->"In[43]:="], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { TagBox[ RowBox[{ TagBox[\(\[Mu]\_T\), HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(m\_\(T - 1\) + \[Lambda]\ q\_T\ V\_T\), HoldForm], ")"}]}], HoldForm]}, { TagBox[ RowBox[{ TagBox[\(\[Sigma]\_T\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(\[Sigma]\_u\), HoldForm]}], HoldForm]} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], TableForm[ { HoldForm[ Times[ HoldForm[ Subscript[ \[Mu], T]], "=", HoldForm[ Plus[ Subscript[ m, Plus[ -1, T]], Times[ \[Lambda], Subscript[ q, T], Subscript[ V, T]]]]]], HoldForm[ Times[ HoldForm[ Subscript[ \[Sigma], T]], "=", HoldForm[ Subscript[ \[Sigma], u]]]]}]], TraditionalForm]], "Output", CellLabel->"Out[44]//TableForm="] }, Open ]], Cell["We normalize and make the draw.", "Text"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Discrete prices", "Section", CellTags->"Discrete Prices"], Cell[CellGroupData[{ Cell["Model Description", "Subsection"], Cell["\<\ This model is a Roll model with price discreteness. The evolution of the \ (log) efficient price is:\ \>", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`m\_t = m\_\(t - 1\) + u\_t\)]], " where ", Cell[BoxData[ FormBox[ RowBox[{\(u\_t\), " ", "is", " ", "distributed", " ", "as", " ", "N", Cell[TextData[{ "(0,", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2\)]], ")" }]]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "The (level) efficient price is therefore ", Cell[BoxData[ \(TraditionalForm\`M\_t = e\^m\_t\)]], ". (The units here are \"dollars.\") The half-spread in levels is ", "C.", " The bid and ask quotes are:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`B\_t = Floor(M\_t - C)\)]], "\n\t", Cell[BoxData[ \(TraditionalForm\`A\_t = Ceiling(M\_t + C)\)]] }], "Text"], Cell["\<\ Note that the rounding is asymmetric. The bid is rounded down to the next \ available increment; the ask is rounded up. It is assumed that the variables \ are scaled so that the tick size is unity. The buy/sell indicator is\ \>", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(q\_t\), "=", RowBox[{"{", GridBox[{ { RowBox[{\(+1\), ",", " ", RowBox[{ StyleBox["a", FontSlant->"Plain"], StyleBox[" ", FontSlant->"Plain"], "buy"}], ",", " ", \(with\ probability\ 1/2\)}]}, { RowBox[{\(-1\), ",", " ", RowBox[{ StyleBox["a", FontSlant->"Plain"], StyleBox[" ", FontSlant->"Plain"], "sell"}], ",", " ", \(with\ probability\ 1/2\)}]} }]}]}], TraditionalForm]]], "\nThe obseved transaction price is" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(P\_t\), "=", RowBox[{"{", GridBox[{ {\(\(A\_t\) if\ q\_t = \(+1\)\)}, {\(\(B\_t\) if\ q\_t = \(-1\)\)} }]}]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "In the model without discreteness, the cost parameter (here, ", Cell[BoxData[ \(TraditionalForm\`C\)]], ") can be estimated from the regression specification eq. (", CounterBox["NumberedEquation", "cRegression"], "). With the rounding transformations in the present case, there is no \ corresponding regression. We discuss the draw of ", Cell[BoxData[ \(TraditionalForm\`C\)]], " below. " }], "Text"], Cell[TextData[{ "The latent data draw is also complicated. Without discreteness, ", Cell[BoxData[ \(TraditionalForm\`p\_t = m\_t + c\ q\_t\)]], ", so (given ", Cell[BoxData[ \(TraditionalForm\`c\)]], ") any variable in ", Cell[BoxData[ \(TraditionalForm\`{p\_t, m\_t, q\_t}\)]], " is determined by the other two. This is not the case here: ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " must be drawn separately. The steps are:" }], "Text"], Cell[TextData[{ "\t1. Draw ", Cell[BoxData[ \(TraditionalForm\`q\_t | m\_\(\(\\\)\(t\)\), q\_\(\(\\\)\(t\)\), P\_t\)]] }], "Text"], Cell[TextData[{ "\t2. Draw ", Cell[BoxData[ \(TraditionalForm\`m\_t | m\_\(\(\\\)\(t\)\), q, P\_t\)]] }], "Text"], Cell[TextData[{ "Note that the conditioning set at step 2 includes ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Drawing ", Cell[BoxData[ \(TraditionalForm\`q\_t | m\_\(\(\\\)\(t\)\), q\_\(\(\\\)\(t\)\), P\_t\)]] }], "Subsection"], Cell["From the properties of conditional probabilities:", "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), P\_t)\), "\[IndentingNewLine]", "=", RowBox[{ RowBox[{ StyleBox[\(\(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t)\)\ \[Times]\(Pr(q\_t, \(\(|\)\(m\_\(t - 1\)\)\), m\_\(t + 1\))\)\[Times]\(f(m\_\(t - 1\), m\_\(t + 1\))\)\)\/\(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\))\) \(f(m\_\(t - 1\), m\_\(t + 1\))\)\)\), ScriptLevel->0], "\[IndentingNewLine]", "\[Proportional]", \(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t)\)\ \[Times]\(Pr(q\_t, \(\(|\)\(m\_\(t - 1\)\)\), m\_\(t + 1\))\)\)}], "\[IndentingNewLine]", " ", "=", \(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t)\)\ \[Times]\(Pr(q\_t)\)\)}]}], TraditionalForm]]]], "NumberedEquation"], Cell[TextData[{ "where we have used the fact that the denominator will be a constant of \ proportionality. The last equality follows from the fact that ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " is independent of the evolution of ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], ". Next," }], "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t) = \[Integral]\_\(m\+_\)\%\(m\&_\)\(f(m\_t | m\_\(t - 1\), m\_\(t + 1\))\) \[DifferentialD]m\_t\)]]], "NumberedEquation", CellTags->"DiscretenessPr"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`m\+_\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\&_\)]], " are the limits established by ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " and the Floor and Ceiling rounding functions (see below). ", Cell[BoxData[ \(TraditionalForm\`f(m\_t | m\_\(t - 1\), m\_\(t + 1\))\)]], " is given in eq. (", CounterBox["NumberedEquation", "RollDensity"], "). Using (", CounterBox["NumberedEquation"], "), we compute unnormalized probabilities for ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(\(+1\)\ and\ q\_t = \(-1\)\)\)]], ". We normalize these probabilities and draw ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], ". We then proceed to the ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " draw. " }], "Text"], Cell[TextData[{ "The limits of integration in eq. (", CounterBox["NumberedEquation"], ") are computed as follows. From the definition of the Floor and Ceiling \ functions, " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MBidLimits = InequalitySolve[B\_t < M\_t - C < B\_t + 1, M\_t]\)], "Input", CellLabel->"In[45]:="], Cell[BoxData[ \(TraditionalForm\`C + B\_t < M\_t < C + B\_t + 1\)], "Output", CellLabel->"Out[45]="] }, Open ]], Cell["and", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MAskLimits = InequalitySolve[A\_t - 1 < M\_t + C < A\_t, M\_t]\)], "Input", CellLabel->"In[46]:="], Cell[BoxData[ \(TraditionalForm\`\(-C\) + A\_t - 1 < M\_t < A\_t - C\)], "Output", CellLabel->"Out[46]="] }, Open ]], Cell[TextData[{ "When ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(-1\)\)]], ", ", Cell[BoxData[ \(TraditionalForm\`P\_t = B\_t\)]], " and:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MBidLimits = MBidLimits /. B\_t \[Rule] P\_t\)], "Input", CellLabel->"In[47]:="], Cell[BoxData[ \(TraditionalForm\`C + P\_t < M\_t < C + P\_t + 1\)], "Output", CellLabel->"Out[47]="] }, Open ]], Cell[TextData[{ "When ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(+1\)\)]], ", ", Cell[BoxData[ \(TraditionalForm\`P\_t = A\_t\)]], " and:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MAskLimits = MAskLimits /. A\_t \[Rule] P\_t\)], "Input", CellLabel->"In[48]:="], Cell[BoxData[ \(TraditionalForm\`\(-C\) + P\_t - 1 < M\_t < P\_t - C\)], "Output", CellLabel->"Out[48]="] }, Open ]], Cell[TextData[{ "As long as ", Cell[BoxData[ \(TraditionalForm\`q\_t \[Element] {\(-1\), \(+1\)}\)]], ", the lower and upper limits may be expressed as functions:" }], "Text"], Cell[TextData[{ StyleBox[Cell[BoxData[ FormBox[ TagBox[ RowBox[{ TagBox[ TagBox[\(\(M\+_\)(q\_t)\), HoldForm], HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(1\/2\ \((2\ P\_t - 2\ C\ q\_t - q\_t - 1)\)\), HoldForm], ")"}]}], HoldForm], TraditionalForm]], "TextStripped"], "TextStripped"], " \nand \n", StyleBox[Cell[BoxData[ FormBox[ TagBox[ RowBox[{ TagBox[ TagBox[\(\(M\&_\)(q\_t)\), HoldForm], HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(P\_t - 1\/2\ \((2\ C + 1)\)\ q\_t + 1\/2\), HoldForm], ")"}]}], HoldForm], TraditionalForm]], "TextStripped"], "TextStripped"] }], "NumberedEquation", CellTags->"MLimits"], Cell[TextData[{ "The limits on the log efficient price are then ", Cell[BoxData[ \(TraditionalForm\`\(m\+_\)(q\_t) = log[\(M\+_\)(q\_t)]\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\(m\&_\)(q\_t) = log[\(M\&_\)(q\_t)]\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " details)" }], "MathGroup"], Cell[CellGroupData[{ Cell[BoxData[ \({MBidLimits[\([1]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(-1\), MAskLimits[\([1]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(+1\)}\)], "Input", CellLabel->"In[49]:="], Cell[BoxData[ \(TraditionalForm\`{C + P\_t == a - b, \(-C\) + P\_t - 1 == a + b}\)], "Output", CellLabel->"Out[49]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Flatten[Solve[%, {a, b}] // Simplify]\)], "Input", CellLabel->"In[50]:="], Cell[BoxData[ \(TraditionalForm\`{a \[Rule] P\_t - 1\/2, b \[Rule] \(-C\) - 1\/2}\)], "Output", CellLabel->"Out[50]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(M\+_[q_] := Evaluate[a + b\ q\ /. % // FullSimplify]; HoldForm[M\+_[\[VeryThinSpace]q\_t\[VeryThinSpace]]] \[Rule] M\+_[q\_t] /. RuleToEquals\)], "Input", CellLabel->"In[51]:="], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ TagBox[ TagBox[\(\(M\+_\)(q\_t)\), HoldForm], HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(1\/2\ \((2\ P\_t - 2\ C\ q\_t - q\_t - 1)\)\), HoldForm], ")"}]}], HoldForm], TraditionalForm]], "Output", CellLabel->"Out[51]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(M\+_[q\_t] /. q\_t \[Rule] {1, \(-1\)} // Simplify\)], "Input", CellLabel->"In[52]:="], Cell[BoxData[ \(TraditionalForm\`{\(-C\) + P\_t - 1, C + P\_t}\)], "Output", CellLabel->"Out[52]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \({MBidLimits[\([5]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(-1\), MAskLimits[\([5]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(+1\)}\)], "Input", CellLabel->"In[53]:="], Cell[BoxData[ \(TraditionalForm\`{C + P\_t + 1 == a - b, P\_t - C == a + b}\)], "Output",\ CellLabel->"Out[53]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Flatten[Solve[%, {a, b}] // Simplify]\)], "Input", CellLabel->"In[54]:="], Cell[BoxData[ \(TraditionalForm\`{a \[Rule] P\_t + 1\/2, b \[Rule] \(-C\) - 1\/2}\)], "Output", CellLabel->"Out[54]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(M\&_[q_] := Evaluate[a + b\ q\ /. % // FullSimplify]; HoldForm[M\&_[\[VeryThinSpace]q\_t\[VeryThinSpace]]] \[Rule] M\&_[q\_t] /. RuleToEquals\)], "Input", CellLabel->"In[55]:="], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ TagBox[ TagBox[\(\(M\&_\)(q\_t)\), HoldForm], HoldForm], " ", "\<\"=\"\>", " ", RowBox[{"(", TagBox[\(P\_t - 1\/2\ \((2\ C + 1)\)\ q\_t + 1\/2\), HoldForm], ")"}]}], HoldForm], TraditionalForm]], "Output", CellLabel->"Out[55]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(M\&_[q\_t]\)], "Input", CellLabel->"In[56]:="], Cell[BoxData[ \(TraditionalForm\`P\_t - 1\/2\ \((2\ C + 1)\)\ q\_t + 1\/2\)], "Output", CellLabel->"Out[56]="] }, Open ]], Cell[BoxData[ \(m\+_[q_] := Log[M\+_[q]]; m\&_[q_] := Log[M\&_[q]]\)], "InputOnly", CellLabel->"In[57]:="] }, Closed]], Cell[CellGroupData[{ Cell["Recall that ", "TextGroup"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\(\(f(m\_t | m\_\(t - 1\), m\_\(t + 1\))\)\(=\)\)\)]], Cell[BoxData[ \(TraditionalForm\`\[Phi][\[Mu]\_m, \[Sigma]\_m, m\_t]\)]], " with ", Cell[BoxData[ \(TraditionalForm\`{\[Mu]\_m = \ \((m\_\(t - 1\) + m\_\(t + 1\))\)/ 2, \[Sigma]\_m = \[Sigma]\_u/\@2}\)], "Caption"], ". " }], "Text"], Cell[TextData[{ "From eq. (", CounterBox["NumberedEquation", "DiscretenessPr"], "), ", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), P\_t)\)]], Cell[BoxData[ \(TraditionalForm\`\(\(\[Proportional]\)\(\ \)\(\[CapitalPhi][\[Mu]\_m, \ \[Sigma]\_m, \(m\+_\)(q\_t), \(m\&_\)(q\_t)]\)\)\)]], " for ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(\[PlusMinus]1\)\)]], ". Therefore, the normalized probability of a buy is:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ StyleBox[\(\(\[CapitalPhi](\[Mu]\_m, \[Sigma]\_m, \(m\+_\)(\(+1\)), \ \(m\&_\)(\(+1\)))\)\/\(\[CapitalPhi](\[Mu]\_m, \[Sigma]\_m, \(m\+_\)(\(-1\)), \ \(m\&_\)(\(-1\))) + \[CapitalPhi](\[Mu]\_m, \[Sigma]\_m, \(m\+_\)(\(+1\)), \ \(m\&_\)(\(+1\)))\)\), ScriptLevel->0], TraditionalForm]], "Caption"] }], "Text"], Cell[TextData[{ "At the values ", StyleBox[Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ TagBox[ RowBox[{ TagBox[\(m\_\(t - 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(log(100)\), HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(m\_\(t + 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(log(104)\), HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(P\_t\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["101", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox["C", HoldForm], " ", "\<\"=\"\>", " ", TagBox["0.2`", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(\[Sigma]\_u\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["0.01`", HoldForm]}], HoldForm]}], "}"}], TraditionalForm]], "TextStripped"], "TextStripped"], " this becomes ", Cell[BoxData[ \(TraditionalForm\`0.092\)], "Caption"], ". Intuitively, given the locations of ", Cell[BoxData[ \(TraditionalForm\`m\_\(t - 1\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\_\(t + 1\)\)]], ", ", Cell[BoxData[ \(TraditionalForm\`E\[VeryThinSpace]m\_t \[TildeTilde] 102\)]], ". Since ", Cell[BoxData[ \(TraditionalForm\`P\_t\)]], " lies below this, it is more likely that the transaction was a sale, and \ the buy probability is below one-half." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " details)" }], "MathGroup"], Cell[CellGroupData[{ Cell[BoxData[ \(Pr = HoldForm[\[CapitalPhi][\[Mu]\_m, \[Sigma]\_m, m\+_[\(+1\)], \ m\&_[\(+1\)]]\/\(\[CapitalPhi][\[Mu]\_m, \[Sigma]\_m, m\+_[\(+1\)], m\&_[\(+1\ \)]] + \[CapitalPhi][\[Mu]\_m, \[Sigma]\_m, m\+_[\(-1\)], \ m\&_[\(-1\)]]\)]\)], "Input", CellLabel->"In[58]:="], Cell[BoxData[ FormBox[ TagBox[\(\(\[CapitalPhi](\[Mu]\_m, \[Sigma]\_m, \(m\+_\)(\(+1\)), \ \(m\&_\)(\(+1\)))\)\/\(\[CapitalPhi](\[Mu]\_m, \[Sigma]\_m, \(m\+_\)(\(-1\)), \ \(m\&_\)(\(-1\))) + \[CapitalPhi](\[Mu]\_m, \[Sigma]\_m, \(m\+_\)(\(+1\)), \ \(m\&_\)(\(+1\)))\)\), HoldForm], TraditionalForm]], "Output", CellLabel->"Out[58]="] }, Open ]], Cell[BoxData[ \(\(mParameters = {\[Mu]\_m \[Rule] 1\/2\ \((m\_\(t - 1\) + m\_\(t + 1\))\), \[Sigma]\_m \[Rule] \ \[Sigma]\_u\/\@2};\)\)], "Input", CellLabel->"In[59]:="], Cell[CellGroupData[{ Cell[BoxData[{ \(\(TrialValues = {m\_\(t - 1\) \[Rule] Log[100], m\_\(t + 1\) \[Rule] Log[104], P\_t \[Rule] 101, C \[Rule] .2, \[Sigma]\_u \[Rule] .01};\)\), \ "\[IndentingNewLine]", \(TrialValues /. RuleToEquals\)}], "Input", CellLabel->"In[60]:="], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ TagBox[ RowBox[{ TagBox[\(m\_\(t - 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(log(100)\), HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(m\_\(t + 1\)\), HoldForm], " ", "\<\"=\"\>", " ", TagBox[\(log(104)\), HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(P\_t\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["101", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox["C", HoldForm], " ", "\<\"=\"\>", " ", TagBox["0.2`", HoldForm]}], HoldForm], ",", TagBox[ RowBox[{ TagBox[\(\[Sigma]\_u\), HoldForm], " ", "\<\"=\"\>", " ", TagBox["0.01`", HoldForm]}], HoldForm]}], "}"}], TraditionalForm]], "Output", CellLabel->"Out[61]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(ReleaseHold[Pr] /. mParameters\) /. TrialValues\) /. \[CapitalPhi]Def\)], "Input", CellLabel->"In[62]:="], Cell[BoxData[ \(TraditionalForm\`0.09198927957304893`\)], "Output", CellLabel->"Out[62]="] }, Open ]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Drawing ", Cell[BoxData[ \(TraditionalForm\`m\_t | m\_\(\(\\\)\(t\)\), q, P\_t\)]] }], "Subsection"], Cell[TextData[{ "As noted, ", Cell[BoxData[ \(TraditionalForm\`f(m\_t | m\_\(t - 1\), m\_\(t + 1\)) = \[Phi][\[Mu]\_m, \[Sigma]\_m, m\_t]\)]], " where ", Cell[BoxData[ \(TraditionalForm\`\[Mu]\_m\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_m\)]], " are given above. Conditioning on ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`P\_t\)]], " merely restricts the range of the distribution. Therefore, the draw is \ from the normal distribution ", Cell[BoxData[ \(TraditionalForm\`\[Phi][\[Mu]\_m, \[Sigma]\_m, m\_t]\)]], " truncated to the range ", Cell[BoxData[ \(TraditionalForm\`\((m\+_[q\_t], m\&_[q\_t])\)\)]], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Drawing ", Cell[BoxData[ \(TraditionalForm\`C | P, m, q\)]] }], "Subsection"], Cell[TextData[{ "The upper and lower bounds on ", Cell[BoxData[ \(TraditionalForm\`C\)]], ", given everything else, can be computed in a fashion similar to that used \ above for ", Cell[BoxData[ \(TraditionalForm\`M\_t\)]], ". If ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(-1\)\)]], "," }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(CBidLimits = InequalitySolve[B\_t < M\_t - C < B\_t + 1, C] /. B\_t \[Rule] P\_t\)], "Input", CellLabel->"In[63]:="], Cell[BoxData[ \(TraditionalForm\`M\_t - P\_t - 1 < C < M\_t - P\_t\)], "Output", CellLabel->"Out[63]="] }, Open ]], Cell[TextData[{ "If ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(+1\)\)]], "," }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(CAskLimits = InequalitySolve[A\_t - 1 < M\_t + C < A\_t, C] /. A\_t \[Rule] P\_t\)], "Input", CellLabel->"In[64]:="], Cell[BoxData[ \(TraditionalForm\`\(-M\_t\) + P\_t - 1 < C < P\_t - M\_t\)], "Output", CellLabel->"Out[64]="] }, Open ]], Cell[TextData[{ "Written as a linear function of ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], ", the lower and upper bounds on ", Cell[BoxData[ \(TraditionalForm\`C\)]], " are:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`"\!\(\(C\_t\)\+_\) =(-\!\(M\_t\)+\!\(P\_t\)-\!\(1\/2\ \)) \!\(q\_t\)-\!\(1\/2\)"\)], "Caption"], "\nand\n\t", Cell[BoxData[ \(TraditionalForm\`"\!\(\(C\_t\)\&_\) =(-\!\(M\_t\)+\!\(P\_t\)+\!\(1\/2\ \)) \!\(q\_t\)-\!\(1\/2\)"\)]] }], "Text"], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " details)" }], "MathGroup"], Cell[CellGroupData[{ Cell[BoxData[ \({CBidLimits[\([5]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(-1\), CAskLimits[\([1]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(+1\)}\)], "Input", CellLabel->"In[65]:="], Cell[BoxData[ \(TraditionalForm\`{M\_t - P\_t == a - b, \(-M\_t\) + P\_t - 1 == a + b}\)], "Output", CellLabel->"Out[65]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Flatten[Solve[%, {a, b}] // Simplify]\)], "Input", CellLabel->"In[66]:="], Cell[BoxData[ \(TraditionalForm\`{a \[Rule] \(-\(1\/2\)\), b \[Rule] \(-M\_t\) + P\_t - 1\/2}\)], "Output", CellLabel->"Out[66]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(C\+_ = Evaluate[a + b\ q\_t\ ] /. %\)], "Input", CellLabel->"In[67]:="], Cell[BoxData[ \(TraditionalForm\`\((\(-M\_t\) + P\_t - 1\/2)\)\ q\_t - 1\/2\)], "Output",\ CellLabel->"Out[67]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \({CBidLimits[\([1]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(-1\), CAskLimits[\([5]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(+1\)}\)], "Input", CellLabel->"In[68]:="], Cell[BoxData[ \(TraditionalForm\`{M\_t - P\_t - 1 == a - b, P\_t - M\_t == a + b}\)], "Output", CellLabel->"Out[68]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Flatten[Solve[%, {a, b}] // Simplify]\)], "Input", CellLabel->"In[69]:="], Cell[BoxData[ \(TraditionalForm\`{a \[Rule] \(-\(1\/2\)\), b \[Rule] \(-M\_t\) + P\_t + 1\/2}\)], "Output", CellLabel->"Out[69]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(C\&_ = Evaluate[a + b\ q\_t\ /. %]\)], "Input", CellLabel->"In[70]:="], Cell[BoxData[ \(TraditionalForm\`\((\(-M\_t\) + P\_t + 1\/2)\)\ q\_t - 1\/2\)], "Output",\ CellLabel->"Out[70]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "These bounds cause difficulty because, if we are taking ", Cell[BoxData[ \(TraditionalForm\`P\)]], " and ", Cell[BoxData[ \(TraditionalForm\`M\)]], " as fixed when we make the ", Cell[BoxData[ \(TraditionalForm\`C\)]], " draw, then the new value ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], " is bounded by:" }], "TextGroup"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Max\+t\ \(C\_t\)\+_ \[LessEqual] \(C\^*\) \ \[LessEqual] \(Min\+t\) \(C\_t\)\&_\)]] }], "Text"], Cell[TextData[{ "As the maxima and minima are over the full sample, these bounds are likely \ to be extremely confining. This is likely to prevent the ", Cell[BoxData[ \(TraditionalForm\`C\)]], " draws from mixing well." }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Alternative approach: A joint draw of ", Cell[BoxData[ \(TraditionalForm\`C, m | P, q\)]] }], "Subsection"], Cell[TextData[{ "The preceding discussion demonstrated the difficulty of drawing ", Cell[BoxData[ \(TraditionalForm\`C\)]], " from its full conditional distribution. One way of viewing the problem is \ to note that if a hypothetical new draw of ", Cell[BoxData[ \(TraditionalForm\`C\)]], " were to move more than a very small step away from the present value, it \ would be likely that for some observation in the sample, the existing value \ of ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " lie outside of the ", Cell[BoxData[ \(TraditionalForm\`\((\(m\_t\)\+_, m\&_\_t)\)\)]], " bounds implied by the newly drawn ", Cell[BoxData[ \(TraditionalForm\`C\)]], ", i.e., that the new draw would not be feasible. This suggests that a new \ draw of ", Cell[BoxData[ \(TraditionalForm\`C\)]], " would have greater latitude if new ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " were also drawn as well." }], "Text"], Cell[TextData[{ "This is feasible. An overview of the procedure is as follows. We start \ with the current values of ", Cell[BoxData[ \(TraditionalForm\`C\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\)]], ". Suppose for the moment that we have some new candidate draw ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], ". We assume only that ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\) > 0\)]], ". It might be the case that ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], " implies infeasibility for some or all elements of the current ", Cell[BoxData[ \(TraditionalForm\`m\)]], ". A simple way of generating new feasible ", Cell[BoxData[ \(TraditionalForm\`m\)]], " is via a deterministic shift. Consider the upper and lower bounds for the \ level efficient price given in eq. (", CounterBox["NumberedEquation", "MLimits"], "), holding ", Cell[BoxData[ \(TraditionalForm\`P\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " fixed. In moving from ", Cell[BoxData[ \(TraditionalForm\`C\)]], " to ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], ", these bounds shift from ", Cell[BoxData[ \(TraditionalForm\`\((\(M\_t\)\+_, \(M\_t\)\&_)\)\)]], " to ", Cell[BoxData[ \(TraditionalForm\`\((\(M\_t\%*\)\+_, \(M\_t\%*\)\&_)\)\)]], ". The shifts in bounds are identical: ", Cell[BoxData[ \(TraditionalForm\`\(M\_t\%*\)\+_ - \(M\_t\)\+_ = \(M\_t\%*\)\&_ - \ \(M\_t\)\&_\)]], ". This suggests setting the new value" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(M\_t\%*\), "=", RowBox[{\(\(M\_t\%*\)\+_\), "+", RowBox[{\((M\_t - \(M\_t\)\+_)\), Cell[""]}]}]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "(and setting ", Cell[BoxData[ FormBox[ RowBox[{\(m\_t\%*\), "=", RowBox[{\(log(\(M\_t\%*\))\), Cell[""]}]}], TraditionalForm]]], "). In doing this, we are keeping the relative position of the efficient \ price the same within the new set of bounds.\n\nThere are two remaining \ problems. First, how should the ", Cell[BoxData[ FormBox[Cell[TextData[Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]]]], TraditionalForm]]], " be generated? Second, how can this procedure be integrated into the Gibbs \ sweep in a valid manner?" }], "Text"], Cell[TextData[{ "The first issue is straightforward. In the basic Roll model, the new draws \ for the cost parameter ", Cell[BoxData[ \(TraditionalForm\`c\)]], " arose from the linear regression ", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]p\_t = c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t + u\_t\)]], " (where the variables in the model were in logs). This equation doesn't \ hold in the present case due to the discreteness transformations. It does \ suggest, however, a way for generating new values of ", "C", ". We could randomly generated ", Cell[BoxData[ \(TraditionalForm\`U\_t~\(N(0, \[Sigma]\_U\%2)\)\)]], ", and then set up the regression:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\((C\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\ \_t + U\_t)\) = \(C\^*\)\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t + U\_t\)]] }], "NumberedEquation", CellTags->"SimulatedCRegression"], Cell[TextData[{ "That is, we use the current value ", Cell[BoxData[ \(TraditionalForm\`C\)]], " to simulate a dependent variable, regress it against the ", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]q\_t\)]], ", and draw ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], " from the coefficient posterior. Obviously, this regression loosely \ corresponds to the one used in the basic model." }], "Text"], Cell[TextData[{ "This procedure defines what is generally termed a candidate or proposal \ distribution for generating a new parameter value from an existing one. It \ defines a conditional distribution ", Cell[BoxData[ \(TraditionalForm\`g(\(C\^*\) | C)\)]], ". The convention, however, is to write this as ", Cell[BoxData[ FormBox[ RowBox[{\(g(C, \(C\^*\))\), Cell[""]}], TraditionalForm]]], ", where ", "g", " is a transition density in a Markov chain. Since a new value ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], " implies new values ", Cell[BoxData[ \(TraditionalForm\`\(m\^*\)\)]], ", this candidate/proposal/transition density is more properly written ", Cell[BoxData[ \(TraditionalForm\`g(C, m, \(C\^*\), \(m\^*\))\)]], ". (In this case, though, once we've chosen the new value ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], ", however, the new ", Cell[BoxData[ \(TraditionalForm\`\(m\^*\)\)]], "are automatically determined.)" }], "Text"], Cell[TextData[{ "We now turn to the second question, viz., how to use this candidate \ density. The Gibbs sampler turns out to be a special case of a more general \ sampling scheme called the Metropolis-Hastings sampler. The program for this \ sampler can be described as follows. Suppose that we enter sweep ", Cell[BoxData[ \(TraditionalForm\`j + 1\)]], " with values ", Cell[BoxData[ \(TraditionalForm\`C\^\((j)\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\^\((j)\)\)]], ". Then:" }], "Text"], Cell[TextData[{ "1. Draw ", Cell[BoxData[ \(TraditionalForm\`\(C\^*\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\(m\^*\)\)]], " from the candidate density ", Cell[BoxData[ \(TraditionalForm\`g(C, m, \(C\^*\), \(m\^*\))\)]] }], "Text"], Cell["2. Compute", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{"\[Alpha]", "=", RowBox[{"Min", "(", RowBox[{"1", ",", StyleBox[ FractionBox[\(\(f(\(C\^*\), \(m\^*\))\) \(g(\(C\^*\), \ \(m\^*\), C\^\((j)\), m\^\((j)\))\)\), RowBox[{\(f(C\^\((j)\), m\^\((j)\))\), RowBox[{"g", "(", RowBox[{\(C\^\((j)\)\), ",", RowBox[{\(m\^\((j)\)\), Cell[""]}], ",", \(C\^*\), ",", \(m\^*\)}], ")"}]}]], ScriptLevel->0]}], ")"}]}], TraditionalForm]]] }], "NumberedEquation"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`f(\(C\^*\), \(m\^*\))\)]], " is the true (\"target\") density evaluated at the proposal draws, ", Cell[BoxData[ \(TraditionalForm\`f(C\^\((j)\), m\^\((j)\))\)]], " is the true density evaluated at the sweep-", Cell[BoxData[ \(TraditionalForm\`j\)]], " values, ", Cell[BoxData[ FormBox[ RowBox[{"g", "(", RowBox[{\(C\^\((j)\)\), ",", RowBox[{\(m\^\((j)\)\), Cell[""]}], ",", \(C\^*\), ",", \(m\^*\)}], ")"}], TraditionalForm]]], " is the transition probability associated with generating the new values \ (conditional on the old ones), and ", Cell[BoxData[ \(TraditionalForm\`g(\(C\^*\), \(m\^*\), C\^\((j)\), m\^\((j)\))\)]], " is the reverse transition probability (i.e., the probability of \ generating the old values if we'd started with the new ones)." }], "Text"], Cell[TextData[{ "3. Generate ", Cell[BoxData[ \(TraditionalForm\`z\)]], " a uniform random number between zero and one." }], "Text"], Cell[TextData[{ "4. If ", Cell[BoxData[ \(TraditionalForm\`z < \[Alpha]\)]], ", \"accept the proposal\". That is, set ", Cell[BoxData[ \(TraditionalForm\`C\^\((j + 1)\) = \(C\^*\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\^\((j + 1)\) = \(m\^*\)\)]], ".\nIf ", Cell[BoxData[ \(TraditionalForm\`z \[GreaterEqual] \[Alpha]\)]], ", \"reject the proposal\". That is, set ", Cell[BoxData[ \(TraditionalForm\`\(\(C\^\((j + 1)\)\)\(=\)\(C\^\((j)\)\)\(\ \)\)\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\^\((j + 1)\) = m\^\((j)\)\)]], "." }], "Text"], Cell[TextData[{ "As with the Gibbs sampler, in the limit as ", Cell[BoxData[ \(TraditionalForm\`j \[Rule] \[Infinity]\)]], ", ", Cell[BoxData[ \(TraditionalForm\`\((C\^\((j)\), m\^\((j)\))\)\)]], " are random numbers distributed in accordance with the target density ", Cell[BoxData[ \(TraditionalForm\`f\)]], "." }], "Text"], Cell[TextData[{ "In the present case, the target density is the conditional density ", Cell[BoxData[ \(TraditionalForm\`f(C, m | \[Sigma]\_u, q, P)\)]], ", i.e., the full conditional density given the observed data, the latent \ data and remaining parameter. " }], "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{\(f(C, m | \[Sigma]\_u, q, P)\), "=", StyleBox[\(\(\(Pr(P | m, q, C, \[Sigma]\_u)\) \(f(m | q, C, \[Sigma]\_u)\) \(Pr(q | C, \[Sigma]\_u)\) \(f( C, \[Sigma]\_u)\)\)\/\(\(Pr(P, q | \[Sigma]\_u)\) \(f(\[Sigma]\_u)\)\)\), ScriptLevel->0]}], TraditionalForm]]]], "NumberedEquation"], Cell[TextData[{ "Since the mapping from ", Cell[BoxData[ \(TraditionalForm\`m, q, \ and\ C\)]], " to ", Cell[BoxData[ \(TraditionalForm\`P\)]], " is nonstochastic, ", Cell[BoxData[ \(TraditionalForm\`Pr(P | m, q, C, \[Sigma]\_u) = 1\)]], ". From the assumed independence of the prior distributions," }], "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`\(Pr(q | C, \[Sigma]\_u)\) \(f( C, \[Sigma]\_u)\) = \(Pr(q)\) \(f( C)\) \(f(\[Sigma]\_u)\)\)]]], "NumberedEquation"], Cell["Therefore", "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`f(C, m | \[Sigma]\_u, q, P) \[Proportional] \(f(m | q, C, \[Sigma]\_u)\) \(f(C)\) = \(f( m | \[Sigma]\_u)\) \(f(C)\)\)]]], "NumberedEquation"], Cell[TextData[{ "(since ", Cell[BoxData[ \(TraditionalForm\`C\)]], " and ", Cell[BoxData[ \(TraditionalForm\`q\)]], " are independent of ", Cell[BoxData[ \(TraditionalForm\`m\)]], "). These two quantities are simple to evaluate for the existing and \ proposed draws." }], "Text"], Cell[TextData[{ "In drawing from the proposal density, it is not really necessary to \ simulate the ", Cell[BoxData[ \(TraditionalForm\`U\_t\)]], " and actually run the regression given in eq. (", CounterBox["NumberedEquation", "SimulatedCRegression"], "). Suppose that the prior for ", Cell[BoxData[ \(TraditionalForm\`C\)]], " is ", Cell[BoxData[ \(TraditionalForm\`\(N\^+\)(0, \[CapitalOmega]\_C\%Prior)\)]], ". Using the classic Bayesian regression results from section ", CounterBox["None"], ".", CounterBox["None"], ", if we simulated and ran the regression, the posterior would be ", Cell[BoxData[ \(TraditionalForm\`\(N\^+\)(\[Mu]\_C\%Posterior, \ \[CapitalOmega]\_C\%Posterior)\)]], " with" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(\[Mu]\_C\%Posterior\), "=", RowBox[{ SuperscriptBox[ RowBox[{"(", RowBox[{ StyleBox[\(\(\[Sum]\+t \ \[CapitalDelta]\[VeryThinSpace]q\_t\%2\)\/\[Sigma]\_U\%2\), ScriptLevel->0], "+", StyleBox[\(1\/\[CapitalOmega]\_C\%Prior\), ScriptLevel->0]}], ")"}], \(-1\)], RowBox[{"(", StyleBox[\(\(\[Sum]\+t \ \[CapitalDelta]\[VeryThinSpace]\(\(q\_t\)( C\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_\ t + U\_t)\)\)\/\[Sigma]\_U\%2\), ScriptLevel->0], ")"}]}]}], TraditionalForm]]] }], "Text"], Cell["and", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(\[CapitalOmega]\_C\%Posterior\), "=", SuperscriptBox[ RowBox[{"(", RowBox[{ StyleBox[\(\(\[Sum]\+t \[CapitalDelta]\[VeryThinSpace]q\_t\%2\ \)\/\[Sigma]\_U\%2\), ScriptLevel->0], "+", StyleBox[\(1\/\[CapitalOmega]\_C\%Prior\), ScriptLevel->0]}], ")"}], \(-1\)]}], TraditionalForm]]], "\n" }], "Text"], Cell["A sensible expedient is to take", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(\[Mu]\_C\%Posterior\), "=", RowBox[{ SuperscriptBox[ RowBox[{"(", RowBox[{ StyleBox[\(\(\[Sum]\+t \ \[CapitalDelta]\[VeryThinSpace]q\_t\%2\)\/\[Sigma]\_U\%2\), ScriptLevel->0], "+", StyleBox[\(1\/\[CapitalOmega]\_C\%Prior\), ScriptLevel->0]}], ")"}], \(-1\)], RowBox[{"(", StyleBox[\(\(C \(\[Sum]\+t \ \[CapitalDelta]\[VeryThinSpace]q\_t\%2\)\)\/\[Sigma]\_U\%2\), ScriptLevel->0], ")"}]}]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "Since ", Cell[BoxData[ \(TraditionalForm\`C\)]], " is a cost parameter in levels (rather than logs), ", Cell[BoxData[ \(TraditionalForm\`U\_t\)]], " is also a level disturbance. A logical choice for ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_U\%2\)]], " is ", Cell[BoxData[ \(TraditionalForm\`\(P\&_\) \[Sigma]\_u\%2\)]], " where ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\)]], " is the current draw of this parameter and ", Cell[BoxData[ \(TraditionalForm\`P\&_\)]], " is the average price level over the sample. In taking these shortcuts, we \ are departing from the full conditional distribution. This is permissible \ because ", Cell[BoxData[ \(TraditionalForm\`g( ... )\)]], " is only a proposal density." }], "Text"], Cell[TextData[{ "Although this draw is joint over both ", Cell[BoxData[ \(TraditionalForm\`C\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\)]], ", it does not replace the ", Cell[BoxData[ \(TraditionalForm\`m\)]], " draw described above. The reason is that this joint draw cannot generate \ all values of ", Cell[BoxData[ \(TraditionalForm\`m\)]], "; it only shifts the values in a rather limited fashion." }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Clustered prices", "Section", CellTags->"Clustered prices"], Cell[CellGroupData[{ Cell["Model description", "Subsection"], Cell["\<\ This is an extension of the simple discreteness model. The evolution of the \ (log) efficient price is:\ \>", "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`m\_t = m\_\(t - 1\) + u\_t\)]], " where ", Cell[BoxData[ FormBox[ RowBox[{\(u\_t\ ~N\), Cell[TextData[{ "(0,", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_u\%2\)]], ")" }]]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "The (level) efficient price is therefore ", Cell[BoxData[ \(TraditionalForm\`M\_t = e\^m\_t\)]], ". (The units here are \"dollars.\") The half-spread in levels is ", Cell[BoxData[ \(TraditionalForm\`C\)]], ". The bid and ask quotes are:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`B\_t = Floor(M\_t - C, K\_t)\)]], "\n\t", Cell[BoxData[ \(TraditionalForm\`A\_t = Ceiling(M\_t + C, K\_t)\)]] }], "Text"], Cell[TextData[{ "The rounding functions here round down or up to the nearest ", Cell[BoxData[ \(TraditionalForm\`K\)]], "-multiple of the \"official\" tick size. It is assumed that the variables \ are scaled so that the minimum tick size is unity. The ", Cell[BoxData[ \(TraditionalForm\`K\_t\)]], " are then i.i.d. Bernoulli variates:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\(\(K\_t\)\(=\)\)\)]], Cell[BoxData[ FormBox[ RowBox[{"{", GridBox[{ {\(1, \ with\ probability\ \((1 - k)\)\)}, {\(\[Kappa], \ \(\(with\)\(\ \)\(probability\)\(\ \)\(k\)\(\ \ \ \ \ \ \ \ \ \ \ \ \)\)\)} }]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "\[Kappa] is a \"natural multiple\" of the basic tick size, like 2, 5 or \ 10. ", Cell[BoxData[ \(TraditionalForm\`k\)]], " is the clustering probability. The buy/sell indicator is" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(q\_t\), "=", RowBox[{"{", GridBox[{ { RowBox[{\(+1\), ",", " ", RowBox[{ StyleBox["a", FontSlant->"Plain"], " ", "buy"}], ",", " ", \(with\ probability\ 1\/2\)}]}, { RowBox[{\(-1\), ",", " ", RowBox[{ StyleBox["a", FontSlant->"Plain"], " ", "sell"}], ",", " ", \(with\ probability\ 1\/2\)}]} }]}]}], TraditionalForm]]], "\nThe obseved transaction price is" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ FormBox[ RowBox[{\(P\_t\), "=", RowBox[{"{", GridBox[{ {\(\(A\_t\) if\ q\_t = \(+1\)\)}, {\(\(B\_t\) if\ q\_t = \(-1\)\)} }], "]"}]}], TraditionalForm]]] }], "Text"], Cell[TextData[{ "In the latent data draw, at each time ", "t", ", we need to draw ", Cell[BoxData[ \(TraditionalForm\`m\_t, q\_t, K\_t | m\_\(\(\\\)\(t\)\), q\_\(\(\\\)\(t\)\), P\_t\)]], ". The draw is made in two steps:" }], "Text"], Cell[TextData[{ "1. Draw ", Cell[BoxData[ \(TraditionalForm\`q\_t, K\_t | m\_\(t - 1\), m\_\(t + 1\), P\_t\)]], "." }], "Text"], Cell[TextData[{ "2. Draw ", Cell[BoxData[ \(TraditionalForm\`m\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, K\_t, P\_t\)]], "." }], "Text"], Cell[TextData[{ "The parameter draw for ", Cell[BoxData[ \(TraditionalForm\`C\)]], " proceeds exactly as in discreteness model. (That is, we make a joint draw \ of ", Cell[BoxData[ \(TraditionalForm\`C\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\)]], ". See section ", CounterBox["Section", "Discrete Prices"], ".) There is also an additional parameter draw, ", Cell[BoxData[ \(TraditionalForm\`k | K\)]], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "The draw for ", Cell[BoxData[ \(TraditionalForm\`q\_t, K\_t | m\_\(t - 1\), m\_\(t + 1\), P\_t\)]] }], "Subsection"], Cell["We have:", "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_t, K\_t | m\_\(t - 1\), m\_\(t + 1\), P\_t)\), "\[IndentingNewLine]", "=", RowBox[{ RowBox[{ StyleBox[\(\(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, K\_t)\)\ \[Times]\(Pr(q\_t, K\_t | m\_\(t - 1\), m\_\(t + 1\))\)\[Times]\(f(m\_\(t - 1\), m\_\(t + 1\))\)\)\/\(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\))\) \(f(m\_\(t - 1\), m\_\(t + 1\))\)\)\), ScriptLevel->0], "\[IndentingNewLine]", "\[Proportional]", \(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, K\_t)\)\ \[Times]\(Pr(q\_t, K\_t | m\_\(t - 1\), m\_\(t + 1\))\)\)}], "\[IndentingNewLine]", " ", "=", \(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, K\_t)\)\ \[Times]\(Pr(q\_t)\) \(Pr(K\_t)\)\)}]}], TraditionalForm]]]], "NumberedEquation", CellTags->"ClusterBayes"], Cell[TextData[{ "The last equality follows from the fact that ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`K\_t\)]], " are mutually independent and also independent of the evolution of ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], ". Next," }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, K\_t) = \[Integral]\_\(m\+_\)\%\(m\&_\)\(f(m\_t | m\_\(t - 1\), m\_\(t + 1\))\) \[DifferentialD]m\_t\)]] }], "Text"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`m\+_\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\&_\)]], " are the limits established by ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`K\_t\)]], " (see below). The general plan is as follows. Using (", CounterBox["NumberedEquation", "ClusterBayes"], "), we compute unnormalized probabilities for the four possible \ combinations of ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " and ", Cell[BoxData[ \(TraditionalForm\`K\_t\)]], ". We normalize these probabilities and make the draw of the ", Cell[BoxData[ \(TraditionalForm\`{q\_t, K\_t}\)]], " pair. We then proceed to the ", Cell[BoxData[ \(TraditionalForm\`m\_t\)]], " draw. We turn now to the details." }], "Text"], Cell["The floor and ceiling functions in the model imply ", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MBidLimits = InequalitySolve[B\_t < M\_t - C < B\_t + K\_t, M\_t]\)], "Input", CellLabel->"In[71]:="], Cell[BoxData[ \(TraditionalForm\`C + B\_t < M\_t < C + B\_t + K\_t\)], "Output", CellLabel->"Out[71]="] }, Open ]], Cell["and", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MAskLimits = InequalitySolve[A\_t - K\_t < M\_t + C < A\_t, M\_t]\)], "Input", CellLabel->"In[72]:="], Cell[BoxData[ \(TraditionalForm\`\(-C\) + A\_t - K\_t < M\_t < A\_t - C\)], "Output", CellLabel->"Out[72]="] }, Open ]], Cell[TextData[{ "When ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(-1\)\)]], ", ", Cell[BoxData[ \(TraditionalForm\`B\_t = P\_t\)]], ", and" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MBidLimits = MBidLimits /. B\_t \[Rule] P\_t\)], "Input", CellLabel->"In[73]:="], Cell[BoxData[ \(TraditionalForm\`C + P\_t < M\_t < C + K\_t + P\_t\)], "Output", CellLabel->"Out[73]="] }, Open ]], Cell[TextData[{ "When ", Cell[BoxData[ \(TraditionalForm\`q\_t = \(+1\)\)]], ", ", Cell[BoxData[ \(TraditionalForm\`A\_t = P\_t\)]], ", and" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MAskLimits = MAskLimits /. A\_t \[Rule] P\_t\)], "Input", CellLabel->"In[74]:="], Cell[BoxData[ \(TraditionalForm\`\(-C\) - K\_t + P\_t < M\_t < P\_t - C\)], "Output", CellLabel->"Out[74]="] }, Open ]], Cell[TextData[{ "The lower and upper limit functions for ", Cell[BoxData[ \(TraditionalForm\`M\)]], " are:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\(M\+_\)(q\_t, K\_t) = 1\/2\ \((\(-q\_t\)\ K\_t - K\_t + 2\ P\_t - 2\ C\ q\_t)\)\)]], " \nand \n\t", Cell[BoxData[ \(TraditionalForm\`\(M\&_\)(q\_t, K\_t) = P\_t + \(\(1\/2\)\(\ \)\((K\_t - \((2\ C + K\_t)\)\ q\_t)\)\(\ \)\)\)]] }], "Text"], Cell[TextData[{ "The limits on the log efficient price are then ", Cell[BoxData[ \(TraditionalForm\`m\+_[q\_t, K\_t] = log[\(M\+_\)(q\_t, K\_t)]\)]], " and ", Cell[BoxData[ \(TraditionalForm\`m\&_[q\_t, K\_t] = log[\(M\&_\)(q\_t, K\_t)]\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[TextData[{ "(", StyleBox["Mathematica", FontSlant->"Italic"], " code)" }], "MathGroup"], Cell[CellGroupData[{ Cell[BoxData[ \({MBidLimits[\([1]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(-1\), \[IndentingNewLine]MAskLimits[\([1]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(+1\)}\)], "Input", CellLabel->"In[75]:="], Cell[BoxData[ \(TraditionalForm\`{C + P\_t == a - b, \(-C\) - K\_t + P\_t == a + b}\)], "Output", CellLabel->"Out[75]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Flatten[Solve[%, {a, b}] // Simplify]\)], "Input", CellLabel->"In[76]:="], Cell[BoxData[ \(TraditionalForm\`{a \[Rule] P\_t - K\_t\/2, b \[Rule] 1\/2\ \((\(-2\)\ C - K\_t)\)}\)], "Output", CellLabel->"Out[76]="] }, Open ]], Cell[BoxData[ \(M\+_[q_, K_] := Evaluate[\(a + b\ q\ /. %\)\ /. K\_t \[Rule] K // FullSimplify]\)], "InputOnly", CellLabel->"In[77]:="], Cell[CellGroupData[{ Cell[BoxData[ \(M\+_[q\_t, K\_t]\)], "Input", CellLabel->"In[78]:="], Cell[BoxData[ \(TraditionalForm\`1\/2\ \((\(-q\_t\)\ K\_t - K\_t + 2\ P\_t - 2\ C\ q\_t)\)\)], "Output", CellLabel->"Out[78]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \({MBidLimits[\([5]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(-1\), MAskLimits[\([5]\)] \[Equal] a + b\ q\_t /. q\_t \[Rule] \(+1\)}\)], "Input", CellLabel->"In[79]:="], Cell[BoxData[ \(TraditionalForm\`{C + K\_t + P\_t == a - b, P\_t - C == a + b}\)], "Output", CellLabel->"Out[79]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Flatten[Solve[%, {a, b}] // Simplify]\)], "Input", CellLabel->"In[80]:="], Cell[BoxData[ \(TraditionalForm\`{a \[Rule] K\_t\/2 + P\_t, b \[Rule] 1\/2\ \((\(-2\)\ C - K\_t)\)}\)], "Output", CellLabel->"Out[80]="] }, Open ]], Cell[BoxData[ \(M\&_[q_, K_] := Evaluate[\(a + b\ q\ /. %\) /. K\_t \[Rule] K // FullSimplify]\)], "InputOnly", CellLabel->"In[81]:="], Cell[CellGroupData[{ Cell[BoxData[ \(M\&_[q\_t, K\_t]\)], "Input", CellLabel->"In[82]:="], Cell[BoxData[ \(TraditionalForm\`P\_t + 1\/2\ \((K\_t - \((2\ C + K\_t)\)\ q\_t)\)\)], "Output", CellLabel->"Out[82]="] }, Open ]], Cell[BoxData[ \(m\+_[q_, K_] := Log[M\+_[q, K]]; m\&_[q_, K_] := Log[M\&_[q, K]]\)], "InputOnly", CellLabel->"In[83]:="] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ "From eq. (", CounterBox["NumberedEquation", "ClusterBayes"], "), and using the fact that ", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t) = 1/2\)]], ", " }], "TextGroup"], Cell[TextData[{ Cell[BoxData[ \(TraditionalForm\`Pr(q\_t, K\_t | m\_\(t - 1\), m\_\(t + 1\), P\_t)\)]], Cell[BoxData[ \(TraditionalForm\`\(\(\[Proportional]\)\(\(Pr(P\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, K\_t)\)\ \[Times]\(Pr(K\_t)\)\)\)\)]] }], "NumberedEquation"], Cell[TextData[{ "Recall that ", Cell[BoxData[ \(TraditionalForm\`f(m\_t | m\_\(t - 1\), m\_\(t + 1\)) = \[Phi](\[Mu]\_m, \[Sigma]\_m, m\_t)\)]], " with ", Cell[BoxData[ \(TraditionalForm\`\[Mu]\_m = \(\((m\_\(t - 1\) + m\_\(t + 1\))\)/ 2\ \ and\ \ \[Sigma]\_m = \[Sigma]\_u/\@2\)\)], "TextGroup"], ". Thus," }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t, K\_t | m\_\(t - 1\), m\_\(t + 1\), P\_t) \[Proportional] \ \[CapitalPhi][\[Mu]\_m, \[Sigma]\_m, \(m\+_\ \)(q\_t, K\_t), \(m\&_\)(q\_t, K\_t)] \(Pr(K\_t)\)\)]], " " }], "Text"], Cell[TextData[{ "for ", Cell[BoxData[ \(TraditionalForm\`\((q\_t, K\_t)\) \[Element] {\(+1\), \(-1\)}\[Times]{1, \[Kappa]}\)]], ". Let ", Cell[BoxData[ \(TraditionalForm\`i\)]], " index the four possible combinations of ", Cell[BoxData[ \(TraditionalForm\`\((q\_t, K\_t)\)\)]], ", and let " }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Z\_i = \ \[CapitalPhi][\[Mu]\_m, \[Sigma]\_m, \(m\+_\ \)(q\_t, K\_t), \(m\&_\)(q\_t, K\_t)] \(Pr(K\_t)\)\)]], " " }], "Text"], Cell[TextData[{ "evaluated at the the ", Cell[BoxData[ \(TraditionalForm\`i\)]], "th values. Then the normalized probability of outcome ", Cell[BoxData[ \(TraditionalForm\`i\)]], " is ", Cell[BoxData[ \(TraditionalForm\`Z\_i/\[CapitalSigma]Z\_i\)]], "." }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "The draw for ", Cell[BoxData[ \(TraditionalForm\`m\_t | m\_\(t - 1\), m\_\(t + 1\), q\_t, K\_t, P\_t\)]] }], "Subsection"], Cell[TextData[{ "This is simply a draw from ", Cell[BoxData[ FormBox[ RowBox[{\(f(m\_t | m\_\(t - 1\), m\_\(t + 1\))\), Cell[""]}], TraditionalForm]]], "truncated to ", Cell[BoxData[ \(TraditionalForm\`\((m\+_, m\&_)\)\)]], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "The parameter draw for ", Cell[BoxData[ \(TraditionalForm\`k | K\)]] }], "Subsection"], Cell[TextData[{ "The clustering variables are defined by ", Cell[BoxData[ \(TraditionalForm\`K = {K\_1, ... , K\_T}\)]], ", where each ", Cell[BoxData[ \(TraditionalForm\`K\_t \[Element] {1, \[Kappa]}\)]], ". Let ", Cell[BoxData[ \(TraditionalForm\`n\)]], " be the number of ", Cell[BoxData[ \(TraditionalForm\`t\)]], " for which ", Cell[BoxData[ \(TraditionalForm\`K\_t = \[Kappa]\)]], ". If the probability of ", Cell[BoxData[ \(TraditionalForm\`K\_t = \[Kappa]\)]], " is ", Cell[BoxData[ \(TraditionalForm\`k\)]], ", then ", Cell[BoxData[ \(TraditionalForm\`n\)]], " is a binomial random variable. The beta distribution is conjugate to the \ binomal (Tanner, 1996), so ", Cell[BoxData[ \(TraditionalForm\`Beta[a, b]\)]], " is a convenient prior for ", Cell[BoxData[ \(TraditionalForm\`k\)]], ". We let ", Cell[BoxData[ \(TraditionalForm\`a\^Prior = \(b\^Prior = 1/2\)\)]], ", for which the Beta density is uniform on the unit interval. The \ posterior for ", Cell[BoxData[ \(TraditionalForm\`k\)]], " is then ", Cell[BoxData[ \(TraditionalForm\`Beta[a\^Posterior, b\^Posterior]\)]], " where ", Cell[BoxData[ \(TraditionalForm\`a\^Posterior = a\^Prior + n\)]], " and ", Cell[BoxData[ \(TraditionalForm\`b\^Posterior = b\^Prior + T - n\)]], "." }], "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Lagged trade dependencies", "Section", CellTags->"LaggedTradeDependencies"], Cell[CellGroupData[{ Cell["Model description", "Subsection"], Cell["\<\ In this extension of the informative trade model, the evolution of the \ efficient price is allowed to depend on lagged signed trades (as well as the \ contemporaneous one).\ \>", "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`m\_t = m\_\(t - 1\) + \[CapitalLambda]\_t + u\_t\)]]], "NumberedEquation"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`\[CapitalLambda]\_t\)]], " is the impact term:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\[CapitalLambda]\_t = \[Sum]\+\(j = 0\)\%\(Min(J, t \ - 1)\)\(q\_\(t - j\)\) \(\[Lambda]\_j\) V\_\(t - j\)\)]] }], "Text"], Cell[TextData[{ Cell[BoxData[ \(TraditionalForm\`J\)]], " is the order of the lagged dependence. The upper limit of the sum \ indicates that the lags do not extend before the beginning of the sample. The \ observed price is:" }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`p\_t = m\_t + c\[VeryThinSpace]q\_t\)]] }], "Text"], Cell[TextData[{ "The parameter draw for ", Cell[BoxData[ \(TraditionalForm\`{\[Lambda]\_0, ... , \[Lambda]\_J, c, \[Sigma]\_u}\)]], " is (mostly) straightforward. Given the observed and latent data," }], "Text"], Cell[TextData[Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]p\_t = \ \(\[CapitalDelta]\[VeryThinSpace]m\_t + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t = \(\ \[CapitalLambda]\_t + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t + u\_t = \[VeryThinSpace]\[Sum]\+\(j = 0\)\%\(Min(J, t - 1)\)\(\(\(\ \[Lambda]\)\(\[VeryThinSpace]\)\)\_j\) \(q\_\(t - j\)\) V\_\(t - j\) + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t + u\_t\)\)\)]]], "NumberedEquation", CellTags->"LaggedTradeDepRegression"], Cell[TextData[{ "This fits into the Bayesian multiple regression framework (with ", Cell[BoxData[ \(TraditionalForm\`c\)]], " and the ", Cell[BoxData[ \(TraditionalForm\`\[Lambda]\_j\)]], " the coefficients). " }], "Text"], Cell[TextData[{ "There is the potential for multicollinearity here, however. Suppose that \ ", Cell[BoxData[ \(TraditionalForm\`J = 1\)]], " and ", Cell[BoxData[ \(TraditionalForm\`V\_t = 1\)]], ". Then " }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]p\_t = \(\[Lambda]\_0\ \) q\_t + \(\[Lambda]\_1\) q\_\(t - 1\) + c\[VeryThinSpace]\[CapitalDelta]\[VeryThinSpace]q\_t + u\_t\)]] }], "Text"], Cell[TextData[{ "In economic terms, the impact of a trade on the efficient price depends \ only on the direction of the trade, and not its size. Since ", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\[VeryThinSpace]q\_t = q\_t - q\_\(t - 1\)\)]], ", however, the cross-product matrix is singular. Some sort of additional \ structure is needed. (One possibility is to simply let ", Cell[BoxData[ \(TraditionalForm\`V\_t = Vol\_t\)]], ".)" }], "Text"], Cell[TextData[{ "The latent data draw is of ", Cell[BoxData[ \(TraditionalForm\`q\_t | m\_\(\(\\\)\(t\)\), p\_t, q\_\(\(\\\)\(t\)\)\)]], ". This follows the design of the draw for the contemporaneous impact \ model, but the lagged structure extends the ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " dependencies. From the structure of the sum, it is clear that ", Cell[BoxData[ \(TraditionalForm\`q\_t\)]], " influences ", Cell[BoxData[ \(TraditionalForm\`m\_t, ... , m\_\(t + P\)\)]], ". Therefore ", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | m\_\(\(\\\)\(t\)\), q\_\(\(\\\)\(t\)\))\)]], " depends on ", Cell[BoxData[ \(TraditionalForm\`\[Product]\+\(s = 0\)\%J f(u\_\(t + s\))\)]], ". From inspection of these terms, " }], "Text"], Cell[TextData[{ "\t", Cell[BoxData[ \(TraditionalForm\`Pr(q\_t | m\_\(\(\\\)\(t\)\), p\_t, q\_\(\(\\\)\(t\)\)) = Pr(q\_t | m\_\(t - 1\), m\_\(t + 1\), \(\(...\) \(m\_\(t + P\)\)\), p\_t, q\_\(t - P\), ... , q\_\(t - 1\), q\_\(t + 1\), ... , q\_\(t + P\))\)]], ". " }], "Text"], Cell["\<\ For notational simplicity, however, the conditioning set indicated on the \ l.h.s. will be used below.\ \>", "Text"], Cell[TextData[{ "Analogous to eq. (", CounterBox["NumberedEquation", "BayesContemporaneousImpact"], ")," }], "Text"], Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{\(Pr(q\_t | m\_\(\(\\\)\(t\)\), p\_t, q\_\(\(\\\)\(t\)\))\), "=", StyleBox[\(\(\(f(p\_t | m\_\(\(\\\)\(t\)\), q\_\(\(\\\)\(t\)\), q\_t)\)\[Times]\(Pr(q\_t | m\_\(\(\\\)\(t\)\),