'Want to get coefficients, s.e., and t-stat using gls but they are not showing up in output
I am having trouble making the coefficients from the regression show up. They appear to be blank in the section where they should appear.
Here is the code I am running:
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)
This is the output that I get but the coefficients, s.e. and t-stats are not showing up.
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
The title for coefficients shows up and they should usually be listed there, but they aren't. I can't figure out what is wrong with this.
Solution 1:[1]
I was not able to recreate your error. It looks like something unusual in your data is causing a problem. Can you try tweaking this example so that it raises the issue you see?
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
The output of summary is a list-like object, meaning you can extract components of the summary with $.
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
