Programming an estimation command in Stata: Using Stata matrix commands and functions to compute OLS objects
\newcommand{\epsilonb}{\boldsymbol{\epsilon}} \newcommand{\ebi}{\boldsymbol{\epsilon}_i} \newcommand{\Sigmab}{\boldsymbol{\Sigma}} \newcommand{\betab}{\boldsymbol{\beta}} \newcommand{\eb}{{\bf e}} \newcommand{\xb}{{\bf x}} \newcommand{\zb}{{\bf z}} \newcommand{\yb}{{\bf y}} \newcommand{\Xb}{{\bf X}} \newcommand{\Mb}{{\bf M}} \newcommand{\Eb}{{\bf E}} \newcommand{\Xtb}{\tilde{\bf X}} \newcommand{\Vb}{{\bf V}}I present the formulas for computing the ordinary least-squares (OLS) estimator, and I discuss some do-file implementations of them. I discuss the formulas and the computation of independence-based standard errors, robust standard errors, and cluster-robust standard errors. I introduce the Stata matrix commands and matrix functions that I use in ado-commands that I discuss in upcoming posts.
This is the fifth post in the series Programming an estimation command in Stata. I recommend that you start at the beginning. See Programming an estimation command in Stata: A map to posted entries for a map to all the posts in this series. Read more…