okay should work out okay then-- so
- Yes or you can use the lmer() and lme4. There is another one but I don't remember off the top of my head I think it is just lme?
2.You have a nested structure so yes you need (1|sample/participant)
Did you plot rating score vs stim.level to see evidence of a quadratic relationship? If not try plotting to see-- i you do see a quadratic pattern then yes you should add stim.level quadratic effect by
model <- lmer (rating.score ~ stim.level + I(stim.level^2) factor + stim.level*factor +(1|sample/participant) , mydata)
To reply to the comment
so if you are fitting a parabola and not a line you are fitting the generic
y= a + b*x + c*x^2
so you need the linear and quadratic term so stim.level is the linear term and I(stim.level^2) would be the quadratic term. Try writing your model out on paper in equation form like
rating score = b_0 + b_1 * stim.level + b_2 *stim.level^2 + b.3*(stim.level*factor)
and if wanted you could have an interaction with the squared term but that might not be directly interpretable. 2) Remember you are fitting a parabola NOT a line http://biopt.ub.edu/_/rsrc/1257372769717/force-detection/equipartition-theorem/ex4%20X%20potential.jpg?height=315&width=420 something that looks like that. Did you plot stim.level against rating.score and see a quadratic relationship?
The only random part here is the individual. Both Time and Treatment are fixed parts. As I understand it, you want global (ie. fixed) estimates of the effect of
- Time
- Each level of Treatment (except for the reference level)
- The interaction between each level of Treatment (except for the
reference level) and Time.
The following models will give you that.
fm1 <- lmer(PosQ ~ Treatm * Time + (1|ID), data = analyses.4)
fm2 <- glmer(Conc ~ Treatm * Time + (1|ID), data = analyses.4, family = binomial)
That being said, you can get a random effect of time, ie. a random slope model where the effect of time varies between the individuals.
fm3 <- lmer(PosQ ~ Treatm * Time + (Time|ID), data = analyses.4)
fm4 <- glmer(Conc ~ Treatm * Time + (Time|ID), data = analyses.4, family = binomial)
This is possible since there is within-subject variation with respect to time. However, since there is no within-subject variation with respect to treatment, you cannot do the same for treatment.
Since there is no within-subject variation with respect to treatment, the effect of time in a random slope model is actually the deviance between the individual effect of the particular treatment that the indivdual received and the global estimate of Time, which would measure the average effect of the treatment that corresponds to the reference category of the variable Treatment.
You can use anova() to compare the models and test whether or not it is justified to let the effect of time vary by subject:
anova(fm1, fm3)
anova(fm2, fm4)
would do the testing you need.
Best Answer
The important question here is whether
visit
indicate a pre-during-post design, where you measure the chickens'mass
before, during and after the treatment. In this case, if you want to assess the effectiveness of the treatment option 2 would be the correct choice.However, additionally you might want to look at the interaction effect of
treatment
*condition
*visit
. If this interaction was significant it would tell you that the change inmass
over time (between the different visits) would differ between the treatments, i.e. whether the effectiveness of the treatment differs between conditions (dry vs. wet). Moreover, you might want to estimate a random slope for each chick, to see whether the effectiveness of the treatment varies across chicks and nests.In that case your model would be:
If the
treatment
was already administered and finished before the first visit, you should go with option 1.