+ Reply to Thread
Results 1 to 9 of 9

Value of LINEST

Hybrid View

  1. #1
    Registered User
    Join Date
    03-03-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    11

    Value of LINEST

    Hi All,
    I got problem when using the LINEST function (linear regression). How do one add the value of the slope to a cell?

    I use the code below but I get the #VALUE! message in the cell. The cell's format is General.

       Dim v As Variant
       Dim x As Variant
       Dim Y As Variant
       x = Range("B2:B3")
       Y = Range("D2:D3")
       v = Application.LinEst(Y, x, True, True)
       Worksheets("Sheet1").Range("H1").Value = v
    What is wrong here?

    Cheers!
    Last edited by aner1755; 03-09-2009 at 04:30 AM.

  2. #2
    Registered User
    Join Date
    03-03-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value of LINEST

    Oh yeah, one more thing.

    How can I expand the formula to a say 4:th degree polynomial regression and use the result to calculate new values for some new x-values?

    Thanks!

  3. #3
    Registered User
    Join Date
    03-03-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value of LINEST

    Ok I found the answer for a 2nd degree and I guess it will solve all my problems;

       Dim CurveFitParams As Variant
       Dim CurveFitA As Single 'Coefficient A of polynomial curve fit equation (Y = AX˛ + BX + C)
       Dim CurveFitB As Single 'Coefficient B of polynomial curve fit equation (Y = AX˛ + BX + C)
       Dim CurveFitC As Single 'Coefficient C of polynomial curve fit equation (Y = AX˛ + BX + C)
       Dim MinRow As Long
       Dim MaxRow As Long
    
       CurveFitParams = Application.LinEst(Range("B2:B5"), Application.Power(Range("D2:D5"), Array(1, 2)), True, 0)
       CurveFitA = Application.WorksheetFunction.Index(CurveFitParams, 1)
       CurveFitB = Application.WorksheetFunction.Index(CurveFitParams, 2)
       CurveFitC = Application.WorksheetFunction.Index(CurveFitParams, 3)
    
       Worksheets("Sheet1").Range("H3").Value = CurveFitA
       Worksheets("Sheet1").Range("H4").Value = CurveFitB
       Worksheets("Sheet1").Range("H5").Value = CurveFitC
    Last edited by Andy Pope; 03-06-2009 at 05:26 AM.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Value of LINEST

    Please remember to use code tags when posting any code.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    03-03-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value of LINEST

    Oh, sorry!

    But what's that? :-)

    Cheers!

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Value of LINEST

    Here is the offical message with links on explanation.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  7. #7
    Registered User
    Join Date
    03-03-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value of LINEST

    Thank you very!

    I'll read this through and hopefully the next post will be better composed.

    Have a blessed day!

  8. #8
    Registered User
    Join Date
    03-03-2009
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value of LINEST

    Oh, that was neat! I'll use that.

    Thanks very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1