I am trying to use the linear regression function ee.Reducer.linearFit()
in GEE.
But this function does not provide a mean to force the y-intercept to be equal to 0.
Is there functions I can use to force the y-intercept equal 0 in GEE?
Below is the code example without fixing y-intercept(GEE website, https://code.earthengine.google.com/74570c9f13022e5ee6e058d9fc132087):
// Define a list of lists, where columns represent variables. The first column
// is the independent variable and the second is the dependent variable.
var listenter code heresVarColumns = ee.List([
[1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5]
]);
// Compute the least squares estimate of a linear function. Note that an
// object is returned; cast it as an ee.Dictionary to make accessing the
// coefficients easier.
var linearFit = ee.Dictionary(listsVarColumns.reduce(ee.Reducer.linearFit()));
// Inspect the result.
print(linearFit);
print('y-intercept:', linearFit.get('offset'));
print('Slope:', linearFit.get('scale'));