2

I computed the following quantile regressions using the quantreg package

    qr_10 = rq(inno_DELTA ~ deDomains + R_and_D_pc + Pop_dens + Agr_GDP + Manufacturing_GDP + Service_GDP + Infr_Area_Percent + Res_pc + Debt_GDP + GOV_EXP_GDP + firms_total + factor(landkreis) + factor(jahr), tau = 0.10, data = df_ip_c)
    qr_25 = rq(inno_DELTA ~ deDomains + R_and_D_pc + Pop_dens + Agr_GDP + Manufacturing_GDP + Service_GDP + Infr_Area_Percent + Res_pc + Debt_GDP + GOV_EXP_GDP + firms_total + factor(landkreis) + factor(jahr), tau = 0.25, data = df_ip_c)
    qr_50 = rq(inno_DELTA ~ deDomains + R_and_D_pc + Pop_dens + Agr_GDP + Manufacturing_GDP + Service_GDP + Infr_Area_Percent + Res_pc + Debt_GDP + GOV_EXP_GDP + firms_total + factor(landkreis) + factor(jahr), tau = 0.5, data = df_ip_c)
    qr_75 = rq(inno_DELTA ~ deDomains + R_and_D_pc + Pop_dens + Agr_GDP + Manufacturing_GDP + Service_GDP + Infr_Area_Percent + Res_pc + Debt_GDP + GOV_EXP_GDP + firms_total + factor(landkreis) + factor(jahr), tau = 0.75, data = df_ip_c)
    qr_95 = rq(inno_DELTA ~ deDomains + R_and_D_pc + Pop_dens + Agr_GDP + Manufacturing_GDP + Service_GDP + Infr_Area_Percent + Res_pc + Debt_GDP + GOV_EXP_GDP + firms_total + factor(landkreis) + factor(jahr), tau = 0.95, data = df_ip_c)

I am trying to display these regressions using stargazer. The code I am trying to run is the following:

stargazer(qr_10,qr_25,qr_50,qr_75,qr_95, rq.se = "iid", type = "text", title="Regression Results" ,initial.zero = F,single.row=TRUE, out="table_quantile_regression.html")

However, I receive the following error message

Error in base::backsolve(r, x, k = k, upper.tri = upper.tri, transpose = transpose,  : 
  singular matrix in 'backsolve'. First zero in diagonal [421]

I am assuming that this error message has something to do with the standard error function rq.se in stargazer as for example summary(qr_10, se = "iid") works fine.

Does anybody have a solution for this problem? Thank you.

2 Answers2

1

I suppose it's due to your data. "singular matrix" indicating some problem with the regression. Minimal example works fine and stargazer supports quantreg:

library(quantreg)
library(stargazer)

stargazer(mtcars, type="text")

qr_10 = rq(mpg ~ factor(cyl) + disp, tau = 0.10, data = mtcars)
qr_25 = rq(mpg ~ factor(cyl) + disp, tau = 0.25, data = mtcars)
qr_50 = rq(mpg ~ factor(cyl) + disp, tau = 0.50, data = mtcars)
qr_75 = rq(mpg ~ factor(cyl) + disp, tau = 0.75, data = mtcars)
qr_95 = rq(mpg ~ factor(cyl) + disp, tau = 0.95, data = mtcars)

stargazer(qr_10,qr_25,qr_50,qr_75,qr_95, rq.se = "iid", type = "text", title="Regression Results", initial.zero = F,single.row=TRUE)
stargazer(qr_10,qr_25,qr_50,qr_75,qr_95, type = "text", title="Regression Results", initial.zero = F,single.row=TRUE)

Regression Results
=======================================================================================================
                                                Dependent variable:                                    
             ------------------------------------------------------------------------------------------
                                                        mpg                                            
                   (1)               (2)               (3)               (4)                (5)        
-------------------------------------------------------------------------------------------------------
factor(cyl)6 -2.462** (.992)   -2.105 (1.324)   -4.365*** (1.453) -8.598*** (1.605)  -14.011*** (1.024)
factor(cyl)8  -2.243 (1.735)   -2.608 (2.317)    -3.885 (2.542)   -11.437*** (2.809) -18.811*** (1.792)
disp         -.026*** (.006)   -.027*** (.009)   -.033*** (.009)     -.012 (.010)       .013* (.007)   
Constant     24.630*** (.858) 25.705*** (1.145) 29.916*** (1.256) 31.575*** (1.388)   33.011*** (.885) 
-------------------------------------------------------------------------------------------------------
Observations        32               32                32                 32                 32        
=======================================================================================================

Can you give more information or summary statistics for your data?

Check https://stats.stackexchange.com/questions/78022/cause-of-singularity-in-matrix-for-quantile-regression and related posts. Best regards

Marco
  • 2,368
  • 6
  • 22
  • 48
0

I have exactly the same issue now. If I use summary(rqregression, se= "iid") it works fine, but not with stargazer = (rqregression, rq.se="iid"). I also checked the thread from the first answer and try df %>% group_by(variables) %>% filter(n()==1) to remove duplicated rows, but I still got the same result. And I´m wondering if you have already solved this issue.

Fang
  • 23
  • 3