回顾性地在模型摘要中包含因变量的名称

时间:2013-11-13 22:35:04

标签: r

我有一个名为“mylist”的列表,其中包含gam输出。第一个列表的摘要如下:

> summary(mylist[[1]][[1]])

Family: quasipoisson 
Link function: log 

Formula:
cardva ~ s(trend, k = 11 * 6, fx = T, bs = "cr") + s(temp_01,      k = 6, fx = F, bs = "cr") + rh_01 + as.factor(dow) + s(fluepi,     k = 4, fx = F, bs = "cr") + as.factor(holiday) + Lag(pm1010,    0)

Parametric coefficients:
                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)          3.1584139  0.0331388  95.309  < 2e-16 ***
rh_01                0.0005441  0.0004024   1.352  0.17639    
as.factor(dow)2      0.0356757  0.0127979   2.788  0.00533 ** 
as.factor(dow)3      0.0388823  0.0128057   3.036  0.00241 ** 
as.factor(dow)4      0.0107302  0.0129014   0.832  0.40561    
as.factor(dow)5      0.0243382  0.0128705   1.891  0.05867 .  
as.factor(dow)6      0.0277954  0.0128360   2.165  0.03040 *  
as.factor(dow)7      0.0275593  0.0127373   2.164  0.03053 *  
as.factor(holiday)1  0.0444349  0.0147219   3.018  0.00255 ** 
Lag(pm1010, 0)      -0.0010816  0.0042891  -0.252  0.80091    

在列出单列表后,我已经提取了第一个列表的线性项的系数:

> head(plist)
[[1]]
                         Estimate   Std. Error    t value    Pr(>|t|)
(Intercept)          3.1584139271 0.0331388386 95.3085280 0.000000000
rh_01                0.0005441175 0.0004024202  1.3521128 0.176392590
as.factor(dow)2      0.0356757100 0.0127979429  2.7876128 0.005327293
as.factor(dow)3      0.0388823055 0.0128056733  3.0363343 0.002405504
as.factor(dow)4      0.0107302325 0.0129013816  0.8317119 0.405606249
as.factor(dow)5      0.0243382447 0.0128704711  1.8910143 0.058672841
as.factor(dow)6      0.0277953708 0.0128359850  2.1654256 0.030396240
as.factor(dow)7      0.0275592574 0.0127372874  2.1636677 0.030531063
as.factor(holiday)1  0.0444348611 0.0147218816  3.0182868 0.002553265
Lag(pm1010, 0)      -0.0010816252 0.0042890866 -0.2521808 0.800910389

我的问题是:可以将因变量(在本例中为心脏)的名称包含在plist中吗?

我想要实现的是(故意减少输出)

cardva          Estimate   Std. Error    t value    Pr(>|t|)
(Intercept)          3.1584139271 0.0331388386 95.3085280 0.000000000
rh_01                0.0005441175 0.0004024202  1.3521128 0.176392590
as.factor(dow)2      0.0356757100 0.0127979429  2.7876128 0.005327293

                        Estimate   Std. Error    t value    Pr(>|t|) 
(Intercept)          3.1584139271 0.0331388386 95.3085280 0.000000000
rh_01                0.0005441175 0.0004024202  1.3521128 0.176392590
as.factor(dow)7      0.0275592574 0.0127372874  2.1636677 0.030531063
as.factor(holiday)1  0.0444348611 0.0147218816  3.0182868 0.002553265
cardva_Lag(pm1010, 0)      -0.0010816252 0.0042890866 -0.2521808 0.800910389

1 个答案:

答案 0 :(得分:1)

两个选项:为列表的节点命名,然后将它们打印为:

names(plist)[1] <- 'cardva'
plist[1]
$cardva
                         Estimate   Std. Error    t value    Pr(>|t|)
(Intercept)          3.1584139271 0.0331388386 95.3085280 0.000000000
rh_01                0.0005441175 0.0004024202  1.3521128 0.176392590
as.factor(dow)2      0.0356757100 0.0127979429  2.7876128 0.005327293
as.factor(dow)3      0.0388823055 0.0128056733  3.0363343 0.002405504
as.factor(dow)4      0.0107302325 0.0129013816  0.8317119 0.405606249
as.factor(dow)5      0.0243382447 0.0128704711  1.8910143 0.058672841
as.factor(dow)6      0.0277953708 0.0128359850  2.1654256 0.030396240
as.factor(dow)7      0.0275592574 0.0127372874  2.1636677 0.030531063
as.factor(holiday)1  0.0444348611 0.0147218816  3.0182868 0.002553265
Lag(pm1010, 0)      -0.0010816252 0.0042890866 -0.2521808 0.800910389

或者:

temp <- plist[[1]] 
rownames(temp)[nrow(temp)] <- paste0( "cardva_", rownames(temp)[nrow(temp)]  )