---
title: Computation using a Matern Kernel
author: Julian Faraway
output:
html_document:
toc: true
theme: cosmo
---
```{r global_options, include=FALSE}
library(knitr)
opts_chunk$set(comment=NA, fig.path='/tmp/Figs/', warning=FALSE, message=FALSE)
```
```{r echo=FALSE}
paste("Created:",date())
```
We repeat the computation except using a
different kernel. We choose the Matern Kernel of order 3/2 as this is perhaps the
next most popular choice after the squared exponential.
```{r}
load("lcdb.rda")
source("funcs.R")
GPR <- TRUE
```
Set the kernel type and choose an invers ewidth which gives similar fits to the squared exponential kernel.
```{r}
kerntype <- "matern"
wvec <- 2e-2
```
Now compute all the measures. Only those measures that depend on the GP fit will be changed. The Richards measures are unchanged.
```{r}
firstdate <- 53464
daterange <- 2764
detection.limit <- 20.5
```
```{r child="meascomp.Rmd",eval=TRUE}
```
Split the data into a training(2/3) and a test(1/3) sample in the same
way as before. The split will not be identical to that used on the
Richards measures because of the problem that not all the Richards
stats are computed on the NV group resulting in the discard of some
objects from the calculation.
```{r}
set.seed(123)
n <- nrow(cmdb)
isel <- sample(1:n,round(n/3))
trains <- cmdb[-isel,]
tests <- cmdb[isel,]
```
There are `r round(n/3)` observations in the test set and `r (n-round(n/3))` observations in the training set.
Redo the classification for this set of measures using the Matern kernel:
```{r}
opts_chunk$set(comment=NA, warning=FALSE, message=FALSE, error=FALSE)
load("feat.rda")
source("funcs.R")
require(MASS)
require(nnet)
require(ggplot2)
require(rpart)
require(rpart.plot)
require(xtable)
require(kernlab)
require(randomForest)
```
Set up the predictors that we will use throughout. Note that I have
transformed some of the variables as seen in the setup.
```{r}
predform <- "shov + maxdiff + dscore + log(totvar) + log(quadvar) + log(famp) + log(fslope) + log(outl) + gscore + lsd + nudlog(gtvar) + rm.amplitude + rm.beyond1std + rm.fpr20 +rm.fpr35 + rm.fpr50 + rm.fpr80 + log(rm.maxslope) + rm.mad +asylog(rm.medbuf) + rm.pairslope + log(rm.peramp) + log(rm.pdfp) + rm.skew + log(rm.kurtosis)+ rm.std + dublog(rm.rcorbor)"
preds <- c("shov","maxdiff","dscore","totvar","quadvar","famp","fslope","outl","gscore","lsd","gtvar","rm.amplitude","rm.beyond1std","rm.fpr20","rm.fpr35","rm.fpr50","rm.fpr80","rm.maxslope","rm.mad","rm.medbuf","rm.pairslope","rm.peramp","rm.pdfp","rm.skew","rm.kurtosis","rm.std","rm.rcorbor")
tpredform <- paste(preds,collapse="+")
```
```{r child="childfeat.Rmd",eval=TRUE}
```
```{r}
cmaternGPR <- cmat
```