simulate_regression {nprotreg}R Documentation

Simulates a 3D Spherical Regression.

Description

Returns the response points corresponding to the specified explanatory points, given a model for local rotations and an error term sampler.

Usage

simulate_regression(
  explanatory_points,
  local_rotation_composer,
  local_error_sampler
)

Arguments

explanatory_points

An m-by-3 matrix whose rows contain the Cartesian coordinates of the points at which the regression will be simulated.

local_rotation_composer

A function that returns a 3-length numeric vector representing the independent components of a skew symmetric matrix local to an explanatory point, given its Cartesian coordinates.

local_error_sampler

A function that returns a 3-length numeric vector representing a sampled error term local to an explanatory point, given its Cartesian coordinates.

Details

Let E be the m-by-3 matrix of explanatory points. This function will return an m-by-3 matrix whose i-th row is obtained by transposition of the following expression:

exp(\Phi(\epsilon(x))) exp(\Phi(s(x))) x

where x is the transpose of the i-th row of E. Terms \epsilon(x) and s(x) are obtained by evaluating at x functions local_error_sampler and local_rotation_composer, respectively, while matrix \Phi(c), for a 3-length numeric vector c, is the skew symmetric matrix having its independent components represented by the entries of c (for a thorough discussion, see function get_skew_symmetric_matrix).

Functions local_error_sampler and local_rotation_composer must be prototyped as having one argument, point, representing the Cartesian coordinates of a point on a 3D sphere, and returning a non NULL numerical object having length equal to 3.

Value

An m-by-3 matrix whose rows contain the Cartesian coordinates of the response points corresponding to the explanatory points.

See Also

Other Regression functions: cross_validate_concentration(), fit_regression(), get_equally_spaced_points(), get_skew_symmetric_matrix(), simulate_rigid_regression(), weight_explanatory_points()

Examples

library(nprotreg)

# Define a matrix of explanatory points.

explanatory_points <- rbind(
  cbind(.5, 0, .8660254),
  cbind(-.5, 0, .8660254),
  cbind(1, 0, 0),
  cbind(0, 1, 0),
  cbind(-1, 0, 0),
  cbind(0, -1, 0),
  cbind(.5, 0, -.8660254),
  cbind(-.5, 0, -.8660254)
)

# Define a local rotation composer.

local_rotation_composer <- function(point) {
  independent_components <- (1 / 2) *
    c(exp(2.0 * point[3]), - exp(2.0 * point[2]), exp(2.0 * point[1]))
}

# Define a local error sampler.

local_error_sampler <- function(point) {
  rnorm(3)
}

# Get the corresponding 8-by-3 matrix of response points.
# Rows corresponds to explanatory points,
# columns to Cartesian coordinates.

response_points <- simulate_regression(explanatory_points,
                                       local_rotation_composer,
                                       local_error_sampler)

# Get the response point corresponding to the second
# explanatory point.

cat("Response point corresponding to the second explanatory point: \n")
cat(response_points[2, ], "\n")

[Package nprotreg version 1.1.1 Index]