[R] Non-constant variance and non-Gaussian errors

Monica Pisica pisicandru at hotmail.com
Wed Sep 3 19:01:46 CEST 2008

Hi Paul,

Take a look at gam() from package mgcv (gam = generalized additive models), maybe this will help you. GAMs can work with other distributions as well. Generalized additive models consist of a random component, an additive component, and a link function relating these two components. The response Y, the random component, is assumed to have a density in the exponential family. I am not sure about errors, though.

This modeling package uses penalized versions of the least squares or maximum –likelihood / IRLS methods. The penalizing or smoothing factor is calculated by minimizing the generalized cross validation (GCV), or the information criterion (AIC) scores using a Newton type optimization based on exact first and second derivatives, as described in Wood (2008). 

Wood, S.N. (2004) Stable and efficient multiple smoothing parameter estimation for generalized additive models.Journal of the American Statistical Association. 99:673-686.

Wood, S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC.

Wood, S.N. (2008) Fast stable direct fitting and smoothness selection for generalized additive models. Journal of the Royal Statistical Society (B) 70(2): - .

Hope this helps some,


Message: 94
Date: Wed, 3 Sep 2008 09:24:10 +0100
From: "Paul Suckling" 
Subject: Re: [R] Non-constant variance and non-Gaussian errors with
To: r-help at r-project.org

Content-Type: text/plain; charset=UTF-8

Well, it looks like I am partly answering my own question. gnls is
clearly not going to be the right method to use to try out a
non-Gaussian error structure. The "ls"=Least Squares in "gnls" means
minimising the sum of the square of the residuals ... which is
equivalent to assuming a Gaussian error structure and maximising the
likelihood. So gnls is implicitly Gaussian.

Still, there must be some packages out there that can be applied to
non-linear regression with not-necessarily-Gaussian error structures
and weighting, although I appreciate that that's a difficult problem
to solve. Does anyone here know of any?

Thank you,


2008/9/2 Paul Suckling :
> I have been using the nls function to fit some simple non-linear
> regression models for properties of graphite bricks to historical
> datasets. I have then been using these fits to obtain mean predictions
> for the properties of the bricks a short time into the future. I have
> also been calculating approximate prediction intervals.
> The information I have suggests that the assumption of a normal
> distribution with constant variance is not necessarily the most
> appropriate. I would like to see if I can obtain improved fits and
> hence more accurate predictions and prediction intervals by
> experimenting with a) a non-constant (time dependent) variance and b)
> a non-normal
> error distribution.
> It looks to me like the gnls function from the nlme R package is
> probably the appropriate one to use for both these situations.
> However, I have looked at the gnls help files/documentation and am
> still left unsure as to how to specify the arguments of the gnls
> function in order to achieve what I want. In particular, I am unsure
> how to use the params argument.
> Is anyone here able to help me out or point me to some documentation
> that is likely to help me achieve this?
> Thank you.



More information about the R-help mailing list