# How to impose restrictions on a regression using offsets?

An offset is a variable that is included in the regression but without coefficient (i.e. the coefficient is fixed at/assumed to be 1). I want to impose restrictions on my regression and I read that it can be done with offsets (source). However, I do not understand how an offset can result in a restriction. Furthermore, I implemented a basic example in python and the other coefficients do not change (thus if I charge 10% extra on everybody, the total amount also increases with 10% but this should not happen. The other coefficients should adjust accordingly such that the total amount remains similar. The money should just be redistributed among the members).

The goal of my regression is to impose a bonus-malus system (i.e. give some people a discount) on a pricing model for insurance.

Consider the following (GLM) regression:

$$\log(\text{cost}) = \beta_0 + \beta_1X_1+...+\beta_nX_n + \epsilon$$

where the cost is assumed to follow a Gamma distribution. Suppose that one of the variables $$X_i$$ is the number of years without a claim. Furthermore, suppose that I want to give everybody that had zero claims last year a discount of 20%. According to the mentioned source, I need to add $$\log(0.8)$$. To see why this lead to a discount (or surplus?), consider:

$$\text{cost} = e^{\beta_0} \hspace{2mm} e^{X_i} \hspace{2mm}e^{\log(0.8)}$$ $$\hspace{9mm} = 0.8 \hspace{2mm}e^{\beta_0} \hspace{2mm} e^{X_i}$$

However, I am not sure if this is correct. Does this effect all my other coefficient estimates? How do I implement this in python using statsmodels? Because the source mentions SAS has support for this by default, using:

In the SAS code above, we see that the offset is conditionally set (using an if-statement). How could I do this in python?

UPDATE: I just learned this is called "relativities" in actuarial science.

• Yes, of course restricting some coefficient estimates will have an impact on all other parameter estimates. If that is the extent of the statistical content of your question, it looks like your main request is how to implement this in Python, which is better asked elsewhere. Mar 16, 2023 at 9:14
• However, in my results non of the other coefficients change. Mar 16, 2023 at 10:20
• I know how to implement it in python, but I get strange results. I also want to have an understanding of the math. Mar 16, 2023 at 10:21
• Maybe then show us the strange results, as the question by now is overly abstract Dec 20, 2023 at 16:38

After browsing the source document you mentioned, I made the following R script. To keep it simple, I used "wage" as dependent, but translation to log(wage) should be obvious, I hope. Explanatory comments are added. Note that the offset variable has to have different values for specific groups of cases. I used "gender", so there are two groups. Men have a higher wage, so men get an offset of 10 points, whereas for women the offset is 0 points. Further, "education" is the independent variable. I'm not familiar with Python, so I used R.

set.seed(123)

# Generate some data.
gender    <- c(rep(0,10), rep(1,10))
education <- ifelse(gender==0, rnorm(10,0,1), rnorm(10,1,1))
cor(education, gender)

# Generate dependent wage.
wage <- 10 + 10*education + 5*gender + rnorm(20,0,10)

# Suppose we would estimate the influence of education and gender on wage first.
m1 <- lm(wage ~ education + gender)
summary(m1)

# Next, we could eliminate the influence of gender from wage, leading to a new
# variable, wage minus gender, or wage_gender. Men have a 13.657 points
# higher wage than women, as the summary of m1 shows.
# Also see page 369, 2nd paragraph in the source mentioned.
# Resulting regr. coeff. for m2 below are identical to those in m1.
# Std. errors in m2 are different from those in m1, of course.
# The ifelse below removes the influence of gender from wage.
wage_gender <- ifelse(gender==1, wage - 13.675, wage)
m2 <- lm(wage_gender ~ education)
summary(m2)

# Above, we estimated the influence of gender. Instead suppose we know beforehand that men
# have a 10 points higher wage than women do. So, we don't have to estimate this difference.
# Now, we make an offset to specify the difference.
# So, men have an offset of 10 points and women of 0 points.
# The regression equation would then be: wage = b0 + b1*eduction + offset
# In this equation "offset" should have a regr. coeff. of 1, so this regr. coeff.
# must NOT be estimated. To achieve this, we can simply subtract the offset from both
# sides of the equation. This is what the ifelse below does. It makes a new
# variable, wage minus offset, or "wage_offset".
wage_offset <- ifelse(gender==1, wage - 10, wage)
m3 <- lm(wage_offset ~ education)
summary(m3)

# Using wage as dependent gives another regr. coeff. for education and another intercept.
m4 <- lm(wage ~ education)
summary(m4)