[Tex/LaTex] Regression Functions and Variable Names

math-modestatistics

I would like to present a regression function in my LaTeX Document that includes actual variable names from my (Stata) code as its covariates. This screenshot gives an example of what I want it to look like – with the exception that I want the functions to be numbered using a \label{} command or anything of that sort.

Example

Using the math mode, I was not able to construct regression functions that look any similar

\documentclass[12pt,a4paper]{article}

\usepackage[applemac]{inputenc}
\usepackage{amsmath, amsthm, amssymb}

\begin{document}

\begin{align}
    \text{dep\_var}_i = f(\text{some\_var}_i) + \beta_1 \text{wage\_female}_i + u_i \label{eq:1}
\end{align}

\end{document}

So my approach was to combine the listings package with the above code which however turns out not to work. I would appreciate any advice on that!

Note: The screenshot is from the Stata Journal Article "Difference-based semiparametric estimation of partial linear regression models"

Best Answer

I would recommend taking a two-step approach: (i) define a high-level macro named (say) \vn -- short for "variable name" -- to denote that some string is supposed to be a variable name, and (ii) a low-level macro named (say) \vnform that determine the "look" of variable names. That way, if you change your mind about the preferred look of variable names, all you need to do is to change the macro \vnform in the preamble.

enter image description here

\documentclass{article}
\newcommand{\vn}[1]{\vnform{#1}}
\newcommand{\vnform}[1]{\mathtt{#1}}  % "look": monospaced/upright
\usepackage{amsmath}
\begin{document}
\begin{align*}
\vn{tc}_i &= f(\vn{cust}_i) + \beta_1 \vn{wage}_i + \beta_2\vn{pcap}_i + \beta_3\vn{puc}_i + \beta_4\vn{kwh}_i\\
&\quad + \beta_5\vn{life}_i + \beta_6\vn{lf}_i + \beta_7\vn{kmwire}_i + \epsilon_i
\end{align*}

\renewcommand{\vnform}[1]{\textnormal{#1}}  % change "look" to roman/upright

\begin{align*}
\vn{tc}_i &= f(\vn{cust}_i) + \beta_1 \vn{wage}_i + \beta_2\vn{pcap}_i + \beta_3\vn{puc}_i + \beta_4\vn{kwh}_i\\
&\quad + \beta_5\vn{life}_i + \beta_6\vn{lf}_i + \beta_7\vn{kmwire}_i + \epsilon_i
\end{align*}
\end{document}