Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Is there a formula for simple linear regression

Posted on 2011-09-09
9
Medium Priority
?
375 Views
Last Modified: 2012-05-12
I have two columns data like below
A        B
1.2     0.518
4.6     0.776
5.6     0.805

3.8       ?(should be between 0.518 and 0.776, any formula I can use?)

Now I want to calculate data B when A = 3.8 and suppose it is linear relation
0
Comment
Question by:jjxia2001
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 2000 total points
ID: 36512900
If 3.8 is in A4 then I think this works

=B1+(A4-A1)/(A2-A1)*(B2-B1)

Btw this is interpolation, not regression.
0
 

Author Comment

by:jjxia2001
ID: 36512943
I used the similar formula, but I want to know if there is a function built inside Excel that I can use.
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 36512962
Nothing built in.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 50

Expert Comment

by:barry houdini
ID: 36513134
of course that formula assumes that you already know that 3.8 falls between A1 and A2. If that you need the formula to work unaltered for other values, e.g. if A4 = 4.8 then you can use this formula

=FORECAST(A4,OFFSET(B1:B3,MATCH(A4,A1:A3)-1,0,2,1),OFFSET(A1:A3,MATCH(A4,A1:A3)-1,0,2,1))

A4 must be >=A1 and < A3

regards, barry
0
 
LVL 81

Expert Comment

by:byundt
ID: 36513139
Is there a function built into Excel? Of course there is--the TREND function. You use like this:
=TREND(B2:B4,A2:A4,D2)
=TREND(KnownX, KnownY, NewX)         returns Predicted Y

TREND does a linear regression to make its prediction, and can handle more than one X variable if necessary.
TrendFunctionQ27300562.xlsx
0
 

Author Comment

by:jjxia2001
ID: 36513178
This is great! This is what I'm looking for!  
0
 
LVL 81

Expert Comment

by:byundt
ID: 36513204
I misspoke. The format for TREND is:
=TREND(KnownY, KnownX, NewX)         returns Predicted Y

The sample workbook and suggested formula with addresses were both correct, however.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 36513222
Hi Brad,

Surely TREND doesn't give your linear interpolation (unless the known Xs and known Ys are only 2 value ranges)? If you use 4.6 in D2, i.e. one of the A2:A4 values then wouldn't you expect the result to be the corresponding B2:B4 value, i.e. 0.776 - with TREND you get 0.754

For the original sample you can also use LOOKUP for linear interpolation, i.e. this will do the same as the FORECAST function I posted

=LOOKUP(A4,A1:A2,B1:B2+(B2:B3-B1:B2)*(A4-A1:A2)/(A2:A3-A1:A2))

regards, barry
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 36513410
See attached file which demonstrates the different results obtained. There are random X and Y values in A2:B9 and (mostly) random "lookup values" in D2:D6. Press F9 key to re-generate random numbers

regards, barry
interpolation.xlsx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question