私はlmerモデルでいくつかの固定係数をテストしていますが、それ以降のプロセス(各変数の寄与率を計算する)でそのモデルを使用する必要があるため、 lmerModモデル。
私は次のエラーメッセージに
エラーオブジェクト@の頁の$ Xを変更しているに苦しんだワン:無効な交換:参照クラスのフィールド「X」は読み取り専用です
再現例を以下に:
#Load package and data
library(lme4)
data(iris)
#build the model
mod<-lmer(Sepal.Length~Petal.Length + offset(Petal.Width*1) + (1|Species),data=iris)
fixef(mod) #not showing the offset coefficient
#apply changes to mod to get fixef(mod) to work with new coefficient
[email protected] <- c([email protected],1) #because model was offset by 1*Petal.Width
[email protected]$X <- matrix(data.frame([email protected]$X, iris["Petal.Width"])) #causes the error
#check fixef:
fixef(mod) # should have Petal.Width at the end with a value of 1
は注意するには、次の
[fixef] :(https://github.com/lme4/lme4/blob/master/R/lmer.R#L876)!
- は、@ betaに(すでに正常に変更されています);
- はgetME(オブジェクト、 "X"):(https://github.com/lme4/lme4/blob/master/R/lmer.R#L1932)です。
私は彼らの変数名(直接lmerModを調整することができること)事前に
おかげでfixef係数に取得する別の方法に開いています!
感謝マルコ我々は例えば
[email protected]$X
の2番目の列を変更することができ、このように続い。これは完全にうまくいった –
こんにちはマルコ、おそらく解決策を提供することができます[**このlme4質問**](https://stackoverflow.com/questions/49120251/specification-of-a-multilevel-model-in-package- lme4-in-r)? – rnorouzian