[GRASS-user] r.regression.line... differences with regression function LINEST in openoffice.org-calc (?)

Markus Neteler OSGeo neteler at osgeo.org
Sun Jan 27 16:57:02 EST 2008


hi Nikos,

I have replicated (partially) your experiment:

GRASS 6.3.svn (pat): > cat mapA.asc
north: 2
south: 0
east: 3
west: 0
rows: 2
cols: 3
326 641 1336
2020 3197 3484

GRASS 6.3.svn (pat): > cat mapB.asc
north: 2
south: 0
east: 3
west: 0
rows: 2
cols: 3
432 850 931
1956 2582 2622

r.in.ascii mapA.asc out=mapA
r.in.ascii mapB.asc out=mapB
g.region w=0 e=3 s=0 n=2 res=1 -p

r.regression.line map2=mapA  map1=mapB -g
 100%
a=-276.162
b=1.35079
R=0.979519
N=6
F=-0.827183
medX=1562.17
sdX=866.145
medY=1834
sdY=1194.44

# note the new -s flag for slow but accurate computation in
# case of FP maps

To compare, I run the same in R-stats:
> library(spgrass6)
> maps <- readRAST6(c("mapA","mapB"), cat=c(FALSE,FALSE))
> names(maps) <- c("mapA","mapB")
> mapA <- as.vector(maps$mapA)
> mapB <- as.vector(maps$mapB)
> lm(mapA ~ mapB)
Call:
lm(formula = mapA ~ mapB)

Coefficients:
(Intercept)         mapB
   -276.162        1.351

> summary(lm(mapA ~ mapB))

Call:
lm(formula = mapA ~ mapB)

Residuals:
      1       2       3       4       5       6
  18.62 -231.01  354.57 -345.99  -14.58  218.39

Coefficients:
             Estimate Std. Error t value Pr(>|t|)
(Intercept) -276.1615   247.9893  -1.114 0.327852
mapB           1.3508     0.1388   9.729 0.000625 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 294.6 on 4 degrees of freedom
Multiple R-Squared: 0.9595,     Adjusted R-squared: 0.9493
F-statistic: 94.66 on 1 and 4 DF,  p-value: 0.0006249

It would be good to have a bit more statistics in r.regression.line.

Best,
Markus



Nikos Alexandris wrote:
> 
> I have submitted some comments upon the documentation of
> the "r.regression.line" script in
> http://wald.intevation.org/tracker/?func=detail&aid=552&group_id=21&atid=207
> 
> Now I have 2 questions.
> 
> Apologies if I miss some obvious things but I am confused!
> 
> Here it goes:
> 
> 1. I don't understand why (in lines 84 and 85 in the
> r.regression.line script) "sumsqX=sumsqX/tot" and
> "sumsqY=sumsqY/tot" ?
> 
> 2. I can't understand the differences in the following... :
> I created two raster maps with the same MASK, each
> containing only 6 pixels with the following values:
> 
> mapA: 326 641 1336 2020 3197 3484
> mapB: 432 850  931 1956 2582 2622
> 
> For mapA "r.univar" gives:
> n: 6
> minimum: 326
> maximum: 3484
> range: 3158
> mean: 1834
> mean of absolute values: 1834
> standard deviation: 1194.44
> variance: 1.4267e+06
> variation coefficient: 65.1278 %
> sum: 11004)
> 
> For mapB... :
> n: 6
> minimum: 432
> maximum: 2622
> range: 2190
> mean: 1562.17
> mean of absolute values: 1562.17
> standard deviation: 866.145
> variance: 750207
> variation coefficient: 55.4451 %
> sum: 9373)
> 
> In openoffice calc (some of) the respective results are:
> 
> For mapA:
> MIN: 326
> MAX: 3484
> AVERAGE: 1834
> STDEV: 1308,45
> VAR: 1,71E+06
> SUM: 11004
> 
> For mapB:
> MIN: 432
> MAX: 2622
> AVERAGE: 156217
> STDEV: 948,81
> VAR: 9,00E+05
> SUM: 9373
> 
> 
> Based on r.regression.line I get
> 
> for map1=mapA and map2=mapB:
> 
> a  b  R  N  F medX  sdX  medY  sdY
> 0.000458151 0.809242 0.99157 1021726 -0.98321 0.01077
> 5.3038 0.00917369 4.32854
> 
> and
> 
> for map1=mapB and map2=mapB:
> a  b  R  N  F medX  sdX  medY  sdY
> -0.000375823 1.21498 0.99157 1021726 -0.98321 0.00917369
> 4.32854 0.01077 5.3038
> 
> "R" is Pearson's correlation coefficient (as correctly
> defined in the script "r.regression.line" in line 83 but
> wrongly expressed as "sumXY - sumX*sumY/tot" in the
> print-out in line 101).
> 
> In openoffice-calc I get for these:
> MapA    MapB
> 326	432	1,350792		Slope m	
> 641	850	0,138835		standard error of the slope	
> 1336	931	0,959458		RSQ (Square of "r")
> 2020	1956	94,662802	4,000000	F value from the variance
> analysis    std error of regression for Y
> 3197	2582	8213134,001379		sum of squared deviation of
> estimated Y values from their linear mean	
> 3484	2622				
> 
> or
> 
> MapB    MapB
> 432	326	0,710293		Slope m	
> 850	641	0,073004		standard error of the slope	
> 931	1336	0,959458		RSQ	
> 1956	2020	94,662802	4,000000	F value from the variance
> analysis    std error of regression for Y
> 2582	3197	4318750,949062		sum of squared deviation of
> estimated Y values from their linear mean	
> 2622	3484
> 
> 
> (How is really r.regression.line functioning? Trying to
> interpret the script is not that easy for me since I lack
> of some basics in scripting)
> 
> 
> Thank you,
> 
> Nikos.
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-with-v.external-tp14154685p15124758.html
Sent from the Grass - Users mailing list archive at Nabble.com.



More information about the grass-user mailing list