The Statistician’s Apprentice: An Introduction to the SWP Operator
MeanMean
[This article was first published on MeanMean, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The sweep operator as defined in (Dempster, 1969), commonly referred to as the SWP operator, is a useful tool for a computational statistician working with covariance matrices. In particular, the SWP operator allows a statistician to quickly regress all variables against one specified variable, obtaining OLS estimates for regression coefficients and variances in a single application. Subsequent applications of the SWP operator allows for regressing against more variables.
In this blog post, I will define the sweep operator, provide an application of the sweep data to simulated data, and provide some references for further study. Examples will be provided in R through the ISR3 package (Lisic, 2016).
The basic SWP operator is parameterized by a matrix and a set of indices associated with rows and columns of the matrix being swept. E.g. to sweep the matrix < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.678ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 722.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3A3"> by the < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.42ex" height="2.676ex" style="vertical-align: -0.338ex;" viewBox="0 -1006.6 1041.8 1152.1" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-6C">< g transform="translate(278,422)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="361" y="0" xlink:href="#MJMATHI-68"> index, such that < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="7.86ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 3384.1 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-41">< use x="1028" y="0" xlink:href="#MJMAIN-3D">< use x="2084" y="0" xlink:href="#MJMAIN-7B">< use x="2585" y="0" xlink:href="#MJMATHI-6C">< use x="2883" y="0" xlink:href="#MJMAIN-7D">, the operator has the form < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="11.788ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 5075.5 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use xlink:href="#MJMAIN-53">< use x="556" y="0" xlink:href="#MJMAIN-57">< use x="1585" y="0" xlink:href="#MJMAIN-50">< use x="2266" y="0" xlink:href="#MJMAIN-5B">< use x="2545" y="0" xlink:href="#MJMATHI-41">< use x="3295" y="0" xlink:href="#MJMAIN-5D">< use x="3574" y="0" xlink:href="#MJMAIN-28">< use x="3963" y="0" xlink:href="#MJMAIN-3A3">< use x="4686" y="0" xlink:href="#MJMAIN-29">. The operator may also be written more descriptively by listing the elements of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.743ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 750.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-41"> as < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="10.738ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 4623.5 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use xlink:href="#MJMAIN-53">< use x="556" y="0" xlink:href="#MJMAIN-57">< use x="1585" y="0" xlink:href="#MJMAIN-50">< use x="2266" y="0" xlink:href="#MJMAIN-5B">< use x="2545" y="0" xlink:href="#MJMATHI-6C">< use x="2843" y="0" xlink:href="#MJMAIN-5D">< use x="3122" y="0" xlink:href="#MJMAIN-28">< use x="3511" y="0" xlink:href="#MJMAIN-3A3">< use x="4234" y="0" xlink:href="#MJMAIN-29">. The application of the SWP operator to the < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.42ex" height="2.676ex" style="vertical-align: -0.338ex;" viewBox="0 -1006.6 1041.8 1152.1" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-6C">< g transform="translate(278,422)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="361" y="0" xlink:href="#MJMATHI-68"> row and column of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.678ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 722.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3A3"> produces a new matrix with elements
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="35.039ex" height="13.176ex" style="vertical-align: -5.772ex;" viewBox="0 -3087.6 15086.1 5673" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.707)" x="412" y="0" xlink:href="#MJMATHI-6B">< use x="1609" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(2665,0)">< g transform="translate(0,2985)">< use x="0" y="-1156" xlink:href="#MJSZ4-239B">< g transform="translate(0,-3671.5230125529683) scale(1,3.1252422464042033)">< use xlink:href="#MJSZ4-239C">< use x="0" y="-4826" xlink:href="#MJSZ4-239D">< g transform="translate(1042,0)">< g transform="translate(-11,0)">< g transform="translate(0,2068)">< use x="0" y="0" xlink:href="#MJMATHI-6A">< use x="690" y="0" xlink:href="#MJMAIN-3D">< use x="1746" y="0" xlink:href="#MJMATHI-6B">< use x="2545" y="0" xlink:href="#MJMAIN-3D">< use x="3602" y="0" xlink:href="#MJMATHI-6C">< g transform="translate(0,45)">< use x="0" y="0" xlink:href="#MJMATHI-6A">< use x="690" y="0" xlink:href="#MJMAIN-3D">< use x="1746" y="0" xlink:href="#MJMATHI-6C">< use x="2295" y="0" xlink:href="#MJMAIN-26">< use x="3323" y="0" xlink:href="#MJMATHI-6B">< use x="4122" y="0" xlink:href="#MJMAIN-2260">< use x="5179" y="0" xlink:href="#MJMATHI-6C">< g transform="translate(0,-1977)">< use x="0" y="0" xlink:href="#MJMATHI-6A">< use x="690" y="0" xlink:href="#MJMAIN-2260">< use x="1746" y="0" xlink:href="#MJMATHI-6C">< use x="2295" y="0" xlink:href="#MJMAIN-26">< use x="3323" y="0" xlink:href="#MJMATHI-6B">< use x="4122" y="0" xlink:href="#MJMAIN-2260">< use x="5179" y="0" xlink:href="#MJMATHI-6C">< g transform="translate(6467,0)">< g transform="translate(1328,2068)">< use x="0" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(778,0)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< use transform="scale(0.707)" x="505" y="629" xlink:href="#MJMAIN-31">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-137)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.574)" x="412" y="0" xlink:href="#MJMATHI-6A">< g transform="translate(1686,45)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,717)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.574)" x="412" y="0" xlink:href="#MJMATHI-6B">< g transform="translate(91,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-137)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.574)" x="412" y="0" xlink:href="#MJMATHI-6A">< g transform="translate(0,-1977)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.707)" x="412" y="0" xlink:href="#MJMATHI-6B">< use x="1554" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(2332,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,718)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.574)" x="298" y="0" xlink:href="#MJMATHI-6B">< g transform="translate(945,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.574)" x="298" y="0" xlink:href="#MJMATHI-6A">< g transform="translate(565,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.574)" x="298" y="0" xlink:href="#MJMATHI-6C">
As an example, consider the application of the SWP operator to the first row and column of the < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.165ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 2223.9 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-33">< use x="722" y="0" xlink:href="#MJMAIN-D7">< use x="1723" y="0" xlink:href="#MJMAIN-33"> covariance matrix for the random variables < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="13.328ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 5738.6 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-7B">< g transform="translate(500,0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-31">< use x="1782" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(2228,0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-32">< use x="3510" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(3955,0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-33">< use x="5238" y="0" xlink:href="#MJMAIN-7D">,
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="23.851ex" height="9.176ex" style="vertical-align: -4.005ex;" viewBox="0 -2226.5 10269 3950.7" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3A3">< use x="1000" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(2056,0)">< g transform="translate(0,2150)">< use x="0" y="-1156" xlink:href="#MJSZ4-239B">< g transform="translate(0,-2033.6645264847511) scale(1,0.4446227929373997)">< use xlink:href="#MJSZ4-239C">< use x="0" y="-3155" xlink:href="#MJSZ4-239D">< g transform="translate(1042,0)">< g transform="translate(-11,0)">< g transform="translate(0,1350)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(0,-50)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(0,-1450)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(2368,0)">< g transform="translate(0,1350)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(0,-50)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(0,-1450)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(4748,0)">< g transform="translate(0,1350)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(0,-50)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(0,-1450)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(7336,2150)">< use x="0" y="-1155" xlink:href="#MJSZ4-239E">< g transform="translate(0,-2033.645264847512) scale(1,0.4462279293739968)">< use xlink:href="#MJSZ4-239F">< use x="0" y="-3155" xlink:href="#MJSZ4-23A0">
resulting in
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="53.783ex" height="14.176ex" style="vertical-align: -6.505ex;" viewBox="0 -3302.9 23156.3 6103.5" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use xlink:href="#MJMAIN-53">< use x="556" y="0" xlink:href="#MJMAIN-57">< use x="1585" y="0" xlink:href="#MJMAIN-50">< use x="2266" y="0" xlink:href="#MJMAIN-5B">< use x="2545" y="0" xlink:href="#MJMAIN-31">< use x="3045" y="0" xlink:href="#MJMAIN-5D">< g transform="translate(3490,0)">< use x="0" y="0" xlink:href="#MJMAIN-28">< use x="389" y="0" xlink:href="#MJMAIN-3A3">< use x="1112" y="0" xlink:href="#MJMAIN-29">< use x="5269" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(6326,0)">< g transform="translate(0,3180)">< use x="0" y="-1156" xlink:href="#MJSZ4-239B">< g transform="translate(0,-4055.347833388574) scale(1,3.75343344253449)">< use xlink:href="#MJSZ4-239C">< use x="0" y="-5217" xlink:href="#MJSZ4-239D">< g transform="translate(1042,0)">< g transform="translate(-11,0)">< g transform="translate(0,2263)">< use x="0" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(778,0)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< use transform="scale(0.707)" x="576" y="629" xlink:href="#MJMAIN-31">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(778,40)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,584)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(778,-2196)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,597)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(3177,0)">< g transform="translate(3651,2263)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,584)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(1049,40)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< use x="1601" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(2380,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,711)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< use transform="scale(0.574)" x="705" y="425" xlink:href="#MJMAIN-32">< g transform="translate(404,-267)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(0,-2196)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use x="1601" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(2380,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,597)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(1049,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(584,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(9238,0)">< g transform="translate(3651,2263)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,597)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(0,40)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use x="1601" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(2380,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,597)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-32">< g transform="translate(1049,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(584,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(1049,-2196)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use x="1601" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(2380,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,724)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< use transform="scale(0.574)" x="705" y="425" xlink:href="#MJMAIN-32">< g transform="translate(404,-267)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-33">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-140)">< use transform="scale(0.574)" xlink:href="#MJMAIN-31">< use transform="scale(0.574)" x="500" y="0" xlink:href="#MJMAIN-31">< g transform="translate(15509,3180)">< use x="0" y="-1155" xlink:href="#MJSZ4-239E">< g transform="translate(0,-4055.3285717513345) scale(1,3.7550385789710874)">< use xlink:href="#MJSZ4-239F">< use x="0" y="-5217" xlink:href="#MJSZ4-23A0">< use x="22877" y="0" xlink:href="#MJMAIN-2E">
How is this useful? Well, if we substitute the < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.165ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 2223.9 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-33">< use x="722" y="0" xlink:href="#MJMAIN-D7">< use x="1723" y="0" xlink:href="#MJMAIN-33"> covariance matrix < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.678ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 722.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3A3"> with the sample covariance matrix, where < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.576ex" height="3.176ex" style="vertical-align: -1.005ex;" viewBox="0 -934.9 1109.1 1367.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-53">< use transform="scale(0.707)" x="926" y="488" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="867" y="-463" xlink:href="#MJMATHI-6B"> is an estimator of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.273ex" height="2.009ex" style="vertical-align: -0.671ex;" viewBox="0 -576.1 1409 865.1" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6B">< use transform="scale(0.707)" x="521" y="0" xlink:href="#MJMATHI-6B"> and
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="50.361ex" height="6.676ex" style="vertical-align: -2.671ex;" viewBox="0 -1724.2 21683.2 2874.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use xlink:href="#MJMAIN-63">< use x="444" y="0" xlink:href="#MJMAIN-6F">< use x="945" y="0" xlink:href="#MJMAIN-76">< use x="14" y="-7" xlink:href="#MJSZ3-2C6">< use x="1473" y="0" xlink:href="#MJMAIN-28">< g transform="translate(1863,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use x="63" y="7" xlink:href="#MJMAIN-AF">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMATHI-6B">< use x="2904" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(3349,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use x="63" y="7" xlink:href="#MJMAIN-AF">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMATHI-6A">< use x="4313" y="0" xlink:href="#MJMAIN-29">< use x="4980" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(5759,0)">< g transform="translate(397,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,814)">< use x="0" y="0" xlink:href="#MJSZ1-2211">< use transform="scale(0.707)" x="1494" y="675" xlink:href="#MJMATHI-6E">< g transform="translate(1056,-287)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-69">< use transform="scale(0.707)" x="345" y="0" xlink:href="#MJMAIN-3D">< use transform="scale(0.707)" x="1124" y="0" xlink:href="#MJMAIN-31">< g transform="translate(2471,0)">< use x="0" y="0" xlink:href="#MJSZ1-2211">< use transform="scale(0.707)" x="1494" y="675" xlink:href="#MJMATHI-6E">< g transform="translate(1056,-287)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6D">< use transform="scale(0.707)" x="878" y="0" xlink:href="#MJMAIN-3D">< use transform="scale(0.707)" x="1657" y="0" xlink:href="#MJMAIN-31">< use x="5153" y="0" xlink:href="#MJMAIN-28">< g transform="translate(5543,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< g transform="translate(572,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-69">< use transform="scale(0.707)" x="345" y="0" xlink:href="#MJMAIN-2C">< use transform="scale(0.707)" x="624" y="0" xlink:href="#MJMATHI-6A">< use x="7171" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(8171,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use x="63" y="7" xlink:href="#MJMAIN-AF">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMATHI-6D">< use x="9465" y="0" xlink:href="#MJMAIN-29">< use x="9854" y="0" xlink:href="#MJMAIN-28">< g transform="translate(10244,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< g transform="translate(572,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6D">< use transform="scale(0.707)" x="878" y="0" xlink:href="#MJMAIN-2C">< use transform="scale(0.707)" x="1157" y="0" xlink:href="#MJMATHI-6B">< use x="12326" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(13326,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use x="63" y="7" xlink:href="#MJMAIN-AF">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMATHI-6B">< use x="14368" y="0" xlink:href="#MJMAIN-29">< g transform="translate(5587,-771)">< use x="0" y="0" xlink:href="#MJMATHI-6E">< use x="600" y="0" xlink:href="#MJMAIN-28">< use x="990" y="0" xlink:href="#MJMATHI-6E">< use x="1812" y="0" xlink:href="#MJMAIN-2212">< use x="2813" y="0" xlink:href="#MJMAIN-31">< use x="3313" y="0" xlink:href="#MJMAIN-29">< use x="21404" y="0" xlink:href="#MJMAIN-2C">
is an estimator of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.094ex" height="2.343ex" style="vertical-align: -1.005ex;" viewBox="0 -576.1 1331.9 1008.6" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.707)" x="412" y="0" xlink:href="#MJMATHI-6B">, then by sweeping by the < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.682ex" height="2.509ex" style="vertical-align: -0.338ex;" viewBox="0 -934.9 1154.9 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-31">< g transform="translate(500,393)">< use transform="scale(0.707)" xlink:href="#MJMAIN-73">< use transform="scale(0.707)" x="394" y="0" xlink:href="#MJMAIN-74"> index, < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="8.329ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 3586.1 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-41">< use x="1028" y="0" xlink:href="#MJMAIN-3D">< use x="2084" y="0" xlink:href="#MJMAIN-7B">< use x="2585" y="0" xlink:href="#MJMAIN-31">< use x="3085" y="0" xlink:href="#MJMAIN-7D">, we can get the simple linear regression (SLR) estimates for < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="15.506ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 6676.3 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMATHI-6B">< use x="1575" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(2631,0)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< g transform="translate(566,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMATHI-6B">< g transform="translate(4020,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMAIN-31">< use x="5269" y="0" xlink:href="#MJMAIN-2B">< use x="6269" y="0" xlink:href="#MJMATHI-3F5"> for all < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="9.736ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 4191.7 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6B">< use x="799" y="0" xlink:href="#MJMAIN-2208">< use x="1744" y="0" xlink:href="#MJMAIN-7B">< use x="2245" y="0" xlink:href="#MJMAIN-32">< use x="2745" y="0" xlink:href="#MJMAIN-2C">< use x="3190" y="0" xlink:href="#MJMAIN-33">< use x="3691" y="0" xlink:href="#MJMAIN-7D">:
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="39.011ex" height="12.176ex" style="vertical-align: -5.189ex;" viewBox="0 -2872.4 16796.5 5242.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use xlink:href="#MJMAIN-53">< use x="556" y="0" xlink:href="#MJMAIN-57">< use x="1585" y="0" xlink:href="#MJMAIN-50">< use x="2266" y="0" xlink:href="#MJMAIN-5B">< use x="2545" y="0" xlink:href="#MJMAIN-31">< use x="3045" y="0" xlink:href="#MJMAIN-5D">< g transform="translate(3490,0)">< use x="0" y="0" xlink:href="#MJMAIN-28">< use x="389" y="0" xlink:href="#MJMAIN-3A3">< use x="1112" y="0" xlink:href="#MJMAIN-29">< use x="5269" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(6326,0)">< g transform="translate(0,2734)">< use x="0" y="-1156" xlink:href="#MJSZ4-239B">< g transform="translate(0,-3179.4725352720416) scale(1,2.319922316320854)">< use xlink:href="#MJSZ4-239C">< use x="0" y="-4324" xlink:href="#MJSZ4-239D">< g transform="translate(1042,0)">< g transform="translate(-11,0)">< g transform="translate(56,1744)">< use x="0" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(778,0)">< use x="0" y="0" xlink:href="#MJMAIN-39B">< use x="97" y="294" xlink:href="#MJMAIN-5E">< use transform="scale(0.707)" x="982" y="-213" xlink:href="#MJMAIN-31">< g transform="translate(0,-42)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(0,-1828)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(2973,0)">< g transform="translate(0,1744)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(52,-42)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< use x="36" y="9" xlink:href="#MJMAIN-5E">< g transform="translate(572,-187)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(52,-1828)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< use x="36" y="9" xlink:href="#MJMAIN-5E">< g transform="translate(572,-187)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(5956,0)">< g transform="translate(0,1744)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(52,-42)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< use x="36" y="9" xlink:href="#MJMAIN-5E">< g transform="translate(572,-187)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(52,-1828)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< use x="36" y="9" xlink:href="#MJMAIN-5E">< g transform="translate(572,-187)">< use transform="scale(0.707)" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMAIN-31">< g transform="translate(9149,2734)">< use x="0" y="-1155" xlink:href="#MJSZ4-239E">< g transform="translate(0,-3179.453273634803) scale(1,2.321527452757451)">< use xlink:href="#MJSZ4-239F">< use x="0" y="-4324" xlink:href="#MJSZ4-23A0">< use x="16518" y="0" xlink:href="#MJMAIN-2C">
where < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="4.72ex" height="3.676ex" style="vertical-align: -1.171ex;" viewBox="0 -1078.4 2032.3 1582.7" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.707)" x="298" y="0" xlink:href="#MJMATHI-6B">< use transform="scale(0.707)" x="820" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1098" y="0" xlink:href="#MJMATHI-41"> is the simple linear model estimator of the regression coefficient for the linear model < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="14.843ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 6390.7 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMATHI-6B">< use x="1575" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(2631,0)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< g transform="translate(566,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.707)" x="298" y="0" xlink:href="#MJMATHI-6B">< g transform="translate(3877,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMATHI-6C">< use x="4983" y="0" xlink:href="#MJMAIN-2B">< use x="5984" y="0" xlink:href="#MJMATHI-3F5"> for < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="9.736ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 4191.7 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6B">< use x="799" y="0" xlink:href="#MJMAIN-2208">< g transform="translate(1744,0)">< use x="0" y="0" xlink:href="#MJMAIN-7B">< g transform="translate(500,0)">< use x="0" y="0" xlink:href="#MJMAIN-32">< use x="500" y="0" xlink:href="#MJMAIN-2C">< use x="945" y="0" xlink:href="#MJMAIN-33">< use x="1946" y="0" xlink:href="#MJMAIN-7D">, < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.078ex" height="3.176ex" style="vertical-align: -0.671ex;" viewBox="0 -1078.4 1325.2 1367.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-39B">< use x="97" y="294" xlink:href="#MJMAIN-5E">< use transform="scale(0.707)" x="982" y="-230" xlink:href="#MJMATHI-41"> is the inverse of the covariance matrix of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="0.693ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 298.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6C"> unscaled by < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.398ex" height="2.343ex" style="vertical-align: -0.505ex;" viewBox="0 -791.3 2323.9 1008.6" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6E">< use x="822" y="0" xlink:href="#MJMAIN-2212">< use x="1823" y="0" xlink:href="#MJMAIN-31">, and < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="4.786ex" height="3.009ex" style="vertical-align: -1.171ex;" viewBox="0 -791.3 2060.6 1295.7" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< use x="36" y="9" xlink:href="#MJMAIN-5E">< g transform="translate(572,-187)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.707)" x="412" y="0" xlink:href="#MJMATHI-6B">< use transform="scale(0.707)" x="934" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1212" y="0" xlink:href="#MJMATHI-41"> is the sample covariance of the residuals from the regression models on < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="0.693ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 298.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6C"> unscaled by < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.398ex" height="2.343ex" style="vertical-align: -0.505ex;" viewBox="0 -791.3 2323.9 1008.6" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6E">< use x="822" y="0" xlink:href="#MJMAIN-2212">< use x="1823" y="0" xlink:href="#MJMAIN-31">.
Example
Lets try this with some real data. I have used the SWP function included with the ISR3 package.
library(ISR3)
set.seed(12)
n <- 100
p <- 3
# generate a positive definite matrix for covariance
Sigma <- rWishart(1,p+1,diag(p))[,,1]
Sigma_inv <- chol2inv(chol(Sigma))
Sigma_inv_chol <- chol(Sigma_inv)
# generate 'n' multivate normal deviates
X <- Sigma_inv_chol %*% matrix(rnorm(n*p),nrow=p)
X <- t(X)
colnames(X) <- sprintf("X_%d",1:p)
XX <- t(X) %*% X
#Sweep by the first row/column of XX
SWP_1 <- SWP(XX,1)
SWP_1
## X_1 X_2 X_3
## X_1 -0.002381092 0.1375626 -0.01674788
## X_2 0.137562633 50.0987932 -4.95181624
## X_3 -0.016747875 -4.9518162 41.73979419
We can compare this output with the results from the simple linear models < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="11.653ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 5017.2 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-32">< use x="1560" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(2616,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMAIN-31">< g transform="translate(3642,0)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< g transform="translate(566,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32"> and < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="11.653ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 5017.2 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-33">< use x="1560" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(2616,0)">< use x="0" y="0" xlink:href="#MJMATHI-78">< use transform="scale(0.707)" x="809" y="-213" xlink:href="#MJMAIN-31">< g transform="translate(3642,0)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< g transform="translate(566,-150)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">:
# linear models
fit_21 <- lm(X_2 ~ -1 + X_1, data=as.data.frame(X))
fit_31 <- lm(X_3 ~ -1 + X_1, data=as.data.frame(X))
# SLR coefficents for X_1
print(fit_21$coefficients)
## X_1
## 0.1375626
print(fit_31$coefficients)
## X_1
## -0.01674788
# sum of squares
print(sum(fit_21$residuals^2))
## [1] 50.09879
print(sum(fit_31$residuals^2))
## [1] 41.73979
# covariance between X_2 and X_3 given X_1
print(sum(fit_21$residuals * fit_31$residuals))
## [1] -4.951816
# negative inverse of the covariance matrix of X_1
print( -1/((n-1)*var(X[,1])) )
## [1] -0.002381293
Here we see that the coefficients from lm match up to our swept results. Likewise, the diagonal terms for the second and third column are equivalent to the sum of squares or the residuals. The remaining unmatched term is just the negative inverse of the covariance matrix of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.979ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 1282.4 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-31"> unscaled by < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.398ex" height="2.343ex" style="vertical-align: -0.505ex;" viewBox="0 -791.3 2323.9 1008.6" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6E">< use x="822" y="0" xlink:href="#MJMAIN-2212">< use x="1823" y="0" xlink:href="#MJMAIN-31">.
A subsequent sweep on the second rows and columns produces the matrix,
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="58.708ex" height="8.843ex" style="vertical-align: -3.838ex;" viewBox="0 -2154.8 25277.1 3807.2" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use xlink:href="#MJMAIN-53">< use x="556" y="0" xlink:href="#MJMAIN-57">< use x="1585" y="0" xlink:href="#MJMAIN-50">< use x="2266" y="0" xlink:href="#MJMAIN-5B">< use x="2545" y="0" xlink:href="#MJMAIN-32">< use x="3045" y="0" xlink:href="#MJMAIN-5D">< g transform="translate(3490,0)">< use x="0" y="0" xlink:href="#MJMAIN-28">< g transform="translate(389,0)">< use xlink:href="#MJMAIN-53">< use x="556" y="0" xlink:href="#MJMAIN-57">< use x="1585" y="0" xlink:href="#MJMAIN-50">< use x="2266" y="0" xlink:href="#MJMAIN-5B">< use x="2545" y="0" xlink:href="#MJMAIN-31">< use x="3045" y="0" xlink:href="#MJMAIN-5D">< g transform="translate(3490,0)">< use x="0" y="0" xlink:href="#MJMAIN-28">< use x="389" y="0" xlink:href="#MJMAIN-3A3">< use x="1112" y="0" xlink:href="#MJMAIN-29">< use x="5381" y="0" xlink:href="#MJMAIN-29">< use x="9539" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(10595,0)">< use xlink:href="#MJMAIN-53">< use x="556" y="0" xlink:href="#MJMAIN-57">< use x="1585" y="0" xlink:href="#MJMAIN-50">< use x="12862" y="0" xlink:href="#MJMAIN-5B">< use x="13140" y="0" xlink:href="#MJMATHI-41">< use x="13891" y="0" xlink:href="#MJMAIN-5D">< g transform="translate(14336,0)">< use x="0" y="0" xlink:href="#MJMAIN-28">< use x="389" y="0" xlink:href="#MJMAIN-3A3">< use x="1112" y="0" xlink:href="#MJMAIN-29">< use x="16115" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(17172,0)">< g transform="translate(0,2052)">< use x="0" y="-1156" xlink:href="#MJSZ4-239B">< use x="0" y="-2960" xlink:href="#MJSZ4-239D">< g transform="translate(1042,0)">< g transform="translate(-11,0)">< g transform="translate(0,863)">< use x="0" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(778,0)">< use x="0" y="0" xlink:href="#MJMAIN-39B">< use x="97" y="294" xlink:href="#MJMAIN-5E">< g transform="translate(694,716)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-2212">< use transform="scale(0.707)" x="778" y="0" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="982" y="-350" xlink:href="#MJMATHI-41">< g transform="translate(1024,-1129)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< use transform="scale(0.707)" x="883" y="997" xlink:href="#MJMATHI-54">< g transform="translate(624,-248)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="278" y="0" xlink:href="#MJMATHI-41">< g transform="translate(3466,0)">< g transform="translate(655,863)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="278" y="0" xlink:href="#MJMATHI-41">< g transform="translate(0,-1129)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< use x="36" y="9" xlink:href="#MJMAIN-5E">< g transform="translate(572,-187)">< use transform="scale(0.707)" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMATHI-41">< g transform="translate(6784,2052)">< use x="0" y="-1155" xlink:href="#MJSZ4-239E">< use x="0" y="-2960" xlink:href="#MJSZ4-23A0">< use x="24998" y="0" xlink:href="#MJMAIN-2C">
where < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="10.525ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 4531.7 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-41">< use x="1028" y="0" xlink:href="#MJMAIN-3D">< use x="2084" y="0" xlink:href="#MJMAIN-7B">< use x="2585" y="0" xlink:href="#MJMAIN-31">< use x="3085" y="0" xlink:href="#MJMAIN-2C">< use x="3530" y="0" xlink:href="#MJMAIN-32">< use x="4031" y="0" xlink:href="#MJMAIN-7D">, < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.946ex" height="3.843ex" style="vertical-align: -0.838ex;" viewBox="0 -1293.7 1698.9 1654.5" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-39B">< use x="97" y="294" xlink:href="#MJMAIN-5E">< g transform="translate(694,716)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-2212">< use transform="scale(0.707)" x="778" y="0" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="982" y="-350" xlink:href="#MJMATHI-41"> is now the inverse covariance matrix of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.979ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 1282.4 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-31"> and < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.979ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 1282.4 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use transform="scale(0.707)" x="1171" y="-213" xlink:href="#MJMAIN-32"> and < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="3.374ex" height="3.676ex" style="vertical-align: -1.171ex;" viewBox="0 -1078.4 1452.5 1582.7" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="278" y="0" xlink:href="#MJMATHI-41"> is the matrix
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="10.484ex" height="7.843ex" style="vertical-align: -3.338ex;" viewBox="0 -1939.5 4514 3376.7" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use xlink:href="#MJSZ4-28">< g transform="translate(959,0)">< g transform="translate(-11,0)">< g transform="translate(0,857)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMATHI-41">< g transform="translate(0,-929)">< use x="0" y="0" xlink:href="#MJMATHI-3B2">< use x="124" y="283" xlink:href="#MJMAIN-5E">< g transform="translate(624,-231)">< use transform="scale(0.707)" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-33">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="1279" y="0" xlink:href="#MJMATHI-41">< use x="3276" y="0" xlink:href="#MJSZ4-29">< use x="4235" y="0" xlink:href="#MJMAIN-2E">
Again, we can quickly check the results by comparing the output from lm to our SWP operator.
A final sweep by the third row and column produces < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="6.119ex" height="3.843ex" style="vertical-align: -0.838ex;" viewBox="0 -1293.7 2634.7 1654.5" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(778,0)">< use x="0" y="0" xlink:href="#MJMAIN-39B">< use x="97" y="294" xlink:href="#MJMAIN-5E">< g transform="translate(694,716)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-2212">< use transform="scale(0.707)" x="778" y="0" xlink:href="#MJMAIN-31">< g transform="translate(694,-248)">< use transform="scale(0.707)" xlink:href="#MJMAIN-31">< use transform="scale(0.707)" x="500" y="0" xlink:href="#MJMAIN-32">< use transform="scale(0.707)" x="1001" y="0" xlink:href="#MJMAIN-33">, the negative inverse of the unscaled covariance matrix of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.98ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 852.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">. This can be quickly verified through R:
We can also undo sweeps with the reverse sweep (RSWP) operator through the following element-wise operations
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="35.039ex" height="13.176ex" style="vertical-align: -5.772ex;" viewBox="0 -3087.6 15086.1 5673" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.707)" x="412" y="0" xlink:href="#MJMATHI-6B">< use x="1609" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(2665,0)">< g transform="translate(0,2985)">< use x="0" y="-1156" xlink:href="#MJSZ4-239B">< g transform="translate(0,-3671.5230125529683) scale(1,3.1252422464042033)">< use xlink:href="#MJSZ4-239C">< use x="0" y="-4826" xlink:href="#MJSZ4-239D">< g transform="translate(1042,0)">< g transform="translate(-11,0)">< g transform="translate(0,2068)">< use x="0" y="0" xlink:href="#MJMATHI-6A">< use x="690" y="0" xlink:href="#MJMAIN-3D">< use x="1746" y="0" xlink:href="#MJMATHI-6B">< use x="2545" y="0" xlink:href="#MJMAIN-3D">< use x="3602" y="0" xlink:href="#MJMATHI-6C">< g transform="translate(0,45)">< use x="0" y="0" xlink:href="#MJMATHI-6A">< use x="690" y="0" xlink:href="#MJMAIN-3D">< use x="1746" y="0" xlink:href="#MJMATHI-6C">< use x="2295" y="0" xlink:href="#MJMAIN-26">< use x="3323" y="0" xlink:href="#MJMATHI-6B">< use x="4122" y="0" xlink:href="#MJMAIN-2260">< use x="5179" y="0" xlink:href="#MJMATHI-6C">< g transform="translate(0,-1977)">< use x="0" y="0" xlink:href="#MJMATHI-6A">< use x="690" y="0" xlink:href="#MJMAIN-2260">< use x="1746" y="0" xlink:href="#MJMATHI-6C">< use x="2295" y="0" xlink:href="#MJMAIN-26">< use x="3323" y="0" xlink:href="#MJMATHI-6B">< use x="4122" y="0" xlink:href="#MJMAIN-2260">< use x="5179" y="0" xlink:href="#MJMATHI-6C">< g transform="translate(6467,0)">< g transform="translate(1328,2068)">< use x="0" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(778,0)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< use transform="scale(0.707)" x="505" y="629" xlink:href="#MJMAIN-31">< g transform="translate(60,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-137)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.574)" x="412" y="0" xlink:href="#MJMATHI-6A">< g transform="translate(1296,45)">< use x="0" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(778,0)">< g transform="translate(120,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,717)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.574)" x="412" y="0" xlink:href="#MJMATHI-6B">< g transform="translate(91,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-137)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.574)" x="412" y="0" xlink:href="#MJMATHI-6A">< g transform="translate(0,-1977)">< use x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(571,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-6A">< use transform="scale(0.707)" x="412" y="0" xlink:href="#MJMATHI-6B">< use x="1554" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(2332,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,718)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.574)" x="298" y="0" xlink:href="#MJMATHI-6B">< g transform="translate(945,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.574)" x="298" y="0" xlink:href="#MJMATHI-6A">< g transform="translate(565,-345)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-3C3">< g transform="translate(404,-156)">< use transform="scale(0.574)" x="0" y="0" xlink:href="#MJMATHI-6C">< use transform="scale(0.574)" x="298" y="0" xlink:href="#MJMATHI-6C">
Caution should be used when reverse sweeping, as in application < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="24.494ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 10546 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-52">< use x="759" y="0" xlink:href="#MJMATHI-53">< use x="1405" y="0" xlink:href="#MJMATHI-57">< use x="2453" y="0" xlink:href="#MJMATHI-50">< use x="3205" y="0" xlink:href="#MJMAIN-5B">< use x="3483" y="0" xlink:href="#MJMATHI-41">< use x="4234" y="0" xlink:href="#MJMAIN-5D">< use x="4512" y="0" xlink:href="#MJMAIN-28">< use x="4902" y="0" xlink:href="#MJMATHI-53">< use x="5547" y="0" xlink:href="#MJMATHI-57">< use x="6596" y="0" xlink:href="#MJMATHI-50">< use x="7347" y="0" xlink:href="#MJMAIN-5B">< use x="7626" y="0" xlink:href="#MJMATHI-41">< use x="8376" y="0" xlink:href="#MJMAIN-5D">< use x="8655" y="0" xlink:href="#MJMAIN-28">< use x="9044" y="0" xlink:href="#MJMAIN-3A3">< use x="9767" y="0" xlink:href="#MJMAIN-29">< use x="10156" y="0" xlink:href="#MJMAIN-29"> is not necessarily equal to < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.678ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 722.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3A3"> due to floating point error. In particular when the matrix is ill-conditioned there may be considerable departure between the calculated identity and the original matrix.
What Next?
A few good references on the subject beyond (Dempster, 1969) can be found in (Goodknight, 1979) and (Little and Rubin, 2014). There are a few slight differences between these implementations, but all generally do the same thing.
One function that doesn’t do the same thing is the sweep function in R. This function can be used to write a SWP implementation, but doesn’t sweep by itself.
Code examples can be found in the ISR3 package on CRAN and in lots of other packages.
Examples in C can be found in ISR3 and as an internal function in the MNP package (Imai and Van Dyk, 2013).
Enjoy your sweeping, next time I’ll go over sweeping with the generalized inverse!
References
Dempster, A.P. (1969). Elements of continuous multivariate analysis. Reading, MA: Addison-Wesley.
Goodnight, J. H. (1979). A tutorial on the SWEEP operator. The American Statistician, 33(3), 149-158.
Imai, K., and Van Dyk, D. A. (2013). MNP: R Package for fitting the Multinomial Probit Model, R package version 2.6-4, https://CRAN.R-project.org/package=MNP