Reputation: 43
I am trying to run glmmLasso
to estimate a mixed model with the command:
glm1_final <- glmmLasso(Activity~Novelty + Valence + ROI, rnd =
list(Subject=~1), data = KNov, lambda=lambda[opt],switch.NR=F,final.re=TRUE)
This code is basically taken from demo("glmmLasso-soccer")
, but with my variables substituted in. Activity is a measure of brain activity, Novelty and Valence are categorical variables coding the type of stimulus used to elicit the response and ROI is a categorical variable coding three regions of the brain that we have sampled this activity from. Subject is an ID number for the individuals the data was sampled from (n=94). lambda[opt]
is being set in a previous step, although that previous step is giving me the errors in question as well, so I don't know if it is accurate.
I keep getting two warnings:
Warning messages: 1: In split.default((1:ncol(X))[-inotpen.which], ipen) : data length is not a multiple of split variable 2: In est.glmmLasso.RE(fix = fix, rnd = rnd, data = data, lambda = lambda, : Cluster variable should be specified as a factor variable!
The first only occurs if ROI is in the model. I haven't identified any change I can make to the model to make the second go away.
I have no idea what these warnings mean, and google hasn't turned up anything on them. I do still get estimates for my parameters, I just don't know if they are accurate, since I don't know what the warnings mean.
Anyone know what these warnings mean?
UPDATE:
I have uploaded an abreviated version of my data to: Google Drive
I have confirmed I still get the second error if I run the code:
KNov <- read.table("Nov_abr.txt", header = TRUE)
KNov$Subject <- factor(KNov$Subject)
library(glmmLasso)
glmmLasso(Activity~Novelty + Valence + ROI, rnd = list(Subject=~1), data = KNov, lambda=10,switch.NR=F,final.re=TRUE)
The KNov$Subject <- factor(KNov$Subject) did clear up the other error.
The version of R I have is: R version 3.3.0 (2016-05-03), Platform: "i386-w64-mingw32"
Upvotes: 2
Views: 2723
Reputation: 226522
You should use
KNov$Subject <- factor(KNov$Subject)
to get rid of the first warning, and as.factor(ROI)
in your fixed-effect formula, as documented (emphasis added below):
fix: a two-sided linear formula object describing the fixed-effects part of the model, with the response on the left of a ‘~’ operator and the terms, separated by ‘+’ operators, on the right. For categorical covariables use ‘as.factor(.)’ in the formula. Note, that the corresponding dummies are treated as a group and are updated blockwise
So
glmmLasso(Activity~Novelty + Valence + as.factor(ROI),
rnd = list(Subject=~1),
data = KNov, lambda=10,switch.NR=F,final.re=TRUE)
seems to work (I still get a warning, but I think that's because I'm using a tiny subset of the data). (This syntax is also illustrated in the"linear mixed model with categorical covariates" example in ?glmmLasso
.) Yes, it would be nice to get a more explicit warning message, but the answer is in the documentation ...
Upvotes: 5