1. Home
2. ORTHPOLYNOMIAL procedure

# ORTHPOLYNOMIAL procedure

Calculates orthogonal polynomials (P.W. Lane).

### Options

`MAXDEGREE` = scalar Maximum degree of polynomial to be calculated; default is the number of identifiers in the pointer specified by the `POLYNOMIAL` parameter Weights to be used in orthogonalization; default `*` gives an equal weight to each unit

### Parameters

`X` = variates Values from which to calculate the polynomials; no default – this parameter must be set Identifiers of variates to store results; no default – this parameter must be set

### Description

Polynomials of low degree can be fitted by ordinary linear regression, estimating effects of terms `X`, `X**2`, `X**3`, and so on for a variate `X`. However, it is sometimes preferable to arrange that successive polynomial terms are orthogonal to each other; certainly, there are likely to be numerical problems with polynomials of degree five or more, if they are not orthogonal. `ORTHPOLYNOMIAL` calculates orthogonal polynomials up to a specified maximum degree from a given variate. The orthogonalization can be weighted by specifying a variate of weights.

Options: `MAXDEGREE`, `WEIGHTS`. Parameters: `X`, `POLYNOMIAL`.

### Method

Successive formation of polynomials, starting with p1 = x – mean(x), ensuring orthogonality of pi with p1pi1; that is:

∑ ( weight × pi × pj ) = 0

### Action with `RESTRICT`

A variate in the `X` parameter can be restricted: the restriction is transferred to the calculated polynomials, and to the weight variate if specified.

Procedure: `VORTHPOLYNOMIAL`.

Functions: `POL`, `POLND`, `REG`.

Commands for: Calculations and manipulation.

### Example

```CAPTION  'ORTHPOLYNOMIAL example',!t(\
'The example models changes of population with time by fitting a',\
'quartic regression model; future populations are predicted by',\
'including future dates with weight zero. Thus population figures',\
'(variate pop) are available for dates 1811, 1821 ... 1931; for',\
'dates 1941, 1951 ... 1991 population figures are given as missing',\
'values * and weights w as 0.'); STYLE=meta,plain
VARIATE  [VALUES=1811, 1821 ... 1991] year
&        [VALUES=13(1), 6(0)] w
&        [VALUES=10.16, 12.00, 13.90, 15.91, 17.93, 20.07, 22.71,\
25.97, 29.00, 32.53, 36.07, 37.89, 39.95, 6(*)] pop
PRINT    'Get (weighted) orthogonal polynomials up to degree 4.'
ORTHPOLYNOMIAL [MAX=4; WEIGHT=w] year; POLY=p2
PRINT    year,w,pop,p2[]; FIELD=5,2,6,4(12); DEC=0,0,2,4(0)
PRINT    'Fit quartic model: correlations should be zero.'
MODEL    [WEIGHT=w] pop
FIT      [PRINT=model,summary,estimates,correlation,fitted] p2[]
PRINT    'Display dangers of extrapolation!'
RKEEP    FITTED=fitted
GRAPH    [NROWS=21; NCOLUMNS=61] fitted,pop; year; METHOD=curve,point
PRINT    'Compare with non-orthogonal polynomials.'
CALC     year2,year3,year4 = year,year2,year3 * year
FIT      year,year2,year3,year4
```
Updated on March 6, 2019