[19125] in s-news-athena

home help back first fref pref prev next nref lref last post

[S] query on a more efficient method for writing a nonlinear function

daemon@ATHENA.MIT.EDU (Gene Felber)
Tue Sep 7 08:57:15 1999

From: "Gene Felber" <gfelber@rxttm.com>
To: "S-News" <s-news@wubios.wustl.edu>
Date: Tue, 7 Sep 1999 08:49:58 -0400
Message-Id: <LOBBKJFMEMHLDHOLHNOFGENHCAAA.gfelber@rxttm.com>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit


Dear:

I am using the function below to fit an nls model:

sin.cos.fcn <- function(A,B,C1,C2,C3,C4,D1,D2,D3,D4,time)
{
	A+B*time
	+ (C1 * sin(2*1*pi*time/52)) + (D1 * cos(2*1*pi*time/52))
	+ (C2 * sin(2*2*pi*time/52)) + (D2 * cos(2*2*pi*time/52))
	+ (C3 * sin(2*3*pi*time/52)) + (D3 * cos(2*3*pi*time/52))
	+ (C4 * sin(2*4*pi*time/52)) + (D4 * cos(2*4*pi*time/52))
}

Is there a more efficient method to write this function so that one could
more easily change the summation of k=1:4 to 1:n without having to
explicitly write (and obtain estimates for) each parameter?

Thanks kindly in advance.

Sincerely,

Gene D. Felber

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post