# Backfitting

## Backfitting :

Backfitting is a technique used in regression analysis to estimate the parameters of a model by iteratively fitting each variable in the model while holding the remaining variables fixed. This technique is often used when the number of variables in the model is large, or when there is collinearity among the variables, which can make it difficult to estimate the parameters of the model using traditional methods.
To understand how backfitting works, consider the following example. Suppose we want to build a regression model to predict the price of a house based on its size, number of bedrooms, and number of bathrooms. Using traditional regression techniques, we might estimate the parameters of the model as follows:
Price = a + b * Size + c * Bedrooms + d * Bathrooms
where a, b, c, and d are the estimated parameters of the model. However, if there is collinearity among the variables (i.e. the variables are highly correlated with each other), it can be difficult to accurately estimate the parameters of the model using this approach. In this case, backfitting can be used to improve the estimates of the model parameters.
To use backfitting, we first fit a simple regression model using only one of the variables (e.g. size) to predict the outcome variable (i.e. price). This gives us an initial estimate of the parameter for that variable (i.e. b). We then hold that parameter fixed and fit a regression model using the remaining variables (i.e. bedrooms and bathrooms) to predict the outcome variable. This gives us updated estimates of the parameters for the remaining variables (i.e. c and d).
Next, we hold the updated estimates of the parameters for the remaining variables fixed, and fit a regression model using the remaining variable (i.e. size) to predict the outcome variable. This gives us an updated estimate of the parameter for that variable (i.e. b), which may be different from the initial estimate.
We then repeat this process, alternating between fitting a model using one variable and then using the remaining variables, until the estimates of the parameters for all of the variables have converged (i.e. they do not change significantly from one iteration to the next). This process is known as backfitting, and it can help improve the accuracy of the estimated parameters of the model.
Here is an example of how backfitting might work in practice. Suppose we have the following data on house prices, sizes, bedrooms, and bathrooms:
Price Size  Bedrooms Bathrooms
300000 1000 3 2
325000 1500 4 2.5
350000 2000 3 3
400000 2500 5 3.5
To use backfitting, we first fit a simple linear regression model using only the size variable to predict the price of a house. This gives us the following equation:
Price = a + b * Size
where a and b are the estimated parameters of the model. Using the data above, we can estimate the values of a and b as follows:
Price = a + b * Size
300000 = a + b * 1000
325000 = a + b * 1500
350000 = a + b * 2000
400000 = a + b * 2500
Solving for a and b, we get:
a = 17500
b = 75
Thus, the initial estimates of the parameters of the model are:
Price = 17500 + 75 * Size
Next, we hold the estimated value of b fixed at 75, and fit a regression model using the remaining variables (i.e. bedrooms and bathrooms) to predict the price of a house. This gives us the following equation:
Price = c + d * Bedrooms + e * Bathrooms
where c, d, and e are the updated estimates of the parameters of the model. Using the data above, we can estimate the values of c, d, and e as follows:
Price = c + d * Bedrooms + e * Bathrooms
300000 = c + d * 3 + e * 2
325000 = c + d * 4 + e * 2.5
350000 = c + d * 3 + e * 3
400000 = c + d * 5 + e * 3.5
Solving for c, d, and e, we get:
c = -10000
d = 12500
e = 2500
Thus, the updated estimates of the parameters of the model are:
Price = -10000 + 12500 * Bedrooms + 2500 * Bathrooms
Now, we hold the updated estimates of the parameters c and d fixed, and fit a regression model using the remaining variable (i.e. size) to predict the price of a house. This gives us the following equation:
Price = f + g * Size
where f and g are the updated estimates of the parameters of the model. Using the data above, we can estimate the values of f and g as follows:
Price = f + g * Size
300000 = f + g * 1000
325000 = f + g * 1500
350000 = f + g * 2000
400000 = f + g * 2500
Solving for f and g, we get:
f = 23000
g = 75
Thus, the updated estimates of the parameters of the model are:
Price = 23000 + 75 * Size
We can repeat this process, alternating between fitting a model using one variable and then using the remaining variables, until the estimates of the parameters for all of the variables have converged.
In this way, backfitting can be used to improve the accuracy of the estimated parameters of a regression model, especially when there is collinearity among the variables in the model. It is a useful technique for dealing with large or complex models, and can help improve the accuracy of the predictions made by the model.