Results 1 to 5 of 5

LinEst for polynomial regression in VBA - error...

Threaded View

  1. #1
    Registered User
    Join Date
    05-17-2014
    MS-Off Ver
    Excel 2013
    Posts
    2

    Question LinEst for polynomial regression in VBA - error...

    Hello everyone,

    I am trying to use the LinEst function in VBA to get the best fit coefficients for some data fitted by a polynomial curve. I can get this for a single variable, but not multi-variable.

    My code is:

    Sub IWishThisSubWorked()
    
    
    Dim LinestArray(1 To 250, 1 To 4) As Double
    Dim DependentVariable(1 To 250) As Variant
    
    ' some code inputting the dependent variable data into the DependentVariable array
    
    
    For i = 1 To 250
        LinestArray(i, 1) = i
        LinestArray(i, 2) = i ^ 2
        LinestArray(i, 3) = i ^ 3
        LinestArray(i, 4) = i ^ 4
    Next i
    
    coefficient1 = WorksheetFunction.Index(WorksheetFunction.LinEst(DependentVariable, LinestArray, 0), 1, 1)

    This approach seems to work when I do it via array formulas directly in Excel, but for some reason it is not working in VBA.

    The error message is: "Run-time error '1004': Unable to get the LinEst property of the WorksheetFunction class"

    (p.s. this is not just because 250^4 is a large number: I have tried this with a shorter set of arrays, but the issue does not go away...)


    Thanks in advance for any help or suggestions. I've tried all of Google and am completely stuck.
    Last edited by IDidNotWantToRegiste; 05-17-2014 at 09:02 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. LINEST for specifying polynomial regression function
    By InderpalHothi in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-27-2014, 03:11 PM
  2. [SOLVED] trend/linest regression error
    By MrShorty in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-07-2013, 01:16 PM
  3. Converting a polynomial LINEST formula to VBA
    By AARONWEBSTER in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-12-2012, 12:23 PM
  4. Replies: 5
    Last Post: 06-25-2009, 10:25 AM
  5. [SOLVED] How to clear "linest ( ) function error " in regression analysis?
    By dev in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 08-21-2005, 04:05 PM

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