如何在 Spatstat 中提取保存的包络值?
How to extract saved envelope values in Spatstat?
我是 R 和 spatstat 的新手,正在使用非齐次对相关函数。我的数据集由分布在多个时间间隔的点值组成。
sp77.ppp = ppp(sp77.dat$Plot_X, sp77.dat$Plot_Y, window = window77, marks = sp77.dat$STATUS)
Dvall77 = envelope((Y=dv77.ppp[dv77.ppp$marks=='2']),fun=pcfinhom, r=seq(0,20,0.25), nsim=999,divisor = 'd', simulate=expression((rlabel(dv77.ppp)[rlabel(dv77.ppp)$marks=='1']),(rlabel(dv77.ppp)[rlabel(dv77.ppp)$marks=='2'])), savepatterns = T, savefuns = T).
我正在尝试比较多个成对比较(来自不同时间段),并且需要创建一个函数,该函数将在每个“r”值处针对每个计算的包络值进行遍历,并找出两者之间的最小和最大差异信封。
我的问题是:如何找到保存的包络值?我知道 savefuns = T
正在保存所有模拟包络值,但我找不到如何提取这些值。摘要(如下)表示值已存储。如何调用值并提取它们?
> print(Dvall77)
Pointwise critical envelopes for g[inhom](r)
and observed value for ‘(Y = dv77.ppp[dv77.ppp$marks == "2"])’
Edge correction: “iso”
Obtained from 999 evaluations of user-supplied expression
(All simulated function values are stored)
(All simulated point patterns are stored)
Alternative: two.sided
Significance level of pointwise Monte Carlo test: 2/1000 = 0.002
.......................................................................................
Math.label Description
r r distance argument r
obs {hat(g)[inhom]^{obs}}(r) observed value of g[inhom](r) for data pattern
mmean {bar(g)[inhom]}(r) sample mean of g[inhom](r) from simulations
lo {hat(g)[inhom]^{lo}}(r) lower pointwise envelope of g[inhom](r) from simulations
hi {hat(g)[inhom]^{hi}}(r) upper pointwise envelope of g[inhom](r) from simulations
.......................................................................................
Default plot formula: .~r
where “.” stands for ‘obs’, ‘mmean’, ‘hi’, ‘lo’
Columns ‘lo’ and ‘hi’ will be plotted as shading (by default)
Recommended range of argument r: [0, 20]
Available range of argument r: [0, 20]
提前感谢您的任何建议!
如果您要访问每个随机标记模式的汇总统计值 (ginhom
),这原则上记录在 help(envelope.ppp)
中。诚然,这很长,如果您是 R 和 spatstat
的新手,很容易迷路。线索在帮助文件的 value
部分。结果是 data.frame
加上一些额外的 类(envelope
和 fv
),正如帮助文件所说:
Additionally, if ‘savepatterns=TRUE’, the return value has an
attribute ‘"simpatterns"’ which is a list containing the ‘nsim’
simulated patterns. If ‘savefuns=TRUE’, the return value has an
attribute ‘"simfuns"’ which is an object of class ‘"fv"’
containing the summary functions computed for each of the ‘nsim’
simulated patterns.
那么你当然需要知道如何访问 R 中的属性,这是使用 attr
:
完成的
funs <- attr(Dvall77, "simfuns")
那么 funs
是一个 data.frame
(和 fv
-对象),其中包含每个随机标记模式的所有函数值。
我无法从你的问题中真正理解你是否只需要定义包络线的上下曲线的值?在那种情况下,您只需像普通的 data.frame
一样访问它们(并且无需将所有单独的函数值保存在信封中):
lo <- Dvall77$lo
hi <- Dvall77$hi
d <- hi - lo
你可以更优雅地做:
d <- with(Dvall77, hi - lo)
我是 R 和 spatstat 的新手,正在使用非齐次对相关函数。我的数据集由分布在多个时间间隔的点值组成。
sp77.ppp = ppp(sp77.dat$Plot_X, sp77.dat$Plot_Y, window = window77, marks = sp77.dat$STATUS)
Dvall77 = envelope((Y=dv77.ppp[dv77.ppp$marks=='2']),fun=pcfinhom, r=seq(0,20,0.25), nsim=999,divisor = 'd', simulate=expression((rlabel(dv77.ppp)[rlabel(dv77.ppp)$marks=='1']),(rlabel(dv77.ppp)[rlabel(dv77.ppp)$marks=='2'])), savepatterns = T, savefuns = T).
我正在尝试比较多个成对比较(来自不同时间段),并且需要创建一个函数,该函数将在每个“r”值处针对每个计算的包络值进行遍历,并找出两者之间的最小和最大差异信封。
我的问题是:如何找到保存的包络值?我知道 savefuns = T
正在保存所有模拟包络值,但我找不到如何提取这些值。摘要(如下)表示值已存储。如何调用值并提取它们?
> print(Dvall77)
Pointwise critical envelopes for g[inhom](r)
and observed value for ‘(Y = dv77.ppp[dv77.ppp$marks == "2"])’
Edge correction: “iso”
Obtained from 999 evaluations of user-supplied expression
(All simulated function values are stored)
(All simulated point patterns are stored)
Alternative: two.sided
Significance level of pointwise Monte Carlo test: 2/1000 = 0.002
.......................................................................................
Math.label Description
r r distance argument r
obs {hat(g)[inhom]^{obs}}(r) observed value of g[inhom](r) for data pattern
mmean {bar(g)[inhom]}(r) sample mean of g[inhom](r) from simulations
lo {hat(g)[inhom]^{lo}}(r) lower pointwise envelope of g[inhom](r) from simulations
hi {hat(g)[inhom]^{hi}}(r) upper pointwise envelope of g[inhom](r) from simulations
.......................................................................................
Default plot formula: .~r
where “.” stands for ‘obs’, ‘mmean’, ‘hi’, ‘lo’
Columns ‘lo’ and ‘hi’ will be plotted as shading (by default)
Recommended range of argument r: [0, 20]
Available range of argument r: [0, 20]
提前感谢您的任何建议!
如果您要访问每个随机标记模式的汇总统计值 (ginhom
),这原则上记录在 help(envelope.ppp)
中。诚然,这很长,如果您是 R 和 spatstat
的新手,很容易迷路。线索在帮助文件的 value
部分。结果是 data.frame
加上一些额外的 类(envelope
和 fv
),正如帮助文件所说:
Additionally, if ‘savepatterns=TRUE’, the return value has an attribute ‘"simpatterns"’ which is a list containing the ‘nsim’ simulated patterns. If ‘savefuns=TRUE’, the return value has an attribute ‘"simfuns"’ which is an object of class ‘"fv"’ containing the summary functions computed for each of the ‘nsim’ simulated patterns.
那么你当然需要知道如何访问 R 中的属性,这是使用 attr
:
funs <- attr(Dvall77, "simfuns")
那么 funs
是一个 data.frame
(和 fv
-对象),其中包含每个随机标记模式的所有函数值。
我无法从你的问题中真正理解你是否只需要定义包络线的上下曲线的值?在那种情况下,您只需像普通的 data.frame
一样访问它们(并且无需将所有单独的函数值保存在信封中):
lo <- Dvall77$lo
hi <- Dvall77$hi
d <- hi - lo
你可以更优雅地做:
d <- with(Dvall77, hi - lo)