1

我正在尝试估计和模拟各种模型。我可以安装许多模型,sapply但不知何故,我无法访问输出。

models <- sapply("accept.progov ~ ptot_dev+swacceptcn+(swacceptcn|coal.general)", FUN = function(X) lmer(X, data=dbq))

我已经做到了,我可以通过进一步应用来使用模型sapply,例如,模拟:

sims <- sapply(X = models , FUN = function(X) sim(X, n=10))

但是,现在我需要提取fixefand ranefof sims。通过打印models或者sims它们看起来很像lmer输出,但它们不是。在尝试访问固定效果时,我收到这样的错误消息,就像使用 lmer 输出一样,这似乎是合乎逻辑的:

sims@fixef
Error: trying to get slot "fixef" from an object of a basic class ("list") with no slots

class(sims)
[1] "list"

关于如何访问输出(或将其转换为能够访问它)的任何想法?

谢谢

这是输出sims

sims
$`accept.progov ~ ptot_dev+swacceptcn+(swacceptcn|coal.general)`
An object of class "sim.merMod"
Slot "fixef":
  (Intercept)   ptot_dev swacceptcn
 [1,]    71.26230 -0.5967700  -5.125157
 [2,]    72.31654 -0.3331660 -13.210371
 [3,]    72.73718 -0.3910768 -15.319903
 [4,]    68.60344 -0.5775278 -10.106682
 [5,]    70.36609 -0.3897952  -7.883180
 [6,]    70.11542 -0.3413212 -10.959867
 [7,]    73.26847 -0.4599989 -10.302523
 [8,]    73.46677 -0.4627529 -14.547429
 [9,]    69.99146 -0.5947487  -8.681075
 [10,]    71.97546 -0.4976680 -10.109415

Slot "ranef":
$coal.general
, , (Intercept)

              1            2         3          4           5           6          7          8         9
[1,] -0.3275480720 -10.93724811 12.692639  -3.727188  -0.2119881  1.63602645  1.4972587 -0.4007792  1.354840
[2,] -2.9357382258  -8.47344764  9.832591 -15.602822  -2.0867660 -3.32143496  7.1446528 -7.2902852 10.593827
[3,] -0.5738514837  -6.58777257  7.189278   3.272100  -3.7302182 -2.77115752  4.6410860 -6.9497532  7.013610
[4,]  0.0008799287  -9.42620987  7.733388  -8.888649  -2.7795506 -1.98193393 -3.1739529  2.4603618  1.307669
[5,]  1.5177874134 -10.51052960 10.816926  -4.103975  -8.2232044  0.43857146  4.5353983 -8.1371223 -5.734714
[6,]  0.3591081598  -4.71170518 11.391860 -15.928789 -10.3654403  5.13397114 -1.9557418  3.6573842  7.846707
[7,] -0.1520099025  -9.97569519  5.973820  -6.601445  -5.8213534 -5.97398796  9.1813633 12.0905868 -2.689435
[8,] -3.2966495558  -3.88700417 12.069134   3.972661  -1.3056792 -5.41674684 -0.7940412  3.3800106  6.113203
[9,]  0.9239716129  -0.03016792 -4.695256  -5.092695  -1.4194101  5.82820816  6.7456858  9.4024483  7.683213
[10,]  1.8038318596  -6.69924367  9.612527  -7.118014 -13.3545691  0.03555004  7.5745529  1.6765752  8.020667

, , swacceptcn

           1         2         3           4          5         6          7          8           9
[1,] -10.799839  7.400621  3.835463  -7.5630236  -4.112801 -1.108058  -9.648384  -1.729799  -0.5488257
[2,]  -4.962062  4.103715 11.493087   6.1079040  -4.432072  6.097044  -5.972890   5.072467  -2.7055490
[3,]  -3.831015  0.486487 13.724554 -16.0322440  -5.487974  6.453326  -1.208757  13.072152  -3.1340066
[4,]  -3.053745  8.054387 12.682886   2.8787329   3.365597  2.195597   4.271775   5.460537   2.9898383
[5,]  -8.098502  4.055499  3.944880  -3.8708456 -14.567725  3.413494 -10.604984  12.821358   7.1130135
[6,]  -6.626984  3.892675  7.205407   6.3425843   9.328326 -4.693105   5.304151  11.150812  -3.4270667
[7,] -13.920626  7.548634  9.682934  -5.3058276  -1.991851  4.429253 -16.905243 -10.927869  -2.0806977
[8,]  -3.863126  2.470756  9.284932 -20.1617879  -5.352519  8.871024  -1.122215  -1.211589  -0.1492944
[9,]  -7.229178 -5.695966 25.527378  -1.7627386  -8.622444 -2.557726  -8.459804  -7.526883  -3.7090101
[10,] -11.098350  3.598449  7.642130   0.2573062   2.701967  5.834333 -14.552764   4.590748 -12.1888232



Slot "sigma":
[1] 11.96711 11.93222 11.93597 11.35270 11.31093 11.23100 11.89647 11.62934 11.61448 11.74406
4

0 回答 0