predict.FRESHD {FRESHD} | R Documentation |
Make Prediction From a FRESHD Object
Description
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 . Note
x
will
typically be the original design (covariate data) that was used to produce object
using maximin
or magging
so is the number of
marginal data points in the
th dimension i.e.
.
Usage
## S3 method for class 'FRESHD'
predict(object, x, ...)
Arguments
object |
An object of class FRESHD, produced with |
x |
An object that should be like the input to the call
that produced |
... |
ignored. |
Value
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
, with
.
Author(s)
Adam Lund
Examples
##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")