Extracting data used to make a smooth plot in mgcv

后端 未结 3 1377
我在风中等你
我在风中等你 2020-12-10 03:11

This thread from a couple of years ago describes how to extract data used to plot the smooth components of a fitted gam model. It works, but only when there is one smooth v

3条回答
  •  天命终不由人
    2020-12-10 03:56

    In addition to Gavin Simpson's brilliant answer, there is now also an R package called itsadug which provides several functions for visualizing GAMs fit with mgcv.

    Among these is plot_smooth (which according to the help 'plots the summed effects and optionally removes the random effects'). If I understand the documentation correctly this is close to Option 1 mentioned by Gavin Simpson.

    There is also get_modelterm which returns a list (or optionally, a data.frame) with estimates of the selected smooth term. This seems to be equivalent to Option 2 (or the values returned from plot.gam, but without the plotting).

提交回复
热议问题