[19174] in s-news-athena

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

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

daemon@ATHENA.MIT.EDU (Gene Felber)
Thu Sep 9 13:37:37 1999

From: "Gene Felber" <gfelber@rxttm.com>
To: "Bill Venables" <venables@acland.qld.cmis.csiro.au>
Cc: <s-news@wubios.wustl.edu>
Date: Thu, 9 Sep 1999 13:28:02 -0400
Message-Id: <LOBBKJFMEMHLDHOLHNOFMEOHCAAA.gfelber@rxttm.com>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
In-Reply-To: <199909080000.KAA25075@snowy.nsw.cmis.CSIRO.AU>


I apologize as I inadvertently left out the nonlinear components in the
example.  Assuming intrinsically nonlinear parameter(s), can a function be
written for, in this case, the fourier component so that nls can estimate
these parameters as well without having to explicitly write each?

Or should I opt for the "fascinating" story?

Gene D. Felber

> -----Original Message-----
> From: owner-s-news@wubios.wustl.edu
> [mailto:owner-s-news@wubios.wustl.edu]On Behalf Of Bill Venables
> Sent: Tuesday, September 07, 1999 7:59 PM
> To: Gene Felber
> Cc: s-news@wubios.wustl.edu
> Subject: Re: [S] query on a more efficient method for writing a
> nonlinear function
>
>
>
> >
> > 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?
>
> Eh?  This isn't a non-linear model at all, it's only a linear
> model, as you
> should be delighted to discover.  The way I would handle such a model with
> variable numbers of terms in the approximating fourier series would be as
> follows:
>
> sin.cos.fcn <- function(k, time) {
> 	X <- matrix(0, length(time), 2*k)
> 	for(i in 1:k) {
> 		X[,i] <- sin(i*2*pi*time/52)
> 		X[,k+i] <- cos(i*2*pi*time/52)
> 	}
> 	X
> }
>
> m0 <- lm(y ~ time                       , data = mycat)
> m1 <- lm(y ~ time + sin.cos.fcn(1, time), data = mycat)
> m2 <- lm(y ~ time + sin.cos.fcn(2, time), data = mycat)
> &c
>
> anova(m0, m1, m2, .....)
>
> If you do have a genuinely nonlinear model there are very useful
> ways to use
> vector (as opposed to scalar) parameters that should be better
> known than they
> are, but that's another fascinating story...
>
> Bill Venables.
> -----------------------------------------------------------------
> Bill Venables, Statistician, CMIS Environmetrics Project.
>
> Physical address:                            Postal address:
> CSIRO Marine Laboratories,                   PO Box 120,
> 233 Middle St, Cleveland, Queensland         Cleveland, Qld, 4163
> AUSTRALIA                                    AUSTRALIA
>
> Telephone: +61 7 3826 7251     Email: Bill.Venables@cmis.csiro.au
>       Fax: +61 7 3826 7304
>
>
> -----------------------------------------------------------------------
> 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
>

-----------------------------------------------------------------------
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