无法适合正确的lme()

时间:2014-08-05 20:47:38

标签: r mixed-models

我想要一个混合效果模型,它允许我考虑不同地理位置之间的不等差异。具体来说,我希望将response预测为具有X的固定效果geo的函数作为随机效应。

以下是数据的样子:

         X      response       geo
1        4      5.521461     other
2        4      5.164786     other
3        4      5.164786     other
4        6      3.401197     other
5        5      4.867534     other
6        4      5.010635     other

地理列的唯一值:

[1] "other"                                   "Atlanta-Sandy Springs-Marietta, GA"      "Chicago-Naperville-Joliet, IL-IN-WI"     "Dallas-Fort Worth-Arlington, TX"        
[5] "Houston-Sugar Land-Baytown, TX"          "Los Angeles-Long Beach-Santa Ana, CA"    "Miami-Fort Lauderdale-Pompano Beach, FL" "Phoenix-Mesa-Glendale, AZ"              

以下是我尝试过的模型:

> lme0 <- lme(response ~ factor(predictor) , random = ~1|factor(geo), data = HC_hired)
> summary(lme0)
Linear mixed-effects model fit by REML
 Data: HC_hired 
       AIC     BIC    logLik
  54770.69 54836.3 -27377.34

Random effects:
 Formula: ~1 | factor(geo)
        (Intercept) Residual
StdDev:  0.08689381  0.66802

Fixed effects: response ~ factor(predictor) 
                      Value  Std.Error    DF  t-value p-value
(Intercept)        4.255531 0.04410213 26918 96.49264  0.0000
factor(predictor)2 0.022986 0.03336742 26918  0.68889  0.4909
factor(predictor)3 0.166341 0.03221410 26918  5.16361  0.0000
factor(predictor)4 0.299172 0.03194177 26918  9.36618  0.0000
factor(predictor)5 0.378645 0.03249053 26918 11.65402  0.0000
factor(predictor)6 0.472583 0.03664732 26918 12.89543  0.0000
 Correlation: 
                   (Intr) fct()2 fct()3 fct()4 fct()5
factor(predictor)2 -0.660                            
factor(predictor)3 -0.683  0.903                     
factor(predictor)4 -0.689  0.912  0.945              
factor(predictor)5 -0.679  0.897  0.930  0.940       
factor(predictor)6 -0.603  0.795  0.824  0.832  0.819

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-4.7047458 -0.3424262  0.1883132  0.7045260  2.1949313 

Number of Observations: 26931
Number of Groups: 8 

我的问题是输出没有为每个级别的地理位置指定随机效果。这样做的正确型号规范是什么?我没有运气,尝试过很多公式的排列。对整个过程的任何评论也是受欢迎的。非常感谢提前!


对评论的回应(强迫地理因素不会改变输出):

  

HC_hired $ geo&lt; - as.factor(HC_hired $ geo)   lme0&lt; - lme(响应〜因子(预测变量),随机= ~1 |因子(地理),数据= HC_hired)   摘要(lme0)

0 个答案:

没有答案