# How to calculate the weight of the stocks using the linear regression?

I do a simple example with the follow three series(stocks prices):

a = 1, 1.2, 1.8, 1.3, 0.9, 2
b = 56, 58, 63, 61.5, 57.6, 58
c = 105.6, 110, 106.9, 103, 101.2, 107

ok, so let assume those series are the prices of the three stocks, named A, B and C.

Now, I do the linear regression doing:

mod = lm(a ~ b + c + 0)

the result of the linear model is:

Call:
lm(formula = a ~ b + c + 0)

Coefficients:
b          c
0.030570  -0.004095

> mod\$residuals
1          2          3          4          5          6
-0.2795238 -0.1226474  0.3118110 -0.1583030 -0.4464512  0.6650691

Now we know the coefficients of b and c and here I have a doubt regarding, how can I understand reading these coefficients the weight of the stocks I need to buy.

With the weight I mean, example:

A: 10 stocks
B: 2 stocks
C: 16 stocks

I would like to create this spread and calculate the correct number of stocks.

IMPORTANT: This is only an example, I know that I need more tests to check the stability etc etc but with this example I only would like to understand:

How can I calculate the number of the stocks reading the linear regression coefficients?

Thank you!

• Seven of your 11 questions on here have been closed. Given the sheer volume of warnings you've received, you should know by now what's considered appropriate level of material. Commented May 25, 2012 at 14:15