[GRASS-user] Linear regression between 2 rasters (old and new)
markus.metz.giswork at googlemail.com
Fri Sep 30 14:15:50 EDT 2011
2011/9/30 António Rocha <antonio.rocha at deimos.com.pt>:
> I have been using r.series to calculate a linear regression slope for an old
> and new raster map using r.series. But now I need to also obtain the error.
> It seems not to be possible to use r.series. Is this true? if yes, what
> alternative do I have?
In your case, the error is always zero. This is because the regression
equation is based on only two maps.
Just for clarification, r.series does not calculate a linear
regression between raster maps. r.series can calculate a linear
regression between raster values and the order number of raster maps,
and this is done for each cell separately. For example, with 4 input
maps map1,map2,map3,map4, r.series calculates the regression
coefficients for each cell for x = (1, 2, 3, 4) and y = (value of map1
and current cell, value of map2 and current cell, value of map3 and
current cell, value of map4 and current cell). The general form of a
linear regression is
y = b0 + b1 * x1 + b2 * x2 + ... + bn * xn + error
with n = number of explaining variables
With only one explaining variable, this reduces to
y = b0 + b1 * x1 + error
with b0 = offset, b1 = slope
With only two values available for x and y, this reduces to
y = b0 + b1 * x1
i.e. no error, the regression line passes exactly through the two given points.
In your case, there are only two points per cell, the first point is
(1, value of map1 at current cell), the second point is (2, value of
map2 at current cell).
The regression coefficients of r.series are interesting for time
series maps to detect trends in time, e.g. correlating temperature
with time (implied by the order of the input maps).
r.regression.line calculates regression coefficients between two
raster maps which is something completely different.
More information about the grass-user