# why regress a y variable on a vector of just ones

I am trying to understand some code somebody has written.

I have a y vector which is a factor say book to price for 500 companies.

Then I also have a x vector of the same shape which is just ones.

A OLS regression is performed. The beta of the x variable is saved and called coeff.

The residual is then calculate as

   residual = y - (x * coeff)


The residuals are then sorted and then ranked be being passed into a normal inverse function which gives us our final factor.

I do not follow what is going on here? Why is a factor being regressed against a vector of ones?

## 1 Answer

(OLS) regressing a response variable against a vector of ones is equivalent to fitting a constant model consisting of the mean of the response. The residuals are then $r_i=Y_i-\bar{Y}$.

If the response has already been centred then this is a no-op.

• thanks for your reply. Can you tell me why you would want to do this? – user8170 Aug 31 '16 at 8:27
• Generally such a model is referred to as a "null model", against which other models are compared. It is also necessary to fit it in order to calculate some statistics about goodness of fit of other, more complicated models. – JDL Aug 31 '16 at 8:29