# regcoef

Calculates the linear regression coefficient (trend, slope,...) between two series. Missing data are allowed.

## Synopsis

```    function regcoef(
x     : float,
y     : float,
tval  : float,
nptxy : integer
)
```

## Arguments

x
Input vector array of any dimensionality (last dimension is npts). Missing values should be indicated by x@_FillValue. If x@_FillValue is not set, then the NCL default (-999) will be assumed.
y
Input vector array of any dimensionality. The right-most dimensions of y must the same as the dimensions of x. Missing values should be indicated by y@_FillValue. If y@_FillValue is not set, then the NCL default (-999) will be assumed.
tval
t-statistic (assuming null hypothesis) array (output) of the same dimensionality as y, minus the last dimension, npts. Space for this must be explicity allocated by the user (see example below).
nptxy
number of points used (output), same dimensionality as tval. Space for this must be explicity allocated by the user (see example below).

## Description

regcoef computes the regression coefficient (trend, slope,...) and returns it as a float array, for which the space is automatically allocated by NCL.

## Example

In the example below, the regression coefficient for the case with no missing data is 0.97, the number of points used (nptxy) was 18 which yields 16 degrees of freedom (=nptxy-2). A test of the null hypothesis (i.e., that the regression coefficient is zero) yields a t-statistic of 38.7, which is distributed as t(16). Obviously, the null hypothesis would be rejected.

```begin

x = (/ 1190.,1455.,1550.,1730.,1745.,1770. \
,  1900.,1920.,1960.,2295.,2335.,2490. \
,  2720.,2710.,2530.,2900.,2760.,3010. /)

y = (/ 1115.,1425.,1515.,1795.,1715.,1710. \
,  1830.,1920.,1970.,2300.,2280.,2520. \
,  2630.,2740.,2390.,2800.,2630.,2970. /)

x@_FillValue = -999.
y@_FillValue = -999.

tval  = 0.
nptxy = 0
rc = regcoef(x,y,tval,nptxy)

print ("NO MSG DATA: rc="+rc+"  tval="+tval+"  nptxy="+nptxy)

x(2) = x@_FillValue
y(8) = y@_FillValue

rc = regcoef(x,y,tval,nptxy)
print ("MSG DATA: rc="+rc+"  tval="+tval+"  nptxy="+nptxy)

end
```

### Reference Manual Control Panel

\$Revision: 1.7 \$ \$Date: 1999/03/22 20:49:10 \$