{smcl} {bf:Mata course: Accuracy 2} {hline} {title:1. Solvers vs. inversion} {p 4 4 2} Pretend we have a numeric method to solve {it:A}{it:X} = {it:B} {p 4 4 2} for {it:X}. Then that method can be used to obtain the inversion of A, because inv(A) = X such that {it:A}{it:X} = {it:I} {p 4 4 2} Hence, we use our method, and substitute {it:B}={it:I}. {title:2. Is using a solver for inversion inaccurate?} {p 4 4 2} No. {p 4 4 2} The {it:B}={it:I} matrix contains 0s and 1s only: {p 8 12 2} 1. Multiplying by 0 introduces no loss of precision: 0*{it:z} = 0. {p 8 12 2} 2. Multiplying by 1 introduces no loss of precision: 1*{it:z} = z. {p 8 12 2} 3. Adding 0 introduces no loss of precision: 0+{it:z} = {it:z}. {p 8 12 2} 4. Adding 1 could introduce a loss of precision, but such terms seldom (never) arise. {title:3. Is using a solver for inversion efficient?} {p 4 4 2} No. {p 4 4 2} We do lots of calculations, just to multiply them by 0, which we add to other nonzsero terms, and we are often multiplying or dividing results by 1. {title:4. Solving versus inverting} {p 4 4 2} We statistician's are often thought to think in terms of inverses, e.g., {it:b} = ({it:X}'{it:X})^(-1){it:X}'{it:y} {p 4 4 2} Numerical types look down on us, because better is Solve ({it:X}'{it:X}){it:b} = {it:X}'{it:y} for {it:b} {p 4 4 2} That is because solving requires fewer operations (additions, importantly) than inverting {it:X}'{it:X} and then multiplying the result by {it:X}'{it:y}. {p 4 4 2} There are {it:k}^2 additions in that last multiplication. {title:Inverses serve a purpose} {p 4 4 2} It is from inverses that we statisticians obtain our variances. {title:The way Stata's -regress- works} {p 4 8 2} 1. Form {it:X}'{it:X} and {it:X}'{it:y}.{break} (Formed accurately, with means removed.) {p 4 8 2} 2. Invert {it:X}'{it:X}.{break} Use ({it:X}'{it:X})^(-1) for standard errors (variance matrix). {p 4 8 2} 3. Solve ({it:X}'{it:X}){it:b} = {it:X}'{it:y} to obtain {it:b}.{break} Do not use use ({it:X}'{it:X})^(-1) from step (2). {p 4 4 2} Concerning collinearity, it is identified at step (2) and then the reduced problem is solved in step (3). {hline} {bf:{view talk.smcl:Top}}