Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default polynomial regression

Hello,
I need to do a polynomial regression, 5th order.
I think I am using the right formula: application.linest(x,y^{1,2,3,4,5})
My problem is that {} is not accepted! Invalid character.
I am using excel 2000.

What can I do to fix this problem?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default polynomial regression

VBA doesn't accept { } character, so I can not write this formula!

If x & y are range names for your data, this is one way.
The highest order polynomial coefficient is index 1.

Sub Demo()
Dim M
M = [Linest(y,x^{1,2,3,4,5})]
End Sub

= = =
HTH :)
Dana DeLouis



Lucile wrote:
I already tried that.

VBA doesn't accept { } character, so I can not write this formula!

But thanks for the help!

"Gary''s Student" wrote:

Follow:

http://spreadsheetpage.com/index.php...line_formulas/

Consider using VBA to place the formulas in worksheet cells or use
EVALUATE() to evaluate then directly.
--
Gary''s Student - gsnu200825


"Lucile" wrote:

Hello,
I need to do a polynomial regression, 5th order.
I think I am using the right formula: application.linest(x,y^{1,2,3,4,5})
My problem is that {} is not accepted! Invalid character.
I am using excel 2000.

What can I do to fix this problem?
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default polynomial regression

Thanks everybody fro your help... But it is not working!

First I know that a 5th order polynomial regression is too much, but it is
what I have to do for now. And with a 3rd order I will have the same
problem...

I tried evaluate... But what I understand is I have to define my range and
not only put a range name...

I tried:

lastrow = Cells(Rows.Count, 1).End(xlUp).Row

x = Range(Cells(2, 1), Cells(lastrow, 1))
y = Range(Cells(2, 7), Cells(lastrow, 7))

M = [linest(y,x^{1,2,3,4,5})]

ActiveCell = M

--- It gives me #NAME?

And:

lastrow = Cells(Rows.Count, 1).End(xlUp).Row

x = Range(Cells(2, 1), Cells(lastrow, 1))
y = Range(Cells(2, 7), Cells(lastrow, 7))

a=application.index(application.linest(y,x^{1,2,3, 4,5}),1)

--- It gives invalid character for { }

I really need to find a way to do that!
Thanks!

"Mike Middleton" wrote:

Lucile -

(1) I suggest that you think seriously about whether you have data that
should be analyzed using a 5th order polynomial. Use google to search for
"regression overfit" (without the quote marks).

(2) The correct order of the arguments for LINEST is known_y first and
known_x second. It's the known_x data that are raised to the various powers.

(3) Show the VBA code you are using. One approach is to use FormulaArray and
build the arguments as concatenated text strings, in which case the curly
brackets are part of a text string enclosed in double-quote marks.

- Mike Middleton
http://www.MikeMiddleton.com
Excel Add-ins and Books for Data Analysis and Decision Analysis



"Lucile" wrote in message
...
Hello,
I need to do a polynomial regression, 5th order.
I think I am using the right formula: application.linest(x,y^{1,2,3,4,5})
My problem is that {} is not accepted! Invalid character.
I am using excel 2000.

What can I do to fix this problem?
Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default polynomial regression

Ok, I solve my problem!

Application.LinEst(y, Application.Power(x, Array(1, 2, 3, 4, 5)), True, True)

Thaks all


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default polynomial regression

VBA doesn't accept { } character, so I can not write this formula!

Hi. Glad you got it working. ;)
Just to add to your library...this is what I meant by a named Range...

Sub Demo()
Dim NRows As Long
Dim M

NRows = Cells(Rows.Count, 1).End(xlUp).Row - 2 + 1

With ActiveWorkbook.Names
.Add "x", Cells(2, 1).Resize(NRows)
.Add "y", Cells(2, 7).Resize(NRows)
End With

M = [Linest(y,x^{1,2,3,4,5})]

'Horizontal
[I2].Resize(1, 6) = M
'or Verticle
[I4].Resize(6) = WorksheetFunction.Transpose(M)
End Sub

= = =
HTH
Dana DeLouis


Lucile wrote:
Ok, I solve my problem!

Application.LinEst(y, Application.Power(x, Array(1, 2, 3, 4, 5)), True, True)

Thaks all


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
polynomial regression Gary''s Student Excel Programming 1 January 9th 09 04:44 PM
Polynomial Regression with Dates OBR Excel Discussion (Misc queries) 3 May 6th 08 04:54 AM
Polynomial Regression with Dates OBR New Users to Excel 2 April 15th 08 09:38 PM
how to get coefficients for Polynomial regression as for rgp() AZ Excel Worksheet Functions 1 January 26th 06 12:27 PM
example of a polynomial regression analysis Houston banker[_2_] Excel Programming 0 July 28th 05 05:31 PM


All times are GMT +1. The time now is 07:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"