I am working with the mgcv package in r and I am fitting tensor product P-splines.

test1<-function(x,z,sx=0.3,sz=0.4){ x<-x*20

f <- test1(x,z)
y <- f + rnorm(n)*0.2


I think that is the code for how to fit it with two variables and no intercepts.

My question is how do I find the P-spline smoothing parameters. I am under the assumption there should be two, one for each variable, and possibly one for the interaction between the two P-splines, but this should be the product of the first two. I could be wrong about this.

Anyway reading the documentation this should give me my smoothing parameters:


 # t2(x,z)rr       t2(x,z)nr        t2(x,z)rn

# 4.280221e-04     3.884871e+06     1.386065e+06 

However, these are not products of eachother and I don't know how they relate to the x and z fitted p-spline.

The reason for me thinking this way is due to equation five in this paper.

Any help would be much appreciated.


I have found these definitions for rr, nr, and rn

## label "rr" indicates interaction (range space times range space)

## label "nr" (null space for x0 times range space for x1) is main effect for x1.

## label "rn" is main effect for x0

x0 is x in our case and x1 is z.

Then according to my understanding nr*rn=rr should be the case, I wonder if my interpretation of equation 5 in the paper is wrong?

  • $\begingroup$ Looking at "Straightforward intermediate rank tensor product smoothing in mixed models" page 348 bottom of left col, I read "if the smoothing parameter for the interaction penalty → ∞, the smooth tends to the additive model" which seems to imply that the smoothing parameter of the interaction term is not a product of the other two (otherwise they would have to go to infinity together). However, I am not sure this is referring to the t2 basis. $\endgroup$ Jun 30, 2017 at 12:51
  • $\begingroup$ @MatteoFasiolo Thanks for the references. They should be helpful. I am including a link to the paper here. $\endgroup$
    – mprice
    Jul 5, 2017 at 13:29

1 Answer 1


Using the links provided by @MatteoFasiolo, I found that the problem was that I should not be using t2 in the gam function, which divideds the tensor product smooth model matrix into non-overlapping subsets. Instead I should be using the function te, which in the set up that David Ruppert talks about in his paper. Just answering this question for completeness in case someone has a similar question in the future.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.