How to write the functional form of multivariate polynomial cubic spline?

I got some articles/books about the cubic splines. However, I didn't see anyone mentioning the bivariate case of cubic spline much in detail. My question is how to write the cubic spline in a bivariate case with knots?

I am trying to perform the multiple linear regression with two regressors x and y, and 1 predicted variable z = f(x,y).

• You're interested in regression, not interpolation, right? – DeltaIV Aug 13 '17 at 18:18
• @DeltalV Yes. Piecewise polynomial regression using spline basis functions.Basically on an image. x and y are the rows and columns and z is the intensity values. – Jay Patel Aug 13 '17 at 18:27
• Then just use tensor product splines. Here is a fully worked out example. The answer uses ginv, which is not the best choice (qr would be more appropriate), but in practice unless you have a lot of data, or the condition number of X is large (in which case the condition number of t(X) %*% X will be quadratically as large), you shouldn't have problems. – DeltaIV Aug 13 '17 at 19:52
• I was considering csaps for the surface fit. I tried thin plate spline but my rows and columns are of different scale so I couldn't use it in Matlab as they need to be same for thin plate spline. I am interested in using interpolation as well if that is giving a good estimation of the intensity distribution of grayscale image – Jay Patel Aug 13 '17 at 20:04
• If this is an implementation-specific question, then it's not a good fit for CV: it would be better suited for SO. Anyway, did you read this? – DeltaIV Aug 14 '17 at 7:38