0

我有以下模型:

Y_{it} = alpha_i + B1*weight_{it} + B2*Dummy_Foreign_{i} + B3*(weight*Dummy_Foreign)_ {it} + e_{it}

我对外国汽车重量对 Y 的影响感兴趣,并用各自的标准误差绘制相关系数跨分位数的演变图。也就是说,我需要看到系数(B1 + B3)的演变。我知道这是一种非线性效应,需要某种 delta 方法来获得方差-协方差矩阵,从而获得 (B1+B3) 的标准误差。

在我深入编写一个尝试执行此操作的程序之前,我想我会尝试询问是否有办法使用 grqreg 来执行此操作。如果 grqreg 无法做到这一点,请有人指导我如何开始编写代码来计算正确的标准误差并绘制分位数系数。

有关我正在尝试做的横截面示例,请参阅下面的代码。

  1. 我使用 grqred 来生成单独系数的演变(但我需要联合系数)——(B1+B3)演变的一张图及其各自的标准误差。

谢谢。体重的影响和体重与国外虚拟变量的交互作用。

(我在 Windows 10 上使用 Stata 14.1):

clear
sysuse auto
set scheme s1color

gen gptm = 1000/mpg
label var gptm "gallons / 1000 miles"

gen weight_foreign= weight*foreign
label var weight_foreign "Interaction weight and foreign car"

qreg gptm weight foreign weight_foreign , q(.5) 
grqreg  weight weight_foreign , ci ols olsci reps(40)  

*** Question 1: How to constuct the plot of the coefficient of interest?
4

1 回答 1

1

您的第二个问题在这里是题外话,因为它是统计的。试试 CV SE 网站或 Statalist。

以下是您可以在横截面中执行 (1) 的方法,使用marginsand marginsplot

clear
set more off
sysuse auto
set scheme s1color
gen gptm = 1000/mpg
label var gptm "gallons / 1000 miles"
sqreg gptm c.weight##i.foreign, q(10 25 50 75 95) reps(500) coefl
margins, dydx(weight) predict(outcome(q10)) predict(outcome(q25)) predict(outcome(q50)) predict(outcome(q75)) predict(outcome(q95)) at(foreign=(0 1)) 
marginsplot, xdimension(_predict) xtitle("Quantile") ///
legend(label(1 "Domestic") label(2 "Foreign")) ///
xlabel(none) xlabel(1 "Q10" 2 "Q25" 3 "Q50" 4 "Q75" 5 "Q95", add) ///
title("Marginal Effect of Weight By Origin") ///
ytitle("GPTM")

这会产生一个像这样的图表:

在此处输入图像描述

I didn't recast the CI here since it would look cluttered, but that would make it look more like your graph. Just add recastci(rarea) to the options.

Unfortunately, none of the panel quantile regression commands play nice with factor variables and margins. But we can hack something together. First, you can calculate the sums of coefficients with nlcom (instead of more natural lincom, which the lacks the post option), store them, and use Ben Jann's coefplot to graph them. Here's a toy example to give you the main idea where we will look at the effect of tenure for union members:

set more off
estimates clear
webuse nlswork, clear
gen tXu = tenure*union
local quantiles 1 5 10 25 50 75 90 95 99    // K quantiles that you care about
local models ""                             // names of K quantile models for coefplot to graph 
local xlabel ""                             // for x-axis labels
local j=1                                   // counter for quantiles
foreach q of numlist `quantiles' {
    qregpd ln_wage tenure union tXu, id(idcode) fix(year) quantile(`q')
    nlcom (me_tu:_b[tenure]+_b[tXu]), post
    estimates store me_tu`q'
    local models `"`models' me_tu`q' || "'
    local xlabel `"`xlabel' `j++' "Q{sub:`q'}""'
}
di "`models'
di `"`xlabel'"'
coefplot `models' /// 
, vertical bycoefs rescale(100) ///
xlab(none) xlabel(`xlabel', add) ///
title("Marginal Effect of Tenure for Union Members On Each Conditional Quantile Q{sub:{&tau}}", size(medsmall)) ///
ytitle("Wage Change in Percent" "") yline(0) ciopts(recast(rcap))

This makes a dromedary curve, which suggests that the effect of tenure is larger in the middle of the wage distribution than at the tails:

在此处输入图像描述

于 2016-08-10T05:04:02.010 回答