See this post:
http://r.789695.n4.nabble.com/varIdent-error-using-gam-function-in-mgcv-td2260556.html

Kevin



On Tue, Oct 1, 2013 at 4:37 PM, Sonya Odsen <odsen@ualberta.ca> wrote:

> I'm running R version 3.0.2 (2013-09-25) on a Windows computer.
> Here is a simplified version of my data:
>
> a <- expand.grid(SITE=c("A","B"),TREAT=c("low","med","high"), REP=c(1:5))
> VAR <- round(rep(c(10,12,14,15,17,18),5)+rnorm(30)*2,1)
> dat <- cbind(a,VAR)
>
> I'm running a GAM on my data (package: mgcv, version 1.7.12). My initial
> model is of the form:
>
> M1 <- gam(VAR ~ SITE + TREAT,
>           data = dat)
>
> Model validation shows heterogeneity in Residuals vs. Treatment (in my true
> dataset, not the demo), so I want to apply a weighted variance structure to
> my gam, following examples given in Zuur (2009), using function varIdent
> (package: nlme, version 3.1.102):
>
> M2 <- gam(VAR ~ SITE + TREAT,
>           weights = varIdent(form=~1|TREAT),
>           data = dat)
>
> Given examples from the help files and books, I expect this to run as-is.
> Instead, Running the gam returns the following error message:
>
> Error in model.frame.default(formula = VAR ~ SITE + TREAT, data = dat,  :
>   variable lengths differ (found for '(weights)')
>
> > varIdent(form=~1|TREAT)
> Variance function structure of class varIdent with no parameters, or
> uninitialized
>
> > coef(varIdent(form=~1|TREAT))
> numeric(0)
>
>
> This behavior of varIdent() is unlike anything I've seen in examples, in
> the helpfile or in textbooks. I would be grateful for any help.
>
> Regards,
> Sonya Odsen
>
>
> ---
> Sonya Odsen
> M.Sc. Candidate
> University of Alberta
> Dept. of Renewable Resources
> odsen@ualberta.ca
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Kevin Wright

	[[alternative HTML version deleted]]

