My guess is that for some datapoints, the optimization algorithm explores coefficient values for which the result of the equation is negative, and therefore tries to estimate the parameters of the Gamma distribution using a negative number (which is outside its domain, and therefore returns NaN), even though all my real datapoints are positive ... More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.