简体   繁体   English

使用plot.gam标记参数项的标记轴

[英]labeling axis for parametric terms with plot.gam

I am trying to plot my gam results. 我正在尝试绘制我的游戏结果。 The plotting works very well for all the smooth terms (in my case terms 1 to 8) but if I want to plot parametric terms (from 9 onwards), I can't change the axis labels. 对于所有平滑项(在我的情况下为1到8),该绘制效果都很好,但是如果要绘制参数项(从9开始),则无法更改轴标签。 No matter if I use plot, plot.gam, termplot or text I can't do it. 无论我使用plot,plot.gam,termplot还是文本,我都无法做到。 Any tips? 有小费吗? Below is the code example 下面是代码示例

par(mfrow=c(3,3), oma=c(1,1,1,1),pty="s",mar=c(4.5,4.5,1,1)) 
# the first three graphs work perfectly
plot.gam(model$gam,select=1,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Water depth",ylab="") 
plot.gam(model$gam,select=2,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Bottom current speed",ylab="")
plot.gam(model$gam,select=3,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Substance",ylab="")
# this graph for the parametric term is plotted but I cannot change axis labels
plot.gam(model$gam,select=9,scale=0,pers=T,all.terms=T,shade=T,xlab="AIS",ylab="")

If you are using RStudio you can check the source code of plot.gam by hitting the F2 button. 如果您使用的是RStudio,则可以通过按F2按钮来检查plot.gam的源代码。 In R execute the plot.gam without brackets. 在R中执行不带括号的plot.gam Then you can find, that plot() is replaced by termplot() for some select values. 然后您会发现,对于某些select值, plot()termplot()代替。 Thus, to maipulate the x-axis labels you have to use xlabs instead of xlab . 因此,要操纵x轴标签,您必须使用xlabs而不是xlab

require(mgcv) 
pa <- c(1, rep(0, 9))
term_A <- runif(10, 9, 15)
term_B <- runif(10, 1, 25)
data <- as.data.frame(cbind(pa, term_A, term_B)) 
mod <- gam(pa ~ s(term_A, k=3) + term_B, family=binomial, data=data) 
summary(mod)
par(mfrow=c(2, 2)) 
# xlab=""
plot.gam(mod, select=1, all.terms=T, shade=T, xlab="your own lab title", ylab="") 
# xlabs=""
plot.gam(mod, select=2, all.terms=T, shade=T, xlabs="your own lab title", ylab="")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM