# How to generate b-splines that are orthogonal to the corresponding variables in non-linear regression?

I want to fit a non-linear regression model of the type

$$y_i = \alpha_0 + x_i\alpha_1 + s_i^T\beta + e_i,$$

$$i=1,\dots,n$$, $$\alpha_0,\alpha_1\in{\mathbb R}$$, $$\beta\in {\mathbb R}^p$$. I am only using one covariate in order to simplify notation but I have a dozen variables in my application. I want to use a b-spline basis of $$x_i$$, $$s_i$$, in order to account for non-linear effects of $$x_i$$, but due to this formulation, I want $$s_i$$ to be orthogonal to $$x_i$$ as I also want to compare this to the model

$$y_i = \alpha_0 + x_i\alpha_1 + e_i.$$

Q1: How, if at all possible, can I do this in R? This is, how to generate $$s_i$$ such that it is orthogonal to $$x_i?$$

Q2: Is there another spline basis that may simplify this formulation?

• The spline basis is usually constructed in such a way that you don't need to include $x_i$ in the regression at all, making this sort of a moot point. You can compare the two models w/o having $s_i$ be orthogonal to $x_i$ using any of a number of techniques for comparing nested models - AIC, BIC, ANOVA, ... – jbowman Aug 13 at 14:44
• @jbowman I see your point, and I agree with it. However, I am interested in conducting a number of experiments where this formulation would be helpful. – Totoro Aug 13 at 15:45