问题标签 [random-effects]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
r - 无法估计差异中的差异 RE 模型(系统完全是奇异误差)
我正在尝试使用面板数据方法(池化、FE 和 RE)来估计 DiD 模型。该模型用于确定卡特尔的存在(E1
回归中的虚拟变量 -1
对于卡特尔时期和0
其他情况)是否影响所检查市场上鱼的消费价格(虚拟变量Cartel
-1
对于假定的卡特尔化市场,0
否则,有两个市场)总计。据我了解,在 DiD 回归中,我需要有一个方程E1
,Cartel
以及它们的交互项E1*Cartel
(以及一些控制变量 - FPI
(鱼价指数)和季度虚拟变量Q2
,Q3
和Q4
)。
这种结构可以很好地用于估计线性模型,但是当我尝试实际实现面板数据方法时,特别是 RE,R 给了我system is exactly singular
错误。如果我理解正确,这意味着两个虚拟变量完全共线。我测试了这个理论并得出结论,问题是由虚拟变量引起的Cartel
——当我将它添加到模型中时,它停止工作。我不明白为什么 - 如果这个变量实际上与另一个变量共线,那么常规lm
回归不应该也失败了吗?
任何意见是极大的赞赏。
这很好用:
这些模型也是如此:
但这给了我错误:
这是面板数据(用 转换index = c("Market", "Month)
):
structure(list(Market = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("RU", "UK"), class = "factor"),
Month = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L,
35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L,
59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L,
71L, 72L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L,
37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L,
49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L,
61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L
), .Label = c("2009-01-31", "2009-02-28", "2009-03-31", "2009-04-30",
"2009-05-31", "2009-06-30", "2009-07-31", "2009-08-31", "2009-09-30",
"2009-10-31", "2009-11-30", "2009-12-31", "2010-01-31", "2010-02-28",
"2010-03-31", "2010-04-30", "2010-05-31", "2010-06-30", "2010-07-31",
"2010-08-31", "2010-09-30", "2010-10-31", "2010-11-30", "2010-12-31",
"2011-01-31", "2011-02-28", "2011-03-31", "2011-04-30", "2011-05-31",
"2011-06-30", "2011-07-31", "2011-08-31", "2011-09-30", "2011-10-31",
"2011-11-30", "2011-12-31", "2012-01-31", "2012-02-29", "2012-03-31",
"2012-04-30", "2012-05-31", "2012-06-30", "2012-07-31", "2012-08-31",
"2012-09-30", "2012-10-31", "2012-11-30", "2012-12-31", "2013-01-31",
"2013-02-28", "2013-03-31", "2013-04-30", "2013-05-31", "2013-06-30",
"2013-07-31", "2013-08-31", "2013-09-30", "2013-10-31", "2013-11-30",
"2013-12-31", "2014-01-31", "2014-02-28", "2014-03-31", "2014-04-30",
"2014-05-31", "2014-06-30", "2014-07-31", "2014-08-31", "2014-09-30",
"2014-10-31", "2014-11-30", "2014-12-31"), class = "factor"),
Salmonoid = c(218.79, 225.98, 233.85, 239.88, 247.61, 256.19,
263.39, 265.7, 264.38, 261.32, 258.49, 257.18, 259.18, 262.27,
265.11, 266.43, 266.28, 266.95, 269.15, 270.19, 275.43, 280.21,
285.3, 292.06, 298.89, 301.78, 304.49, 307.23, 310.13, 310.77,
312.51, 311.66, 309.92, 308.76, 309.72, 310.08, 306.73, 307.17,
306.03, 305.09, 301.73, 299.08, 299.24, 300.39, 300.09, 299.19,
298.49, 299.38, 298.94, 299.72, 303.33, 305.38, 307.82, 309.52,
312.41, 318.07, 323.53, 326.11, 328.75, 332.44, 341.6, 347.65,
355.87, 363.61, 369.4, 372.36, 377.08, 386.36, 403.76, 418.74,
426, 445.29, 10.07, 11.69, 10.96, 11.77, 11.75, 11.28, 11.43,
11.4, 11.45, 11.53, 11.52, 11.45, 11.71, 12.74, 12.68, 13.04,
13.11, 13.72, 14.69, 14.6, 14.42, 15.29, 15.64, 15.83, 15.78,
15.66, 15.64, 14.47, 15.67, 15.55, 15.3, 14.9, 15.14, 15.75,
15.36, 14.5, 14.96, 16.39, 16.05, 15.87, 16.22, 15.69, 15.7,
16.13, 15.66, 15.96, 15.23, 16.19, 16.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3.4, 3.7, 4.2, 4.1, 4.2, 3.4, 3.4, 3.1, 3.3, 3.4,
3.5, 4.2, 4.6, 5, 5.2, 4.9, 5, 5.1, 4.6, 4.5, 4.3, 5, 5,
5.2, 5.2, 5.5, 5, 4.1, 3.7, 3.4, 3.1, 2.7, 3, 3.3, 3.2, 3.5,
3.7, 3.7, 3.8, 3.4, 3.4, 3.6, 3.4, 3.3, 3.5, 4.1, 4.6, 4.9,
5, 5.5, 5.6, 5.3, 5.6, 5.2, 4, 4.5, 4.7, 5.9, 5.8, 5.7, 5.3,
5.5, 4.8, 4.3, 4.7, 4, 4, 4.1, 4.7, 5), Price_Index = c(0.713298341,
0.736739152, 0.762396896, 0.78205588, 0.807257197, 0.835229681,
0.858703094, 0.866234147, 0.861930688, 0.851954488, 0.842728132,
0.838457275, 0.844977668, 0.855051674, 0.864310632, 0.868614091,
0.868125061, 0.870309393, 0.877481824, 0.880872429, 0.897955857,
0.913539595, 0.930133994, 0.952172921, 0.974440061, 0.983862028,
0.99269716, 1.001630098, 1.011084667, 1.013171193, 1.018843934,
1.016072768, 1.010400026, 1.006618198, 1.009747987, 1.010921657,
1, 1.001434486, 0.997717863, 0.994653278, 0.983699019, 0.975059499,
0.97558113, 0.979330356, 0.978352297, 0.97541812, 0.973135983,
0.976037557, 0.974603071, 0.977146024, 0.988915333, 0.995598735,
1.003553614, 1.009095948, 1.018517915, 1.036970626, 1.054771297,
1.063182604, 1.071789522, 1.083819646, 1.113683044, 1.133407231,
1.160206044, 1.185439963, 1.2043165, 1.213966681, 1.229354807,
1.259609428, 1.316336843, 1.365174584, 1.388843608, 1.451732794,
0.694482759, 0.806206897, 0.755862069, 0.811724138, 0.810344828,
0.777931034, 0.788275862, 0.786206897, 0.789655172, 0.795172414,
0.794482759, 0.789655172, 0.807586207, 0.87862069, 0.874482759,
0.899310345, 0.904137931, 0.946206897, 1.013103448, 1.006896552,
0.994482759, 1.054482759, 1.07862069, 1.091724138, 1.088275862,
1.08, 1.07862069, 0.997931034, 1.080689655, 1.072413793,
1.055172414, 1.027586207, 1.044137931, 1.086206897, 1.059310345,
1, 1.031724138, 1.130344828, 1.106896552, 1.094482759, 1.11862069,
1.082068966, 1.082758621, 1.112413793, 1.08, 1.100689655,
1.050344828, 1.116551724, 1.113793103, 1.00137931, 1.031034483,
1.002068966, 1.059310345, 1.082758621, 1.066206897, 1.068275862,
1.06137931, 1.133793103, 1.130344828, 1.126896552, 1.114482759,
1.17862069, 1.191034483, 1.131724138, 1.202758621, 1.182068966,
1.233793103, 1.192413793, 1.157931034, 1.18, 1.183448276,
1.155172414)), .Names = c("Market", "Month", "Salmonoid",
"E1", "E2", "E4", "E3", "Cartel", "Q2", "Q3", "Q4", "FPI", "Price_Index"
), row.names = c("RU-2009-01-31", "RU-2009-02-28", "RU-2009-03-31",
"RU-2009-04-30", "RU-2009-05-31", "RU-2009-06-30", "RU-2009-07-31",
"RU-2009-08-31", "RU-2009-09-30", "RU-2009-10-31", "RU-2009-11-30",
"RU-2009-12-31", "RU-2010-01-31", "RU-2010-02-28", "RU-2010-03-31",
"RU-2010-04-30", "RU-2010-05-31", "RU-2010-06-30", "RU-2010-07-31",
"RU-2010-08-31", "RU-2010-09-30", "RU-2010-10-31", "RU-2010-11-30",
"RU-2010-12-31", "RU-2011-01-31", "RU-2011-02-28", "RU-2011-03-31",
"RU-2011-04-30", "RU-2011-05-31", "RU-2011-06-30", "RU-2011-07-31",
"RU-2011-08-31", "RU-2011-09-30", "RU-2011-10-31", "RU-2011-11-30",
"RU-2011-12-31", "RU-2012-01-31", "RU-2012-02-29", "RU-2012-03-31",
"RU-2012-04-30", "RU-2012-05-31", "RU-2012-06-30", "RU-2012-07-31",
"RU-2012-08-31", "RU-2012-09-30", "RU-2012-10-31", "RU-2012-11-30",
"RU-2012-12-31", "RU-2013-01-31", "RU-2013-02-28", "RU-2013-03-31",
"RU-2013-04-30", "RU-2013-05-31", "RU-2013-06-30", "RU-2013-07-31",
"RU-2013-08-31", "RU-2013-09-30", "RU-2013-10-31", "RU-2013-11-30",
"RU-2013-12-31", "RU-2014-01-31", "RU-2014-02-28", "RU-2014-03-31",
"RU-2014-04-30", "RU-2014-05-31", "RU-2014-06-30", "RU-2014-07-31",
"RU-2014-08-31", "RU-2014-09-30", "RU-2014-10-31", "RU-2014-11-30",
"RU-2014-12-31", "UK-2009-01-31", "UK-2009-02-28", "UK-2009-03-31",
"UK-2009-04-30", "UK-2009-05-31", "UK-2009-06-30", "UK-2009-07-31",
"UK-2009-08-31", "UK-2009-09-30", "UK-2009-10-31", "UK-2009-11-30",
"UK-2009-12-31", "UK-2010-01-31", "UK-2010-02-28", "UK-2010-03-31",
"UK-2010-04-30", "UK-2010-05-31", "UK-2010-06-30", "UK-2010-07-31",
"UK-2010-08-31", "UK-2010-09-30", "UK-2010-10-31", "UK-2010-11-30",
"UK-2010-12-31", "UK-2011-01-31", "UK-2011-02-28", "UK-2011-03-31",
"UK-2011-04-30", "UK-2011-05-31", "UK-2011-06-30", "UK-2011-07-31",
"UK-2011-08-31", "UK-2011-09-30", "UK-2011-10-31", "UK-2011-11-30",
"UK-2011-12-31", "UK-2012-01-31", "UK-2012-02-29", "UK-2012-03-31",
"UK-2012-04-30", "UK-2012-05-31", "UK-2012-06-30", "UK-2012-07-31",
"UK-2012-08-31", "UK-2012-09-30", "UK-2012-10-31", "UK-2012-11-30",
"UK-2012-12-31", "UK-2013-01-31", "UK-2013-02-28", "UK-2013-03-31",
"UK-2013-04-30", "UK-2013-05-31", "UK-2013-06-30", "UK-2013-07-31",
"UK-2013-08-31", "UK-2013-09-30", "UK-2013-10-31", "UK-2013-11-30",
"UK-2013-12-31", "UK-2014-01-31", "UK-2014-02-28", "UK-2014-03-31",
"UK-2014-04-30", "UK-2014-05-31", "UK-2014-06-30", "UK-2014-07-31",
"UK-2014-08-31", "UK-2014-09-30", "UK-2014-10-31", "UK-2014-11-30",
"UK-2014-12-31"), class = c("pdata.frame", "data.frame"), index = structure(list(
Market = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
), .Label = c("RU", "UK"), class = "factor"), Month = structure(c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L,
27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L,
39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L,
51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L,
63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L,
28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L,
40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L,
52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L), .Label = c("2009-01-31",
"2009-02-28", "2009-03-31", "2009-04-30", "2009-05-31", "2009-06-30",
"2009-07-31", "2009-08-31", "2009-09-30", "2009-10-31", "2009-11-30",
"2009-12-31", "2010-01-31", "2010-02-28", "2010-03-31", "2010-04-30",
"2010-05-31", "2010-06-30", "2010-07-31", "2010-08-31", "2010-09-30",
"2010-10-31", "2010-11-30", "2010-12-31", "2011-01-31", "2011-02-28",
"2011-03-31", "2011-04-30", "2011-05-31", "2011-06-30", "2011-07-31",
"2011-08-31", "2011-09-30", "2011-10-31", "2011-11-30", "2011-12-31",
"2012-01-31", "2012-02-29", "2012-03-31", "2012-04-30", "2012-05-31",
"2012-06-30", "2012-07-31", "2012-08-31", "2012-09-30", "2012-10-31",
"2012-11-30", "2012-12-31", "2013-01-31", "2013-02-28", "2013-03-31",
"2013-04-30", "2013-05-31", "2013-06-30", "2013-07-31", "2013-08-31",
"2013-09-30", "2013-10-31", "2013-11-30", "2013-12-31", "2014-01-31",
"2014-02-28", "2014-03-31", "2014-04-30", "2014-05-31", "2014-06-30",
"2014-07-31", "2014-08-31", "2014-09-30", "2014-10-31", "2014-11-30",
"2014-12-31"), class = "factor")), .Names = c("Market", "Month"
), class = c("pindex", "data.frame"), row.names = c(NA, 144L)))
r - 在逻辑回归随机效应 GLMM 中绘制分类变量
首先是我的问题的一些背景:
我一直在处理一个相当大的动物从围栏中逃脱的数据集(跨越 6 个站点的 2000 多次观察,具有约 20 个分类/连续变量),并运行了一个逻辑回归 GLMM,其中站点作为随机效应。
回应:逃跑概率(1/0)
使用模型平均,我将事情缩小到两个变量(一个分类/一个连续),这两个变量分别是重要的,也是两者之间的相互作用。
分类预测变量:围场质量(3 级因子 = 1、2、3) 连续预测变量:先前逃生次数
我正在努力获得分类变量的信息图,并希望得到一些帮助。我想表明,随着圈地质量的变化,如果可能的话,逃跑的概率会随着某种趋势线而变化。
我已经为连续变量尝试了以下代码,这给了我所追求的:
但是,对于分类变量,我得到了一个相当无信息的输出:
如果有人知道如何获得带有趋势线或分类变量等价物的图,并且可能是连续和分类之间相互作用的图,将不胜感激。
注意。这是我在这个网站上的第一篇文章(虽然我在发帖之前已经搜索过这个问题的答案)而且我是 R 和统计建模的新手,所以如果有什么需要进一步解释的,请告诉我。
谢谢你。
cox-regression - 随机斜率 Cox 比例危险
我一直在尝试使用coxme
为我的模型中的每个协变量提取随机斜率。
我得到的是:
使用我自己的数据时,我经常得到:
是否有可能使用 包含随机斜率coxme
?
如果没有,是否有其他选择使用其他包?
r - 具有交叉随机效应的`nlme`
我正在尝试将交叉非线性随机效应模型拟合为这个问题中提到的线性随机效应模型以及使用该包的邮件列表帖子中提到的线性随机效应模型。但是,无论我尝试什么,我都会遇到错误。这是一个例子nlme
该lme
示例类似于“S 和 S-PLUS 中的混合效果模型”的第 163-166 页,只有 2 个随机效果而不是 3 个。
pandas - 存储回归系数,合并回数据框
我正在尝试估计一个随机效应模型,并存储这些系数。然后我想将它们合并到数据框以预测因变量。
每组都有一个随机效应系数。在数据框中,如果观察属于第 1 组,我希望在此处列出第 1 组系数。对于第 2 组中的观察,第 2 组系数等等。
我能够访问和存储系数。但我无法将它们合并回数据框。我不知道该怎么想。这是我到目前为止的代码:
我尝试以三种方式存储系数:
它们都有效,但没有一个让我将它们合并回原始数据框。我不确定是否使用字典或列表,或者通常如何考虑将这些系数合并回原始数据帧。
我将不胜感激任何建议。
r - 比较 nlme 和 lme4 之间随机截距和斜率无关的脚本
因此,对于随机混合效果,我正在制作两个包之间的脚本比较列表。
对于独立的随机截距和斜率,如果我在 lme4 包中使用以下代码,那么 nlme 中对应的脚本是什么?
另外,对于嵌套混合效果,它以与上述不同的方式计算随机效果,我的脚本是否正确?
和
太感谢了!
python - 需要对 Coef 进行澄清。和 St.Err。MixedLM 结果中的随机参数
我试图了解 Python statsmodel 包提供的混合线性模型的结果。我想避免我的数据分析和解释中的陷阱。问题在数据加载/输出代码块之后。
加载数据和拟合模型:
Q1。(a) Group Var 系数 (params) 究竟是什么?我以为是 Group Var (cov_params) 的方差,但默认输出与内置方法输出不匹配。
Q1。(b) “Group Var”参数(params)是什么意思?
Q2。(a) Group Var 的标准误差 (bse) 是什么意思?为什么默认输出中未报告 Group Var 估计值?不重要吗?
Q2。(b) 与方差标准误差 (bse_re) 有何不同?
Q3。为什么在summary() 中没有报告随机参数的t 值和p 值?
regression - 如何为 lme4 中的特定对比度指定随机斜率?
使用以下数据集...
现在假设事实证明,对于 IV1 级别 2 与 IV1 级别 1 的对比度,随机对象斜率仅存在差异。是否可以仅针对这种对比度拟合随机斜率?
lme4 - 随机结构如何影响固定效应的结果?
我想问一下线性混合模型。
固定变量的显着性随随机结构而变化。例如,假设有 5 个变量:RT(响应变量)、协变量变量 1(CV1)、CV2、IV1、IV2。除 RT 外,所有变量均为受试者内变量。
我想知道的是IV2和IV2的相互作用。
在这种情况下,我使用 lmer() 设置了两个模型。首先是:
第二个是:
当我分析这两个模型时,两个模型之间固定变量的重要性是不同的。例如,IV1 和 IV2 的交互作用在 m1 中显着,但在 m2 中不显着。
我知道设置主题截距意味着响应将与每个主题不同,并且为 IV1 设置主题斜率意味着 IV1 的效果将与每个主题不同。
但我不知道固定效应和随机效应之间的关系。考虑随机效应是什么意思?在控制协变量等其他随机效应的影响时,我可以将固定变量的估计结果解释为系数吗?
为什么固定效应的意义会随着上述两个模型的随机结构而改变?
感谢您的阅读,我希望有人能向我解释这些。