growth curve analysis - problems with model fit I'm very new to GCA so sorry in advance if the question is very basic. I have run an eye-tracking experiment in which participants look either at one of the elements or the other (so I have a binomial distribution). I have two fixed factors in my model:


*

*Type of relative clause (RC.type, with two levels)

*Animacy of the elements, whether they are alive or not (Condition, with three levels). 


Following Mirman's book "Growth Curve Analysis and Visualisation using R" and Fergusson's "R Workshop on Using Linear Models, Logistic Regression, and Growth Curve Analyses to Analyze Eye-tracking Data" (which can be found online) I fit a quasi-logistic regression model, with weight correction for the end-points. The code was the following (note, the data is called "jp"):
#preparation for logistic regression, creation of 3-level polinomy

t <- poly(unique(jp$timebin), 3)
jp[,paste("ot", 1:3, sep="")] <-t[jp$timebin, 1:3]

#Quasi-logistic regression
jp$elog <- with(jp,log((Agent_sum+0.5) / (N-Agent_sum+0.5)))
jp$wts <- with(jp,1/(Agent_sum+0.5) + 1/(N-Agent_sum+0.5))

m.full <- lmer(elog ~ (ot1+ot2+ot3)*Condition +(ot1+ot2+ot3)*RC.type+(ot1+ot2+ot3 | Subject) ,control=lmerControl(optimizer="bobyqa"),data=jp, weights=1/wts, REML=F)

I also played with a quartic level polynomial and with more complex random slopes.
When I checked the fit of my model, I see the following:
ggplot(jp, aes(x=Ms, y=elog, color=Condition))+facet_wrap(~RC.type)+
  stat_summary(fun.y=mean, geom="point") +
  stat_summary(aes(y=predict(m.full,jp,re.form=NA)), fun.y=mean, geom="line")

And this is the plot I obtain:

As you can see, the fit is not really good. There are several problems: 


*

*There are no differences in the predicted model for Condition, although the data is different, but more importantly, 

*There are no differences as well in the predicted line depending on RC.type, when the data itself is the opposite. The t-value of RC.type shows significant differences at the three levels. However, I'm guessing those significant differences don't mean anything, because the model is clearly not good. What am I missing? What is wrong with the model? Do I need to recode my fixed factors to number coding and center them, perhaps? Is there anything else?


Thank you very much in advance for your help!!
 A: So before diving into the solution, fair disclaimer that I do not possess the domain knowledge for your specific problem, I'm approaching it purely in reverse engineering mode.
Additional information that would help:


*

*What do ot1,ot2,ot3 or the timebin column contain/ represent?

*Do you wish to fit a model for each subpopulation of the data by Condition or simply want to include Condition effects in the overall model?


The reason I ask is that in your model building step, you have considered the effects of Condition and RC.type using the * operator, but the following indicates that you want the model to behave differently for each subpopulation split by RC.type.

There are no differences as well in the predicted line depending on RC.type, when the data itself is the opposite

To illustrate this point, in the following image I have created a model collection such that subpopulation by sex is taken separately (colored blue and salmon), in the other model, the effect of the sex is considered but the entire data is used (colored grey). You can see how for the simplest model, there are variations between the fits.
So if you want your model to follow RC.type more closely, since the data is completely opposite- you should build out model for each of the subpopulation.

Code to recreate plot:
library(dplyr)
library(gcookbook) # for the dataset
library(plyr)


fit_model <- function(data) {
  lm(heightIn ~ ageYear + weightLb, data = data)
}

fit <- dlply(heightweight, .(sex), fit_model)

fpredicted <- predict(fit[[1]])
mpredicted <- predict(fit[[2]])

# TO DO: find a better way to combine
heightweight$predicted <- t(cbind(t(fpredicted), t(mpredicted)))
heightweight$predictedeffects <- 
  predict(lm(heightIn ~ ageYear + weightLb*sex, heightweight))

ggplot(heightweight, aes(x=weightLb, y=heightIn, color=sex)) + 
  facet_grid(.~sex) + geom_point() +
  geom_line(aes(y = predictedeffects), color='grey60') +
  geom_line(aes(y=predicted)) 

