On 12/21/2010 08:13 PM, Dennis Murphy wrote:
> Hi:
>
> Just a few questions about your model..see inline.
   Thanks,  I have answered inline. I've been trying a few of your 
suggestions and Ben Bolkers' but don't seem to get the fixed affects. 
See my reply to Ben.
>
> On Tue, Dec 21, 2010 at 11:43 AM, James Widman <jwidman@mi.nmfs.gov 
> <mailto:jwidman@mi.nmfs.gov>> wrote:
>
>     Happy Holidays to All,
>
>      I'm trying to use nlmer to model some data from an experiment I
>     ran and am having some trouble specifying the model correctly.
>     Would appreciate any insight you can provide.
>
>     I am examining the growth of fish fed two diets over 9 weeks -
>     with weekly measurements. Thirty fish were placed in each of 8
>     tanks, 4 tanks fed foodtype NRD and 4 tanks fed foodtype OTO.
>     Unbalanced data due to mortality.
>     I'm trying to fit a nlmer to the data and want to make sure I have
>     specified the model correctly. I can provide additional
>     information if needed.
>     This is what I came up with and have tried a number of
>     alternatives but don't seem to  be progressing.  I realize the
>     model will probably be simplified.
>
>     foodtype should be a fixed effect.
>
>     > str(scupgrowth)
>     'data.frame':   2925 obs. of  11 variables:
>      $ StartDate  : Factor w/ 1 level "2008/07/29": 1 1 1 1 1 1 1 1 1
>     1 ...
>      $ SampleDate : Factor w/ 10 levels "2008/07/29","2008/08/05",..:
>     1 1 1 1 1 1 1 1 1 1 ...
>      $ FishID     : int  1 2 3 4 5 6 7 8 9 10 ...
>      $ Length..mm.: int  38 39 34 33 36 40 39 34 32 35 ...
>      $ Weight..g. : num  0.64 0.81 0.47 0.48 0.62 0.78 0.7 0.47 0.47
>     0.62 ...
>      $ Tank       : int  1 1 1 1 1 1 1 1 1 1 ...
>      $ Days       : int  0 0 0 0 0 0 0 0 0 0 ...
>      $ FishIDf    : Factor w/ 2925 levels "1","2","3","4",..: 1 2 3 4
>     5 6 7 8 9 10 ...
>      $ foodtype   : Factor w/ 2 levels "NRD","OTO": 1 1 1 1 1 1 1 1 1
>     1 ...
>      $ tankf      : Factor w/ 8 levels "1","2","3","4",..: 1 1 1 1 1 1
>     1 1 1 1 ...
>      $ week       : num  0 0 0 0 0 0 0 0 0 0 ...
>     > (nlm1 <- nlmer(Weight..g. ~ SSgompertz(week, Asym, a, b) ~
>     foodtype + tankf + tankf|FishIDf,
>     +  scupgrowth, start = c(Asym = 72.70484, a = 5.34048, b = 0.83792)))
>
>
> I can see where Ben deduced the split plot structure: tanks are the 
> whole plots, fish within tank the split plots and time the repeated 
> measures factor at the split-plot level. Is that correct from your 
> perspective?
>
> (1) I don't see any parentheses around terms to signify random 
> effects, but clearly nlmer() doing something with the tankf|FishIDf 
> term. Why do you have a term for tankf as (presumably) a fixed effect 
> and again as a random effect? (1 + FishIDf | tankf) should produce 
> random intercepts for tanks and random slopes for fish within the same 
> tank. Do you want a correlation structure between tanks and fish or 
> between fish and time?
    I want to see whether there is a food affect on growth of the fish.
    Multiple tanks nested/split plot within two different diets(foodtype)
tankf should be random and nested within foodtype.


    Every time I tried using parentheses I received an error.
> (2) Are the fish uniquely identified or only so within tank? If they 
> are uniquely identified, perhaps   foodtype + (1 | tankf) + (1 | 
> FishIDf) may be sufficient (assuming tanks are random blocks), since 
> the nesting of fish within tanks would then be implicit. If they are 
> only distinguished within tank (e.g., fish 1 in tank 1 is different 
> from fish 1 in tank 2), then you may need something like tankf/FishIDf 
> instead. However, it appears from your str() output that it's the 
> former, so you should be able to get by with a simpler specification 
> due to implicit nesting. (See the list archives for some recent 
> discussion about this - I seem to recall that Prof. Bates commented on 
> coding with implicit nesting shortly after Thanksgiving...) This would 
> also remove the correlation structure at the tank-fish level.
    Fish are not uniquely identified, but were "given" unique IDs 
(because of implicit nesting) for the analysis.
>
> (3) Where is the time term? Isn't there a repeated measures aspect of 
> this design? (Are you holding out on us?? :) If the implicit nesting 
> idea is sensible in (2), it may be enough to use  (1 + week|FishIDf) 
> for the last bit of the model specification, since week would not be 
> an implicitly nested term, but would be nested within the 
> observational unit, FishID. This should yield a correlation matrix in 
> week at the repeated measures level.  The sleepstudy example is useful 
> for studying models with correlated and uncorrelated error structures.
>
   Time is in the equation -  SSgompertz(week, Asym, a, b)
> The suggestion is then (untried!)
> nlmer(weight..g. ~ SS(gompertz(week, Asym, a, b) ~ foodtype + (1 | 
> tankf) + (1 + week | FishIDf), ...)
>
> I'm never quite sure how the random effects specification in 
> (n/g)lmer() is supposed to work, so if you try this out, please double 
> check to make sure it makes sense both biologically and statistically. 
> As always, corrections/insights welcomed.
>
> HTH,
> Dennis
>
>
>     Nonlinear mixed model fit by the Laplace approximation
>     Formula: Weight..g. ~ SSgompertz(week, Asym, a, b) ~ foodtype +
>     tankf +      tankf | FishIDf
>       Data: scupgrowth
>      AIC  BIC logLik deviance
>      6010 6249  -2965     5930
>     Random effects:
>      Groups   Name        Variance   Std.Dev.  Corr
>      FishIDf  foodtypeOTO 4.7489e-06 0.0021792
>              tankf2      2.8193e-04 0.0167909 -0.829
>              tankf3      1.4213e-04 0.0119219  0.001  0.110
>              tankf4      2.0968e-04 0.0144804 -0.913  0.759  0.056
>              tankf5      1.8160e-04 0.0134760 -0.023 -0.007 -0.035  0.019
>              tankf6      3.7620e-04 0.0193958 -0.800  0.704  0.014
>      0.731 -0.260
>              tankf7      2.0907e-04 0.0144592  0.023 -0.195 -0.062
>     -0.022 -0.038
>              tankf8      3.4983e-04 0.0187038 -0.958  0.701 -0.033
>      0.870  0.222
>      Residual             1.1874e+00 1.0896851
>
>      -0.021
>      0.702 -0.107
>
>     Number of obs: 2925, groups: FishIDf, 2925
>
>     Fixed effects:
>          Estimate Std. Error t value
>     Asym 90.150991   5.205204   17.32
>     a     5.160145   0.042640  121.02
>     b     0.868886   0.003198  271.73
>
>     Correlation of Fixed Effects:
>      Asym  a
>     a 0.748
>     b 0.970 0.576
>
>     When I tried the following I get an error.
>      (nlm1 <- nlmer(Weight..g. ~ SSgompertz(week, Asym, a, b) ~ (1 |
>     foodtype) + tankf + tankf|FishIDf,
>     +  scupgrowth, start = c(Asym = 72.70484, a = 5.34048, b = 0.83792)))
>     Error in model.matrix.default(eval(substitute(~expr, list(expr =
>     x[[2]]))),  :
>      model frame and formula mismatch in model.matrix()
>
>     Thanks for any feedback you can provide.
>     Jim Widman
>
>     _______________________________________________
>     R-sig-mixed-models@r-project.org
>     <mailto:R-sig-mixed-models@r-project.org> mailing list
>     https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>


	[[alternative HTML version deleted]]


