[R] nlme error on dimensions in multiplication

Thomas Wutzler twutz at bgc-jena.mpg.de
Wed Mar 21 11:04:44 CET 2012


Hello R users,

When trying to fit a nonlinear mixed model to a respiration time series,
I get the following error message:

Error in recalc.varFunc(object[[i]], conLin) :
  dims [product 30] do not match the length of object [34]
In addition: Warning message:
In conLin$Xy * varWeights(object) :
  longer object length is not a multiple of shorter object length

Below is an example that generates this message on
Windows XP
R 2.14.0
nlme 3.1-103

---
library(nlme)
#load(file="tmp/exampleNmleError.RData")  	#ds1, fm1, ctrl
con <- url("http://www.bgc-jena.mpg.de/~twutz/tmp/exampleNmleError.RData")
load(file=con)  	#ds1, fm1, ctrl
close(con)

ds1 <- subset(ds1, select=c("ColNoM","minT","resp"))
head(ds1)
plot( resp ~ minT, col=rainbow(length(unique(ColNoM)))[ColNoM], ds1)
lines( fitted.values(fm1) ~ minT, ds1 )	# starting values from glns fit

ds2 <- ds1
# ds2 <- unique(ds1)	# does not resolve the error

tmp.fit1 <- nlme(
	resp ~ exp(beta0l) + beta1 * exp(-exp(beta2l)*minT)
	,fixed=list(beta0l+beta1+beta2l~1)	
	,random= beta0l ~ 1 | ColNoM
	, weights =varPower(fixed=0.4, form=~resp)
	, start=list(fixed = coef(fm1))
	#, method='REML'	
	,data=ds2
	#,control=ctrl
)

---
The exp function in the example is used to constrain estimates of the
coefficients to positive values, when actually estimating log of the
coefficients with nlme.

When I try to debug, there find a mismatch between the dims of weights
and the dims of Matrix conLin$Xy generated by function MEdecomp, which
reduced the original 34 rows to just 6 rows.
I tried to remove double entries in my example, but this did not help.

How can I make proper use of nlme?


Yours,
Thomas



More information about the R-help mailing list