View source: R/simulate_rigid_regression.R
simulate_rigid_regression | R Documentation |
Returns the response points corresponding to the specified explanatory points, given a rigid rotation model and an error term sampler.
simulate_rigid_regression(
explanatory_points,
rotation_matrix,
local_error_sampler
)
explanatory_points |
An m-by-3 matrix whose rows contain the Cartesian coordinates of the points at which the regression will be simulated. |
rotation_matrix |
A 3-by-3 rotation matrix. |
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. |
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))) R x
where x
is the transpose of the i
-th row of
E
and R
is rotation_matrix
.
Term \epsilon(x)
is obtained by
evaluating at x
function local_error_sampler
, 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
).
Function local_error_sampler
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
.
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_regression()
,
weight_explanatory_points()
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 rotation matrix.
rotation_matrix <- rbind(
cbind(-0.69492055764131177575, 0.71352099052778772403, 0.08929285886191218324),
cbind(-0.19200697279199935297, -0.30378504433947051133, 0.93319235382364695841),
cbind(0.69297816774177023458, 0.63134969938371787723, 0.34810747783026463331)
)
# 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_rigid_regression(explanatory_points,
rotation_matrix,
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.