简体   繁体   中英

Include a name of a dependent variable in model summary restrospectively

I have a list named "mylist" that contains gam outputs. Summary of the first list is the following:

> 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    

After unlisting the list I have extracted the coefficients of the linear terms for the first list:

> 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

My question is: it possible to include the names of the dependent variable (in this example cardiac) as part of the plist?

What I want to achieve is (output deliberately reduced)

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

or

                        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

Two options: Name the nodes of the list so they would then be printed as:

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

Or:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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