# [GRASS-user] Calculate p value for regression slope in r.series

Markus Metz markus.metz.giswork at gmail.com
Thu Nov 8 11:16:55 PST 2012

```On Thu, Nov 8, 2012 at 6:22 PM, Glynn Clements <glynn at gclements.plus.com> wrote:
>
> Paulo van Breugel wrote:
>
>> Just wondering, if it is implemented in r.regression.series, would it be
>> very difficult to port to r.series? Or do the two things function different
>> internally?
>
> It could probably be added to r.series quite quickly if someone was
> willing to provide definitions for "t-value" and "p-value".

The t-value of a simple linear regression can be calculate with

t = sqrt(Rsq) * sqrt((n - 2) / (1 - Rsq));

Rsq = R squared or coefficient of determination (r.series method=detcoeff)
n = sample size

This formula is used by r.regression.multi and in some modules in
GRASS 5 that also do multiple regressions.

The p-value would then be the cumulative probability of observing t
according to Student's t-distribution for given n. I think somewhere
in GRASS is a function to calculate p for n = inf (normal
distribution). Maybe somewhere hidden there is also a function for
small n?

Markus M
```

More information about the grass-user mailing list