Home › forums › Mixed Models › warning: missing cells for some factors
 This topic has 3 replies, 2 voices, and was last updated 4 years, 10 months ago by henrik.

AuthorPosts


March 23, 2018 at 15:26 GMT+0000 #215statmerkurParticipant
When I work with numeric covariates instead of contrasts in
mixed()
I get the following warning message:In createDesignMat(rho) : missing cells for some factors (combinations of factors) care must be taken with type III hypothesis.
I think this is a false positive because setting the same contrasts via
set_sum_contrasts()
doesn’t produce any warnings:library(afex) data(sk2011.1) d < aggregate(response ~ id + inference, data = sk2011.1, FUN = mean) set_sum_contrasts() contrast_mat < contr.sum(4) d$c1 < contrast_mat[, 1][d$inference] d$c2 < contrast_mat[, 2][d$inference] d$c3 < contrast_mat[, 3][d$inference] summary(mixed(response ~ c1 + c2 + c3 + (1id), d)) # warning displayed summary(mixed(response ~ inference + (1id), d)) # runs without warning
Am I right in thinking that the warning can be ignored or is there something wrong with my contrast specification?

March 24, 2018 at 19:09 GMT+0000 #216henrikKeymaster
The question here really is what you want to achieve. The main goal of
mixed
is to provide tests of effects, such as maineffects or interactions (also called model terms). So splitting the variable into its part is somehow orthogonal to the intended goal. The reason this is not directly clear from your call is the use ofsummary
.summary
gives you output based on the parameters and not based on the terms, as the other functions that deal withmixed
objects such asnice
oranova
(or evenprint
). Invoking one of those also makes the difference between the two calls apparent:library(afex) set_sum_contrasts() data(sk2011.1) d < aggregate(response ~ id + inference, data = sk2011.1, FUN = mean) contrast_mat < contr.sum(4) d$c1 < contrast_mat[, 1][d$inference] d$c2 < contrast_mat[, 2][d$inference] d$c3 < contrast_mat[, 3][d$inference] m1 < mixed(response ~ c1 + c2 + c3 + (1id), d) nice(m1) # Mixed Model Anova Table (Type 3 tests, KRmethod) # # Model: response ~ c1 + c2 + c3 + (1  id) # Data: d # Effect df F p.value # 1 c1 1, 117 7.79 ** .006 # 2 c2 1, 117 0.67 .41 # 3 c3 1, 117 10.52 ** .002 #  # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1 m2 < mixed(response ~ inference + (1id), d) nice(m2) # Mixed Model Anova Table (Type 3 tests, KRmethod) # # Model: response ~ inference + (1  id) # Data: d # Effect df F p.value # 1 inference 3, 117 5.15 ** .002 #  # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
If, for some reason, you are actually interested in pvalues for the individual parameters (which seems quite questionable for factors with more than two levels as in the example), you can get this also via the
lmerTest
summary
method:lmerTest::summary(m2$full_model) # [...] # Fixed effects: # Estimate Std. Error df t value Pr(>t) # (Intercept) 79.141 2.495 39.000 31.725 < 2e16 *** # inference1 8.372 3.000 117.000 2.791 0.00614 ** # inference2 2.459 3.000 117.000 0.820 0.41395 # inference3 9.728 3.000 117.000 3.243 0.00154 ** #  # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Note that for this to work you need to invoke
set_sum_contrasts()
earlier. Alternatively, setset_data_arg = FALSE
. One final comment: You might also want to take a look at theper_parameter
argument. 
March 27, 2018 at 16:16 GMT+0000 #221statmerkurParticipant
I am indeed interested in the individual parameters as I have specific hypotheses for different a priori contrasts. Maybe using
contr.sum()
was not the best example to illustrate this. But thanks for reminding me on the fact thatafex
is designed to provide tests of (main)effects – it now became clear to me that using your package for this purpose seems to be inappropriate. However, when I useset_data_arg = FALSE
I still get the same results. 
March 27, 2018 at 16:30 GMT+0000 #222henrikKeymaster
There are several different ways to test prespecified contrasts. This can be done in
afex
in the way described here. As you correctly notice, the pvalues of the different methoda re identical and the warnings appear to be inconsequential.You could also fit the model with normal (i.e., sumtozero) contrasts and then setup the contrasts later via
emmeans
. There are surely further possibilities (e.g., fit the model withlmerTest::lmer
and usesummary
). All of those should give you the same results (as long as you use the same method for calculating the df).


AuthorPosts
 You must be logged in to reply to this topic.