[R] nls() and arima()

Yan Yu yanyu at cs.ucla.edu
Sat Jan 18 02:52:03 CET 2003

Thank you all for the reply to my nls Q.
after i put a variable at the left hand side of "~", and feed initial
values of coefficients, it works now:)
I have a related Q:
I apply arima() and nls() on the same time series. and try to compare
which one fits better.
the result from nls() provides "residual sum-of-squares"
the result from arima() gives "sigma2, var.coef" and residuals at each
My Q is:   what is the meaningful way to compare these two fittings from
the returned value from nls() and arima()?
should I also compute the sum-of-squares residuals for arima() from the
big individual residual array?
Is there any easy way to do this?

thanks a lot,
have a nice weekend,

On 17 Jan 2003, Douglas Bates wrote:

> "kjetil brinchmann halvorsen" <kjetil at entelnet.bo> writes:
> > On 16 Jan 2003 at 22:15, Yan Yu wrote:
> >
> > > HI,
> > > i have some prob when i try to use nls().
> > > my data is 1D vector, I tried to use a polynomial function(order is 3) to
> > > fit it.
> > > the data series is stored in x.
> > > the a0, a1, a2, a3 below is coefficient, which i  hope i can get from
> > > calls "nls"
> > >
> > > > z <-  nls(  ~ a0 + a1 * x + a2 * x * x + a3 * x * x * x, data = x )
> >
> > You haven't given a response in the formula? nls could possibly give
> > a more informative error message.
> and you didn't give starting estimates for the parameters and the
> model should not be fit with nls in the first place.  A polynomial in
> x is a linear model in the coefficients a0, a1, a2, and a3 and should
> be fit with lm, not nls.

More information about the R-help mailing list