1

I have trouble with my code :(

I heard that {cases} environment cannot be used in math mode,

so I changed $$ to \(\), but still getting various kind of errors.

\begin{frame}{ZIP regression models with covariates}
        \begin{itemize}
            \item Regression-type models can adjust for covariate effects and assess relationships between key predictors and the response
            \item Covariates enter ZIP regression model at both the Bernoulli zero-inflation and Poison count stages\\
            $\rar$ 2 sets of parameters corresponding to p and $\lambda$\\
            \(\begin{cases}
                \(\lambda\) : loglinear model \(\rar log(\frac{p}{1-p}) = \textbf{X_1\alpha} = \alpha_0 + \alpha_1X_{11} + \alpha_2X_{12} + \dots + \alpha_mX_{1m}\)\\
                p : logit model \(\rar log(\lambda) = \textbf{X_2\beta} = \beta_0 + \beta_1X_{21} + \beta_2X_{22} + \dots + \beta_lX_{2l}\)
                \end{cases}\)
           \vspace{0.2cm}
            \item \(\boldsymbol{X_1} = (1, X_{11}, X_{12}, \dots, X_{1m})\) : covariate vector included in the zero stage\\
           \(\boldsymbol{X_2} = (1, X_{21}, X_{22}, \dots, X_{2l})\) : covariate vector included in the Poisson stage
            \item \(\boldsymbol{\alpha} = (\alpha_0, \alpha_1, \dots, \alpha_m)^{T}, \boldsymbol{\beta} = (\beta_0, \beta_1, \dots, \beta_l)^{T}\)\\
          $\rar$ corresponding coefficient vectors
        \end{itemize}
    \end{frame}

I have no idea what is wrong... help me please!

1
  • 1
    \(\begin{cases} \text{math mode} & \text{still math mode}\\ ...\end{csases}\) Commented Jul 13, 2020 at 14:03

2 Answers 2

3

First of all, both $...$ and \(...\) is inline math.

With respect to your cases environment, the following works for me (as mentioned in the comments, the cases environment preserves math mode):

\documentclass{beamer}
\usepackage{amsmath}

\begin{document}
    \begin{frame}{hallo}
        \begin{itemize}
            \item Regression-type models can adjust for covariate effects and assess relationships between key predictors and the response
            \item Covariates enter ZIP regression model at both the Bernoulli zero-inflation and Poison count stages\\
            2 sets of parameters corresponding to p and $\lambda$\\
            \(
                \begin{cases}
                    \lambda\text{:} & \text{loglinear model ...} \\
                    p\text{:} & \text{logit model ...}
                \end{cases}
            \)
        \end{itemize}
    \end{frame}
\end{document}

However, after changing this, your code still didn't compile. I then replaced the \textbf{X_1 \alpha} with \bm{X_1 \alpha} (and included the bm package) which fixed it. Your complete, compiling, example then becomes:

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{bm}

\newcommand{\rar}{\alpha}

\begin{document}
    \begin{frame}{hallo}
        \begin{itemize}
            \item Regression-type models can adjust for covariate effects and assess relationships between key predictors and the response
            \item Covariates enter ZIP regression model at both the Bernoulli zero-inflation and Poison count stages\\
            $\rar$ 2 sets of parameters corresponding to p and $\lambda$\\
            \(
                \begin{cases}
                    \lambda\text{:} & \text{loglinear model } \rar \log(\frac{p}{1-p}) = \bm{X_1\alpha} = \alpha_0 + \alpha_1X_{11} + \alpha_2X_{12} + \dots + \alpha_mX_{1m} \\
                    p\text{:} & \text{logit model } \rar \log(\lambda) = \bm{X_2\beta} = \beta_0 + \beta_1X_{21} + \beta_2X_{22} + \dots + \beta_lX_{2l}
                \end{cases}
            \)
            \item \(\boldsymbol{X_1} = (1, X_{11}, X_{12}, \dots, X_{1m})\) : covariate vector included in the zero stage\\
            \(\boldsymbol{X_2} = (1, X_{21}, X_{22}, \dots, X_{2l})\) : covariate vector included in the Poisson stage
            \item \(\boldsymbol{\alpha} = (\alpha_0, \alpha_1, \dots, \alpha_m)^{T}, \boldsymbol{\beta} = (\beta_0, \beta_1, \dots, \beta_l)^{T}\)\\
            $\rar$ corresponding coefficient vectors
        \end{itemize}
    \end{frame}
\end{document}

But please note that the math in your cases environment doesn't fit on the slides.

2
  • 1
    Unless class option noamsthm is used, beamer auto-loads amsmath package. Commented Jul 13, 2020 at 19:31
  • @muzimuzhiZ Good point. I'll edit my answer. Commented Jul 14, 2020 at 3:40
1

Errors arise because the cases environment inside inline math \(...\) and nesting further inline math commands like \(\lambda\) inside it. This caused errors because LaTeX doesn't allow math environments to be nested. To fix it, use \[ ... \], equation, or align for display math blocks like cases, and use \( ... \) or $...$ only for inline math. Never nest math environments. Use proper formatting commands such as \log, \frac, \mathbf, and \boldsymbol.

After: What is $\rar$ command?

Here a possible MWE:

\documentclass{beamer}

\begin{document}
\begin{frame}{ZIP regression models with covariates}
    \begin{itemize}
        \item Regression-type models can adjust for covariate effects and assess relationships between key predictors and the response.
        \item Covariates enter ZIP regression model at both the Bernoulli zero-inflation and Poisson count stages.\\
        $\Rightarrow$ 2 sets of parameters corresponding to $p$ and $\lambda$
        \[
        \begin{cases}
        \lambda: \log\left(\frac{p}{1 - p}\right) = \mathbf{X_1\alpha} = \alpha_0 + \alpha_1X_{11} + \alpha_2X_{12} + \dots + \alpha_mX_{1m} \\
        p: \log(\lambda) = \mathbf{X_2\beta} = \beta_0 + \beta_1X_{21} + \beta_2X_{22} + \dots + \beta_lX_{2l}
        \end{cases}
        \]
        \item $\boldsymbol{X_1} = (1, X_{11}, X_{12}, \dots, X_{1m})$: covariate vector included in the zero stage
        \item $\boldsymbol{X_2} = (1, X_{21}, X_{22}, \dots, X_{2l})$: covariate vector included in the Poisson stage
        \item $\boldsymbol{\alpha} = (\alpha_0, \alpha_1, \dots, \alpha_m)^{T}, \quad \boldsymbol{\beta} = (\beta_0, \beta_1, \dots, \beta_l)^{T}$\\
        $\Rightarrow$ corresponding coefficient vectors
    \end{itemize}
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.