#' Prediction for the model
#'
#' @title Prediction for the model
#' @param model the object of 'val' generated by val function
#' @param newx new predictors, a vector
#' @param newz new assist variable, a vector
#' @export
valpredict <- function(model,newx,newz){
if(class(model)!="val")
stop("the model must be varying-coffecient!")
n <- length(newx)
p <- model$degree
nknots <- model$nknots
df <- p+nknots
Psi <- bs(newz,df=df,degree = p)
Psi <- as.matrix(Psi[1:n,1:df])
theta <- Psi %*% model$coef
predict <- diag(newx) %*% theta
predict
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.