Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: lsmeans compatibility with mixed() and type 2 tests #121
    Elvio Blini
    Participant

    Yes, sorry. Actually, my solution is working for my data and models, but then with built-in data another one seem to pop-out…

    library(afex)
    
    sessionInfo()
     
    # R version 3.4.0 (2017-04-21)
    # Platform: x86_64-w64-mingw32/x64 (64-bit)
    # Running under: Windows >= 8 x64 (build 9200)
    # 
    # Matrix products: default
    # 
    # locale:
    #   [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
    # [4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    
    # 
    # attached base packages:
    #   [1] stats     graphics  grDevices utils     datasets  methods   base     
    # 
    # other attached packages:
    #   [1] afex_0.18-0      lsmeans_2.26-3   estimability_1.2 lme4_1.1-13      Matrix_1.2-9    
    # 
    # loaded via a namespace (and not attached):
    #   [1] zoo_1.8-0           modeltools_0.2-21   coin_1.2-1          reshape2_1.4.2      splines_3.4.0       lmerTest_2.0-33     lattice_0.20-35    
    # [8] colorspace_1.3-2    htmltools_0.3.6     stats4_3.4.0        mgcv_1.8-17         base64enc_0.1-3     survival_2.41-3     rlang_0.1.1        
    # [15] nloptr_1.0.4        foreign_0.8-69      RColorBrewer_1.1-2  multcomp_1.4-6      plyr_1.8.4          stringr_1.2.0       MatrixModels_0.4-1 
    # [22] munsell_0.4.3       gtable_0.2.0        htmlwidgets_0.9     mvtnorm_1.0-6       coda_0.19-1         codetools_0.2-15    knitr_1.16         
    # [29] latticeExtra_0.6-28 SparseM_1.77        quantreg_5.33       pbkrtest_0.4-7      parallel_3.4.0      htmlTable_1.9       TH.data_1.0-8      
    # [36] Rcpp_0.12.12        xtable_1.8-2        acepack_1.4.1       scales_0.4.1        backports_1.1.0     checkmate_1.8.3     Hmisc_4.0-3        
    # [43] gridExtra_2.2.1     digest_0.6.12       ggplot2_2.2.1       stringi_1.1.5       grid_3.4.0          tools_3.4.0         magrittr_1.5       
    # [50] sandwich_2.4-0      lazyeval_0.2.0      tibble_1.3.3        Formula_1.2-2       cluster_2.0.6       car_2.1-5           MASS_7.3-47        
    # [57] data.table_1.10.4   minqa_1.2.4         rpart_4.1-11        nnet_7.3-12         nlme_3.1-131        compiler_3.4.0 
    
    #example 1
    
    data("sk2011.2")
    
    # use only affirmation problems (S&K also splitted the data like this)
    sk2_aff <- droplevels(sk2011.2[sk2011.2$what == "affirmation",])
    
    # set up model with maximal by-participant random slopes 
    sk_m1 <- mixed(response ~ inference*type+(inference*type|id), sk2_aff, 
                   type= 2, method= "LRT")
    
    #fails
    lsmeans(sk_m1, ~type)
    # 
    # Error in array(seq_len(nrow(RG@linfct)), dims) : 
    #   'dims' cannot be of length 0
    # In addition: Warning message:
    #   In model.matrix.default(trms, m, contrasts.arg = contrasts) :
    #   problem with term 1 in model.matrix: no columns are assigned
    
    #same as before
    lsmeans(sk_m1$full_model[[1]], ~type)
    
    #fails again...
    lsmeans(tail(sk_m1$full_model, 1)[[1]], ~type)
     
    # NOTE: Results may be misleading due to involvement in interactions
    # Error in calculation of the Satterthwaite's approximation. The output of lme4 package is returned
    # Error in base::chol2inv(x, ...) : 'a' must be a numeric matrix
    
    in reply to: lsmeans compatibility with mixed() and type 2 tests #119
    Elvio Blini
    Participant

    Hi!

    Just to add up: in the case of multiple independent factors the work-around would be:

    
    lsmeans(tail(svv_models$full_model, 1)[[1]], specs = c("cond"))
    

    Correct?

    This would avoid this error:

    
    # Error in array(seq_len(nrow(RG@linfct)), dims) : 
    #   'dims' cannot be of length 0
    # In addition: Warning message:
    # In model.matrix.default(trms, m, contrasts.arg = contrasts) :
    #   problem with term 1 in model.matrix: no columns are assigned
    

    (I’ve switched to the github version but I still need this work-around when testing multiple IV, 🙂 )

    Best,
    Elvio

    in reply to: lsmeans compatibility with mixed() and type 2 tests #116
    Elvio Blini
    Participant

    Oh, I see! Thank you very much for your quick reply and fix!

Viewing 3 posts - 1 through 3 (of 3 total)