#####################################################################
# \donttest{
#####################################################################
############## Examples for fitting univariate GP models ############
## Set up the Sine example from the tgp package
code = function(x){
y = (sin(pi*x/5) + 0.2*cos(4*pi*x/5))*(x<=9.6) + (x/10-1)*(x>9.6)
}
n=100
input = seq(0, 20, length=n)
XX = seq(0, 20, length=99)
Ztrue = code(input)
set.seed(1234)
output = Ztrue + rnorm(length(Ztrue), sd=0.1)
df.data = data.frame(x=c(input), y=output, y.true=Ztrue)
## fitting a GaSP model with the Cauchy prior
fit = GaSP(formula=~1, output, input,
param=list(range=3, nugget=0.1, nu=2.5),
smooth.est=FALSE, input.new=XX,
cov.model=list(family="matern", form="isotropic"),
proposal=list(range=.35, nugget=.8, nu=0.8),
dtype="Euclidean", model.fit="Cauchy_prior", nsample=3000,
burnin=500, verbose=TRUE)
## fitting a GaSP model with the beta prior
fit = GaSP(formula=~1, output, input,
param=list(range=3, nugget=0.1, nu=2.5),
smooth.est=FALSE, input.new=XX,
cov.model=list(family="matern", form="isotropic"),
prior=list(range=list(a=1,b=1,lb=0,ub=20),
nugget=list(a=1,b=1,lb=0,ub=var(output)),
proposal=list(range=.35, nugget=.8, nu=0.8),
dtype="Euclidean", model.fit="Beta_prior", nsample=3000,
burnin=500, verbose=TRUE))
## fitting a GaSP model with the marginal maximum likelihood approach
fit = GaSP(formula=~1, output, input,
param=list(range=3, nugget=0.1, nu=2.5),
smooth.est=FALSE, input.new=XX,
cov.model=list(family="matern", form="isotropic"),
dtype="Euclidean", model.fit="MMLE", verbose=TRUE)
## fitting a GaSP model with the profile maximum likelihood approach
fit = GaSP(formula=~1, output, input,
param=list(range=3, nugget=0.1, nu=2.5),
smooth.est=FALSE, input.new=XX,
cov.model=list(family="matern", form="isotropic"),
dtype="Euclidean", model.fit="MPLE", verbose=TRUE)
# }
Run the code above in your browser using DataLab