Meeting on May 12 2017

To check whether the points is in the interior area

## Loading required package: nlme
## This is mgcv 1.8-15. For overview type 'help("mgcv-package")'.

Project 4D to 3D

## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:taRifx':
## 
##     distinct
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

3D plot of lat, long, airtemp

You must enable Javascript to view this page properly.

## Warning: Ignoring 2904 observations

3D plot of lat, long, elevation

You must enable Javascript to view this page properly.

3D plot of lat, elevation, airtemp

You must enable Javascript to view this page properly.

## Warning: Ignoring 2904 observations

3D plot of long, elevation, airtemp

You must enable Javascript to view this page properly.

## Warning: Ignoring 2904 observations

In the training set, there is no SAV, but testing set including SAV.

 Test.Site1 <- c("US-Bo1","US-Ne1","US-ARM","US-Ro1", # CRO
                "US-Ced", # CSH
                "US-Ha1","US-WCr","US-MMS", # DBF
                "US-Skr", # EBF
                "US-Ho1","US-Wrc","US-NR1","CA-TP1","US-GLE","US-Me2","US-SP1", # ENF
                "US-Var","US-Wkg","US-FPe", # GRA
                "US-PFa", # MF
                "US-Whs","US-Ses","US-SRC", # OSH
                "US-Los","US-Brw", # WET
                "US-Ton", # WSA
                "US-Wjs"#SAV
                )
 
Train.data1 <- subset(Full.Data,!(site %in% Test.Site1)) 
Test.data1 <- subset(Full.Data,(site %in% Test.Site1))
Obs1 <- Test.data1[,2]

table(Train.data1$species)
## 
##  CRO  CSH  DBF  EBF  ENF  GRA   MF  OSH  SAV  WET  WSA 
## 1932  920 2461  345 6003 2484  920 1219    0  782  529
table(Test.data1$species)
## 
##  CRO  CSH  DBF  EBF  ENF  GRA   MF  OSH  SAV  WET  WSA 
## 1081  230 1334  184 2438  828  483  552  184  598  322
library(mgcv)
Mod.Train6 <- gam(flux ~ s(elevation,bs="tp")
                  + s(airtemp,bs="tp")
                  + ti(elevation,airtemp) # to use this the main effect has to be smoothed?
                  + s(lat,long,bs="ts"),
                  data=Train.data1,
                  na.action = na.exclude)

Pred6 <- predict(Mod.Train6,Test.data1[,-c(1,2)])
PlotPredRes(Obs1,Pred6)