4
$\begingroup$

I've seen a fair few of these posts already, and I feel a bit silly for posting yet another question on the topic - but I just cant seem to get my head around it. I'm very new to R and esp new to lme, so bear with me.

My study is on behavioural traits in fish, where I have 'sampled' 49 fish over a 3 month period. My response variables are MEANDEPTH (mean depth), CUMDIST (cumulative distance traveled) and HRMND (home range size). My explanatory variables are L (length), A (age), W (weight), K (K-factor) and L1 (1st yr growth).

What I'm trying to figure out is how my responses vary on a monthly basis and what influence these changes - for example, Do lager fish behave in a different fashion?

An example of what I've got so far is

mod11<-lme(log(HRMND)~A+K+L1+L+A*L*L1*K,data=CODDING,random=~1|ID,na.action=na.exclude)

But doesnt this include all months, and just gives me an overview over how things change between FISH? SO I'm thinking that in a way or another that I should nest or group with MONTH?

mod11<-lme(log(HRMND)~A+K+L1+L+A*L*L1*K,data=CODDING,random=~1|ID/MONTH,na.action=na.exclude)

or

mod11<-lme(log(HRMND)~MONTH*A+K+L1+L+A*L*L1*K,data=CODDING,random=~1|ID,na.action=na.exclude)

OR

mod11<-lme(log(HRMND)~A+K+L1+L+A*L*L1*K,data=CODDING,random=~1|ID:MONTH,na.action=na.exclude)

But I still have a feeling that this is all wrong..

Below I've attached my dataset;

> dput(CODDING)
structure(list(ID = c(7288L, 7288L, 7288L, 7293L, 7293L, 7293L, 
7294L, 7294L, 7294L, 7296L, 7296L, 7296L, 7298L, 7298L, 7298L, 
7300L, 7300L, 7300L, 7303L, 7303L, 7303L, 7305L, 7305L, 7305L, 
7306L, 7306L, 7306L, 7307L, 7307L, 7307L, 7308L, 7308L, 7308L, 
7309L, 7309L, 7309L, 7311L, 7311L, 7311L, 7312L, 7312L, 7312L, 
7313L, 7313L, 7313L, 7314L, 7314L, 7314L, 7318L, 7318L, 7318L, 
7320L, 7320L, 7320L, 7321L, 7321L, 7321L, 7325L, 7325L, 7325L, 
7326L, 7326L, 7326L, 7327L, 7327L, 7327L, 7328L, 7328L, 7328L, 
7330L, 7330L, 7330L, 7333L, 7333L, 7333L, 7334L, 7334L, 7334L, 
7336L, 7336L, 7336L, 7338L, 7338L, 7338L, 7339L, 7339L, 7339L, 
7341L, 7341L, 7341L, 7342L, 7342L, 7342L, 7343L, 7343L, 7343L, 
7344L, 7344L, 7344L, 7345L, 7345L, 7345L, 7346L, 7346L, 7346L, 
7347L, 7347L, 7347L, 7349L, 7349L, 7349L, 7351L, 7351L, 7351L, 
7353L, 7353L, 7353L, 7356L, 7356L, 7356L, 7357L, 7357L, 7357L, 
7358L, 7358L, 7358L, 7359L, 7359L, 7359L, 7360L, 7360L, 7360L, 
7362L, 7362L, 7362L, 7363L, 7363L, 7363L, 7364L, 7364L, 7364L, 
7365L, 7365L, 7365L, 7366L, 7366L, 7366L), MEANDEPTHMND = c(10.725262, 
12.200786, 13.564287, 10.707745, 13.587189, 14.198203, 8.462647, 
8.896712, 16.015541, 8.481038, 7.041678, 7.285891, 8.663365, 
9.253053, 17.173524, 11.97339, 11.331733, 13.794026, 11.47386, 
13.07904, 16.5411, 8.771731, 20.405117, 22.202886, 13.29951, 
15.7675, 19.4119, 8.197132, 8.25664, 10.082283, 14.13052, 14.73271, 
18.59407, 11.258819, 10.885207, 9.014883, 13.936096, 18.509176, 
15.562334, 14.165146, 16.427362, 13.590945, 13.65453, 15.08443, 
20.93181, 10.16241, 10.286637, 13.86002, 14.407088, 12.637779, 
18.089143, 6.728938, 14.2741, 14.094891, 5.957861, 5.914509, 
5.826612, 15.764523, 19.651839, 23.124057, 6.865263, 6.678091, 
7.54115, 14.533215, 11.785265, 14.19784, 8.668182, 9.134189, 
11.899737, 9.243074, 9.704021, 12.313194, 8.1842, 8.616996, 13.320201, 
7.443299, 10.705514, 21.653235, 12.58174, 13.93734, 18.04723, 
10.17801, 10.522297, 23.451312, 9.314671, 9.801458, 14.862017, 
14.532722, 13.119887, 10.412089, 5.341649, 5.094039, 5.465425, 
9.124215, 10.050294, 12.503342, 7.170584, 7.343889, 13.018498, 
4.978633, 7.359922, 11.55276, 11.619463, 12.955063, 16.950109, 
8.12889, 9.888701, 18.692396, 8.214024, 9.616029, 15.434882, 
10.157199, 20.685936, 26.921978, 13.24223, 14.71168, 15.24348, 
13.99331, 13.71569, 14.52495, 16.23245, 14.70182, 20.9764, 9.837841, 
20.111058, 21.78553, 7.449171, 8.706451, 11.070614, 10.676216, 
14.008959, 25.81545, 10.453505, 4.206622, 3.582907, 12.899, 13.8475, 
14.38309, 17.55982, 17.32079, 16.53955, 30.602365, 6.328528, 
3.704692, 11.696339, 11.786703, 16.052708), MONTH = c(6L, 7L, 
8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 
6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 
7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 
8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 
6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 
7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 
8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 
6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 
7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 8L, 6L, 7L, 
8L), CUMMND = c(148974.1, 171929.3, 99069.97, 129907, 129835.1, 
149201.9, 69416.58, 62566.24, 130587.8, 50782.51, 31477.03, 9249.42, 
89551.78, 95519.84, 58154.92, 173916.9, 168504.2, 144269.7, 101039.1, 
53324.26, 33865.99, 137442.3, 115678.4, 117456, 175852.3, 168014.9, 
165600.3, 149324.3, 155302.1, 113610.5, 149992, 135209.2, 148616.7, 
95172.35, 90167.98, 101916.9, 141753.1, 127389.7, 152162.4, 154257.1, 
97991.67, 105943.1, 138843.2, 125017.5, 111700.4, 102351.6, 79254.78, 
9964.566, 132743.5, 109509.4, 52689.9, 145669.6, 137691.1, 113990, 
71017.53, 44875.13, 80049.09, 96738.65, 92763.12, 26388.68, 68470.29, 
66847.35, 46495.22, 176603.6, 157265.4, 154788, 79326.2, 40961.61, 
22673.42, 100548.5, 107353.8, 138281.2, 98429.28, 102775.3, 90914.61, 
120933.2, 127609.6, 165635.3, 185937.1, 172564.9, 149174.3, 106384.8, 
53641.83, 65757.93, 62080.82, 49910.08, 130763.9, 168503.3, 156763.7, 
152423.7, 81643.54, 83967.29, 78720.64, 169761.6, 164332.6, 135755.9, 
137047.2, 59321.11, 74910.94, 31278.17, 56611.2, 112278, 154989.7, 
136986, 171017.8, 128664.1, 149874.2, 94740.11, 145985.7, 119399.8, 
104811.8, 83963.69, 56427.02, 26790.39, 125646.7, 125337.3, 131328.9, 
121618.4, 146529.1, 154746.8, 76478.93, 97928.08, 77460.88, 129896.2, 
78492.33, 76384.62, 126209, 97418.64, 116615.9, 99622.77, 101672.3, 
150328.7, 120802.7, 135307.6, 103726.2, 109304.2, 121024.7, 112431.6, 
148247.3, 151481.6, 181459, 85739.81, NA, 83232.05, 170169.9, 
161198.6, 61503.5), HRMND = c(1873168, 637235.6, 2686066, 797586.5, 
680754.9, 397648.9, 480643.1, 373537.4, 1254880, 1608148, 463576.7, 
383217.1, 497585.5, 486003.1, 2877401, 1103932, 473820.5, 4776109, 
329410, 260994.9, 300850.3, 654988.1, 1010306, 1098825, 407661.2, 
528440.8, 1121661, 279148.5, 206099, 206450.8, 573508.3, 541271.5, 
260193.7, 387968.5, 254684.4, 479391.8, 633900.6, 239233.3, 304772.3, 
1354606, 294176.6, 918708.4, 696910.9, 822802.7, 3184885, 3184885, 
581067.4, 1598596, 2384490, 544204.6, 2133508, 252528.5, 153201.8, 
3246378, 253993.7, 194549.3, 112046.9, 512059.9, 339163.6, 762145.2, 
344128.7, 298777.9, 938502.4, 1403911, 706129, 452398.4, 2509116, 
500621.6, 2796525, 309062.7, 191797.2, 2916431, 264717.6, 201020.3, 
222392.5, 477403.8, 398037, 2102339, 1062142, 773654.8, 726203.1, 
416095.5, 109564.9, 3401014, 421404.2, 503160.4, 4815527, 268447.2, 
506682, 4600924, 404484.7, 175489.8, 413650.9, 308857.2, 241956.2, 
673644.6, 956416.3, 414738.8, 4335718, 142446.9, 700196.2, 657465.8, 
1440978, 347600.9, 980805.8, 3658006, 927301, 3628336, 281490.8, 
222893.7, 1887973, 2498449, 404445.7, NA, 315003.8, 274804.6, 
222542.3, 227833, 315854.4, 171730.1, 165038, 480690.2, 328394.1, 
258172.9, 94474.71, 130301, 456144.7, 339891.1, 1939505, 326920, 
326491.4, 1959026, 342101, 226885.6, 373924.5, 389011.7, 418293.7, 
1255376, 914433, 950183.6, 903774.1, 2217491, NA, 1269254, 1810494, 
306736.1, 2733252), L = c(420L, 420L, 420L, 390L, 390L, 390L, 
560L, 560L, 560L, 600L, 600L, 600L, 330L, 330L, 330L, 350L, 350L, 
350L, 400L, 400L, 400L, 560L, 560L, 560L, 420L, 420L, 420L, 450L, 
450L, 450L, 460L, 460L, 460L, 400L, 400L, 400L, 300L, 300L, 300L, 
430L, 430L, 430L, 410L, 410L, 410L, 740L, 740L, 740L, 440L, 440L, 
440L, 600L, 600L, 600L, 460L, 460L, 460L, 370L, 370L, 370L, 540L, 
540L, 540L, 460L, 460L, 460L, 690L, 690L, 690L, 560L, 560L, 560L, 
500L, 500L, 500L, 610L, 610L, 610L, 380L, 380L, 380L, 520L, 520L, 
520L, 630L, 630L, 630L, 370L, 370L, 370L, 330L, 330L, 330L, 500L, 
500L, 500L, 560L, 560L, 560L, 480L, 480L, 480L, 510L, 510L, 510L, 
490L, 490L, 490L, 400L, 400L, 400L, 580L, 580L, 580L, 370L, 370L, 
370L, 560L, 560L, 560L, 800L, 800L, 800L, 630L, 630L, 630L, 600L, 
600L, 600L, 530L, 530L, 530L, 390L, 390L, 390L, 790L, 790L, 790L, 
410L, 410L, 410L, 310L, 310L, 310L, 540L, 540L, 540L), W = c(695L, 
695L, 695L, 615L, 615L, 615L, 1770L, 1770L, 1770L, 2150L, 2150L, 
2150L, 400L, 400L, 400L, 505L, 505L, 505L, 625L, 625L, 625L, 
1825L, 1825L, 1825L, 715L, 715L, 715L, 815L, 815L, 815L, 820L, 
820L, 820L, 670L, 670L, 670L, 280L, 280L, 280L, 720L, 720L, 720L, 
630L, 630L, 630L, 4210L, 4210L, 4210L, 730L, 730L, 730L, 1910L, 
1910L, 1910L, 1080L, 1080L, 1080L, 495L, 495L, 495L, 1540L, 1540L, 
1540L, 920L, 920L, 920L, 2880L, 2880L, 2880L, 1780L, 1780L, 1780L, 
1320L, 1320L, 1320L, 2000L, 2000L, 2000L, 545L, 545L, 545L, 1465L, 
1465L, 1465L, 1945L, 1945L, 1945L, 500L, 500L, 500L, 345L, 345L, 
345L, 1330L, 1330L, 1330L, 1580L, 1580L, 1580L, 1145L, 1145L, 
1145L, 1190L, 1190L, 1190L, 1135L, 1135L, 1135L, 700L, 700L, 
700L, 2105L, 2105L, 2105L, 470L, 470L, 470L, 1850L, 1850L, 1850L, 
4765L, 4765L, 4765L, 2405L, 2405L, 2405L, 2130L, 2130L, 2130L, 
1330L, 1330L, 1330L, 665L, 665L, 665L, 4050L, 4050L, 4050L, 645L, 
645L, 645L, 325L, 325L, 325L, 1630L, 1630L, 1630L), A = c(2L, 
2L, 2L, 3L, 3L, 3L, NA, NA, NA, NA, NA, NA, 3L, 3L, 3L, 2L, 2L, 
2L, 2L, 2L, 2L, 4L, 4L, 4L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 
3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 3L, 
3L, 3L, NA, NA, NA, 3L, 3L, 3L, 2L, 2L, 2L, NA, NA, NA, 4L, 4L, 
4L, 5L, 5L, 5L, NA, NA, NA, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 
4L, 4L, 4L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 
5L, 5L, NA, NA, NA, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 4L, 4L, 
4L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 3L, 3L, 3L, 5L, 5L, 5L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 
3L, 3L), K = c(0.94, 0.94, 0.94, 1.04, 1.04, 1.04, 1.01, 1.01, 
1.01, 1, 1, 1, 1.11, 1.11, 1.11, 1.18, 1.18, 1.18, 0.98, 0.98, 
0.98, 1.04, 1.04, 1.04, 0.97, 0.97, 0.97, 0.89, 0.89, 0.89, 0.84, 
0.84, 0.84, 1.05, 1.05, 1.05, 1.04, 1.04, 1.04, 0.91, 0.91, 0.91, 
0.91, 0.91, 0.91, 1.04, 1.04, 1.04, 0.86, 0.86, 0.86, 0.88, 0.88, 
0.88, 1.11, 1.11, 1.11, 0.98, 0.98, 0.98, 0.89, 0.89, 0.89, 0.95, 
0.95, 0.95, 0.88, 0.88, 0.88, 1.01, 1.01, 1.01, 1.06, 1.06, 1.06, 
0.88, 0.88, 0.88, 0.99, 0.99, 0.99, 1.04, 1.04, 1.04, 0.78, 0.78, 
0.78, 0.99, 0.99, 0.99, 0.96, 0.96, 0.96, 1.06, 1.06, 1.06, 0.9, 
0.9, 0.9, 1.04, 1.04, 1.04, 0.9, 0.9, 0.9, 0.96, 0.96, 0.96, 
1.09, 1.09, 1.09, 1.08, 1.08, 1.08, 0.93, 0.93, 0.93, 1.05, 1.05, 
1.05, 0.93, 0.93, 0.93, 0.96, 0.96, 0.96, 0.99, 0.99, 0.99, 0.89, 
0.89, 0.89, 1.12, 1.12, 1.12, 0.82, 0.82, 0.82, 0.94, 0.94, 0.94, 
1.09, 1.09, 1.09, 1.04, 1.04, 1.04), L1 = c(144.5, 144.5, 144.5, 
152.6, 152.6, 152.6, NA, NA, NA, NA, NA, NA, 118.3, 118.3, 118.3, 
102.1, 102.1, 102.1, 148.6, 148.6, 148.6, 172.3, 172.3, 172.3, 
95.5, 95.5, 95.5, 183.8, 183.8, 183.8, 125.1, 125.1, 125.1, 92.3, 
92.3, 92.3, 133.3, 133.3, 133.3, 140.1, 140.1, 140.1, 136.7, 
136.7, 136.7, 211.4, 211.4, 211.4, 165, 165, 165, NA, NA, NA, 
167.3, 167.3, 167.3, 167.3, 167.3, 167.3, NA, NA, NA, 95.4, 95.4, 
95.4, 167.3, 167.3, 167.3, NA, NA, NA, 136.4, 136.4, 136.4, 183, 
183, 183, 190, 190, 190, 197.2, 197.2, 197.2, 159.4, 159.4, 159.4, 
134.5, 134.5, 134.5, 105, 105, 105, 174.8, 174.8, 174.8, 126.5, 
126.5, 126.5, NA, NA, NA, 143.4, 143.4, 143.4, 132.8, 132.8, 
132.8, 194.7, 194.7, 194.7, 153.1, 153.1, 153.1, 260.4, 260.4, 
260.4, 140, 140, 140, 258.8, 258.8, 258.8, 160.8, 160.8, 160.8, 
201.4, 201.4, 201.4, 138.1, 138.1, 138.1, 140.4, 140.4, 140.4, 
210.7, 210.7, 210.7, 114.8, 114.8, 114.8, 134.5, 134.5, 134.5, 
172.8, 172.8, 172.8)), .Names = c("ID", "MEANDEPTHMND", "MONTH", 
"CUMMND", "HRMND", "L", "W", "A", "K", "L1"), class = "data.frame", row.names = c(NA, 
-147L))

As mentioned, I'm sure the answer to my question is out there on the interwebs somewhere, but I'm confused and reading all these mixed effects model books are not helping either.

All help, pointers and advice would be greatly appreciated!

$\endgroup$
1
  • $\begingroup$ Note to self; mod0<-lme(log(HRMND)~MONTH+L+A+L1+K,data=CODDING,random=~1|ID,na.action=na.exclude) Check AIC to see whether MONTH is important for the model. $\endgroup$
    – IdaFish
    Commented Mar 4, 2013 at 13:24

1 Answer 1

1
$\begingroup$

This is a super old question now, but I figure it gets viewed so should have an answer. OP is interested in nesting within month. Thus, in the random effects section it should be ~1 | MONTH/ID to show that each fish is nested within a given month. I have data where I observed several sites over several years and used ~1 | Year/Site with success.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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