开始使用免费开始使用

可视化汽车性能的不确定性

置信区间是评估模型拟合时非常重要的可视化标识。在这里,您将练习调整置信区间的外观,并对部分效应图的刻度进行变换。

本练习是课程的一部分

R 中的广义可加模型(GAM)非线性建模

查看课程

练习说明

  • 绘制使用 mpg 数据的模型(mod),只绘制 weight 的部分效应。将置信区间设置为带阴影,颜色为 "hotpink"
  • 再绘制一次 weight 的部分效应,这次使用 shift 参数按截距的取值平移刻度,并使用 seWithMean 参数将模型截距的不确定性也包含在内。

交互式实操练习

通过完成这段示例代码来试试这个练习。

library(mgcv)
# Fit the model
mod <- gam(hw.mpg ~ s(weight) + s(rpm) + s(price) + comp.ratio, 
           data = mpg, method = "REML")

# Plot the weight effect with colored shading
plot(mod, select = 1, ___)

# Make another plot adding the intercept value and uncertainty
plot(mod, select = 1, ___)
编辑并运行代码