尝试修改lmer修复效果时出错:找不到函数;fixef<-&引用;

尝试修改lmer修复效果时出错:找不到函数;fixef<-&引用;,r,lme4,R,Lme4,为了进行功率分析,我想修改模型的固定效应系数,以测试不同效应大小下的功率。从主SIMR包pub(),我应该能够在使用以下代码模板运行模型后修改固定效果: fixef(model1)["x"] <- number 如果有人知道发生这种情况的原因,或者知道修改lmer模型对象中固定效应系数值的替代方法,我将非常感谢您的帮助 > sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw3

为了进行功率分析,我想修改模型的固定效应系数,以测试不同效应大小下的功率。从主SIMR包pub(),我应该能够在使用以下代码模板运行模型后修改固定效果:

fixef(model1)["x"] <- number
如果有人知道发生这种情况的原因,或者知道修改lmer模型对象中固定效应系数值的替代方法,我将非常感谢您的帮助

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] sjstats_0.18.0  lmerTest_3.1-2  lme4_1.1-23     Matrix_1.2-17   forcats_0.5.0  
 [6] stringr_1.4.0   dplyr_1.0.0     purrr_0.3.4     readr_1.3.1     tidyr_1.1.0    
[11] tibble_3.0.1    ggplot2_3.3.2   tidyverse_1.3.0

loaded via a namespace (and not attached):
 [1] httr_1.4.1          jsonlite_1.7.0      splines_3.6.0       modelr_0.1.8       
 [5] assertthat_0.2.1    statmod_1.4.34      blob_1.2.1          cellranger_1.1.0   
 [9] yaml_2.2.1          bayestestR_0.7.0    numDeriv_2016.8-1.1 pillar_1.4.4       
[13] backports_1.1.7     lattice_0.20-38     glue_1.4.1          rvest_0.3.5        
[17] minqa_1.2.4         colorspace_1.4-1    sandwich_2.5-1      pkgconfig_2.0.3    
[21] broom_0.5.6         haven_2.3.1         xtable_1.8-4        mvtnorm_1.1-1      
[25] scales_1.1.1        emmeans_1.4.7       generics_0.0.2      sjlabelled_1.1.6   
[29] ellipsis_0.3.1      TH.data_1.0-10      withr_2.2.0         cli_2.0.2          
[33] survival_3.2-3      magrittr_1.5        crayon_1.3.4        effectsize_0.3.1   
[37] readxl_1.3.1        estimability_1.3    fs_1.4.1            fansi_0.4.1        
[41] nlme_3.1-148        MASS_7.3-51.4       xml2_1.3.2          rsconnect_0.8.16   
[45] tools_3.6.0         hms_0.5.3           lifecycle_0.2.0     multcomp_1.4-13    
[49] munsell_0.5.0       reprex_0.3.0        compiler_3.6.0      rlang_0.4.6        
[53] grid_3.6.0          nloptr_1.2.2.1      parameters_0.8.0    rstudioapi_0.11    
[57] boot_1.3-22         gtable_0.3.0        codetools_0.2-16    DBI_1.1.0          
[61] sjmisc_2.8.5        R6_2.4.1            zoo_1.8-8           lubridate_1.7.9    
[65] knitr_1.29          performance_0.4.7   insight_0.8.5       stringi_1.4.6      
[69] Rcpp_1.0.4.6        vctrs_0.3.1         dbplyr_1.4.4        tidyselect_1.1.0   
[73] xfun_0.15           coda_0.19-3        


谢谢。

错误只是说明此功能未实现。当您说
fixef(mod)[“Petal.Width”]时,教程中的第一行代码是
library(simr)
。我在你的代码中看不到同样的东西。大概是
fixef非常感谢!
#Load package and data
library(lme4)
data(iris)

#build the model
mod<-lmer(Sepal.Length~Petal.Length + Petal.Width + (1|Species),
          data=iris)

fixef(mod)["Petal.Width"] #this code works
fixef(mod)["Petal.Width"] <- 1 #this code produces an error
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] sjstats_0.18.0  lmerTest_3.1-2  lme4_1.1-23     Matrix_1.2-17   forcats_0.5.0  
 [6] stringr_1.4.0   dplyr_1.0.0     purrr_0.3.4     readr_1.3.1     tidyr_1.1.0    
[11] tibble_3.0.1    ggplot2_3.3.2   tidyverse_1.3.0

loaded via a namespace (and not attached):
 [1] httr_1.4.1          jsonlite_1.7.0      splines_3.6.0       modelr_0.1.8       
 [5] assertthat_0.2.1    statmod_1.4.34      blob_1.2.1          cellranger_1.1.0   
 [9] yaml_2.2.1          bayestestR_0.7.0    numDeriv_2016.8-1.1 pillar_1.4.4       
[13] backports_1.1.7     lattice_0.20-38     glue_1.4.1          rvest_0.3.5        
[17] minqa_1.2.4         colorspace_1.4-1    sandwich_2.5-1      pkgconfig_2.0.3    
[21] broom_0.5.6         haven_2.3.1         xtable_1.8-4        mvtnorm_1.1-1      
[25] scales_1.1.1        emmeans_1.4.7       generics_0.0.2      sjlabelled_1.1.6   
[29] ellipsis_0.3.1      TH.data_1.0-10      withr_2.2.0         cli_2.0.2          
[33] survival_3.2-3      magrittr_1.5        crayon_1.3.4        effectsize_0.3.1   
[37] readxl_1.3.1        estimability_1.3    fs_1.4.1            fansi_0.4.1        
[41] nlme_3.1-148        MASS_7.3-51.4       xml2_1.3.2          rsconnect_0.8.16   
[45] tools_3.6.0         hms_0.5.3           lifecycle_0.2.0     multcomp_1.4-13    
[49] munsell_0.5.0       reprex_0.3.0        compiler_3.6.0      rlang_0.4.6        
[53] grid_3.6.0          nloptr_1.2.2.1      parameters_0.8.0    rstudioapi_0.11    
[57] boot_1.3-22         gtable_0.3.0        codetools_0.2-16    DBI_1.1.0          
[61] sjmisc_2.8.5        R6_2.4.1            zoo_1.8-8           lubridate_1.7.9    
[65] knitr_1.29          performance_0.4.7   insight_0.8.5       stringi_1.4.6      
[69] Rcpp_1.0.4.6        vctrs_0.3.1         dbplyr_1.4.4        tidyselect_1.1.0   
[73] xfun_0.15           coda_0.19-3        

## before manipulation
fixef(mod)
# (Intercept) Petal.Length  Petal.Width 
#  2.51329946   0.89385535  -0.02424226 

## manipulate    
mod@beta[names(fixef(mod)) %in% "Petal.Width"] <- 1

## after manipulation
fixef(mod)
# (Intercept) Petal.Length  Petal.Width 
#   2.5132995    0.8938554    1.0000000