View source: R/FRESHD_predict.R
predict.FRESHD | R Documentation |
Given covariate data this function computes the linear predictors
based on the estimated model coefficients in an object produced by the function
maximin
or magging
. Note that the data can be supplied in two different
formats:
i) for wavelet based models as a string indicating the wavelet used to produce
the model object.
ii) for models with custom design as a list of one, two or three Kronecker component
matrices each of size n_i' \times p_i, i = 1, 2, 3. Note x
will
typically be the original design (covariate data) that was used to produce object
using maximin
or magging
so n_i' is the number of
marginal data points in the ith dimension i.e. n_i' = n_i.
## S3 method for class 'FRESHD' predict(object, x, ...)
object |
An object of class FRESHD, produced with |
x |
An object that should be like the input to the call
that produced |
... |
ignored. |
If x
is a string indicating a wavelet an array of the same size
as the input data used to produce object
. Otherwise an array of size
n'_1 \times \cdots \times n'_d, with d\in \{1,2,3\}.
Adam Lund
##size of example set.seed(42) G = 50; N1 = 2^10; p = 101; J = 3; amp = 20; sigma2 = 10 y <- matrix(0, N1, G) z <- seq(0, 2, length.out = N1) sig <- cos(10 * pi * z) + 1.5 * sin(5 * pi * z) for (i in 1:G){ freqs <- sample(1:100, size = J, replace = TRUE) y[, i] <- sig * 2 + rnorm(N1, sd = sqrt(sigma2)) for (j in 1:J){ y[, i] <- y[, i] + amp * sin(freqs[j] * pi * z + runif(1, -pi, pi)) } } system.time(fitmm <- maximin(y, "la8", alg = "aradmm", kappa = 0.95)) mmy <- predict(fitmm, "la8") plot(mmy[, 2], type = "l") lines(sig, col = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.