qqplot.ppm(spatstat)
qqplot.ppm()所属R语言包:spatstat
Q-Q Plot of Residuals from Fitted Point Process Model
从拟合点过程模型的残差的QQ图
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Given a point process model fitted to a point pattern, produce a Q-Q plot based on residuals from the model.
由于模式装到一个点一个点过程模型,根据模型的残差的QQ图。
用法----------Usage----------
qqplot.ppm(fit, nsim=100, expr=NULL, ..., type="raw",
style="mean", fast=TRUE, verbose=TRUE, plot.it=TRUE,
dimyx=NULL, nrep=if(fast) 5e4 else 1e5,
control=update(default.rmhcontrol(fit), nrep=nrep),
saveall=FALSE,
monochrome=FALSE,
limcol=if(monochrome) "black" else "red",
maxerr=max(100, ceiling(nsim/10)),
check=TRUE, repair=TRUE)
参数----------Arguments----------
参数:fit
The fitted point process model, which is to be assessed using the Q-Q plot. An object of class "ppm". Smoothed residuals obtained from this fitted model will provide the “data” quantiles for the Q-Q plot.
拟合点过程模型,使用QQ的图,这是进行评估。对象的类"ppm"。从这个模型拟合得到的平滑残差将提供“数据”位数的QQ图。
参数:nsim
The number of simulations from the “reference” point process model.
从“参考”点过程模型的模拟。
参数:expr
Determines the simulation mechanism which provides the “theoretical” quantiles for the Q-Q plot. See Details.
确定的模拟机构提供的“理论”位数的QQ图。查看详细信息。
参数:...
Arguments passed to diagnose.ppm influencing the computation of residuals.
参数传递给diagnose.ppm影响残差计算。
参数:type
String indicating the type of residuals or weights to be used. Current options are "eem" for the Stoyan-Grabarnik exponential energy weights, "raw" for the raw residuals, "inverse" for the inverse-lambda residuals, and "pearson" for the Pearson residuals. A partial match is adequate.
字符串,用于指示要使用的类型的残差或重量的。当前选项"eem"的斯托扬Grabarnik指数的能源的权重,"raw"为原料的残差,"inverse"的逆-λ残差,和"pearson"的Pearson残差。部分匹配的是足够的。
参数:style
Character string controlling the type of Q-Q plot. Options are "classical" and "mean". See Details.
字符串控制类型的QQ图。选项是"classical"和"mean"。查看详细信息。
参数:fast
Logical flag controlling the speed and accuracy of computation. Use fast=TRUE for interactive use and fast=FALSE for publication standard plots. See Details.
逻辑标志控制的计算的速度和准确性。使用fast=TRUE交互使用和fast=FALSE出版的标准样。查看详细信息。
参数:verbose
Logical flag controlling whether the algorithm prints progress reports during long computations.
逻辑控制算法是否打印进度报告,在长时间的计算的标志。
参数:plot.it
Logical flag controlling whether the function produces a plot or simply returns a value (silently).
逻辑控制函数生成一个图,或只是简单地返回一个值(默默)的标志。
参数:dimyx
Dimensions of the pixel grid on which the smoothed residual field will be calculated. A vector of two integers.
平滑的残余电场将被计算的像素网格尺寸。两个整数的矢量。
参数:nrep
If control is absent, then nrep gives the number of iterations of the Metropolis-Hastings algorithm that should be used to generate one simulation of the fitted point process.
如果control不存在,那么nrep给出的的Metropolis-赫斯廷斯的算法,应使用以产生一个模拟的拟合点过程的数目的迭代。
参数:control
List of parameters controlling the Metropolis-Hastings algorithm rmh which generates each simulated realisation from the model (unless the model is Poisson). This list becomes the argument control of rmh.default. It overrides nrep.
控制的大都市“黑斯廷斯算法rmh,产生每个模拟实现从模型(除非该模型是泊松分布)的参数列表。此列表变成了参数controlrmh.default。它覆盖nrep。
参数:saveall
Logical flag indicating whether to save all the intermediate calculations.
逻辑的标志,表示是否保存中间计算。
参数:monochrome
Logical flag indicating whether the plot should be in black and white (monochrome=TRUE), or in colour (monochrome=FALSE).
逻辑标志指示的图是否应在黑色和白色(monochrome=TRUE),或在颜色(monochrome=FALSE)。
参数:limcol
String. The colour to be used when plotting the 95-percent limit curves.
字符串。要使用的颜色绘制的95%的极限曲线时。
参数:maxerr
Maximum number of failures tolerated while generating simulated realisations. See Details.
最大数的故障耐受性而产生模拟的实现。查看详细信息。
参数:check
Logical value indicating whether to check the internal format of fit. If there is any possibility that this object has been restored from a dump file, or has otherwise lost track of the environment where it was originally computed, set check=TRUE.
逻辑值,该值指示是否要检查的内部格式fit。如果有任何可能,这个对象已经从dump文件中恢复,或以其他方式失去它最初被计算的环境中,设置check=TRUE。
参数:repair
Logical value indicating whether to repair the internal format of fit, if it is found to be damaged.
逻辑值,该值指示是否要修复的内部格式fit,如果它被发现损坏。
Details
详细信息----------Details----------
This function generates a Q-Q plot of the residuals from a fitted point process model. It is an addendum to the suite of diagnostic plots produced by the function diagnose.ppm, kept separate because it is computationally intensive. The quantiles of the theoretical distribution are estimated by simulation.
这个函数生成一个装有点过程模型的残差的QQ图。这是一个增编的一套诊断图的功能diagnose.ppm,单独存放,因为它是计算密集型的。通过模拟的理论分布的分位数估计。
In classical statistics, a Q-Q plot of residuals is a useful diagnostic for checking the distributional assumptions. Analogously, in spatial statistics, a Q-Q plot of the (smoothed) residuals from a fitted point process model is a useful way to check the interpoint interaction part of the model (Baddeley et al, 2005). The systematic part of the model (spatial trend, covariate effects, etc) is assessed using other plots made by diagnose.ppm.
残差的QQ图的在经典统计数据,检查分布假设的是一个有用的诊断。类似地,在空间统计,QQ(平滑)从拟合点过程模型的残差图是一个有用的方法来检查INTERPOINT交互部分的模型(巴德利等人,2005)。系统的模型(空间趋势,协变量的影响等)使用由diagnose.ppm的其他图评估。
The argument fit represents the fitted point process model. It must be an object of class "ppm" (typically produced by the maximum pseudolikelihood fitting algorithm ppm). Residuals will be computed for this fitted model using residuals.ppm, and the residuals will be kernel-smoothed to produce a “residual field”. The values of this residual field will provide the “data” quantiles for the Q-Q plot.
参数fit过程模型的拟合点。它必须是一个类的对象"ppm"(,通常由的最大pseudolikelihood拟合算法ppm)。将此拟合模型使用residuals.ppm,和残差计算残差将内核平滑化,以产生一个“剩余场”。这剩余字段的值将提供“数据”位数的QQ图。
The argument expr is not usually specified. It provides a way to modify the “theoretical” or “reference” quantiles for the Q-Q plot.
参数expr通常不指定。它提供了一种修改的“理论”或“参考”位数的QQ图。
In normal usage we set expr=NULL. The default is to generate nsim simulated realisations of the fitted model fit, re-fit this model to each of the simulated patterns, evaluate the residuals from these fitted models, and use the kernel-smoothed residual field from these fitted models as a sample from the reference distribution for the Q-Q plot.
在正常使用中,我们设置expr=NULL。默认为生成nsim模拟实现,拟合模型fit,重新适应这个模型来模拟模式,评估的残差由这些拟合模型,并使用的内核平滑的残余领域从这些拟合模型作为参考的样本分布的QQ图。
In advanced use, expr may be an expression. It will be re-evaluated nsim times, and should include random computations so that the results are not identical each time. The result of evaluating expr should be either a point pattern (object of class "ppp") or a fitted point process model (object of class "ppm"). If the value is a point pattern, then the original fitted model fit will be fitted to this new point pattern using update.ppm, to yield another fitted model. Smoothed residuals obtained from these nsim fitted models will yield the “theoretical” quantiles for the Q-Q plot.
先进的使用,expr可能是一个expression。将重新评估nsim倍,并应包括随机计算,这样的结果是不相同的,每次。结果评估expr应该是一个点模式(类的对象"ppp")或拟合点过程模型(类的对象"ppm")。如果该值是一个点模式,那么原来的拟合模型fit将被安装到这个新的模式,使用update.ppm,产生另一种拟合模型。从这些nsim拟合模型得到的平滑残差产生的“理论”位数的QQ图。
Simulation is performed (if expr=NULL) using the Metropolis-Hastings algorithm rmh. Each simulated realisation is the result of running the Metropolis-Hastings algorithm from an independent random starting state each time. The iterative and termination behaviour of the Metropolis-Hastings algorithm are governed by the argument control. See rmhcontrol for information about this argument. As a shortcut, the argument nrep determines the number of Metropolis-Hastings iterations used to generate each simulated realisation, if control is absent.
模拟(expr=NULL如果)使用的大都市“黑斯廷斯算法rmh。每一个模拟的实现是一个独立的随机状态每次运行的Metropolis-Hastings算法的结果。迭代和终止行为的Metropolis-Hastings算法是由参数control。见rmhcontrol的信息,这个论点。作为一种快捷方式,参数nrep用于生成每个模拟实现的大都市黑斯廷斯迭代的数量决定了,如果control是缺席。
By default, simulations are generated in an expanded window. Use the argument control to change this, as explained in the section on Warning messages.
缺省情况下,在扩大窗模拟生成。使用参数control改变,正如在警告消息的部分。
The argument type selects the type of residual or weight that will be computed. For options, see diagnose.ppm.
的参数type选择的类型残留或重量,将计算。有关选项,请参阅diagnose.ppm。
The argument style determines the type of Q-Q plot. It is highly recommended to use the default, style="mean".
参数style确定类型的QQ图。我们强烈建议使用默认情况下,style="mean"。
The quantiles of the residual field for the data (on the y axis) are plotted against the quantiles of the pooled simulations (on the x axis). This plot is biased, and therefore difficult to interpret, because of strong autocorrelations in the residual field and the large differences in sample size.
位数的剩余磁场的数据(y轴)的绘制对位数的汇集模拟(x轴)。该图是有失偏颇的,因此难以解释,因为在剩余磁场和强自相关样本量差异较大。
The order statistics of the residual field for the data are plotted against the sample means, over the nsim simulations, of the corresponding order statistics of the residual field for the simulated datasets. Dotted lines show the 2.5 and 97.5 percentiles, over the nsim simulations, of each order statistic.
剩余磁场的数据绘制的次序统计量对样品的手段,在nsim模拟,相应的命令统计的剩余磁场的模拟实验。虚线表示2.5和97.5百分位数,nsim模拟,每个订单统计。
The argument fast is a simple way to control the accuracy and speed of computation. If fast=FALSE, the residual field is computed on a fine grid of pixels (by default 100 by 100 pixels, see below) and the Q-Q plot is based on the complete set of order statistics (usually 10,000 quantiles). If fast=TRUE, the residual field is computed on a coarse grid (at most 40 by 40 pixels) and the Q-Q plot is based on the percentiles only. This is about 7 times faster. It is recommended to use fast=TRUE for interactive data analysis and fast=FALSE for definitive plots for publication.
参数fast是一个简单的方法来控制计算的精度和速度。如果fast=FALSE,剩余磁场计算罚款的像素网格(默认为100 100像素,见下文)和QQ图是基于一套完整的订单统计数据(通常为10000位数)。如果fast=TRUE,剩余场计算的粗网格(至多40由40个像素)和QQ图是根据仅在百分。这是约7倍的速度。它建议使用fast=TRUE交互式数据分析和fast=FALSE明确的图出版。
The argument dimyx gives full control over the resolution of the pixel grid used to calculate the smoothed residuals. Its interpretation is the same as the argument dimyx to the function as.mask. Note that dimyx[1] is the number of pixels in the y direction, and dimyx[2] is the number in the x direction. If dimyx is not present, then the default pixel grid dimensions are controlled by spatstat.options("npixel").
参数dimyx给出的分辨率的像素网格,用于计算平滑的残差的完全控制权。它的解释是一样的说法dimyx的功能as.mask的。注意,dimyx[1]是y方向中的像素的数量,和dimyx[2]是在x方向数。如果dimyx是不存在,则默认的像素网格尺寸控制spatstat.options("npixel")。
Since the computation is so time-consuming, qqplot.ppm returns a list containing all the data necessary to re-display the Q-Q plot. It is advisable to assign the result of qqplot.ppm to something (or use .Last.value if you forgot to.) The return value is an object of class "qqppm". There are methods for plot.qqppm and print.qqppm. See the Examples.
由于计算是非常耗费时间,qqplot.ppm返回一个列表,其中包含所有必要的数据,重新显示QQ的图。明智的做法是分配的结果qqplot.ppm的东西(或使用.Last.value,如果你忘了。)的返回值是对象的类"qqppm"。有方法plot.qqppm和print.qqppm。请参阅范例。
The argument saveall is usually set to FALSE. If saveall=TRUE, then the intermediate results of calculation for each simulated realisation are saved and returned. The return value includes a 3-dimensional array sim containing the smoothed residual field images for each of the nsim realisations. When saveall=TRUE, the return value is an object of very large size, and should not be saved on disk.
参数saveall通常被设置为FALSE。如果saveall=TRUE,然后为每个模拟实现计算的中间结果保存并返回。的返回值包括一个3 - 维数组sim含有平滑的残余电场的nsim实现为每个图像。当saveall=TRUE,返回值是一个非常大的大小的对象,不应该被保存在磁盘上。
Errors may occur during the simulation process, because random data are generated. For example:
在模拟过程中,可能会发生错误,因为生成的随机数据。例如:
one of the simulated patterns may be empty.
在模拟模式之一可能是空的。
one of the simulated patterns may cause an error in the code that fits the point process model.
模拟模式之一,在适合的点过程模型的代码可能会导致错误。
the user-supplied argument expr may have a bug.
用户提供的参数expr可能有问题。
Empty point patterns do not cause a problem for the code, but they are reported. Other problems that would lead to a crash are trapped; the offending simulated data are discarded, and the simulation is retried. The argument maxerr determines the maximum number of times that such errors will be tolerated (mainly as a safeguard against an infinite loop).
空点模式不造成问题的代码,但他们报告。其他问题,这将导致系统崩溃被困违规的模拟数据将被丢弃,模拟试。 maxerr的参数决定将容忍这样的错误(主要是对一个无限循环的保障)的最大数量。
值----------Value----------
An object of class "qqppm" containing the information needed to reproduce the Q-Q plot. Entries x and y are numeric vectors containing quantiles of the simulations and of the data, respectively.
类的一个对象"qqppm"包含复制的QQ的图所需要的信息。文章x和y位数的模拟数据,分别是数字向量的。
副作用----------Side Effects----------
Produces a Q-Q plot if plot.it is TRUE.
如果plot.it是TRUE,则产生一个Q-Q图。
警告消息----------Warning messages----------
A warning message will be issued if any of the simulations trapped an error (a potential crash).
会发出一条警告消息,如果有的话被困的模拟错误(一个潜在的崩溃)。
A warning message will be issued if all, or many, of the simulated point patterns are empty. This usually indicates a problem with the simulation procedure.
会发出一条警告消息,如果所有的,还是很多的,的模拟点模式是空的。这通常表明问题的模拟程序。
The default behaviour of qqplot.ppm is to simulate patterns on an expanded window (specified through the argument control) in order to avoid edge effects. The model's trend is extrapolated over this expanded window. If the trend is strongly inhomogeneous, the extrapolated trend may have very large (or even infinite) values. This can cause the simulation algorithm to produce empty patterns.
qqplot.ppm的默认行为是模拟模式的扩展窗口(通过指定参数control),以避免边缘效应。在这个扩大的窗口模型的趋势得以延续。如果这一趋势是强烈的不均匀性,的推算趋势可能有非常大的(甚至是无限的)的值。这可能会导致仿真算法产生空模式。
The only way to suppress this problem entirely is to prohibit the expansion of the window, by setting the control argument to something like control=list(nrep=1e6, expand=1). Here expand=1 means there will be no expansion. See rmhcontrol for more information about the argument control.
只有这样,才能抑制这种问题完全是禁止的扩展的窗口,通过设置control类似control=list(nrep=1e6, expand=1)参数。这是expand=1是指不会有扩张。见rmhcontrol的详细信息的论点control。
(作者)----------Author(s)----------
Adrian Baddeley
<a href="mailto:Adrian.Baddeley@csiro.au">Adrian.Baddeley@csiro.au</a>
<a href="http://www.maths.uwa.edu.au/~adrian/">http://www.maths.uwa.edu.au/~adrian/</a>
and Rolf Turner
<a href="mailto:r.turner@auckland.ac.nz">r.turner@auckland.ac.nz</a>
参考文献----------References----------
Residual analysis for spatial point processes. Journal of the Royal Statistical Society, Series B 67, 617–666.
Second-order characteristics for stochastic structures connected with Gibbs point processes. Mathematische Nachrichten, 151:95–100.
参见----------See Also----------
diagnose.ppm, lurking, residuals.ppm, eem, ppm.object, ppm, rmh, rmhcontrol
diagnose.ppm,lurking,residuals.ppm,eem,ppm.object,ppm,rmh,rmhcontrol
实例----------Examples----------
data(cells)
fit <- ppm(cells, ~1, Poisson())
diagnose.ppm(fit) # no suggestion of departure from stationarity[不建议离开平稳]
## Not run: qqplot.ppm(fit, 80) # strong evidence of non-Poisson interaction[#不运行:qqplot.ppm(适合80)#有力的证据非泊松互动的]
## Not run: [#不运行:]
diagnose.ppm(fit, type="pearson")
qqplot.ppm(fit, type="pearson")
## End(Not run)[#(不执行)]
###########################################[##########################################]
## oops, I need the plot coordinates[#哎呀,我需要的图坐标]
mypreciousdata <- .Last.value
## Not run: mypreciousdata <- qqplot.ppm(fit, type="pearson")[#不运行:mypreciousdata < - qqplot.ppm(适合中,键入=“皮尔森”)]
plot(mypreciousdata)
######################################################[################################################## ###]
# Q-Q plots based on fixed n[根据固定的n Q-Q图]
# The above QQ plots used simulations from the (fitted) Poisson process.[上面的QQ图(已安装)泊松过程的模拟。]
# But I want to simulate conditional on n, instead of Poisson[不过,我想在n模拟条件,而不是泊松]
# Do this by setting rmhcontrol(p=1)[这设置rmhcontrol(P = 1)]
fixit <- list(p=1)
## Not run: qqplot.ppm(fit, 100, control=fixit)[#不运行:qqplot.ppm(适合100,控制FIXIT)]
######################################################[################################################## ###]
# Inhomogeneous Poisson data[非齐次泊松数据]
X <- rpoispp(function(x,y){1000 * exp(-3*x)}, 1000)
plot(X)
# Inhomogeneous Poisson model[非齐次泊松模型]
fit <- ppm(X, ~x, Poisson())
## Not run: qqplot.ppm(fit, 100)[#不运行:qqplot.ppm(适合100)]
# conclusion: fitted inhomogeneous Poisson model looks OK[结论:合身的非齐次泊松模型看起来OK]
######################################################[################################################## ###]
# Advanced use of 'expr' argument[高级用法是expr的说法]
# []
# set the initial conditions in Metropolis-Hastings algorithm[设置在大都市黑斯廷斯算法的初始条件]
# []
expr <- expression(rmh(fit, start=list(n.start=42), verbose=FALSE))
## Not run: qqplot.ppm(fit, 100, expr)[#不运行:qqplot.ppm(适合100中,expr)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|