1. Home
  2. THINPLATE procedure

THINPLATE procedure

Calculates the basis functions for thin-plate splines (S.J. Welham & D.B. Baird).

No options

Parameters

Y = variates or factors Y-coordinates of the data points
X = variates or factors X-coordinates of the data points
YKNOTS = variates or factors Y-coordinates of the knots
XKNOTS = variates or factors X-coordinates of the knots
TPSPLINE = variates or matrices Thin-plate spline basis, as either a pointer of variates (default if not already declared) or a matrix

Description

THINPLATE calculates the basis functions for thin-plate splines. The X and Y parameters each specify a variate or a factor with the x- and y-coordinates of the data points, and the XKNOTS and YKNOTS parameters similarly specify the positions of the knots. The basis functions are saved by the TPSPLINE parameter. By default these are stored in a pointer of variates, but you can save a matrix instead by declaring TPSPLINE in advance to be a matrix.

Options: none.

Parameters: Y, X, YKNOTS, XKNOTS, TPSPLINE.

See also

Directive: VCOMPONENTS.

Procedures: SPLINE, LSPLINE, NCSPLINE, PENSPLINE, PSPLINE, RADIALSPLINE, TENSORSPLINE.

Function: SSPLINE.

Commands for: Calculations and manipulation, Regression analysis, REML analysis of linear mixed models.

Example

CAPTION     'THINPLATE example'; STYLE=meta
SCALAR      n; VALUE=50 "no. grid points for data in each direction"
&           np; VALUE=7 "no. basis points for thin plate in each direction"
"Create data on a regular n x n grid"
VARIATE     [VALUES=1...n] x,y
&           [VALUES=#n(#x)] xe
&           [VALUES=(#y)#n] ye
CALCULATE   [SEED=211869] ve = GRNORMAL(n*n; 0; 0.5)
MATRIX      [ROWS=x; COLUMNS=y] e; VALUES=ve
&           [ROWS=x; COLUMNS=1] xm; VALUES=x
&           [ROWS=1; COLUMNS=y] ym; VALUES=y
CALCULATE   z = 2 * SIN(SQRT(((xm - (n + 1) / 2) *+ ROW1(n) /6)**2\ 
              + (COL1(n) *+ (ym - (n + 1) / 2) / 10)**2))\ 
              + COS(SQRT( ( (xm - (n + 1) / 3) *+ ROW1(n) / 10)**2\ 
              + (COL1(n) *+ (ym - (n + 1) / 3) / 5)**2))
&           zp = z + e
VARIATE     [NVALUES=n*n] ze
EQUATE      OLDSTRUCTURE=zp; NEWSTRUCTURE=ze
"Create spline basis knot points in 2 dimensions"
CALCULATE   p = !(1...np) / (np + 1)
&           pf = 0.5 / n
&           pl = 1 - 0.5 / n
&           pe = 100 * !(pf,#p,pl)
&           xp,yp = PERCENTILES(x,y; pe)
&           nx,ny = NVALUES(xp,yp)
VARIATE     [VALUES=#ny(#xp)] xk
&           [VALUES=(#yp)#nx] yk
"Calculate spline basis functions"
POINTER     tp
THINPLATE   Y=ye; X=xe; YKNOTS=yk; XKNOTS=xk; TPSPLINE=tp
"Fit thin-plate model using restricted maximum likelihood"
VCOMPONENTS [FIXED=xe+ye] RANDOM=tp
REML        [PRINT=#,effects] ze
"Calculate fitted surface values"
VKEEP       [FITTED=xfit] TERMS='Constant',xe,ye,tp;\
            EFFECTS=intercept,xslope,yslope,coeff
CALCULATE   tp[] = #coeff*tp[]
&           zf = #intercept + #xslope*(xe - MEAN(xe)) +\
                 #yslope*(ye - MEAN(ye)) + VSUM(tp)
"Plot fitted surface"
MATRIX     [ROWS=x; COLUMNS=y] zfm; VALUES=zf
DSURFACE   [TITLE='Fitted Thin Plate Surface'; WINDOW=3; KEY=0] zfm
Updated on March 5, 2019

Was this article helpful?