# simulate_regression: Simulates a 3D Spherical Regression. In nprotreg: Nonparametric Rotations for Sphere-Sphere Regression

## Description

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

## Usage

 ```1 2 3 4 5``` ```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(Φ(ε(x))) exp(Φ(s(x))) x

where x is the transpose of the i-th row of E. Terms ε(x) and s(x) are obtained by evaluating at x functions `local_error_sampler` and `local_rotation_composer`, respectively, while matrix Φ(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.

Other Regression functions: `cross_validate_concentration()`, `fit_regression()`, `get_equally_spaced_points()`, `get_skew_symmetric_matrix()`, `simulate_rigid_regression()`, `weight_explanatory_points()`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41``` ```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), - exp(2.0 * point), exp(2.0 * point)) } # 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") ```