# Least Square Monte Carlo Longstaff-Schwartz method implementation problem

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: $$$$b = (X'X)^{-1} X'Y.$$$$ 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?

• Do you by chance know how this function can find a linear regression when I give it a single row of data? for instance where A = [[1,0.3]] and y = [-1]. Because once again this should give me a matrix that doesn't have an inverse because $X'X$ is a matrix with determinant equal to $0$. Apr 27, 2021 at 14:06