update.distfreereg {distfreereg} | R Documentation |
Update distfreereg
objects
Description
This is an update
method for objects of class distfreereg
. The method takes advantage of the override
argument of distfreereg
to prevent unnecessary recalculation of potentially computationally expensive objects.
Usage
## S3 method for class 'distfreereg'
update(object, ..., smart = TRUE, envir = parent.frame())
Arguments
object |
Object of class |
... |
Additional named parameters to pass to |
smart |
Logical. If |
envir |
Environment passed to |
Details
This function updates an object of class distfreereg
. By default, it does so "intelligently" in the sense that it does not unnecessarily recompute elements that are already saved in object
. For example, if a new value for covariance
is not included in ...
, then the value of covariance
saved in object
is automatically passed to the new call, preventing recalculating Q
. If a new value of covariance
is specified, then all objects dependent on that (e.g., \hat\theta
) are recomputed.
In particular, the simulated samples depend on the data and function only through the number of observations, the covariates (if any), and the dimension of the parameter space of the function. If none of these change, then the updated object reuses the simulated samples from the supplied object
.
The price paid for this efficiency is a potentially "large" value of call
in the updated object.
Value
An updated object of class distfreereg
.
Note
The usual behavior of update
is to create an updated call and then evaluate that call. This is what update.distfreereg
does, as well, but some of the updated elements are drawn from object
itself for use as override values. In general, an object created by update.distfreereg
is not identical
to the object created by distfreereg
using corresponding arguments, because the call
values will differ.
Author(s)
Jesse Miller
See Also
Examples
set.seed(20240218)
n <- 1e2
func <- function(X, theta) X[,1]^theta[1] + theta[2]*X[,2]
Sig <- runif(n, min = 1, max = 3)
theta <- c(2,5)
X <- matrix(runif(2*n, min = 1, max = 5), nrow = n)
Y <- X[,1]^theta[1] + theta[2]*X[,2] + rnorm(n, sd = sqrt(Sig))
dfr_1 <- distfreereg(Y = Y, X = X, test_mean = func,
covariance = list(Sigma = Sig),
theta_init = c(1,1))
func_updated <- function(X, theta) X[,1]^theta[1] + theta[2]*X[,2]^2
dfr_2 <- update(dfr_1, test_mean = func_updated)