繁体   English   中英

想要使用 gls 获取系数、se 和 t-stat,但它们没有出现在 output 中

[英]Want to get coefficients, s.e., and t-stat using gls but they are not showing up in output

我无法显示回归的系数。 它们在它们应该出现的部分中似乎是空白的。

这是我正在运行的代码:

gls <- gls(prevm_adh ~ factor(alter_relation) + factor(group) + factor(sa.y) + factor(visno) + factor(female),
           corr = corCompSymm(form = ~ 1 | EgoID),
           data = ego_alter_data_regressions, # compound symmetry
           method = "ML",
           na.action = na.omit,
           control = list(singular.ok = TRUE))
summary(gls)

这是我得到的 output,但系数、se 和 t-stats 没有显示出来。

Generalized least squares fit by maximum likelihood
Model: prevm_adh ~ factor(alter_relation) + factor(group) + factor(sa.y) +      factor(visno) + factor(female) 
Data: ego_alter_data_regressions 
Correlation Structure: Compound symmetry
Formula: ~1 | EgoID 
Parameter estimate(s):
  Rho 
  0.6392145 
Coefficients:

Correlation: 
                         (Intr) fc(_)F fc(_)O fctr(g)2 fct()3 fc(.)1 fctr(v)1 fctr(v)2
factor(alter_relation)Friend -0.048                                                       
factor(alter_relation)Other  -0.023  0.191                                                
factor(group)2               -0.089 -0.002 -0.001                                         
factor(group)3               -0.223  0.005  0.002  0.241                                  
factor(sa.y)1                -0.322 -0.005 -0.004 -0.050   -0.465                         
factor(visno)1               -0.070  0.000  0.000  0.012   -0.003 -0.014                  
factor(visno)2               -0.068  0.000  0.001  0.013   -0.001 -0.008  0.574           
factor(female)1              -0.706  0.005  0.002 -0.283    0.128 -0.043 -0.001   -0.002  

Standardized residuals:
   Min         Q1        Med         Q3        Max 
-3.4338769 -0.1820022  0.1299327  0.6680821  1.6381633 

Residual standard error: 30.75149 
Degrees of freedom: 23765 total; 23756 residual

系数的标题出现了,它们通常应该列在那里,但事实并非如此。 我无法弄清楚这有什么问题。

我无法重现您的错误。 您的数据中似乎有一些不寻常的东西导致了问题。 您可以尝试调整此示例以引发您看到的问题吗?

library(nlme)
set.seed(436456)
ego_alter_data_regressions <- data.frame(
    alter_relation = factor(rep(c("Friend", "Other"), each = 12)), 
    group = factor(rep(1:3, times = 8)), 
    ego_id = factor(rep(1:12, times = 2)), 
    female = factor(0:1), 
    prevm_adh = rpois(24, 2))

gls1 <- gls(prevm_adh ~ factor(alter_relation) + factor(group) + factor(female),
    corr = corCompSymm(form = ~ 1 | ego_id),
    data = ego_alter_data_regressions, # compound symmetry
    method = "ML",
    na.action = na.omit,
    control = list(singular.ok = TRUE))
sg1 <- summary(gls1)
sg1
# Generalized least squares fit by maximum likelihood
# Model: prevm_adh ~ factor(alter_relation) + factor(group) + factor(female)
# Data: ego_alter_data_regressions 
# AIC      BIC    logLik
# 114.7237 122.9701 -50.36187
# 
# Correlation Structure: Compound symmetry
# Formula: ~1 | ego_id 
# Parameter estimate(s):
#     Rho 
# 0.1456311 
# 
# Coefficients:
#     Value Std.Error    t-value p-value
# (Intercept)                  2.1250000 1.0610047  2.0028186  0.0597
# factor(alter_relation)Other  0.3333333 0.8411910  0.3962635  0.6963
# factor(group)2               0.0000000 1.1929986  0.0000000  1.0000
# factor(group)3              -0.1250000 1.1929986 -0.1047780  0.9177
# factor(female)1              0.1666667 0.9740793  0.1711017  0.8660
# 
# Correlation: 
#     (Intr) fc(_)O fct()2 fct()3
# factor(alter_relation)Other -0.396                     
# factor(group)2              -0.562  0.000              
# factor(group)3              -0.562  0.000  0.500       
# factor(female)1             -0.459  0.000  0.000  0.000
# 
# Standardized residuals:
#     Min          Q1         Med          Q3         Max 
# -1.32345932 -0.62496690 -0.07352552  0.35712394  2.85699155 
# 
# Residual standard error: 1.983438 
# Degrees of freedom: 24 total; 19 residual

summary的 output 是一个类似列表的 object,这意味着您可以使用$提取摘要的组件。

names(sg1)
#  [1] "modelStruct"  "dims"        
#  [3] "contrasts"    "coefficients"
#  [5] "varBeta"      "sigma"       
#  [7] "apVar"        "logLik"      
#  [9] "numIter"      "groups"      
# [11] "call"         "method"      
# [13] "fitted"       "residuals"   
# [15] "parAssign"    "na.action"   
# [17] "corBeta"      "tTable"      
# [19] "BIC"          "AIC" 

sg1$coefficients
#                 (Intercept) 
#                2.125000e+00 
# factor(alter_relation)Other 
#                3.333333e-01 
#              factor(group)2 
#                3.896296e-16 
#              factor(group)3 
#               -1.250000e-01 
#             factor(female)1 
#                1.666667e-01 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM