library(nlme) options(digits = 7) ## https://stat.ethz.ch/pipermail/r-help/2014-September/422123.html nfm <- nlme(circumference ~ SSlogis(age, Asym, xmid, scal), data = Orange, fixed = Asym + xmid + scal ~ 1) (sO <- summary(nfm)) vc <- VarCorr(nfm, rdig = 5)# def. 3 storage.mode(vc) <- "double" # -> (correct) NA warning cfO <- sO$tTable stopifnot( identical(cfO[,"Value"], fixef(nfm)), all.equal(cfO[,"Std.Error"], c(Asym = 14.052931, xmid = 34.587933, scal = 30.496917), tol=5e-5) , cfO[,"DF"] == 28, all.equal(cfO[,"t-value"], c(Asym = 13.669478, xmid = 21.035987, scal = 11.693074), tol=6e-5) , all.equal(vc[,"Variance"], vc[,"StdDev"]^2, tol= 5e-7) , all.equal(vc[,"StdDev"], c(Asym = 27.0520, xmid = 24.255, scal = 36.596, Residual = 7.3215), tol = 2e-4) # ~ 7e-5 , all.equal(unname(vc[2:3, 3:4]), # "Corr" rbind(c(-0.3273, NA), c(-0.9920, 0.4430)), tol = 1e-3)# ~ 2e-4 ) ## Confirm predict(*, newdata=.) works (n <- nrow(Orange)) # 35 set.seed(17) newOr <- within(Orange[sample(n, 64, replace=TRUE), ], age <- round(jitter(age, amount = 50))) fit.v <- predict(nfm, newdata = newOr) resiv <- newOr$circumference - fit.v res.T <- c(48, 115, 74, 15, 44, -94, 47, -51, 20, -52, -16, 12, -135, -85, 136, 100, 24, 181, -88, -102, -26, 52, -148, 8, -83, 73, -27, -34, 91, 42, 34, -8, 0, 83, 84, -90, -123, 94, -157, -11, 56, -164, -28, 72, 15, 148, 95, -122, 169, 84, -19, -124, 45, -66, -10, 119, -110, -43, 12, 94, -108, 45, 48, 46) if(!all((res10 <- round(10 * as.vector(resiv))) == res.T)) { iD <- which(res10 != res.T) cat("Differing rounded residuals, at indices", paste(iD, collapse=", "), "; with values:\n") print(cbind(resiv, res10, res.T)[iD,]) }