When I try to run a model in mgcv I get the following error:
Error in while (mean(ldxx/(ldxx + ldss)) > 0.4) { :
missing value where TRUE/FALSE needed
My syntax is based on the 2019 paper 'Analyzing the Time Course of Pupillometric Data' by van Rij et al. This is the syntax I used:
m2.flanker <- bam(pupil_normed ~ condition
+ s(time, by=condition, k=20)
+ s(x_coord, y_coord)
+ s(time, id, bs='fs', m=1)
+ s(time, TRIAL_INDEX, bs='fs', m=1)
+ s(EVENT, bs='re')
+ s(time, EVENT, bs='re')
, data=dat.flank1, discrete=T)
I then run into the error posted above. I looked at the supplementary materials from the paper, and looked at the missigness/data structure and found it to be similar to mine (some missing data, but in the same places I had missing data). I tried to run the syntax provided with their data:
m5 <- bam(Pupil ~ Condition + s(Time, by=Condition, k=20)
+ s(Xgaze, Ygaze)
+ s(Time, Subject, bs='fs', m=1) + s(Time, Item, bs='fs', m=1)
+ s(Event, bs='re') + s(Time, Event, bs='re')
, data=dat0, discrete=TRUE)
I did not get any error. I'm unclear why I get the error when I run the model with my data, but not with the data the authors use. Also, the error is pretty clearly related to the EVENT factor in my data, if I remove it I don't get an error.