Learn R Programming

GPFDA (version 1.1)

cov.linear: Covariance function. Linear covariance function.

Description

Non-stationary covariance function.

Usage

cov.linear(hyper, Data, Data.new = NULL)

Arguments

hyper
The hyper parameters. Must be a list with certain names.
Data
The input data. Must be a vector or a matrix.
Data.new
The data for prediction. Must be a vector or a matrix. Default to be NULL.

Value

  • cov.linCovariance matrix

Details

The names for the hyper parameters should be:"linear.a" for linear covariance function, "pow.ex.w", "pow.ex.v" for power exponential, "rat.qu.s", "rat.qu.a" for rational quadratic, "vv" for white noise. All hyper parameters should be in one list.

References

Shi, J Q., and Choi, T. (2011), Gaussian Process Regression Analysis for Functional Data, Springer, New York.

See Also

cov.pow.ex; cov.rat.qu; gpr; xixj

Examples

Run this code
library(GPFDA)
require(MASS)

set.seed(30)
hp <- list('pow.ex.w'=log(10),'linear.a'=log(10),'pow.ex.v'=log(5),'vv'=log(1))
c <- seq(0,1,len=40)
idx <- sort(sample(1:40,21))
X <- as.matrix(c[idx])
Y <- (mvrnorm(n=40,mu=c-c,Sigma=(cov.linear(hp,c)+cov.pow.ex(hp,c)))[,1])*0.1+sin(c*6)
Y <- as.matrix(Y[idx])
x <- as.matrix(seq(0,1,by=0.03))
a <- gpr(X,Y,c('linear'),hp)
b <- gppredict(a,x)

upper=b$mu+1.96*sqrt(b$sigma)
lower=b$mu-1.96*sqrt(b$sigma)
plot(-100,-100,col=0,xlim=range(x[,1]),ylim=c(min(upper,lower,Y)-0.1*abs(min(upper,lower,Y)),
  max(upper,lower,Y)+0.1*abs(max(upper,lower,Y))),main="Prediction", 
  xlab="input ( x )",ylab="response")
polygon(c(x[,1], rev(x[,1])), c(upper, rev(lower)),col = "grey90", border = NA)
points(X[,1],Y,pch=4,col=2)
#points(x[,1],a$mu)
lines(X[,1],Y)
lines(x[,1],b$mu,col=3,lwd=2)

Run the code above in your browser using DataLab