我在R Studio中为分位数回归绘制系数时遇到问题。这是我的代码:
plot(summary(rq(data = d, normalized_losses ~ price + highway_mpg + fuel_type, tau = c(0.1, 0.25, 0.5, 0.75, 0.9))))
不幸的是,它没有绘制(仅绘制)fuel_type,它是2个级别中的因子变量。出现此错误:
plot.window(...)中的错误:无限轴范围[GEPretty(-inf,inf,5)]
我尝试添加 ylim = c(-Inf,Inf),得到的内容如下:
plot(summary(rq(data = d,
normalized_losses ~ price + highway_mpg + fuel_type,
tau = c(0.1, 0.25, 0.5, 0.75, 0.9))), ylim=c(-Inf,Inf))
似乎可行,但由于 price 太小或 highway_mpg 太大,因此无法在图中看到系数。
这里的数据:
symboling normalized_losses make fuel_type aspiration num_of_doors body_style
1 2 164 audi 2 std four sedan
2 2 164 audi 2 std four sedan
3 1 158 audi 2 std four sedan
4 1 158 audi 2 turbo four sedan
5 2 192 bmw 2 std two sedan
6 0 192 bmw 2 std four sedan
drive_wheels engine_location wheel_base length width height curb_weight engine_type
1 fwd front 99.80 176.60 66.20 54.30 2337 ohc
2 4wd front 99.40 176.60 66.40 54.30 2824 ohc
3 fwd front 105.80 192.70 71.40 55.70 2844 ohc
4 fwd front 105.80 192.70 71.40 55.90 3086 ohc
5 rwd front 101.20 176.80 64.80 54.30 2395 ohc
6 rwd front 101.20 176.80 64.80 54.30 2395 ohc
num_of_cylinders engine_size fuel_system bore stroke compression_ratio horsepower
1 four 109 mpfi 3.19 3.40 10.00 102
2 five 136 mpfi 3.19 3.40 8.00 115
3 five 136 mpfi 3.19 3.40 8.50 110
4 five 131 mpfi 3.13 3.40 8.30 140
5 four 108 mpfi 3.50 2.80 8.80 101
6 four 108 mpfi 3.50 2.80 8.80 101
peak_rpm city_mpg highway_mpg price
1 5500 24 30 13950
2 5500 18 22 17450
3 5500 19 25 17710
4 5500 17 20 23875
5 5800 23 29 16430
6 5800 23 29 16925