如何将`rhohat()`中的协变量转换为因子?

huangapple go评论65阅读模式
英文:

How to make the covariate in rhohat() a factor?

问题

我正在尝试使用rhohat()函数来估计变化,我有我的ppp文件和图像文件。当我运行这个函数时,我得到了以下错误:

Error in spatialCovariateEvidence.exactppm(model = list(X = list(window = list( :
Only implemented for multitype models (factor marks)

我尝试使用factor()和as.factor()将我的im数据转换为因子,但仍然不起作用。我对此不太熟悉,所以我会感激任何帮助。

o_longleaf <- subset(longleaf, marks >= 10)
o_longleaf_den <- density(o_longleaf, sigma=bw.diggle(o_longleaf))
plot(o_longleaf_den, main=NULL)
contour(o_longleaf_den, col="green", add=TRUE)

rho_kp <- rhohat(longleaf, o_longleaf_den, method="ratio")

plot(rho_kp, main=NULL)

我首先对数据进行子集化,然后使用density来估计密度,这会返回一个im文件。然后我将该im文件放入rhohat中。我可能做错了什么?

英文:

I'm trying to use the rhohat() function to estimate changes and I have my ppp file and image file. When I run the fuction I get this error

> Error in spatialCovariateEvidence.exactppm(model = list(X = list(window = list( :
Only implemented for multitype models (factor marks)

I have tried using factor(), as.factor() to make my im data a factor but it still doesn't work. I'm not familiar with this so I'd appreciate any assistance.

o_longleaf &lt;- subset(longleaf, marks &gt;= 10)
o_longleaf_den &lt;- density(o_longleaf, sigma=bw.diggle(o_longleaf))
plot(o_longleaf_den,main=NULL)
contour(o_longleaf_den,col=&quot;green&quot;, add=TRUE)

rho_kp &lt;- rhohat(longleaf, o_longleaf_den, method=&quot;ratio&quot;)

plot(rho_kp, main=NULL)

I'm first getting a subset of the data, then I'm using density to estimate the density, this returns an im file. I then put that im file in rhohat. I'm probably doing something wrong?

答案1

得分: 2

这不涉及到图像协变量。错误是因为点模式数据集 longleaf 具有数字标记(表示每棵树的直径)。函数 rhohat 无法处理具有数字标记的点模式。

我将编辑错误消息,使其更具信息性!

你可以选择删除标记(这是我认为你想要做的)或将标记转换为表示大小类别的因子。

对我来说,做以下操作更有意义

 old <- unmark(subset(longleaf, marks > 10))
 young <- unmark(subset(longleaf, marks <= 10))
 Dold <- density(old, bw.diggle)
 f <- rhohat(young, Dold)
英文:

This is not about the image covariate. The error occurs because the point pattern dataset longleaf has numerical marks (giving the diameter of each tree). The function rhohat does not handle point patterns with numerical marks.

I will edit the error message so that it is a bit more informative!

You can either remove the marks (which is what I think you want to do) or convert the marks to a factor representing size categories.

To me it would make more sense to do something like

 old &lt;- unmark(subset(longleaf, marks &gt; 10))
 young &lt;- unmark(subset(longleaf, marks &lt;= 10))
 Dold &lt;- density(old, bw.diggle)
 f &lt;- rhohat(young, Dold)

huangapple
  • 本文由 发表于 2023年3月1日 09:03:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75598731.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定