pkofod / QuantileRegressions.jl

Quantile regression in Julia
Other
41 stars 17 forks source link

Standard errors different from R #55

Open pdeffebach opened 3 years ago

pdeffebach commented 3 years ago

The coefficients match those of R's "quantreg" but the standard errors do not. I have a dataset df that I can email you the replication data for

r$> rq(logwk ~ educ, tau = .5, data = df) %>% summary                                                     

Call: rq(formula = logwk ~ educ, tau = 0.5, data = df)

tau: [1] 0.5

Coefficients:
            Value     Std. Error t value   Pr(>|t|) 
(Intercept)   5.64624   0.02656  212.62115   0.00000
educ          0.06384   0.00200   31.90678   0.00000
julia> qreg(@formula(logwk ~ educ), df, .5)
StatsModels.TableRegressionModel{QuantileRegressions.QRegModel,Array{Float64,2}}

logwk ~ 1 + educ

Coefficients:
──────────────────────────────────────────────────────
             Quantile   Estimate    Std.Error  t value
──────────────────────────────────────────────────────
(Intercept)       0.5  5.64592    0.00808325   698.471
educ              0.5  0.0638774  0.000609826  104.747
──────────────────────────────────────────────────────

Would be great to pin down the source of these variations. They can't both be right!

pdeffebach commented 3 years ago

A friend of mine has access to Stata. The Julia output matches the Stata output

qreg logwk educ, q(.5)

 Raw sum of deviations 14405.89 (about 6.4515071)
  Min sum of deviations 13273.92                    Pseudo R2     =     0.0786

------------------------------------------------------------------------------
       logwk |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .0638774   .0006674    95.71   0.000     .0625693    .0651855
       _cons |   5.645916   .0088464   638.22   0.000     5.628577    5.663255
------------------------------------------------------------------------------
pkofod commented 3 years ago

Interesting. I think this might be a question of choice of method. There are different ways to obtain the standard errors, so maybe it's just that? I don't remember the default in Koenker's package, but I'm pretty sure it's possible to pick something close to ours.