找回密码
 注册
查看: 5895|回复: 0

R语言:plot.gam()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-17 10:19:32 | 显示全部楼层 |阅读模式
plot.gam(mgcv)
plot.gam()所属R语言包:mgcv

                                        Default GAM plotting
                                         默认的GAM绘制

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Takes a fitted gam object produced by gam() and plots the  component smooth functions that make it up, on the scale of the linear predictor. Optionally produces term plots for parametric model components
注意到一个装有gam对象的由gam()“图顺利功能组件,使其上规模的线性预测,生产。可选参数模型组件生产的长期图


用法----------Usage----------


## S3 method for class 'gam'
plot(x,residuals=FALSE,rug=TRUE,se=TRUE,pages=0,select=NULL,scale=-1,
         n=100,n2=40,pers=FALSE,theta=30,phi=30,jit=FALSE,xlab=NULL,
         ylab=NULL,main=NULL,ylim=NULL,xlim=NULL,too.far=0.1,
         all.terms=FALSE,shade=FALSE,shade.col="gray80",
         shift=0,trans=I,seWithMean=FALSE,by.resids=FALSE,
         scheme=0,...)



参数----------Arguments----------

参数:x
a fitted gam object as produced by gam().
装gam对象由gam()生产。


参数:residuals
If TRUE then partial residuals are added to plots of 1-D smooths. If FALSE  then no residuals are added. If this is an array of the correct length then it is used as the array of  residuals to be used for producing partial residuals. If TRUE then the residuals are the working residuals from the IRLS iteration weighted by the IRLS weights. Partial residuals for a smooth term are the residuals that would be obtained by dropping the term concerned from the model, while leaving all other  estimates fixed (i.e. the estimates for the term plus the residuals).
如果TRUE然后添加部分残留的1-D曲线平滑。如果FALSE然后没有残留增加。如果这是一个正确的长度数组,那么它被用作阵列将用于生产偏残差残差。如果TRUE然后残差IRLS权重加权的IRLS迭代工作残差。偏残差是平稳任期从有关模型的长期下降,而离开固定所有其他的估计(即一词加上残差估计),将获得的残差。


参数:rug
when TRUE (default) then the covariate to which the plot applies is displayed as a rug plot at the foot of each plot of a 1-d smooth, and the locations of the covariates are plotted as points on the contour plot representing a 2-d smooth.  
True(默认),然后图适用的协将显示在各积1-D光滑,协变量的位置,绘制轮廓图较2点脚下的地毯图 - ð顺利。


参数:se
when TRUE (default) upper and lower lines are added to the 1-d plots at 2 standard errors above and below the estimate of the smooth being plotted while for 2-d plots, surfaces at +1 and -1 standard errors are contoured and overlayed on the contour plot for the estimate. If a positive number is supplied then this number is multiplied by the standard errors when calculating standard error curves or surfaces. See also shade, below.  
True(默认)上下行被添加到2上方和下方绘制顺利的人估计标准误差1-D图,而2-D图,轮廓和表面+1和-1的标准误差叠加等高线图上的估计。如果提供一个正数,那么这个数字乘以标准计算标准误差曲线或曲面时的错误。也看到shade,下面。


参数:pages
(default 0) the number of pages over which to spread the output. For example,  if pages=1 then all terms will be plotted on one page with the layout performed automatically.  Set to 0 to have the routine leave all graphics settings as they are.  
(默认为0)的页数来传播的输出。例如,如果pages=1然后所有条款将在一个页面上绘制的布局自动执行。常规离开,因为它们是所有图形设置,设置为0。


参数:select
Allows the  plot for a single model term to be selected for printing. e.g. if you just want the plot for the second smooth term set select=2.  
允许选择打印为一个单一的模式长期图。例如如果你只是想为顺利设置select=2第二任期的图。


参数:scale
set to -1 (default) to have the same y-axis scale for each plot, and to 0 for a  different y axis for each plot. Ignored if ylim supplied.
设置为-1(默认),为每个小区都有不同的Y轴相同的Y轴每个小区规模,为0。如果ylim提供的忽略。


参数:n
number of points used for each 1-d plot - for a nice smooth plot this needs to be several times the estimated  degrees of freedom for the smooth. Default value 100.
用于每个1-D的图点 - 一个很好的平稳的图,这需要多次自由估计的顺利度。默认值为100。


参数:n2
Square root of number of points used to grid estimates of 2-d functions for contouring.
用于电网估计轮廓的2-D功能点数量的平方根。


参数:pers
Set to TRUE if you want perspective plots for 2-d terms.
设置为TRUE如果你想为2-D条款的透视图。


参数:theta
One of the perspective plot angles.
之一透视图角。


参数:phi
The other perspective plot angle.
其他角度图角度。


参数:jit
Set to TRUE if you want rug plots for 1-d terms to be jittered.
如果你想为1-D抖动条款地毯图,设置为TRUE。


参数:xlab
If supplied then this will be used as the x label for all plots.
如果提供,那么这将被用来作为X标签的所有图。


参数:ylab
If supplied then this will be used as the y label for all plots.
如果提供,那么这将被用来作为所有图Ÿ标签。


参数:main
Used as title (or z axis label) for plots if supplied.
作为标题(或Z轴标签)如果提供的图。


参数:ylim
If supplied then this pair of numbers are used as the y limits for each plot.
如果提供,那么这对数字作为每个小区的Y限制。


参数:xlim
If supplied then this pair of numbers are used as the x limits for each plot.
如果提供,那么这对数字作为每个小区的X限制。


参数:too.far
If greater than 0 then this is used to determine when a location is too far from data to be plotted when plotting 2-D smooths. This is useful since smooths tend to go wild away from data. The data are scaled into the unit square before deciding what to exclude, and too.far is a distance  within the unit square.
如果大于0,那么这是用来确定位置太远数据绘制时绘制的2-D平滑。自平滑倾向于去野生远离数据,这是非常有用的。数据缩放到单位正方形,然后才决定排除什么,和too.far是一个单位正方形内的距离。


参数:all.terms
if set to TRUE then the partial effects of parametric model components are also plotted, via a call to termplot. Only terms of order 1 can be plotted in this way.
如果设置TRUE参数模型组件的部分影响也绘制,通过调用termplot。只有1阶,这种方式可以绘制。


参数:shade
Set to TRUE to produce shaded regions as confidence bands for smooths (not avaliable for parametric terms, which are plotted using termplot).
设置TRUE产生平滑的信心带(参数方面,这是使用termplot绘制avaliable)阴影区域。


参数:shade.col
define the color used for shading confidence bands.
定义为底纹的信心带使用的颜色。


参数:shift
constant to add to each smooth (on the scale of the linear predictor) before plotting. Can be useful for some diagnostics, or with trans.
不断添加平滑(线性预测的规模)之前绘制的每个。可能是有用的一些诊断,或用trans。


参数:trans
function to apply to each smooth  (after any shift), before plotting. shift and trans are occasionally useful as a means for getting plots on the response scale, when the model consists only of a single smooth.
功能适用于任何移位后顺利()绘制前,。 shift和trans偶尔有用的手段得到响应规模的图,当模型只包含一个单一的顺利。


参数:seWithMean
if TRUE the component smooths are shown with confidence  intervals that include the uncertainty about the overall mean. If FALSE then the  uncertainty relates purely to the centred smooth itself. An extension of the argument presented in Nychka (1988) suggests that TRUE results in better coverage performance, and this is also suggested by simulation.
如果TRUE组件平滑显示置信区间,其中包括关于总体均值的不确定性。如果FALSE然后不确定性涉及纯粹的中心顺利本身。延长在Nychka(1988)提出的论点表明,TRUE更好的覆盖性能结果,这也是模拟建议。


参数:by.resids
Should partial residuals be plotted for terms with by variables?  Usually the answer is no, they would be meaningless.
应部分残差绘制by变量?通常的答案是否定的,他们会变得毫无意义。


参数:scheme
Integer or integer vector selecting a plotting scheme for each plot. See details.
整数或整数向量选择为每个小区的图计划。查看详情。


参数:...
other graphics parameters to pass on to plotting commands.
其他图形参数传递给绘图命令。


Details

详情----------Details----------

Produces default plot showing the smooth components of a fitted GAM, and optionally parametric terms as well, when these can be handled by termplot.
生成默认图拟合自由亚齐运动的顺利组件,以及可选参数方面,当这些可以termplot的处理。

For smooth  terms plot.gam actually calls plot method functions depending on the  class of the smooth. Currently random.effects, Markov random fields (mrf),  Spherical.Spline  and  factor.smooth.interaction terms have special methods (documented in their help files),  the rest use the defaults described below.
为顺利plot.gam实际上是调用图法的功能取决于类的顺利。目前random.effects,马尔可夫随机场(mrf)Spherical.Spline和factor.smooth.interaction方面有特殊的方法(在他们的帮助文件中记载),其余使用下面描述的默认。

For plots of 1-d smooths, the x axis of each plot is labelled  with the covariate name, while the y axis is labelled s(cov,edf)  where cov is the covariate name, and edf the estimated (or user defined for regression splines)  degrees of freedom of the smooth. scheme == 0 produces a smooth curve with dashed curves  indicating 2 standard error bounds. scheme == 1 illustrates the error bounds using a shaded region.
图1-D平滑,每个小区的X轴协的名称与标记,而Y轴标记s(cov,edf) 其中cov是协的名称,edf估计(或自由的顺利回归样条定义的用户)度。 scheme == 0产生流畅的曲线与虚线的曲线表示2个标准误差范围。 scheme == 1说明使用阴影区域的误差范围。

For scheme==0, contour plots are produced for 2-d smooths with the x-axes labelled with the first covariate name and the y axis with the second covariate name. The main title of the plot is something like s(var1,var2,edf), indicating the variables of which the term is a function, and the estimated degrees of freedom for the term. When se=TRUE, estimator variability is shown by overlaying contour plots at plus and minus 1 s.e. relative to the main estimate. If se is a positive number then contour plots are at plus or minus se multiplied by the s.e. Contour levels are chosen to try and ensure reasonable separation of the contours of the different plots, but this is not always easy to achieve. Note that these plots can not be modified to the same extent as the other plot.
scheme==0,等高线图的2-D平滑第一协协第二名称的名称和Y轴与x轴标记。该图的主标题是像s(var1,var2,edf)的东西,表明其中长期是一个功能,并为长期的自由程度估计的变量。当se=TRUE,估计变异叠加在正负1本身的等高线图所示相对于主要的估计。如果se是一个正数,则等高线图,加上或减去se乘以硒等高层次选择尝试,并确保合理分离不同图的轮廓,但是这并不总是很容易实现。请注意,这些图不能被修改的其他图相同的程度。

For 2-d smooths scheme==1 produces a perspective plot, while scheme==2 produces a heatmap,  with overlaid contours.
对于2-D平滑scheme==1产生透视图,而scheme==2产生叠加轮廓的热图。

Smooths of more than 2 variables are not plotted, but see vis.gam.
超过2个变量平滑不绘制的,但看到vis.gam。

Fine control of plots for parametric terms can be obtained by calling termplot directly, taking care to use its terms argument.
调用termplot直接,照顾到使用它的terms参数,可以得到很好的控制参数条件的图。

Note that, if seWithMean=TRUE, the confidence bands include the uncertainty about the overall mean. In other words  although each smooth is shown centred, the confidence bands are obtained as if every other term in the model was  constrained to have average 0, (average taken over the covariate values), except for the smooth concerned. This seems to correspond more closely to how most users interpret componentwise intervals in practice, and also results in intervals with close to nominal (frequentist) coverage probabilities by an extension of Nychka's (1988) results.
请注意,如果seWithMean=TRUE,有信心带包括关于总体均值的不确定性。换句话说,虽然每个平稳所示为本,得到模型中的其他条款,如果每一个受到限制的平均信心带0,在协值(平均),除了为光滑关注。这似乎更加紧密地符合大多数用户如何解释在实践中的分支间隔,并且在接近标称(frequentist)Nychka的结果(1988年)的延伸覆盖概率区间的结果。

Sometimes you may want a small change to a default plot, and the arguments to plot.gam just won't let you do it.  In this case, the quickest option is sometimes to clone the smooth.construct and Predict.matrix methods for  the smooth concerned, modifying only the returned smoother class (e.g. to foo.smooth).  Then copy the plot method function for the original class (e.g. mgcv:::plot.mgcv.smooth), modify the source code to plot exactly as you want and rename the plot method function (e.g. plot.foo.smooth). You can then use the cloned  smooth in models (e.g. s(x,bs="foo")), and it will automatically plot using the modified plotting function.
有时你可能想以默认图的小变化,参数plot.gam只是不会让你这么做。在这种情况下,最快的选择有时是克隆smooth.construct和Predict.matrix方法有关的顺利,修改返回顺畅类(如到foo.smooth)。然后复制原班图法功能(例如mgcv:::plot.mgcv.smooth),修改源代码绘制完全一样,你想和重命名图法功能(如plot.foo.smooth)。然后,您可以使用模型中的克隆顺利(例如s(x,bs="foo")),它会自动绘制使用修改的绘图功能。


值----------Value----------

The function simply generates plots.
函数只是生成的图。


警告----------WARNING ----------

Note that the behaviour of this function is not identical to  plot.gam() in S-PLUS.
请注意,这个函数的行为是不相同的plot.gam(),S-PLUS。

Plots of 2-D smooths with standard error contours shown can not easily be customized.
平滑的2-D图不能轻易定制显示标准的错误轮廓。

The function can not deal with smooths of more than 2 variables!
该函数不能处理超过2个变量的平滑!


作者(S)----------Author(s)----------


Simon N. Wood <a href="mailto:simon.wood@r-project.org">simon.wood@r-project.org</a>

Henric Nilsson <a href="mailto:henric.nilsson@statisticon.se">henric.nilsson@statisticon.se</a> donated the code for the <code>shade</code> option.

The design is inspired by the S function of the same name described in
Chambers and Hastie (1993) (but is not a clone).




参考文献----------References----------


Journal of the American Statistical Association 83:1134-1143.
and Hall/CRC Press.

参见----------See Also----------

gam, predict.gam, vis.gam
gam,predict.gam,vis.gam


举例----------Examples----------


library(mgcv)
set.seed(0)
## fake some data...[#假冒一些数据...]
f1 <- function(x) {exp(2 * x)}
f2 <- function(x) {
  0.2*x^11*(10*(1-x))^6+10*(10*x)^3*(1-x)^10
}
f3 <- function(x) {x*0}

n<-200
sig2<-4
x0 <- rep(1:4,50)
x1 <- runif(n, 0, 1)
x2 <- runif(n, 0, 1)
x3 <- runif(n, 0, 1)
e <- rnorm(n, 0, sqrt(sig2))
y <- 2*x0 + f1(x1) + f2(x2) + f3(x3) + e
x0 <- factor(x0)

## fit and plot...[#适合和积...]
b<-gam(y~x0+s(x1)+s(x2)+s(x3))
plot(b,pages=1,residuals=TRUE,all.terms=TRUE,shade=TRUE,shade.col=2)
plot(b,pages=1,seWithMean=TRUE) ## better coverage intervals[#更好的覆盖区间]

## just parametric term alone...[#只是参数长期单独...]
termplot(b,terms="x0",se=TRUE)

## more use of color...[#更多的用色...]
op <- par(mfrow=c(2,2),bg="blue")
x <- 0:1000/1000
for (i in 1:3) {
  plot(b,select=i,rug=FALSE,col="green",
    col.axis="white",col.lab="white",all.terms=TRUE)
  for (j in 1:2) axis(j,col="white",labels=FALSE)
  box(col="white")
  eval(parse(text=paste("fx <- f",i,"(x)",sep="")))
  fx <- fx-mean(fx)
  lines(x,fx,col=2) ## overlay `truth' in red[#覆盖红色的真相]
}
par(op)

## example with 2-d plots, and use of schemes...[#2-D图,并计划使用的例子...]
b1 <- gam(y~x0+s(x1,x2)+s(x3))
op <- par(mfrow=c(2,2))
plot(b1,all.terms=TRUE)
par(op)
op <- par(mfrow=c(2,2))
plot(b1,all.terms=TRUE,scheme=1)
par(op)
op <- par(mfrow=c(2,2))
plot(b1,all.terms=TRUE,scheme=c(2,1))
par(op)


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-23 02:22 , Processed in 0.024609 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表