Description Usage Arguments Details Value See Also Examples
View source: R/Package_HAC_RAC_SHAC.r
Evaluate a predefined Kronecker product B-spline basis at provided values.
1 2 |
object |
the result returned by |
tp.valid |
the new time points at which the evaluations are requested; mainly for validation purpose |
cp.valid |
the new covariate points at which the evaluations are requested; mainly for validation purpose |
... |
other arguments passed to the generic function |
When cp.valid is allowed to be null, when only an univariate basis is considerred at
object.
An object just like the inputed object, except evaluated at the new values of tp.valid and cp.valid.
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 | data(data.simulation) # load benchmark data
y <- DST$obs # matrix of observation
y.valid <- DSV$obs # matrix of training data; include missing values
# generate bivariate basis using 3 knots for each direction
basis <- kpbb(DST$tp, DST$cp, nknots.tp = 3, nknots.cp = 3)
# linear regression
lm.fit <- lm(as.vector(y) ~ basis - 1)
# prediction
new.basis <- predict(basis, tp.valid = DSV$tp, cp.valid = DSV$cp)
y.predict <- matrix(crossprod(t(new.basis),coef(lm.fit)), nrow = length(DSV$cp))
# visualize the data and predicted surface
par(mfrow = c(1,2))
persp(DSV$cp, DSV$tp, y.valid, theta=60, phi=15,
ticktype = "detailed", col="lightblue",
xlab = "covariate", ylab = "time",
zlab="data", main="data surface (partically observed)")
persp(DSV$cp, DSV$tp, y.predict, theta=60, phi=15,
ticktype = "detailed", col="lightblue",
xlab = "covariate", ylab = "time",
zlab="data", main="predicted surface via lm")
# predication error
mean(((y.predict - DSV$obs.full)[!is.na(DSV$obs)])^2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.