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!