0

lmer を使用すると奇妙な動作が発生します: lmer を使用してフィットをオブジェクトに保存すると、たとえばfit0、lmer を使用すると、要約を見ることができます (出力は表示されません)。

>summary(fit0)

save.image() を使用してオブジェクトを保存し、セッションを閉じて再度開くと、要約は次のようになります。

>summary(fit0)
Error in diag(vcov(object, use.hessian = use.hessian))
  error in evaluating the argument 'x' in selecting a method for function 'diag': Error in object@pp$unsc() : object 'merPredDunsc' not found

モデルを再度実行すると、予想される要約が得られますが、セッションを閉じると失われます。
何が起こるのですか?このエラーを回避するにはどうすればよいですか?

手伝ってくれてありがとう。


環境とバージョン:
Windows 7
R バージョン 3.1.2 (2014-10-31)
GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601)/ESS


最小限の例を次に示します。

# j: cluster
# i[j]: i in cluster j
# yi[j] = zi[j] + N(0,1)
# zi[j] = b0j + b1*xi[j]
# b0j = g0 + u0j, u0j ~ N(0,sd0)
# b1 = const

library(lme4)

# Number of clusters (level 2)
N   <- 20
# intercept
g0 <- 1
sd0 <- 2
# slope
b1  <- 3
# Number of observations (level 1) for cluster j
nj <- 10
# Vector of clusters indices 1,1...n1,2,2,2,....n2,...N,N,....nN
j <- c(sapply(1:N, function(x) rep(x, nj)))
# Vector of random variable
uj <- c(sapply(1:N, function(x)rep(rnorm(1,0,sd0), nj)))
# Vector of fixed variable
x1 <- rep(runif(nj),N)
# linear combination
z <- g0 + uj + b1*x1
# add error
y <- z + rnorm(N*nj,0,1)
# Put all together
d0 <- data.frame(j, y=y, z=z,x1=x1, uj=uj)
head(d0)

# mixed model
fit0 <- lmer(y ~ x1 + (1|j), data = d0)
vcov(fit0)
summary(fit0)

save.image()

再起動してライブラリ lme4 を追加した後:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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

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

other attached packages:
[1] lme4_1.1-7     Rcpp_0.11.0    Matrix_1.1-2-2

loaded via a namespace (and not attached):
[1] compiler_3.1.2  grid_3.1.2      lattice_0.20-29 MASS_7.3-35    
[5] minqa_1.2.3     nlme_3.1-118    nloptr_1.0.4    splines_3.1.2  
[9] tools_3.1.2    
> 
4

0 に答える 0