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 ORCID iD [aut, cre], Inna Chervoneva ORCID iD [aut]
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:


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 x- and y-coords. The second to last lists, if available, specify the parameters to generate one or more marks.

win

owin.object

n

integer scalar, number of ppp.objects to generate. Default 1L.

element1

logical scalar, whether to return a ppp.object, instead of a length-1L solist, when n==1L. Default TRUE

envir

environment, in which to evaluate the ... dyn-dots argument. Default is the parent.frame.

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

a ppp.object

value

a factor or numeric vector

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

owin.object

envir

environment

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

numeric scalar or vector, multivariate means \mathbf{\mu}'s

Sigma

numeric, either a scalar, a vector or a matrix, variance-covariance matrix \Sigma

...

additional parameter of function mvrnorm

Details

Argument of parameter Sigma could be

scalar

First, Sigma is recycled to the length of mu. Then a diagonal matrix with vector Sigma on the diagonal elements is used as the variance-covariance matrix \Sigma

vector

First, check that length of Sigma and mu 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

character vector, see function factor

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

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 mu of function mvrnorm2

Sigma

list, each element is passed to parameter Sigma of function mvrnorm2

...

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))

mirror server hosted at Truenetwork, Russian Federation.