R Under development (unstable) (2024-06-05 r86695 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(nlme) > fm1 <- nlsList(SSasymp, Loblolly) > fm1 Call: Model: height ~ SSasymp(age, Asym, R0, lrc) | Seed Data: Loblolly Coefficients: Asym R0 lrc 329 94.12820 -8.250753 -3.217578 327 94.94058 -7.757495 -3.229325 325 89.88487 -8.759017 -3.086219 307 110.69919 -8.169431 -3.390345 331 111.00287 -8.462608 -3.397574 311 109.98575 -8.558543 -3.362518 315 101.05622 -8.443628 -3.232825 321 127.13400 -7.679356 -3.575331 319 101.08748 -8.502343 -3.214021 301 95.66688 -9.078241 -3.116381 323 95.55627 -9.665035 -3.092266 309 113.51390 -7.595622 -3.352815 303 105.71792 -8.906081 -3.222957 305 99.17191 -9.916654 -3.084841 Degrees of freedom: 84 total; 42 residual Residual standard error: 0.7003965 > system.time(cnL1 <- confint(fm1)) # 0.48 sec Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... Waiting for profiling to be done... user system elapsed 0.44 0.02 0.45 > > stopifnot( + all.equal(as.matrix(coef(fm1)), + array(c(94.1282, 94.9406, 89.8849, 110.699, 111.003, 109.986, 101.056, + 127.134, 101.087, 95.6669, 95.5563, 113.514, 105.718, 99.1719, + -8.25075, -7.75749, -8.75902, -8.16943, -8.46261, -8.55854, -8.44363, + -7.67936, -8.50234, -9.07824, -9.66503, -7.59562, -8.90608, -9.91665, + -3.21758, -3.22932, -3.08622, -3.39034, -3.39757, -3.36252, -3.23282, + -3.57533, -3.21402, -3.11638, -3.09227, -3.35282, -3.22296, -3.08484), + dim = c(14L, 3L), + dimnames = list(c("329", "327", "325", "307", "331", "311", "315", + "321", "319", "301", "323", "309", "303", "305"), + c("Asym", "R0", "lrc"))), + tol = 1e-5) + , + all.equal(pooledSD(fm1), structure(0.70039649, df = 42), tol = 1e-5) + , + 84 == sum(vapply(lapply(fm1, fitted), length, 1L)) # total deg.freedom + , ## confint() : + is.list(cnL1), identical(names(cnL1), names(fm1)), + vapply(cnL1, is.matrix, NA), + vapply(cnL1, dim, c(NA,0L)) == 3:2, + identical(unname(sapply(cnL1, dim)), matrix(3:2, 2, length(fm1))), + sapply(cnL1, is.finite) + ) > > fm2 <- nlme(fm1, random = Asym ~ 1) > fm2 Nonlinear mixed-effects model fit by maximum likelihood Model: height ~ SSasymp(age, Asym, R0, lrc) Data: Loblolly Log-likelihood: -114.743 Fixed: list(Asym ~ 1, R0 ~ 1, lrc ~ 1) Asym R0 lrc 101.448300 -8.627494 -3.233730 Random effects: Formula: Asym ~ 1 | Seed Asym Residual StdDev: 3.650645 0.7188624 Number of Observations: 84 Number of Groups: 14 > stopifnot( + all.equal(fixef(fm2), + c(Asym = 101.4483, R0 = -8.6274937, lrc = -3.2337304), tol = 4e-7) + , + all.equal(logLik(fm2), + structure(-114.743, class = "logLik", nall = 84, nobs = 84, df = 5), + tol = 4e-6) + , + all.equal(sigma(fm2), 0.71886244, tol = 1e-6) + ) > > pm2.0 <- predict(fm2, Loblolly, level=0)## failed in nlme 3.1-123 > stopifnot(all.equal(head(pm2.0), + c(3.64694, 11.0597, 27.2258, 40.5006, 51.4012, 60.3522), + tol = 1e-5)) # 4e-7 {64b nb-mm4} > > ## same as fm2 but fitted via nlme's formula interface > fm3 <- nlme(height ~ SSasymp(age, Asym, R0, lrc), + data = Loblolly, + fixed = Asym + R0 + lrc ~ 1, + random = Asym ~ 1, groups = ~Seed) > ## explicitly specifying 'groups' failed in 3.1-153 with > ## Error in nlme::nlsList(model = height ~ SSasymp(age, Asym, R0, lrc), data = Loblolly, : > ## unused argument (groups = ~Seed) > fm2$origCall <- NULL > stopifnot(all.equal(fm2, fm3)) > > proc.time() user system elapsed 0.95 0.09 0.98