While trying to implement the Least Square Monte Carlo (LSMC) method by Longstaff-Schwartz I came across an error I am not quite sure how to fix.
The method uses a regression method (be it Multiple linear or Polynomial regression) to find the continuation value. In my solution I use matrix multiplication to find the coefficients with which to find the continuation value for all the paths in the money. However I discovered that if only 1 or 2 paths are in the money and since we only use the paths in the money to find the coefficients for the continuation values then my method can not find the coefficients. This is because I would get matrix's which have a determinant of 0. And the formula for finding the coefficients is: \begin{equation} b = (X'X)^{-1} X'Y. \end{equation} And since a matrix with a determinant of 0 can't have an inverse, my implementation won't work.
$\textbf{The solution I found in case of 2 paths:}$
In my multiple linear regression I used $(1, x, x^2)$ as my $X$ matrix and in order to fix the problem I went from 3 variables to two which meant that my $X$ matrix now consisted of $(1,x)$.
$\textbf{The problem}$
What do I do when only a single path is in the money? How do I find a continuation value?