0

My thesis suddenly does not compile anymore. LaTeX throws the following error :

! Misplaced alignment tab character &. \math@cr@@@ ->\ifst@rred \nonumber \fi & \relax \make@display@tag \ifst@rred ... l.1007 \end{equation} The sensitivity of a classification model will tell us

The strange thing is that I did not even edit the highlighted area, which is compiling correctly if I extract the lines to a new document.

MWE :

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage[margin=1in, paperwidth=8.3in, paperheight=11.7in]{geometry}
\begin{document}
\begin{equation}
    Sensitivity  = \dfrac{\text{\textit{\# of true positives of class i}}}{\text{\textit{\# of true positives of class i + \\
                \# of false negatives positives of class i}}}
\end{equation} The sensitivity of a classification model will tell us
how good each class (climber, spriner, mixed) performs in their own
group. For example, given that the model classified 1000 observations as
climbers in the test subset. While only 700 observations of these
predicted observation actually were climbers (true positives), 300 more
observations which had the class climbers where not predicted as those.
Then, the sensitivity for the class climbers would be 700/700+300 = 0.7. 
\end{document}

The areas that I did edit strangly compile correctly on its own aswell :

MWE 2 :

 \documentclass[11pt]{article}
    \usepackage{amsmath}
    \usepackage[margin=1in, paperwidth=8.3in, paperheight=11.7in]{geometry}
    \begin{document}
1000 observations contained $NA$ data for the variables $avg\_temperature$ and $avg\_calories$. To handle this problem the author decided for two different strategies. First, the observations which contain $NA$ valuers were dropped, second those values were instead imputed.  The imputation was done using the IRMI algorithm mentioned first by \cite{Templ2011}. The basis for the work of the latter authors is the IVEWARE algorithm from \cite{Raghunathan01} which generates iterative estimates for the missing values using a chain of regression models and picking values from the generated predictive distributions. The IRMI algorithm solves the disability of the IVEWARE algorithm to produce robust results for data including outliers, adds more flexibility by removing the restriction of at least one fully observed variable and uses an Akaike information criterion for model selection. In the latter process a user-specified amount of the most important variables for the imputation sequence were chosen. A short example of the algorithm for both variables of the strava dataset than contain missings is the following . \\ In the first step a KNN-algorithm is used to create initial values for those missings. Then, for each variable $j$ of the dataset, those observations that contained missings were marked. Let $A$ describe all observations that were marked containing missings and $m$ describes the variable which include the missings. So $\{A, m\}$ describes all observations of the variable $m$ that contain missings, therefore $m \notin j$ .Then linear regression estimates $\hat{\beta^j}$ were calculated by all other variables including an intercept $X_{A, m}^j$ against the missing observations of the target variable $y_{A, m}^m$. So that $y_{A, m}^m =  \hat{\beta}^jX_{A, m}^j + \epsilon$, with $\epsilon$ being some error term. Alternatively one can choose to use stepwise model selection by AIC. So, that we include only the most important variables $i$ from the best model. If one chooses not to use the stepwise model $i=j$. Then we can replace (new) estimates for the missing values by  $\hat{y}_{A, m}^m = \hat{\beta^i}X_{A, m}^i$. Afterwards the regression and replacing steps were repeated $min(2,M) \quad m \in M$ times until $\sum_{a}^A\left(\hat{\boldsymbol{y}}_{a, m}^{m}-\tilde{\boldsymbol{y}}_{a, m}^{m}\right)^{2}<\delta, \quad \text {for all} a \in A \quad \text {and} m \in M$. Where $\delta$ is a small constant, $\hat{\boldsymbol{y}}_{a, m}^{m}$ is the $a$-th imputed value of the current iteration and  $\tilde{\boldsymbol{y}}_{a, m}^{m}$ is the $a$-th imputed value of the last iteration.   The results of the classification and regression tasks in the results section will explore if an improvement of the results can be achieved with imputed missing values in the dataset. The baseline will be the strava dataset which has simply dropped the missing values and one with imputed values generated by the IRMI algorithm. Possible restrictions of the results obtained with the imputed dataset will be argued in the discussion section.
 
 \begin{equation}
    type_{i_D, k} =  
    \begin{cases}
        climber  & \mbox{if} \quad \sum_{i_{d}}^{i_{D}}climber\_points_{i_d, k} >  \biggl\{ \sum_{i_{d}}^{i_{D}}sprinter\_points_{i_d, k} \biggr\}*1.5 \\
        & \mbox{and} \quad  \biggl\{\sum_{i_{d}}^{i_{D}}climber\_points_{i_d, k} -  \sum_{i_{d}}^{i_{D}}sprinter\_points_{i_d, k} \biggr\} \geq 30  \\
        sprinter & \mbox{if} \quad  \sum_{i_{d}}^{i_{D}}sprinter\_points_{i_d, k} >  \biggl\{ \sum_{i_{d}}^{i_{D}}climber\_points_{i_d, k} \biggr\}*1.5   \\
        & \mbox{and} \quad  \biggl\{\sum_{i_{d}}^{i_{D}}sprinter\_points_{i_d, k} -  \sum_{i_{d}}^{i_{D}}climber\_points_{i_d, k} \biggr\} \geq 30 \\
        mixed   &  \mbox{else} 
    \end{cases}
    \label{eq:type_rule}
 \end{equation}
 
\end{document}

Any idea what the origin of this error could possibly be?

6
  • you apparently have a spurious \\ in theequation that ends on line 1007 of some file but hard to say without an example that shows the error. Jan 18, 2022 at 17:04
  • The MWE contains the lines 1004 to 1012. 1007 is explicitly : "\end{equation} The sensitivity of a classification model will tell us" The whole equation is stated in the MWE (1)
    – mugdi
    Jan 18, 2022 at 17:11
  • Thanks for the help anyway. It looks like that RMarkdown added this \\ without any reason to the knited .tex file!
    – mugdi
    Jan 18, 2022 at 17:13
  • theer must be some difference between your generated document and the mwe posted as that does not give any error. Jan 18, 2022 at 17:18
  • Nope. This is the strange thing that I do not understand. But now I deleted \\ in \dfrac{\text{\textit{\# of true positives of class i}}}{\text{\textit{\# of true positives of class i + \\ \# of false negatives positives of class i}}} and it seems to work. Surprisingly, this error did not appear before with the \\ in the paragraph!
    – mugdi
    Jan 18, 2022 at 17:22

1 Answer 1

2

The posted example produces no error although the \\ does nothing useful as \text is like \mbox and always a single line

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage[margin=1in, paperwidth=8.3in, paperheight=11.7in]{geometry}
\begin{document}
\begin{equation}
    Sensitivity  =
    \dfrac{\text{\textit{\# of true positives of class
    i}}}{\text{\textit{\# of true positives of class i + \\
                 \# of false negatives positives of class i}}}
\end{equation} The sensitivity of a classification model will tell us
how good each class (climber, spriner, mixed) performs in their own
group. For example, given that the model classified 1000 observations as
climbers in the test subset. While only 700 observations of these
predicted observation actually were climbers (true positives), 300 more
observations which had the class climbers where not predicted as those.
Then, the sensitivity for the class climbers would be 700/700+300 = 0.7. 
\end{document}

enter image description here

However the error message shows that you have used an ams alignment \\ in such a place and changing equation to align produces essentially the error that you show.

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage[margin=1in, paperwidth=8.3in, paperheight=11.7in]{geometry}
\begin{document}
\begin{align}
    Sensitivity  =
     \dfrac{\text{\textit{\# of true positives of class
      i}}}{\text{\textit{\# of true positives of class i + \\
     \# of false negatives positives of class i}}}
\end{align} The sensitivity of a classification model will tell us
how good each class (climber, spriner, mixed) performs in their own
group. For example, given that the model classified 1000 observations as
climbers in the test subset. While only 700 observations of these
predicted observation actually were climbers (true positives), 300 more
observations which had the class climbers where not predicted as those.
Then, the sensitivity for the class climbers would be 700/700+300 = 0.7. 
\end{document}

produces

! Misplaced alignment tab character &.
\math@cr@@@ ->&
               \omit \global \advance \row@ \@ne \ifst@rred \nonumber \fi \i...
l.8 \end{align}
                The sensitivity of a classification model will tell us
? 

However the error message that you show does show your document used \end{equation} so (I would guess) that you have a non-standard re-definition of equation based on align. In any case, the fix is to remove the spurious \\ .

5
  • Thanks David, I will accept your answer. Nevertheless, I did not redefine the equation environment in any way. Seems like some part of the problem are still a mystery!
    – mugdi
    Jan 18, 2022 at 17:36
  • 1
    @mugdi if you want to solve the mystery it is easy for you to provide an example that produces the error, start from a copy of your document, delete everything except that paragraph, check the error happens, then delete everything from the preamble not needed for the reduced example, check the error does not go, then post the result. Jan 18, 2022 at 17:40
  • Looks like this error appears due to a package called resizegatherer! Which makes sense since the gather environment actually does adjust the equation environment! Good hint from your side!
    – mugdi
    Jan 18, 2022 at 17:46
  • ok so I guessed align but it's gather but they are very related:-) Jan 18, 2022 at 17:48
  • Thanks for the help and the motivation to solve the loose end!
    – mugdi
    Jan 18, 2022 at 17:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .