1
$\begingroup$

I'm looking at the impact of dietary treatment and sex on weight.

My dataset comprises weight data for 3 dietary treatments and sex (male and female). The experimental design was run in duplicate, so that's 2 fixed factors (temperature and sex) alongside the duplicate tank from which they were sampled (random factor). There are 50 individual animals were weighed per tank.

dataset <- structure(list(Sex = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L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L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L), Weight..g. = c(1.03, 1.02, 1.04, 1, 1.42, 
    0.93, 0.83, 1, 0.75, 1.02, 0.93, 0.72, 1.02, 0.88, 0.96, 
    1.23, 0.96, 0.95, 1.3, 0.99, 1.06, 0.79, 0.84, 0.88, 0.77, 
    0.57, 1.24, 1.05, 1.12, 0.8, 0.7, 1.46, 0.93, 1.22, 1.06, 
    0.97, 1.33, 1.11, 0.47, 1.59, 1.31, 0.96, 0.69, 1.27, 0.87, 
    0.41, 1.06, 0.95, 0.94, 1.33, 1.18, 1.34, 1.25, 1.44, 1.44, 
    1.5, 1.01, 0.9, 1.11, 0.82, 1.58, 1.08, 1.54, 1.13, 1.38, 
    1.28, 1.15, 1.13, 1.35, 1.2, 1.04, 1.44, 1.14, 1.37, 0.98, 
    1.43, 1.36, 1.16, 1.29, 1.23, 1.47, 0.89, 0.95, 1.14, 1.08, 
    1.11, 1.31, 1.02, 1.02, 1.47, 0.91, 1.21, 0.96, 1.08, 1.26, 
    0.96, 1.05, 1.27, 1.04, 1.26, 1.3, 1.26, 1.29, 1.34, 1.21, 
    1.23, 1.28, 0.73, 0.89, 0.95, 0.89, 1.22, 1.24, 0.78, 1.34, 
    0.86, 0.86, 1.16, 0.86, 0.8, 1.19, 0.44, 1.11, 0.76, 0.9, 
    0.91, 1.11, 1.29, 0.99, 1.31, 1.08, 1.21, 1.22, 1.23, 1.19, 
    1.53, 1.04, 0.94, 1.28, 0.85, 1.08, 1.23, 0.94, 0.94, 1.21, 
    1.16, 1.25, 0.9, 0.97, 1.08, 1.37, 1.09, 1.63, 1.2, 1.23, 
    1.3, 1.27, 1.03, 0.97, 1.33, 1.42, 1.05, 0.98, 1.38, 0.36, 
    0.94, 0.95, 0.91, 1.11, 1, 1.12, 0.98, 1.04, 1.17, 0.96, 
    1.3, 0.92, 0.93, 1.06, 1.16, 1.23, 1.07, 1.08, 0.92, 1.28, 
    1.11, 0.87, 1.02, 1.01, 1.14, 1.01, 1.05, 0.87, 1.22, 0.97, 
    1.16, 1.06, 0.81, 1.13, 0.88, 1.09, 1.27, 1.43, 1.17, 0.9, 
    0.79, 1.2, 1.36, 1.27, 0.68, 1.08, 0.86, 1.15, 1.33, 0.97, 
    1.39, 0.9, 0.77, 1.04, 0.92, 1.07, 1.12, 1.15, 0.93, 0.97, 
    1.21, 1.37, 0.82, 1.17, 0.89, 1.17, 1.18, 1.21, 1.09, 1.1, 
    0.72, 0.41, 1.27, 1.16, 1.23, 1.21, 1.2, 1.24, 1.3, 1.08, 
    1.16, 1.36, 0.63, 1.07, 1.01, 1.26, 1.57, 1.37, 1.38, 1.19, 
    1.31, 1.27, 1.2, 1.63, 1.43, 1.3, 0.96, 1.1, 1.43, 1.36, 
    1.14, 1.14, 1.01, 1.31, 1.3, 1.23, 1.19, 1.16, 1.3, 1.22, 
    1.15, 1.13, 1.34, 1.29, 1.41, 1.22, 1.42, 1.53, 1.43, 1.11, 
    1.21, 1.43, 1.01, 1.22, 1.05, 0.95, 1.4, 1.41, 0.69, 1.29, 
    1.36, 1.24, 1.42, 1.18, 1.2, 0.99, 1.09, 1.04, 0.92, 0.75, 
    0.8, 0.84, 1.09, 0.83, 0.96, 0.99, 0.76, 1.14, 0.84, 0.72, 
    0.98, 0.93, 1.06, 1.29, 0.77, 0.92, 0.72, 0.88, 1.42, 1.07, 
    0.73, 0.6, 0.81, 1.12, 0.81, 1.09, 0.89, 0.76, 0.82, 1.02, 
    0.93, 0.87, 0.68, 0.67, 0.77, 1, 1.17, 0.75, 0.72, 0.82, 
    0.6, 1.11, 0.78, 1.08, 0.48, 0.89, 0.69, 0.71, 0.88, 0.91, 
    0.92, 0.55, 0.84, 0.8, 0.43, 0.98, 0.67, 0.85, 1.11, 0.99, 
    0.89, 0.58, 0.9, 0.89, 0.85, 0.87, 0.72, 0.89, 1.06, 0.81, 
    0.83, 0.79, 0.9, 0.87, 0.81, 0.73, 0.77, 0.91, 0.79, 0.98, 
    0.77, 0.72, 0.81, 0.84, 0.75, 0.82, 1.05, 0.61, 0.93, 0.77, 
    0.86, 0.78, 0.77, 0.72, 0.76, 1.22, 0.79, 0.99, 0.99, 0.51, 
    0.96, 0.81, 1.07, 1.1, 0.83, 0.9, 0.9, 0.79, 0.79, 1.22, 
    1.03, 0.59, 1.05, 0.93, 0.72, 0.93, 0.64, 0.94, 0.81, 0.77, 
    0.62, 0.81, 0.98, 0.79, 0.92, 0.98, 0.66, 0.74, 0.91, 0.4, 
    1.05, 0.85, 0.9, 0.94, 0.84, 0.32, 0.87, 0.86, 0.87, 0.82, 
    0.9, 0.21, 0.55, 0.86, 0.87, 1.21, 1.07, 1.02, 1.52, 1.13, 
    1.17, 1.19, 1.21, 0.93, 0.92, 1.19, 0.96, 1.07, 0.93, 0.97, 
    1.15, 1.07, 1.31, 1.21, 1, 1.13, 0.94, 1.3, 1.02, 1.05, 0.87, 
    0.95, 0.5, 1.06, 1.23, 1.27, 0.76, 1, 0.75, 0.98, 0.91, 1.07, 
    0.97, 1.09, 1.17, 1.19, 0.87, 1.12, 1, 1.07, 1.06, 0.91, 
    0.82, 1.37, 1.05, 1.31, 1.28, 1.25, 1.27, 1.16, 0.58, 0.88, 
    0.97, 1.09, 0.59, 1.36, 1.27, 0.84, 0.81, 1.16, 1.14, 1.01, 
    1.31, 1.23, 0.87, 0.78, 0.74, 0.97, 1.18, 0.85, 0.53, 0.57, 
    0.95, 1.2, 1, 0.68, 0.85, 0.94, 0.96, 0.5, 1.36, 0.87, 1.25, 
    1.07, 0.68, 1.43, 1.02, 1.15, 1.41, 1.02, 1.03, 0.44, 1.09, 
    1.01, 1.15, 1.13, 1.25, 1.58, 1.29, 1.18, 1.26, 1.08, 1.29, 
    1.21, 1.36, 1.22, 0.84, 1.08, 1, 0.88, 0.8, 0.75, 1.36, 1.3, 
    1.16, 1.4, 1.26, 0.82, 0.98, 1.43, 0.97, 1.3, 1.15, 1.29, 
    1.12, 1.17, 1.14, 1.54, 0.97, 1.03, 1.28, 1.4, 1.12, 1.13, 
    1.21, 1.15, 1.03, 1.03, 1.15, 1.24, 0.89, 0.8, 1.22, 1.26, 
    1.19)), .Names = c("Sex", "Diet", "Replicate", "Weight..g."
), class = "data.frame", row.names = c(NA, -600L))

I've done some reading to establish that I need to do a linear mixed effects model. I have written the following code but keep getting error about rank deficiency and the dropping of 3 columns. The reasons for which this is happening is over my head and rank deficiencies are seemingly from limitless causes according to other posts!!!

Does anyone know where I might be going wrong here?

lmer(Weight..g. ~ Diet * Sex + (1|Replicate), data = dataset)
$\endgroup$
  • 1
    $\begingroup$ One note -- diet * sex expands out to diet + sex + diet:sex, so you can drop the diet + sex portion, i.e. it's redundant. $\endgroup$ – alexforrence Jan 19 '15 at 20:59
  • $\begingroup$ Thanks, I have edited it to exclude this - I had been using Minitab before and expressing it this way. This still leaves me with rank deficiencies though. $\endgroup$ – Mismedolee Jan 20 '15 at 8:55
  • $\begingroup$ The model seems fine. The error you get probably says that there is not enough observations for fixed effects (I guess that in interaction groups) so groups where there is not enough observations are dropped. If so then the only thing you could do is (a) get more observations or (b) simplify the model (e.g. no interaction). I would be able to say more if you described your data in greater detail (best: provided reproducible example) and posted the exact error message. $\endgroup$ – Tim Jan 20 '15 at 9:03
  • $\begingroup$ Hi there, I have added the data I am using with dput. I'm not sure why its pasted like that but I was having difficulty making it tidy. There are quite a lot of observations (50 per replicate) so I don't know if this should be the problem? I'm getting the error message 'fixed-effect model matrix is rank deficient so dropping 3 columns/coefficients' $\endgroup$ – Mismedolee Jan 20 '15 at 10:13
  • 1
    $\begingroup$ The model fit fine for me. Can you add your sessionInfo()? $\endgroup$ – alexforrence Jan 20 '15 at 12:17
1
$\begingroup$

Ok so by adding unique ID codes for each observation (which occured automatically for me when pasting back from dput) the model runs fine. This avoids continuous replication causing the rank deficiencies! Thanks for the help guys :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.