Ojaswita
Ojaswita

Reputation: 93

Including the (0,0) point in a linear regression in R

I have run a simple linear regression in R with two variables and got the following relation:

y = 30000+1.95x

Which is reasonably fair. My only concern is that, practically the (0,0) point should be included in the model.

Is there any math help I can get please ?


Data set

I needed to post the data somehow... and here it is. This will give a better approach to the problem now.

There are more such data sets available. This is data collected for a marketing strategy.

The objective is to obtain a relation between sales and spend so that we can predict the spend amount that we need in order to obtain a certain amount of sales.

All help will be appreciated.

Upvotes: 0

Views: 1609

Answers (2)

Cettt
Cettt

Reputation: 11981

if you want to include the point (0,0) in your regression line this would mean setting the intercept to zero. In R you can achieve this by

mod_nointercept <- lm(y ~ 0 + x)

In this model only beta is fitted. And alpha (i.e. the intercept is set to zero).

Upvotes: 1

James Phillips
James Phillips

Reputation: 4657

This is not an answer, but rather a comment with graphics.

I converted the month data to "elapsed months", starting with 1 as the first month, then 2, then 3 etc. This allowed me to view the data in 3D, and as you can see from the 3D scatterplot below, both Spend and Sales are related to the number of months that have passed. I also scaled the financial data in thousands so I could more easily read the plots.

I fit the data to a simple flat surface equation of the form "z = f(x,y)" as shown below, as this equation was suggested to me by the scatterplot. My fit of this data gave me the equation

Sales (thousands) = a + b * Months + c * Spend(thousands)

with fitted parameters

a = 2.1934871882483066E+02
b = 6.3389747441412403E+01
c = 1.0011902575903093E+00

for the following data:

Month Spend Sales

1 120.499 327.341
2 168.666 548.424
3 334.308 978.437
4 311.963 885.522
5 275.592 696.238
6 405.845 1268.859
7 399.824 1054.429
8 343.622 1193.147
9 619.030 1118.420
10 541.674 985.816
11 701.460 1263.009
12 957.681 1960.920
13 479.050 1240.943
14 552.718 1821.106
15 633.517 1959.944
16 527.424 2351.679
17 1050.231 2419.749
18 583.889 2104.677
19 322.356 1373.471

scatterplot

surface

Upvotes: 2

Related Questions