Hi list, i'm trying to fit a mixed effects model to photosynthesis data and
I'm getting an error. "Error en nlmer(CO2 ~ fModf(Amax, Aq, LCP, luz) ~
(Amax + Aq + LCP | id), :

  gradient matrix must be of size 48 by 3"

I've seen a message posted a few days ago but nobody answered. I'm putting
a reproducible example below.

Thanks in advance for any help you might provide.

Luciano




fd <- structure(list(id = c(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1,
2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4,
5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), PPF = c(0, 0, 0, 0,
0, 0, 25, 25, 25, 25, 25, 25, 50, 50, 50, 50, 50, 50, 100, 100,
100, 100, 100, 100, 250, 250, 250, 250, 250, 250, 500, 500, 500,
500, 500, 500, 750, 750, 750, 750, 750, 750, 1000, 1000, 1000,
1000, 1000, 1000), CO2 = c(-0.520955552758998, -0.907562754198748,
-1.66205865699882, -0.53869676109461, -0.605843041369449, -0.366232028065627,
0.388919453639233, -0.14470833573833, 0.514398126851655, 0.0124537369651558,
0.258228181567303, 0.110717588460195, 1.07460467226873, 0.381529550619081,
0.745377538122876, 0.255318821257414, 0.859105296368183, 0.394435300574992,
1.67421454072931, 0.885880125113632, 1.43821517099342, 0.709886937131077,
1.34576610009118, 1.82702447832534, 1.89235261681976, 1.45654185989492,
1.99110567468432, 1.59123309771883, 2.59848940588664, 2.09568108239194,
2.07850841019746, 2.21121050828811, 2.78591836717708, 2.01825377168435,
2.90244195237179, 2.59874073510108, 2.32120148449763, 3.22609833242133,
4.41791422585137, 2.73470149739046, 2.90400461039851, 3.05468816217824,
2.67957561704492, 3.5245672937882, 4.86250622797745, 3.47623317503131,
3.5159906538692, 3.48072556276098)), .Names = c("id", "PPF",
"CO2"), class = "data.frame", row.names = c(1L, 2L, 3L, 4L, 5L,
6L, 109L, 110L, 111L, 112L, 113L, 114L, 217L, 218L, 219L, 220L,
221L, 222L, 325L, 326L, 327L, 328L, 329L, 330L, 433L, 434L, 435L,
436L, 437L, 438L, 541L, 542L, 543L, 544L, 545L, 546L, 649L, 650L,
651L, 652L, 653L, 654L, 757L, 758L, 759L, 760L, 761L, 762L))



library(lme4)


model <- nls(CO2 ~ Amax*(1 - exp(-Aq * (PPF - LCP))),
              start = list(Amax = 3, Aq = 0.01, LCP = 40 ), data = fd)

summary(model)


fModel <- function(Amax, Aq, LCP, PPF)  Amax*(1 - exp(-Aq * (PPF - LCP)))
fModf <- deriv(body(fModel), namevec = c("Amax", "Aq", "LCP", "PPF"),
               func = fModel)

model2 <- nlmer(CO2 ~ fModf(Amax, Aq, LCP, PPF) ~ (Amax + Aq + LCP|id),
                start = list(fixef= c(Amax = 3, Aq = 0.01, LCP = 40)),
                data = fd, verbose = TRUE)

#Error en nlmer(CO2 ~ fModf(Amax, Aq, LCP, PPF) ~ (Amax + Aq + LCP | id),  :

#  gradient matrix must be of size 48 by 3


sessionInfo()R version 2.14.0 (2011-10-31)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Spanish_Argentina.1252  LC_CTYPE=Spanish_Argentina.1252
[3] LC_MONETARY=Spanish_Argentina.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Argentina.1252

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
 [1] lme4_0.999375-42 Matrix_1.0-1     lattice_0.20-0   ggplot2_0.8.9
 [5] proto_0.3-9.2    reshape_0.8.4    reshape2_1.1     plyr_1.5.2
 [9] xlsx_0.3.0       xlsxjars_0.3.0   rJava_0.9-1

loaded via a namespace (and not attached):
[1] digest_0.5.1  nlme_3.1-102  stats4_2.14.0 stringr_0.5   tools_2.14.0

	[[alternative HTML version deleted]]


