[GRASS-SVN] r66899 - grass-addons/grass7/raster/r.mregression.series

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 23 05:50:54 PST 2015


Author: DmitryKolesov
Date: 2015-11-23 05:50:54 -0800 (Mon, 23 Nov 2015)
New Revision: 66899

Modified:
   grass-addons/grass7/raster/r.mregression.series/r.mregression.series.html
   grass-addons/grass7/raster/r.mregression.series/r.mregression.series.py
Log:
Fix docs for r.mregression series

Modified: grass-addons/grass7/raster/r.mregression.series/r.mregression.series.html
===================================================================
--- grass-addons/grass7/raster/r.mregression.series/r.mregression.series.html	2015-11-23 07:01:46 UTC (rev 66898)
+++ grass-addons/grass7/raster/r.mregression.series/r.mregression.series.html	2015-11-23 13:50:54 UTC (rev 66899)
@@ -18,7 +18,7 @@
 <h2>NOTES</h2>
 
 The number of maps in <em>X</em> and <em>Y</em> must be 
-identical.
+identical (see examples below).
 <p>
 The list of inputs for each cell (including NULLs) is passed to the 
 regression function. The functin compute the parameters over the 
@@ -62,7 +62,6 @@
 <div class="code"><pre>
 r.mregression.series samples=settings result_prefix="coef."
 </pre></div>
-
 <p>
 If the regression model includes the intercept 
 <div class="code"><pre>
@@ -86,6 +85,67 @@
 </pre></div>
 produces three raster maps: "coef.offset", "coef.elevation", "coef.precipitation".    
 
+<h3>EXAMPLE 1</h3>
+We create test data for the example. Suppose we have five <em>Y</em> maps and
+5 pairs of <em>X</em> = <em>(x1, x2)</em> maps.
+<p>
+Create <em>X</em> variables (random numbers):
+<div class="code"><pre>
+r.mapcalc -s "x11 = rand(0, 20)"
+r.mapcalc -s "x21 = rand(0, 20)"
+r.mapcalc -s "x31 = rand(0, 20)"
+r.mapcalc -s "x41 = rand(0, 20)"
+r.mapcalc -s "x51 = rand(0, 20)"
+</pre></div>
+<div class="code"><pre>
+r.mapcalc -s "x12 = rand(0, 20)"
+r.mapcalc -s "x22 = rand(0, 20)"
+r.mapcalc -s "x32 = rand(0, 20)"
+r.mapcalc -s "x42 = rand(0, 20)"
+r.mapcalc -s "x52 = rand(0, 20)"
+</pre></div>
+<p>
+Create constant raster for intercept:
+
+<div class="code"><pre>
+r.mapcalc  "ones = 1.0"
+</pre></div>
+<p>
+Suppose <em>Y</em> is a linear function of <em>x1</em> and <em>x2</em> variables
+plus a random error.
+(For testing purposes we assume that <em>Y</em> = <em>12 + 5*x1 + 3*x2</em>).
+Create 5 Y rasters:
+<div class="code"><pre>
+r.mapcalc -s "y1 = 12 + 5* x11 + 3*x12 + rand(0, 4)"
+r.mapcalc -s "y2 = 12 + 5* x21 + 3*x22 + rand(0, 4)"
+r.mapcalc -s "y3 = 12 + 5* x31 + 3*x32 + rand(0, 4)"
+r.mapcalc -s "y4 = 12 + 5* x41 + 3*x42 + rand(0, 4)"
+r.mapcalc -s "y5 = 12 + 5* x51 + 3*x52 + rand(0, 4)"
+</pre></div>
+<p>
+So we have five test rasters <em>Y</em> and <em>X</em>. 
+Forget for a moment that we know the function and try
+to find the coeffitinents.
+<p>
+Create <em>samples</em> csv file:
+<div class="code"><pre>
+echo "y,bias,x1,x2
+y1,ones,x11,x12
+y2,ones,x21,x22
+y3,ones,x31,x32
+y4,ones,x41,x42
+y5,ones,x51,x52" > settings.csv
+</pre></div>
+<p>
+Run the command
+<div class="code"><pre>
+r.mregression.series samples=settings.csv result_prefix="coef."
+</pre></div>
+<p>
+Three raster maps will be created: "coef.bias", "coef.x1", "coef.x2".    
+This rasters contains the fitted coefitients.
+
+
 <h2>SEE ALSO</h2>
 
 <em><a href="addons/r.regression.series.html">r.regression.series</a></em>,

Modified: grass-addons/grass7/raster/r.mregression.series/r.mregression.series.py
===================================================================
--- grass-addons/grass7/raster/r.mregression.series/r.mregression.series.py	2015-11-23 07:01:46 UTC (rev 66898)
+++ grass-addons/grass7/raster/r.mregression.series/r.mregression.series.py	2015-11-23 13:50:54 UTC (rev 66899)
@@ -58,7 +58,7 @@
 try:
     import statsmodels.api as sm
 except ImportError:
-    grass.error("Can't import statsmodels. Install scipy package.")
+    grass.error("Can't import statsmodels. Install statmodels package.")
     sys.exit(1)
 
 



More information about the grass-commit mailing list