# A non-linear regression model for within subject observations

I am trying to perform the equivalent of a repeated-measures ANOVA using data that have a non-linear relationship. There are two independent variables: Spacing between stimulus (10, 20, 35, 45, 60), and the number of the stimulus (3-6). The trials are presented in the same block in random order (e.g., trial1 -> 6 stimulus with spacing 20, trial2 -> 4 stimulus with spacing 45, trial3-> 3 stimulus with spacing 60 etc.). What I want to know is the extent the performance is affected by these two variables.

I checked this post: Equivalent to ANOVA for non-linear (quadratic) relationships

Basically, they did a multilevel modelling letting the intercept and coefficients vary by individuals.

Now my question is, can I do the same analysis separately for each level of the 2nd IV (ie, the number of stimulus). Or is it not correct to treat the the levels of the 2nd IV separately? To illustrate what I mean, here is an example:

• I would fit a GAMM. See, e.g., this paper for an introduction. – Roland Jun 5 '19 at 13:41

library("lmerTest")

This fits a linear mixed model for performance with a quadratic effect for spacing and interaction with stimulus, and random intercepts, and linear and quadratic random slopes. The p-values from the anova() function are based on the Satterthwaite's method for the denominator degrees of freedom.