Previous: Multivariate models: Bivariate Normal Up: Writing New Models Next: The Intuitive Layout


Easy Ways to Manage Matrices

Most statistical methods relate explanatory variables 69#69 to a dependent variable of interest 102#102 for each observation 70#70 . Let 12#12 be a set of parameters that correspond to each column in 53#53 , which is an 7#7 matrix with rows 69#69 . For a single equation model, the linear predictor is

103#103    

Thus, 104#104 is the set of 105#105 for 70#70 and is usually represented as an 106#106 matrix.

For a two equation model such as bivariate probit, the linear predictor becomes a matrix with columns corresponding to each dependent variable 107#107 :

108#108    

With 104#104 as an 109#109 matrix, we now have a few choices as to how to create the linear predictor:
  1. An intuitive layout, which stacks matrices of explanatory variables, provides an easy visual representation of the relationship between explanatory variables and coefficients;
  2. A computationally-efficient layout, which takes advantage of computational vectorization; and
  3. A memory-saving layout, which reduces the overall size of the 53#53 and 12#12 matrices.
Using the simple tools described in this section, you can pick the best matrix management method for your model.

In addition, the way in which 104#104 is created also affects the way parameters are estimated. Let's say that you want two parameters to have the same effect in different equations. By setting up 53#53 and 12#12 in a certain way, you can let users set constraints across parameters. Continuing the bivariate probit example above, let the model specification be:

formulae <- list(mu1 = y1 ~ x1 + x2 + tag(x3, "land"), 
                 mu2 = y2 ~ x3 + tag(x4, "land"))
where tag() is a special function that constrains variables to have the same effect across equations. Thus, the coefficient for x3 in equation mu1 is constrained to be equal to the coefficient for x4 in equation mu2, and this effect is identified as the ``land'' effect in both equations. In order to consider constraints across equations, the structure of both 53#53 and 12#12 matter.



Subsections

Gary King 2011-11-29