簡體   English   中英

如何將 stargazer/xtable 與 plm 包中的 pggls 對象一起使用?

[英]How to use stargazer/xtable with pggls objects from the plm package?

我正在嘗試使用xtablestargazer將某些回歸的輸出轉換為乳膠。 我以前從來沒有遇到過問題,多元回歸的結果整齊地組織在乳膠表中。 我正在使用Fixed Effects FGLS 因此,我使用命令pggls而不是plm (來自包plm )。 顯然,該命令的使用是創建這種類型的對象, c("pggls", "panelmodel")

summary(fgls_fixed4)
 Within model

Call:
pggls(formula = YNCI ~ ST_CUM_NCI + ST_PUBS - ST_CLOSENESS + 
    ST_DEGREE + ST_BETWEENNESS + ST_EIGEN_CENTRALITY - ST_STRUC_HOLE - 
    ST_TRANSITIVITY + ST_BETWEENNESS:ST_TRANSITIVITY + ST_N_INST + 
    ST_E_INST + ST_N_DISC + ST_E_DISC - ST_INT_RATIO + GEN + 
    ST_AGE + ST_P_CUM + ST_P_LAG, data = pdata, model = "within")

Unbalanced Panel: n=15631, T=1-11, N=58585

Residuals
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-15.15481  -0.20764  -0.01673   0.00000   0.14333  21.63646 

Coefficients
                                 Estimate Std. Error   z-value  Pr(>|z|)    
ST_CUM_NCI                     -0.7775398  0.0050180 -154.9512 < 2.2e-16 ***
ST_PUBS                         0.1503133  0.0029285   51.3279 < 2.2e-16 ***
ST_DEGREE                      -0.0926861  0.0025087  -36.9451 < 2.2e-16 ***
ST_BETWEENNESS                  0.0316749  0.0027807   11.3909 < 2.2e-16 ***
ST_EIGEN_CENTRALITY             0.0230166  0.0025138    9.1560 < 2.2e-16 ***
ST_N_INST                       0.1784619  0.0040321   44.2605 < 2.2e-16 ***
ST_E_INST                      -0.0426594  0.0036798  -11.5927 < 2.2e-16 ***
ST_N_DISC                      -0.1026538  0.0057513  -17.8489 < 2.2e-16 ***
ST_E_DISC                       0.0810644  0.0060749   13.3441 < 2.2e-16 ***
ST_AGE                         -0.2246429  0.0246820   -9.1015 < 2.2e-16 ***
ST_P_CUM                        0.3234620  0.0129471   24.9834 < 2.2e-16 ***
ST_P_LAG                        0.0102976  0.0037214    2.7672  0.005655 ** 
ST_BETWEENNESS:ST_TRANSITIVITY  0.0396359  0.0040663    9.7475 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Total Sum of Squares: 53634
Residual Sum of Squares: 23619
Multiple R-squared: 0.55962
> stargazer(fgls_fixed4)

% Error: Unrecognized object type.
> class(fgls_fixed4)
[1] "pggls"      "panelmodel"

我在這里找到了一個解決方案: http ://tarohmaru.web.fc2.com/R/ExerciseDiagnostics.html 在運行 texreg 之前,您需要運行下面的代碼。 它對我有用。 運行下面的代碼后使用 texreg。


    extract.pggls <- function (model, include.rsquared = TRUE, include.adjrs = TRUE, 
        include.nobs = TRUE, ...) 
    {
s <- summary(model, ...)
coefficient.names <- rownames(s$CoefTable)
coefficients <- s$CoefTable[, 1]
standard.errors <- s$CoefTable[, 2]
significance <- s$CoefTable[, 4]
rs <- s$rsqr
n <- length(s$resid)
gof <- numeric()
gof.names <- character()
gof.decimal <- logical()
if (include.rsquared == TRUE) {
    gof <- c(gof, rs)
    gof.names <- c(gof.names, "R$^2$")
    gof.decimal <- c(gof.decimal, TRUE)
}
if (include.nobs == TRUE) {
    gof <- c(gof, n)
    gof.names <- c(gof.names, "Num. obs.")
    gof.decimal <- c(gof.decimal, FALSE)
}
tr <- createTexreg(coef.names = coefficient.names, coef = coefficients, 
    se = standard.errors, pvalues = significance, gof.names = gof.names, 
    gof = gof, gof.decimal = gof.decimal)
return(tr)
    }

    setMethod("extract", signature = className("pggls", "plm"),
      definition = extract.pggls)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM