Skip to main content
edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

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? Thanks in advance!

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'));

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? Thanks in advance!

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'));

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'));

Liner regression with fixing Forcing y-intercept (or offset) equalto zero (0) inwith Google Earth Engine (GEE) linear interpolation

I am trying to use the linear regression function (ee.Reducer.linearFit())ee.Reducer.linearFit() in GEE. 

But this function cannotdoes not provide a mean to force the y-intercept alwaysto be equal to 0. 

Is there functions I can use to force the y-intercept equal 0 in GEE? Thanks in advance!

Below is the example 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'));

Liner regression with fixing y-intercept (or offset) equal zero (0) in Google Earth Engine (GEE)

I am trying to use the linear regression function (ee.Reducer.linearFit()) in GEE. But this function cannot force the y-intercept always equal to 0. Is there functions I can force the y-intercept equal 0 in GEE? Thanks in advance!

Below is the example code 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'));

Forcing y-intercept to zero with Google Earth Engine (GEE) linear interpolation

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? Thanks in advance!

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'));
Source Link

Liner regression with fixing y-intercept (or offset) equal zero (0) in Google Earth Engine (GEE)

I am trying to use the linear regression function (ee.Reducer.linearFit()) in GEE. But this function cannot force the y-intercept always equal to 0. Is there functions I can force the y-intercept equal 0 in GEE? Thanks in advance!

Below is the example code 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'));