# Regression regularization penalty center at w0 instead of 0 [duplicate]

How do I regress with regularization penalty term lambda * (w - w0)^2 instead of lambda * w^2? Is there any package to do it?

I produced coef w0 with some old data, now I have some new data, I want to regress again and I want the new coef close to w0.

• The statement "new data" makes me think that you could be interested in bayesian methods, since these methods are explicitly concerned with probability models being updated in the light of new data.
– Sycorax
Sep 5, 2018 at 3:09
• I dont think this is duplicate. The other post is about NN, its accepted answer is just two cost functions, writing down cost function is all the implementation needed. Sep 6, 2018 at 2:19

Arguably the most straightforward way, from the point of view of using existing software that doesn't give you the option of specifying a non-zero point to shrink the coefficients towards, is to subtract $w0\cdot x$ from the target variable.
Assume a simple regression: $y_i = a + w \cdot x_i + e_i$. If we subtract $w0 \cdot x_i$ from both sides and define $y'_i = y_i - w0\cdot x_i$, we have:
$$y'_i = a + (w-w0)\cdot x_i + e_i$$
Defining $w' = w - w0$ gives us $y'_i = a + w'\cdot x_i + e_i$, and, evidently, $w'$ would be shrunk towards $0$ by the usual sorts of regularization, implying that $w$ would be shrunk towards $w0$.