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

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

[复制链接]
发表于 2012-2-16 22:02:06 | 显示全部楼层 |阅读模式
qq.gam(mgcv)
qq.gam()所属R语言包:mgcv

                                        QQ plots for gam model residuals
                                         GAM模型残差的QQ图

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

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

Takes a fitted gam object produced by gam() and produces QQ plots of its residuals (conditional on the fitted model coefficients and scale parameter). If the model distributional assumptions are met then usually these plots should be close to a straight line (although discrete data can yield marked random departures from this line).
注意到一个装有gam对象gam()和生产其残差(有条件的拟合模型系数和尺度参数)的QQ图。如果满足分布假设模型,然后通常这些图应该是接近一条直线(虽然可以产生离散数据标记此行随机班次)。


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


qq.gam(object, rep=0, level=.9,s.rep=10,
       type=c("deviance","pearson","response"),
       pch=".", rl.col=2, rep.col="gray80", ...)



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

参数:object
a fitted gam object as produced by gam() (or a glm object).
装gamgam()(或glm对象)对象作为生产。


参数:rep
How many replicate datasets to generate to simulate quantiles of the residual distribution.  0 results in an efficient simulation free method for direct calculation, if this is possible for the object family.
许多复制数据集如何产生的残余分布模拟位数。 0结果在一个有效的模拟直接计算方法,如果这是可能的对象家庭。


参数:level
If simulation is used for the quantiles, then reference intervals can be provided for the QQ-plot, this specifies the level.  0 or less for no intervals, 1 or more to simply plot the QQ plot for each replicate generated.
如果模拟使用的位数,然后参考区间可以提供的QQ图,这个指定的水平。 1 0或没有间隔,或更简单地绘制为每个生成的复制QQ图。


参数:s.rep
how many times to randomize uniform quantiles to data under direct computation.
多少次随机统一下直接计算的数据位数。


参数:type
what sort of residuals should be plotted?  See residuals.gam.
什么样的残差应绘制?看到residuals.gam。


参数:pch
plot character to use. 19 is good.
使用图字符。 19是良好的。


参数:rl.col
color for the reference line on the plot.
图参考线的颜色。


参数:rep.col
color for reference bands or replicate reference plots.
颜色为参考波段或复制参考图。


参数:...
extra graphics parameters to pass to plotting functions.
额外的图形参数传递给绘图功能。


Details

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

QQ-plots of the the model residuals can be produced in one of two ways. The cheapest method generates reference quantiles by  associating a quantile of the uniform distribution with each datum, and feeding these uniform quantiles into the quantile function associated with each datum. The resulting quantiles are then used in place of each datum to generate approximate quantiles of residuals. The residual quantiles are averaged over s.rep randomizations of the uniform quantiles to data.
可以制作的模型残差的QQ图两种方式之一。最便宜的方法产生关联的每个数据均匀分布的分位数,并送入每个数据的位数功能,这些统一的位数参考位数。每个基准的地方产生的位数,然后用产生的残差近似位数。剩余位数平均s.rep随机化的数据位数统一。

The second method is to use direct simulatation. For each replicate, data are simulated from the fitted model, and the corresponding residuals computed. This is repeated rep times. Quantiles are readily obtained from the empirical distribution of residuals so obtained. From this method reference bands are also computable.  
第二种方法是使用直接simulatation。每个重复,数据拟合模型模拟,计算相应的残差。这是重复rep倍。很容易获得经验,这样得到的残差分布的分位数。从这个方法参考乐队也可计算。

Even if rep is set to zero, the routine will attempt to simulate quantiles if no quantile function is available for the family. If no random deviate generating function family is available (e.g. for the quasi families), then a normal QQ-plot is produced. The routine conditions on the fitted model coefficents and the scale parameter estimate.
即使rep设置为零,程序将尝试模拟位数,如果没有分量的功能是可用于家庭。如果没有随机的偏离产生家庭功能可用(例如准家庭),然后正常的QQ图制作。拟合模型系数和尺度参数估计的例行条件。

The plots are very similar to those proposed in Ben and Yohai (2004), but are substantially cheaper to produce (the interpretation of  residuals for binary data in Ben and Yohai is not recommended).  
在本和Yohai的(2004)提出的图非常相似,但大大便宜的生产(不建议残差Ben和Yohai的二进制数据的解释)。

Note that plots for raw residuals from fits to binary data contain almost no useful information  about model fit. Whether the residual is negative or positive is decided by whether the response is zero or one. The magnitude of the  residual, given its sign, is determined entirely by the fitted values. In consequence only the most gross violations of the model  are detectable from QQ-plots of residuals for binary data. To really check distributional assumptions from residuals for binary data you have to be able to group the data somehow.  Binomial models other than binary are ok.  
请注意,从千篇一律的原始二进制数据的残差图中几乎没有有用的信息模型的拟合。是否残留是正面或负面的反应是否是零或一个决定。残余的幅度,给它的符号,完全取决于由拟合值。因而只有模型的最严重侵犯QQ残差图可检测到的二进制数据。真正检查从残差分布假设为二进制数据,你必须要能够以某种方式对数据进行分组。比二进制其他二项式模型是确定的。


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


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



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




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

choose.k,  gam, mgcv, magic
choose.k,gam,mgcv,magic


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



library(mgcv)
## simulate binomial data...[#模拟二项式数据...]
set.seed(0)
n.samp <- 400
dat <- gamSim(1,n=n.samp,dist="binary",scale=.33)
p &lt;- binomial()$linkinv(dat$f) ## binomial p[#二项式带够]
n &lt;- sample(c(1,3),n.samp,replace=TRUE) ## binomial n[#二项式列印]
dat$y <- rbinom(n,n,p)
dat$n <- n

lr.fit <- gam(y/n~s(x0)+s(x1)+s(x2)+s(x3)
             ,family=binomial,data=dat,weights=n,method="REML")

par(mfrow=c(2,2))
## normal QQ-plot of deviance residuals[#正常的QQ偏差残差图]
qqnorm(residuals(lr.fit),pch=19,cex=.3)
## Quick QQ-plot of deviance residuals[#快速的QQ偏差残差图]
qq.gam(lr.fit,pch=19,cex=.3)
## Simulation based QQ-plot with reference bands [#仿真基于参考波段的QQ图]
qq.gam(lr.fit,rep=100,level=.9)
## Simulation based QQ-plot, Pearson resids, all[#模拟QQ的图,皮尔逊resids,所有]
## simulated reference plots shown...  [#模拟参考图所示...]
qq.gam(lr.fit,rep=100,level=1,type="pearson",pch=19,cex=.2)

## Now fit the wrong model and check....[#现在适应了错误的模型,并检查......]

pif <- gam(y~s(x0)+s(x1)+s(x2)+s(x3)
             ,family=poisson,data=dat,method="REML")
par(mfrow=c(2,2))
qqnorm(residuals(pif),pch=19,cex=.3)
qq.gam(pif,pch=19,cex=.3)
qq.gam(pif,rep=100,level=.9)
qq.gam(pif,rep=100,level=1,type="pearson",pch=19,cex=.2)

## Example of binary data model violation so gross that you see a problem [#示例的二进制数据模型违反所以总,你看到一个问题]
## on the QQ plot...[#QQ图...]

y <- c(rep(1,10),rep(0,20),rep(1,40),rep(0,10),rep(1,40),rep(0,40))
x <- 1:160
b <- glm(y~x,family=binomial)
par(mfrow=c(2,2))
## Note that the next two are not necessarily similar under gross [#注意,接下来的两个不一定是根据总的类似]
## model violation...[#模型违反...]
qq.gam(b)
qq.gam(b,rep=50,level=1)
## and a much better plot for detecting the problem[#更好的图和检测问题]
plot(x,residuals(b),pch=19,cex=.3)
plot(x,y);lines(x,fitted(b))

## alternative model[#替代模式]
b <- gam(y~s(x,k=5),family=binomial,method="ML")
qq.gam(b)
qq.gam(b,rep=50,level=1)
plot(x,residuals(b),pch=19,cex=.3)
plot(b,residuals=TRUE,pch=19,cex=.3)



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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 09:28 , Processed in 0.035227 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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