Type: | Package |
Title: | Simulated Grouped Hyper Data Frame |
Version: | 0.1.0 |
Date: | 2025-04-03 |
Description: | An intuitive interface to simulate (1) superimposed (marked) point patterns with vectorized parameterization of random point pattern and distribution of marks; and (2) grouped hyper data frame based on population parameters and subject-specific random effects. |
RoxygenNote: | 7.3.2 |
Encoding: | UTF-8 |
License: | GPL-2 |
Depends: | R (≥ 4.4), spatstat.random, groupedHyperframe |
Language: | en-US |
Imports: | cli, spatstat.geom, MASS |
Suggests: | knitr, rmarkdown, spatstat.data |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2025-04-03 20:25:10 UTC; tingtingzhan |
Author: | Tingting Zhan |
Maintainer: | Tingting Zhan <tingtingzhan@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-04-07 16:20:05 UTC |
groupedHyperframe.random: Simulated Grouped Hyper Data Frame
Description
An intuitive interface to simulate (1) superimposed (marked) point patterns with vectorized parameterization of random point pattern and distribution of marks; and (2) grouped hyper data frame based on population parameters and subject-specific random effects.
Note
Help files of individual functions are intentionally suppressed in the pdf
manual.
Users are encouraged to get started with
vignette('intro', package = 'groupedHyperframe.random')
Author(s)
Maintainer: Tingting Zhan tingtingzhan@gmail.com (ORCID)
Authors:
Inna Chervoneva Inna.Chervoneva@jefferson.edu (ORCID)
Simulate (Marked) Point Pattern
Description
To generate ppp.object(s), with none or one or multiple marks.
Usage
.rppp(
...,
dots,
win = square(),
n = 1L,
element1 = TRUE,
envir = parent.frame()
)
Arguments
... |
see vignettes |
dots |
(for internal use) list of one or more named lists.
The first list specifies the parameters to
generate the |
win |
|
n |
integer scalar,
number of ppp.objects to generate.
Default |
element1 |
logical scalar, whether to return
a ppp.object,
instead of a length- |
envir |
environment, in which to evaluate the |
Value
Function .rppp()
returns a ppp.object if (n==1L)&element1
,
otherwise returns a length-n
solist
(which also has class 'ppplist'
).
The returned ppp.object(s) contain only
x
- and y
-coords,
if only one call is present in the ...
dyn-dots argument.
Otherwise, they contain one or more marks
according to the rest of the call(s) in the ...
argument.
Note
The name rppp()
is too aggressive, which might be claimed in future by package spatstat.random.
Therefore we name this function .rppp()
as if it is hidden (see parameter all.names
of function ls).
Append to marks
Description
Append to marks
Usage
append_marks.ppp(x) <- value
Arguments
x |
|
value |
Value
This syntax sugar returns a ppp.object.
Examples
library(spatstat.geom)
# no marks
data(vesicles, package = 'spatstat.data')
plot(vesicles)
append_marks.ppp(vesicles) = rlnorm(n = npoints(vesicles))
plot(vesicles)
# vector marks, numeric
data(waka, package = 'spatstat.data')
plot(waka)
append_marks.ppp(waka) = rlnorm(n = npoints(waka))
plot(waka)
# vector marks, multitype
data(urkiola, package = 'spatstat.data')
plot(urkiola)
append_marks.ppp(urkiola) = rlnorm(n = npoints(urkiola))
plot(urkiola)
# dataframe marks
data(stonetools, package = 'spatstat.data')
plot(stonetools)
append_marks.ppp(stonetools) = rlnorm(n = npoints(stonetools))
plot(stonetools)
Simulate groupedHyperframe
Description
Simulate groupedHyperframe
Usage
grouped_rppp(..., n, win = square(), envir = parent.frame())
Arguments
... |
see examples, for now |
n |
integer vector, numbers of ppp.objects to generate for each set of parameters |
win |
|
envir |
Value
Function grouped_rppp()
returns a groupedHyperframe.
Expand Types of Sigma
in mvrnorm
Description
To accommodate more types of Sigma
in function mvrnorm.
Usage
mvrnorm2(n, mu, Sigma, ...)
Arguments
n |
integer scalar, sample size |
mu |
|
Sigma |
numeric, either
a scalar, a vector or a matrix,
variance-covariance
matrix |
... |
additional parameter of function mvrnorm |
Details
Argument of parameter Sigma
could be
- scalar
First,
Sigma
is recycled to the length ofmu
. Then a diagonal matrix with vectorSigma
on the diagonal elements is used as the variance-covariance matrix\Sigma
- vector
First, check that length of
Sigma
andmu
must be the same. Then the diagonal matrix is used as\Sigma
- matrix
Sigma
is used as\Sigma
Value
Function mvrnorm2()
returns a double matrix.
Note
Workhorse function mvrnorm from package MASS is faster than ?mvtnorm::rmvnorm
.
Generate Random factor
Description
..
Usage
rfactor(n, prob, levels = as.character(seq_along(prob)))
Arguments
n |
integer scalar |
prob |
numeric vector, see function sample.int |
levels |
Value
Function rfactor()
returns a factor
Examples
rfactor(n = 100L, prob = c(4,2,3))
rfactor(n = 100L, prob = c(4,2,3), levels = letters[1:3])
Create Random marks
Generation Function for ppp.object
Description
Create random marks
generation function for ppp.object.
Usage
rmarks_ppp(f)
Arguments
f |
function of random number generation, e.g., rlnorm, rnbinom, etc. Can also be the function name as a character scalar. |
Value
Function rmarks_ppp()
returns a function,
which generates random marks of a ppp.object
following the probability distribution specified by argument f
.
The returned function
-
has first parameter
x
taking an argument of a ppp.object. -
returns a ppp.object.
Examples
rmarks_ppp(rlnorm)
rmarks_ppp('rnbinom')
plot(pp <- rpoispp(lambda = 100))
plot(pp |>
rmarks_ppp(rlnorm)(sdlog = .5) |>
rmarks_ppp(rnbinom)(size = 5L, prob = .3) |>
rmarks_ppp(rfactor)(prob = c(2,1,3), levels = letters[1:3]))
Batch Process of Random Multivariate Normal Generation
Description
Batch process of random multivariate normal generation mvrnorm2.
Usage
rmvnorm_(n, mu, Sigma, ...)
Arguments
n |
integer scalar |
mu |
list, each element is passed to parameter |
Sigma |
list, each element is passed to parameter |
... |
additional parameters of function mvrnorm |
Value
Function rmvnorm_()
returns a list of matrixes.
Examples
rmvnorm_(n = 5L, mu = list(a = c(0, 3), b = c(3, 7)), Sigma = list(a = .5, b = 1.2))
rmvnorm_(n = 5L, mu = list(a = 0, b = c(3, 7)), Sigma = list(a = .5, b = 1.2))