2

I've been trying to fit a nonlinear mixed model in R to my data but I'm having a hard time understanding the help files and examples people are using. I'm a masters student trying to model changes in behaviour as welfare measures in 4 sheep over the course of 22 days. Days -4 to -1 is used as baseline, day 0 has no measures as they were in surgery and days 1 to 17 are what I'm interested in. Plotting the different datasets gives me nice dips around days 1 to 3 after surgery after which they more or less return to baseline. I was first told to square my explanatory variable (Day) but when using lmer() that doesn't really change my results at all. So I want to try nlmer to see if that works better.

My dataset looks like this and goes down to 500 lines or so. "Sheep" is read as a factor:

. Behaviour Sheep Day DaySq Block Observed Frequency 1 Standing 2 -4 16 0 49 71.01449 2 Lying 2 -4 16 0 12 17.39130 3 Eating 2 -4 16 0 36 52.17391 4 Ruminating 2 -4 16 0 16 23.18841 5 Moving in pen 2 -4 16 0 0 0.00000 6 XDisturbance 2 -4 16 0 9 13.04348

My lmer model looks like this

lmer(Frequency ~ Behaviour * Day + (1|Sheep), behdata2)

I want to do something similar but as nonlinear. Is that possible? I've tried a few versions but I don't know how to do this correctly and keep getting error messages. And the examples in the R help file seems to assume a lot of knowledge I don't have. Any help would be appreciated!

Del
  • 21
  • 2
  • What did you try? What errors did you get? Just squaring a covariate still results in a "linear" model. What exactly what model are you trying to fit? – MrFlick Jul 20 '15 at 13:49
  • I'm trying to look at the effect of the observation day on the behaviour of the sheep. Obviously the type of behaviour affects the frequency of observation of that behaviour and each animal behaves slightly differently. I tried nlmer(Frequency ~ Day * Frequency ~ (1|Sheep), behdata2) and variations with the middle part exchanged for SSlogis(Day*Frequency) for example. The error message for those is Error: is.numeric(nlpars <- start$nlpars) is not TRUE. This comes up a lot. I know I'm not coding right but I don't know what to do or what code like SSlogis() does. – Del Jul 20 '15 at 14:57
  • If you are concerned with the error message, then make sure you provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and the code necessary to reproduce the error in your main question. If you really just need help choosing the appropriate statistical model for your data, you might consider asking your question over at [stats.se] where statistical questions are on-topic. – MrFlick Jul 20 '15 at 17:25
  • Thanks, I did post there yesterday. Apparently this is far more complex than I realized so I'm going to meet with some faculty members and see if it's something I strictly need to do. Thanks for the replies though. – Del Jul 21 '15 at 21:59

0 Answers0