## Loading required package: nlme
## This is mgcv 1.8-15. For overview type 'help("mgcv-package")'.
## 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
You must enable Javascript to view this page properly.
## Warning: Ignoring 2904 observations
You must enable Javascript to view this page properly.
You must enable Javascript to view this page properly.
## Warning: Ignoring 2904 observations
You must enable Javascript to view this page properly.
## Warning: Ignoring 2904 observations
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)