0

我正在使用包 mgcv 运行 GAMM。该模型运行良好并给出了有意义的输出,但是当我使用 vis.gam(plot.type="persp") 我的图表如下所示: 在此处输入图像描述

为什么会这样?当我使用 vis.gam(plot.type="contour") 时,没有透明的区域。

这似乎不仅仅是热调色板的问题。当我更改“persp”图的配色方案时,也会发生同样的事情: persp 图,“topo”颜色

等高线图完全填充,而透视图在顶部仍然是透明的。数据:

      logcpue assnage distkm fsamplingyr
1  -1.5218399       7  3.490        2015
2  -1.6863990       4  3.490        2012
3  -1.4534337       6  3.490        2014
4  -1.5207723       5  3.490        2013
5  -2.4061258       2  3.490        2010
6  -2.5427262       3  3.490        2011
7  -1.6177367       3  3.313        1998
8  -4.4067192      10  3.313        2005
9  -4.3438054      11  3.313        2006
10 -2.8834031       7  3.313        2002
11 -2.3182512       2  3.313        1997
12 -4.1108738       1  3.235        2010
13 -2.0149030       3  3.235        2012
14 -1.4900912       6  3.235        2015
15 -3.7954892       2  3.235        2011
16 -1.6499840       4  3.235        2013
17 -1.9924302       5  3.235        2014
18 -1.2122716       4  3.189        1998
19 -0.6675703       3  3.189        1997
20 -4.7957905       7  3.106        1998
21 -3.8763958       6  3.106        1997
22 -1.2205021       4  3.073        2010
23 -1.9262374       7  3.073        2013
24 -3.3463891       9  3.073        2015
25 -1.7805862       2  3.073        2008
26 -3.2451931       8  3.073        2014
27 -1.4441139       5  3.073        2011
28 -1.4395389       6  3.073        2012
29 -1.6357552       4  2.876        2014
30 -1.3449091       5  2.876        2015
31 -2.3782225       3  2.876        2013
32 -4.4886364       1  2.876        2011
33 -2.6026897       2  2.876        2012
34 -3.5765503       1  2.147        2002
35 -4.8040211       9  2.147        2010
36 -1.3993664       5  2.147        2006
37 -1.2712250       4  2.147        2005
38 -1.8495790       7  2.147        2008
39 -2.5073795       1  2.034        2012
40 -2.0654553       4  2.034        2015
41 -3.6309855       2  2.034        2013
42 -2.2643639       3  2.034        2014
43 -2.2643639       6  1.452        2006
44 -3.3900241       8  1.452        2008
45 -4.9628446       2  1.452        2002
46 -2.0088240       5  1.452        2005
47 -3.9186675       1  1.323        2013
48 -4.3438054       2  1.323        2014
49 -3.5695327       3  1.323        2015
50 -1.6986690       7  1.200        2005
51 -3.2451931       8  1.200        2006
52 -0.9024016       4  1.200        2002

library(mgcv)
f1 <- formula(logcpue ~ s(assnage)+distkm)
m1 <- gamm(f1,random = list(fsamplingyr =~ 1),
                 method = "REML", 
                 data =ycsnew)
vis.gam(m1$gam,color="topo",plot.type = "persp",theta=180)
vis.gam(m1$gam,color="heat",plot.type = "persp",theta=180)
vis.gam(m1$gam,view=c("assnage","distkm"),
    plot.type="contour",color="heat",las=1)
vis.gam(m1$gam,view=c("assnage","distkm"),
    plot.type="contour",color="terrain",las=1,contour.col="black")
4

1 回答 1

1

vis.gam 的代码是这样的:

            surf.col[surf.col > max.z * 2] <- NA

我无法理解它在做什么,而且它似乎相当临时。颜色的 NA 值通常是透明的。如果您注释掉该行(并将新函数的环境分配为:

environment(vis.gam2) <- environment(vis.gam)

.... 你得到了表面的完整着色。

在此处输入图像描述

于 2017-01-30T19:25:33.817 回答