I am trying to regress stock returns on a series of factor scores to get factor coefficients. I want to weight the regression by the square root of market cap which I'm doing by applying a weighting function to my x and y variables before running the regression.

I'm a bit confused, however, but whether I should be using square root or fourth root as in the end I'm trying to minimize the square of the errors. Does this mean I need to use fourth root or have I over-complicated it?



1 Answer 1


Let $\text{SSR}$ denote the sum of squared residuals and $\text{WSSR}$ the weighted $\text{SSR}$. Standard OLS-regression approach minimizes the $\text{SSR}$ with $y$ as the dependent and $y$ as the independent variable:

$$\text{SSR}(\beta) = \sum^n_{i=1}{(y_i - \hat{x}_i \cdot \beta)^2}$$

The WLS-approach adds a weight $w$ for each of the observations $x_i$. OLS-regression is the special case of WLS when applying $w=1$ for all $x_i$. WLS minimizes the weighted $\text{SSR}$:

$$\text{SSR}(\beta, w) = \sum^n_{i=1}{w \cdot (y_i - \hat{x}_i \cdot \beta)^2}$$

If your weights $w_i$ are the squared root of firms $i$ market cap, this results in:

$$\text{SSR}(\beta, w) = \sum^n_{i=1}{\sqrt{MV_i} \cdot (y_i - \hat{x}_i \cdot \beta)^2}$$

where $MV_i$ is the market capitalization of firm $i$. As a result, the weight $w$ still remains the "squared" root and not the "fourth".

In Python, WLS with weights from one to seven is applied as:

import statsmodels.api as sm
Y = [1,3,4,5,2,3,4]
X = range(1,8)
X = sm.add_constant(X)
wls_model = sm.WLS(Y,X, weights=list(range(1,8)))
results = wls_model.fit()
array([ 2.91666667,  0.0952381 ])

Whereas in R, you just run:

y <- c(1,3,4,5,2,3,4)
x <- 1:7
summary(lm(y ~ x , weights = 1:7))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.