data(data.simulation) # load benchmark data
y <- DST$obs # matrix of observation
# 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)
y.fit <- matrix(fitted(lm.fit), nrow = 100, ncol = 80)
# visualize the data and fitted surface
par(mfrow = c(1,2))
persp(DST$cp, DST$tp, y, theta=60, phi=15,
ticktype = "detailed", col="lightblue",
xlab = "covariate", ylab = "time",
zlab="data", main="data surface")
persp(DST$cp, DST$tp, y.fit, theta=60, phi=15,
ticktype = "detailed", col="lightblue",
xlab = "covariate", ylab = "time",
zlab="data", main="fitted surface via lm")
Run the code above in your browser using DataLab