R 系数表在秩亏拟合中没有NA行;如何插入它们?

R 系数表在秩亏拟合中没有NA行;如何插入它们?,r,regression,permutation,linear-regression,lm,R,Regression,Permutation,Linear Regression,Lm,这不是我想要的。我也需要b:c行,在正确的位置。 我想从上面得到的输出示例如下: y <- summary(x)$coef[, "Pr(Prob)"] #(Intercept) b c d1 d2 # 0.09459459 1.00000000 0.26334520 0.63333333 0.38181818 # d3 e # 1.00000000

这不是我想要的。我也需要
b:c
行,在正确的位置。

我想从上面得到的输出示例如下:

y <- summary(x)$coef[, "Pr(Prob)"]

#(Intercept)           b            c           d1           d2 
# 0.09459459  1.00000000   0.26334520   0.63333333   0.38181818 
#         d3           e 
# 1.00000000          NA 

我还想拉出与每个变量对应的
Iter
列。谢谢。

lmp
基于
lm
summary。lmp
的行为也类似于
summary.lm
,因此我将首先使用
lm
进行说明,然后说明我们可以对
lmp
执行相同的操作


lm
summary.lm

阅读
?summary.lm
,注意以下返回值:

# (Intercept)           b            c    b:c           d1           d2 
#  0.09459459  1.00000000   0.26334520     NA   0.63333333   0.38181818 
#         d3            e 
# 1.00000000           NA 
当您有秩缺陷模型时,
NA
系数在系数表中被省略,它们被称为
别名
变量。考虑下面的小的、可重复的例子:

coefficients: a p x 4 matrix with columns for the estimated
              coefficient, its standard error, t-statistic and
              corresponding (two-sided) p-value.  Aliased coefficients are
              omitted.

     aliased: named logical vector showing if the original coefficients are
              aliased.

lmp
summary.lmp

什么都不需要改变

## an augmented matrix of `NA`
e <- matrix(nrow = length(d), ncol = ncol(b),
            dimnames = list(names(d), dimnames(b)[[2]]))
## fill rows for non-aliased variables
e[!d] <- b

#             Estimate Std. Error   t value  Pr(>|t|)
#(Intercept) 0.1295147  0.3142758 0.4121051 0.6910837
#xx          0.2706560  0.2669118 1.0140279 0.3402525
#zz                 NA         NA        NA        NA

lmp
基于
lm
summary。lmp
的行为也类似于
summary.lm
,因此我将首先使用
lm
进行说明,然后说明我们可以对
lmp
执行相同的操作


lm
summary.lm

阅读
?summary.lm
,注意以下返回值:

# (Intercept)           b            c    b:c           d1           d2 
#  0.09459459  1.00000000   0.26334520     NA   0.63333333   0.38181818 
#         d3            e 
# 1.00000000           NA 
当您有秩缺陷模型时,
NA
系数在系数表中被省略,它们被称为
别名
变量。考虑下面的小的、可重复的例子:

coefficients: a p x 4 matrix with columns for the estimated
              coefficient, its standard error, t-statistic and
              corresponding (two-sided) p-value.  Aliased coefficients are
              omitted.

     aliased: named logical vector showing if the original coefficients are
              aliased.

lmp
summary.lmp

什么都不需要改变

## an augmented matrix of `NA`
e <- matrix(nrow = length(d), ncol = ncol(b),
            dimnames = list(names(d), dimnames(b)[[2]]))
## fill rows for non-aliased variables
e[!d] <- b

#             Estimate Std. Error   t value  Pr(>|t|)
#(Intercept) 0.1295147  0.3142758 0.4121051 0.6910837
#xx          0.2706560  0.2669118 1.0140279 0.3402525
#zz                 NA         NA        NA        NA
也许从R3.5.0开始,我们可以在
coef()
中使用
complete=TRUE
,但我还没有测试这一点,因为我仍然在R3.4.4上,可能从R3.5.0开始,我们可以在
coef()
中使用
complete=TRUE
,但我还没有测试这一点,因为我仍然在R3.4.4上
e[, 2]  ## e[, "Iter"]
#(Intercept)          xx          zz 
#        241         241          NA 

e[, 3]  ## e[, "Pr(Prob)"]
#(Intercept)          xx          zz 
#  0.2946058   0.2946058          NA