{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# python packages \n",
    "import numpy as np\n",
    "import datetime\n",
    "import netCDF4\n",
    "import sys\n",
    "import math \n",
    "from pandas import DataFrame \n",
    "from collections import Counter\n",
    "\n",
    "# python packages to handle R functions\n",
    "import rpy2.robjects as robjects\n",
    "import rpy2.robjects.packages as rpackages # import rpy2's package module\n",
    "from rpy2.robjects.packages import importr # import R's utility package\n",
    "# This is the command to call R: r('R_expression')\n",
    "r = robjects.r\n",
    "# Some R packages\n",
    "base = importr('base')\n",
    "psych = importr('psych')\n",
    "car = importr('car')\n",
    "reshape2 = importr('reshape2')\n",
    "ggplot2 = importr('ggplot2')\n",
    "mgcv = importr('mgcv')\n",
    "utils = importr('utils')\n",
    "importr(\"data.table\")\n",
    "# select a mirror for R packages\n",
    "utils.chooseCRANmirror(ind=1) # select the first mirror in the list\n",
    "from rpy2.robjects import FloatVector\n",
    "import rpy2.robjects.numpy2ri # For the conversion of numpy objects into R \n",
    "rpy2.robjects.numpy2ri.activate()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#East Eurasia with 1000 subsamples \n",
    "def gam_1000subsample_ea_east(dataforr_ea_east):\n",
    "\n",
    "    columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "    dataframe_ea_east = DataFrame(dataforr_ea_east[:,0:13], columns=columns[0:13])\n",
    "\n",
    "    r.assign('datainr_ea_east',dataforr_ea_east); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('data_ea_east <- data.table(datainr_ea_east)');\n",
    "    r('names(data_ea_east) <- c(\"VCFF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )')\n",
    "    #r('print(data_ea_east)')\n",
    "\n",
    "\n",
    "    # with subsampling\n",
    "    index = np.random.random_integers(0, len(dataforr_ea_east[:,0])-1, 1000)\n",
    "    subsample_forr_ea_east = np.transpose(np.array([np.take(dataforr_ea_east[:,0],index), np.take(dataforr_ea_east[:,1],index), \\\n",
    "                                           np.take(dataforr_ea_east[:,2],index), np.take(dataforr_ea_east[:,3],index), \\\n",
    "                                                np.take(dataforr_ea_east[:,4],index),\\\n",
    "                                           np.take(dataforr_ea_east[:,5],index), np.take(dataforr_ea_east[:,6],index),\\\n",
    "                                           np.take(dataforr_ea_east[:,7],index), np.take(dataforr_ea_east[:,8],index)])) \n",
    "    sub_lons_ea_east = np.take(dataforr_ea_east[:,-2], index)\n",
    "    sub_lats_ea_east = np.take(dataforr_ea_east[:,-1], index)\n",
    "    r.assign('subinr_ea_east',subsample_forr_ea_east); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('sub_ea_east <- data.table(subinr_ea_east)');\n",
    "    r('names(sub_ea_east) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\")')\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR), data = sub_ea_east)'); # gam to explain VCFF using s(MAR) \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MSSM), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI), data = sub_ea_east)');\n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(FF), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(GDD0), data = sub_ea_east)');\n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PTD), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(ST), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin)+s(GDD0), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI)+s(FF), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM)+s(MTmin)+s(PZI)+s(FF)+s(GDD0)+s(ST), data = sub_ea_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    \n",
    "    # to print to a txt, substitute print(r('summary(mod_gam_sub)')) with \n",
    "    # path = 'path_to_txt'\n",
    "    #f = open('path/gam_ea_east_all.txt', 'a')\n",
    "    #print >> f, \"Northern East Eurasia - 1000 Subsampling\",'\\n',r('summary(mod_gam)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam)')  # or f.write('...\\n') #from second on\n",
    "\n",
    "    #f.close()\n",
    "    \n",
    "    \n",
    "    return\n",
    "\n",
    "def gam_1000subsample_ea_west(dataforr_ea_west):\n",
    "\n",
    "    columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "    dataframe_ea_west = DataFrame(dataforr_ea_west[:,0:13], columns=columns[0:13])\n",
    "\n",
    "    r.assign('datainr_ea_west',dataforr_ea_west); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('data_ea_west <- data.table(datainr_ea_west)');\n",
    "    r('names(data_ea_west) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )')\n",
    "    #r('print(data_ea_west)')\n",
    "\n",
    "\n",
    "    # with subsampling\n",
    "    index = np.random.random_integers(0, len(dataforr_ea_west[:,0])-1, 1000)\n",
    "    subsample_forr_ea_west = np.transpose(np.array([np.take(dataforr_ea_west[:,0],index), np.take(dataforr_ea_west[:,1],index), \\\n",
    "                                               np.take(dataforr_ea_west[:,2],index), np.take(dataforr_ea_west[:,3],index), \\\n",
    "                                                    np.take(dataforr_ea_west[:,4],index),\\\n",
    "                                               np.take(dataforr_ea_west[:,5],index), np.take(dataforr_ea_west[:,6],index),\\\n",
    "                                               np.take(dataforr_ea_west[:,7],index), np.take(dataforr_ea_west[:,8],index)])) \n",
    "    sub_lons_ea_west = np.take(dataforr_ea_west[:,-2], index)\n",
    "    sub_lats_ea_west = np.take(dataforr_ea_west[:,-1], index)\n",
    "    r.assign('subinr_ea_west',subsample_forr_ea_west); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('sub_ea_west <- data.table(subinr_ea_west)');\n",
    "    r('names(sub_ea_west) <- c(\"VCFF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\")')\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)') # print full summary\n",
    "    # to print on txt use the following \n",
    "    # f = open('path_to_txt/gam_ea_west_single_1000_MAR.txt', 'a')\n",
    "    #for full output\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    # for deviance only output \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MSSM), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_single_1000_MASM.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_single_1000_MTmin.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_single_1000_PZI.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(FF), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_single_1000_FF.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(GDD0), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_single_1000_GDD0.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PTD), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_single_1000_PTD.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "    \n",
    "    k_ST = np.unique(subsample_forr_ea_west[:,8]).shape[0] #ST has less than 10 unique values, so we need to reassign the maximum number of smooths\n",
    "    r.assign('k_ST',k_ST);\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(ST, k=k_ST), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_single_1000_ST.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first #\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_double_1000_MAR+MASM.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin)+s(GDD0), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_double_1000_MTmin+GDD0.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI)+s(FF), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_double_1000_PZI+FF.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM)+s(MTmin)+s(PZI)+s(FF)+s(GDD0)+s(ST, k=k_ST), data = sub_ea_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_ea_west_all_1000.txt', 'a')\n",
    "    #print >> f, \"Northern West Eurasia - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "    \n",
    "    return\n",
    "\n",
    "\n",
    "def gam_1000subsample_na_west(dataforr_na_west):\n",
    "\n",
    "    columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "    dataframe_na_west = DataFrame(dataforr_na_west[:,0:13], columns=columns[0:13])\n",
    "\n",
    "    r.assign('datainr_na_west',dataforr_na_west); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('data_na_west <- data.table(datainr_na_west)');\n",
    "    r('names(data_na_west) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )')\n",
    "    #r('print(data_na_west)')\n",
    "\n",
    "\n",
    "    # with subsampling\n",
    "    index = np.random.random_integers(0, len(dataforr_na_west[:,0])-1, 1000)\n",
    "    subsample_forr_na_west = np.transpose(np.array([np.take(dataforr_na_west[:,0],index), np.take(dataforr_na_west[:,1],index), \\\n",
    "                                               np.take(dataforr_na_west[:,2],index), np.take(dataforr_na_west[:,3],index), \\\n",
    "                                                    np.take(dataforr_na_west[:,4],index),\\\n",
    "                                               np.take(dataforr_na_west[:,5],index), np.take(dataforr_na_west[:,6],index),\\\n",
    "                                               np.take(dataforr_na_west[:,7],index), np.take(dataforr_na_west[:,8],index)])) \n",
    "    sub_lons_na_west = np.take(dataforr_na_west[:,-2], index)\n",
    "    sub_lats_na_west = np.take(dataforr_na_west[:,-1], index)\n",
    "    r.assign('subinr_na_west',subsample_forr_na_west); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('sub_na_west <- data.table(subinr_na_west)');\n",
    "    r('names(sub_na_west) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\")')\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_MAR.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MSSM), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_MSSM.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_MTmin.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_PZI.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(FF), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_FF.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(GDD0), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_GDD0.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PTD), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_PTD.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(ST), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_single_1000_ST.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first #\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_double_1000_MAR+MSSM.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin)+s(GDD0), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_double_1000_MTmin+GDD0.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI)+s(FF), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_double_1000_PZI+FF.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM)+s(MTmin)+s(PZI)+s(FF)+s(GDD0)+s(ST), data = sub_na_west)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_west_all_1000.txt', 'a')\n",
    "    #print >> f, \"Western North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "    \n",
    "    return\n",
    "\n",
    "\n",
    "#East North America with 1000 subsamples \n",
    "#dataforr_na_east = np.loadtxt('boreal_na_east_database_canadianupdate.txt')\n",
    "def gam_1000subsample_na_east(dataforr_na_east):\n",
    "     \n",
    "#(\"boreal_na_west_database_canadianupdate.txt\")\n",
    "#'boreal_na_east_database.txt'\n",
    "#boreal_ea_west_russia_database#\n",
    "#boreal_na_east_database_canadianupdate\n",
    "    columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "    dataframe_na_east = DataFrame(dataforr_na_east[:,0:13], columns=columns[0:13])\n",
    "\n",
    "    r.assign('datainr_na_east',dataforr_na_east); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('data_na_east <- data.table(datainr_na_east)');\n",
    "    r('names(data_na_east) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )')\n",
    "    #r('print(data_na_east)')\n",
    "\n",
    "\n",
    "    # with subsampling\n",
    "    index = np.random.random_integers(0, len(dataforr_na_east[:,0])-1, 1000)\n",
    "    subsample_forr_na_east = np.transpose(np.array([np.take(dataforr_na_east[:,0],index), np.take(dataforr_na_east[:,1],index), \\\n",
    "                                               np.take(dataforr_na_east[:,2],index), np.take(dataforr_na_east[:,3],index), \\\n",
    "                                                    np.take(dataforr_na_east[:,4],index),\\\n",
    "                                               np.take(dataforr_na_east[:,5],index), np.take(dataforr_na_east[:,6],index),\\\n",
    "                                               np.take(dataforr_na_east[:,7],index), np.take(dataforr_na_east[:,8],index)])) \n",
    "    sub_lons_na_east = np.take(dataforr_na_east[:,-2], index)\n",
    "    sub_lats_na_east = np.take(dataforr_na_east[:,-1], index)\n",
    "    r.assign('subinr_na_east',subsample_forr_na_east); # However, this is a matrix and we need a data.frame object in R\n",
    "    r('sub_na_east <- data.table(subinr_na_east)');\n",
    "    r('names(sub_na_east) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\")')\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_MAR.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MSSM), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_MSSM.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_MTmin.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_PZI.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(FF), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_FF.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(GDD0), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_GDD0.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PTD), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_PTD.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(ST), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_single_1000_ST.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first #\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_double_1000_MAR+MSSM.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MTmin)+s(GDD0), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_double_1000_MTmin+GDD0.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(PZI)+s(FF), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_double_1000_PZI+FF.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "\n",
    "    r('mod_gam_sub <- gam(TCF ~ s(MAR)+s(MSSM)+s(MTmin)+s(PZI)+s(FF)+s(GDD0)+s(ST), data = sub_na_east)'); \n",
    "    print r('summary(mod_gam_sub)')\n",
    "    #f = open('path_to_txt/gam_na_east_all_1000.txt', 'a')\n",
    "    #print >> f, \"Eastern North America - Subsample n=1000\",'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') # for first \n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)')  # or f.write('...\\n') #from second on\n",
    "    #print >> f,'\\n',r('summary(mod_gam_sub)$dev.expl')\n",
    "    #f.close()\n",
    "    \n",
    "    return"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MTmin) + s(MSSM) + s(ST) + s(PZI) + s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.5660     0.1942   105.9   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MAR)   8.262  8.850 13.41  <2e-16 ***\n",
      "s(MTmin) 7.813  8.662 11.69  <2e-16 ***\n",
      "s(MSSM)  7.647  8.544 20.12  <2e-16 ***\n",
      "s(ST)    8.028  8.641 25.20  <2e-16 ***\n",
      "s(PZI)   8.635  8.958 59.48  <2e-16 ***\n",
      "s(FF)    5.023  5.988 35.21  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.519   Deviance explained = 52.3%\n",
      "GCV = 222.26  Scale est. = 220.49    n = 5848\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   20.566      0.217   94.79   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 8.509  8.932 436.7  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =    0.4   Deviance explained = 40.1%\n",
      "GCV = 275.71  Scale est. = 275.26    n = 5848\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# dataset to be used\n",
    "#East Eurasia without subsamples\n",
    "\n",
    "dataforr_ea_east = np.loadtxt('/Users/Beniamino/Documents/OneDrive/MPI-M/Git_MyPaper/2016_BG_Abis/Analysis/files_to_load_and_import/boreal_ea_east_database.txt') #eventually add path to database. \n",
    "columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "dataframe_ea_east = DataFrame(dataforr_ea_east[:,0:13], columns=columns[0:13]) # transformed into a dataframe, as needed for R\n",
    "\n",
    "# assign dataframe to R\n",
    "r.assign('datainr_ea_east',dataforr_ea_east); # However, this is a matrix and we need a data.frame object in R\n",
    "r('data_ea_east <- data.table(datainr_ea_east)'); #transform it to a data.table for fast handling\n",
    "r('names(data_ea_east) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )');\n",
    "#r('print(data_ea_east)')\n",
    "\n",
    "# no subsampling \n",
    "r('mod_gam <- gam(TCF ~ s(MAR)+s(MTmin)+s(MSSM)+s(ST)+s(PZI)+s(FF), data = data_ea_east)'); # explains TCF using specified variables\n",
    "print r('summary(mod_gam)')\n",
    "# let's print to a txt\n",
    "#f = open('/pathtotxt/gam_ea_east_all.txt', 'a')\n",
    "#print >> f, \"Northern East Eurasia - No Subsampling\",'\\n',r('summary(mod_gam)')  # or f.write('...\\n') # for first \n",
    "#print >> f,'\\n',r('summary(mod_gam)')  # or f.write('...\\n') #from second on\n",
    "#r('mod_gam <- gam(TCF ~ s(MAR), data = data_ea_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "r('mod_gam <- gam(TCF ~ s(MTmin), data = data_ea_east)'); # explains TCF using specified variables\n",
    "print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(MSSM), data = data_ea_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(PZI), data = data_ea_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(FF), data = data_ea_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(ST), data = data_ea_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(FF) + s(MTmin) + s(PZI) + s(ST, k = k_ST) + \n",
      "    s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  34.2777     0.4404   77.83   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   4.777  5.914  3.466  0.00226 ** \n",
      "s(FF)    6.042  7.117  4.908 1.54e-05 ***\n",
      "s(MTmin) 7.553  8.453  9.287 5.41e-13 ***\n",
      "s(PZI)   2.459  3.102  8.842 6.78e-06 ***\n",
      "s(ST)    5.665  6.491 26.912  < 2e-16 ***\n",
      "s(MSSM)  1.265  1.485 26.876 5.14e-09 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.486   Deviance explained = 49.5%\n",
      "GCV = 308.11  Scale est. = 302.43    n = 1559\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  34.2777     0.5244   65.36   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 4.173  5.164 109.7  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.271   Deviance explained = 27.3%\n",
      "GCV = 430.21  Scale est. = 428.79    n = 1559\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#West Eurasia without subsamples \n",
    "dataforr_ea_west = np.loadtxt('/Users/Beniamino/Documents/OneDrive/MPI-M/Git_MyPaper/2016_BG_Abis/Analysis/files_to_load_and_import/boreal_ea_west_russia_database.txt') \n",
    "columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "dataframe_ea_west = DataFrame(dataforr_ea_west[:,0:13], columns=columns[0:13])\n",
    "\n",
    "r.assign('datainr_ea_west',dataforr_ea_west); # However, this is a matrix and we need a data.frame object in R\n",
    "r('data_ea_west <- data.table(datainr_ea_west)');\n",
    "r('names(data_ea_west) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )')\n",
    "#r('print(data_ea_west)')\n",
    "\n",
    "# no subsample for West Eurasia\n",
    "k_ST = np.unique(dataforr_ea_west[:,8]).shape[0] #ST has only 9 different values in this dataset. gam autoamtically\n",
    "# assign a maximum number of degree of freedom k = 10, since 9<10 we need to specify in the smooth that we want at maximum \n",
    "# k=9 dof\n",
    "r.assign('k_ST', k_ST);\n",
    "\n",
    "r('mod_gam <- gam(TCF ~ s(MAR)+s(FF)+s(MTmin)+s(PZI)+s(ST,k=k_ST)+s(MSSM), data = data_ea_west)'); #+s(MASM)+s(Tmin)+s(PZI)+s(FF)+s(PTD)+s(GDD0)\n",
    "print r('summary(mod_gam)')\n",
    "# let's print to a txt\n",
    "#f = open('path_to_txt/gam_ea_west_settuple.txt', 'a')\n",
    "#print >> f, \"Northern West Eurasia - No Subsampling\",'\\n',r('summary(mod_gam)')  # or f.write('...\\n') # for first \n",
    "#print >> f,'\\n',r('summary(mod_gam)')  # or f.write('...\\n') #from second on\n",
    "#r('mod_gam <- gam(TCF ~ s(MAR), data = data_ea_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "r('mod_gam <- gam(TCF ~ s(MTmin), data = data_ea_west)'); # explains TCF using specified variables\n",
    "print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(MSSM), data = data_ea_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(PZI), data = data_ea_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(FF), data = data_ea_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(ST,k=k_ST), data = data_ea_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(FF) + s(MTmin) + s(PZI) + s(ST) + s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   22.358      0.261   85.65   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   8.620  8.959 16.093  < 2e-16 ***\n",
      "s(FF)    7.562  8.246  7.895 9.72e-11 ***\n",
      "s(MTmin) 7.855  8.687 51.374  < 2e-16 ***\n",
      "s(PZI)   7.157  8.174 58.611  < 2e-16 ***\n",
      "s(ST)    8.505  8.872 26.576  < 2e-16 ***\n",
      "s(MSSM)  7.837  8.661  3.675 0.000188 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.549   Deviance explained = 55.6%\n",
      "GCV =  214.2  Scale est. = 210.84    n = 3094\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   22.358      0.306   73.06   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(MTmin) 8.54  8.943 212.2  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =   0.38   Deviance explained = 38.2%\n",
      "GCV = 290.65  Scale est. = 289.76    n = 3094\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#West North America without subsamples\n",
    "dataforr_na_west = np.loadtxt('/Users/Beniamino/Documents/OneDrive/MPI-M/Git_MyPaper/2016_BG_Abis/Analysis/files_to_load_and_import/boreal_na_west_database_canadianupdate.txt') \n",
    "columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "dataframe_na_west = DataFrame(dataforr_na_west[:,0:13], columns=columns[0:13])\n",
    "\n",
    "r.assign('datainr_na_west',dataforr_na_west); # However, this is a matrix and we need a data.frame object in R\n",
    "r('data_na_west <- data.table(datainr_na_west)');\n",
    "r('names(data_na_west) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )')\n",
    "#r('print(data_na_west)')\n",
    "\n",
    "#no subsample \n",
    "r('mod_gam <- gam(TCF ~ s(MAR)+s(FF)+s(MTmin)+s(PZI)+s(ST)+s(MSSM), data = data_na_west)'); \n",
    "print r('summary(mod_gam)')\n",
    "# let's print to a txt\n",
    "#f = open('path_to_txt/gam_na_west_settuple.txt', 'a')\n",
    "#print >> f, \"Western North America - No Subsampling\",'\\n',r('summary(mod_gam)')  # or f.write('...\\n') # for first \n",
    "#print >> f,'\\n',r('summary(mod_gam)')  # or f.write('...\\n') #from second on\n",
    "#r('mod_gam <- gam(TCF ~ s(MAR), data = data_na_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "r('mod_gam <- gam(TCF ~ s(MTmin), data = data_na_west)'); # explains TCF using specified variables\n",
    "print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(MSSM), data = data_na_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(PZI), data = data_na_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(FF), data = data_na_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(ST,k=k_ST), data = data_na_west)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(FF) + s(MTmin) + s(PZI) + s(ST) + s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  27.5279     0.2663   103.4   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   8.303  8.864  6.027 3.22e-08 ***\n",
      "s(FF)    7.721  8.498  6.672 6.21e-09 ***\n",
      "s(MTmin) 4.503  5.671  4.738 0.000139 ***\n",
      "s(PZI)   1.892  2.324 27.918 1.09e-13 ***\n",
      "s(ST)    6.560  7.469 13.576  < 2e-16 ***\n",
      "s(MSSM)  8.095  8.781  5.547 2.24e-07 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.772   Deviance explained = 77.6%\n",
      "GCV = 128.62  Scale est. = 125.86    n = 1775\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   27.528      0.296   92.98   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 6.211  7.382 609.3  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.718   Deviance explained = 71.9%\n",
      "GCV =  156.2  Scale est. = 155.57    n = 1775\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#East North America without subsamples\n",
    "dataforr_na_east = np.loadtxt('/Users/Beniamino/Documents/OneDrive/MPI-M/Git_MyPaper/2016_BG_Abis/Analysis/files_to_load_and_import/boreal_na_east_database_canadianupdate.txt')\n",
    "columns=[\"TCF\", \"MAR\", \"Mean_Spring_SM\", \"Mean_Tmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" ]\n",
    "dataframe_na_east = DataFrame(dataforr_na_east[:,0:13], columns=columns[0:13])\n",
    "r.assign('datainr_na_east',dataforr_na_east); # However, this is a matrix and we need a data.frame object in R\n",
    "r('data_na_east <- data.table(datainr_na_east)');\n",
    "r('names(data_na_east) <- c(\"TCF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\", \"State\",\"Elev\", \"Lon\", \"Lat\" )')\n",
    "\n",
    "# no subsample\n",
    "r('mod_gam <- gam(TCF ~ s(MAR)+s(FF)+s(MTmin)+s(PZI)+s(ST)+s(MSSM), data = data_na_east)'); \n",
    "print r('summary(mod_gam)')\n",
    "# let's print to a txt\n",
    "#f = open('path_to_txt/gam_na_west_settuple.txt', 'a')\n",
    "#print >> f, \"Western North America - No Subsampling\",'\\n',r('summary(mod_gam)')  # or f.write('...\\n') # for first \n",
    "#print >> f,'\\n',r('summary(mod_gam)')  # or f.write('...\\n') #from second on\n",
    "#r('mod_gam <- gam(TCF ~ s(MAR), data = data_na_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "r('mod_gam <- gam(TCF ~ s(MTmin), data = data_na_east)'); # explains TCF using specified variables\n",
    "print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(MSSM), data = data_na_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(PZI), data = data_na_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(FF), data = data_na_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#r('mod_gam <- gam(TCF ~ s(ST,k=k_ST), data = data_na_east)'); # explains TCF using specified variables\n",
    "#print r('summary(mod_gam)')\n",
    "#f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#All regions with 1000 gridcells subsamples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.5993   34.82   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(MAR) 5.429  6.598 55.54  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.268   Deviance explained = 27.2%\n",
      "GCV = 361.44  Scale est. = 359.12    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.6336   32.93   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(MSSM) 5.162  6.284 35.34  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.182   Deviance explained = 18.6%\n",
      "GCV = 403.89  Scale est. = 401.4     n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.5423   38.48   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 5.766   6.94 95.43  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.401   Deviance explained = 40.4%\n",
      "GCV = 296.04  Scale est. = 294.04    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.5405   38.61   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PZI) 6.905  7.963 85.67  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.405   Deviance explained = 40.9%\n",
      "GCV = 294.44  Scale est. = 292.11    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.6887    30.3   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F  p-value    \n",
      "s(FF) 6.641  7.602 4.886 1.11e-05 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.0332   Deviance explained = 3.97%\n",
      "GCV =    478  Scale est. = 474.35    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.4664   44.74   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(GDD0) 8.108  8.788 143.2  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.557   Deviance explained =   56%\n",
      "GCV = 219.48  Scale est. = 217.48    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PTD)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.5861    35.6   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PTD) 8.917  8.998 47.94  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =    0.3   Deviance explained = 30.6%\n",
      "GCV =  346.9  Scale est. = 343.46    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.6584   31.69   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(ST) 6.885  7.783 17.02  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.117   Deviance explained = 12.3%\n",
      "GCV = 436.89  Scale est. = 433.45    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.5933   35.17   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df      F  p-value    \n",
      "s(MAR)  4.855  5.968 26.700  < 2e-16 ***\n",
      "s(MSSM) 2.720  3.491  6.585 0.000102 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.283   Deviance explained = 28.8%\n",
      "GCV = 355.01  Scale est. = 351.97    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin) + s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.4519   46.17   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F  p-value    \n",
      "s(MTmin) 3.874  4.879 13.42 2.68e-12 ***\n",
      "s(GDD0)  7.904  8.681 56.54  < 2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.584   Deviance explained = 58.9%\n",
      "GCV =  206.9  Scale est. = 204.25    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI) + s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.5179   40.29   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F  p-value    \n",
      "s(PZI) 6.892  7.950 96.59  < 2e-16 ***\n",
      "s(FF)  6.585  7.552 12.09 1.27e-15 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.453   Deviance explained = 46.1%\n",
      "GCV = 272.21  Scale est. = 268.27    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM) + s(MTmin) + s(PZI) + s(FF) + s(GDD0) + \n",
      "    s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  20.8660     0.4208   49.59   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   4.243  5.278  4.472 0.000397 ***\n",
      "s(MSSM)  1.000  1.000  0.323 0.570103    \n",
      "s(MTmin) 1.000  1.000  6.261 0.012499 *  \n",
      "s(PZI)   2.879  3.559 17.362 3.81e-12 ***\n",
      "s(FF)    1.000  1.000 42.363 1.19e-10 ***\n",
      "s(GDD0)  6.052  7.222 54.063  < 2e-16 ***\n",
      "s(ST)    7.318  8.136  6.459 2.73e-08 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.639   Deviance explained = 64.8%\n",
      "GCV = 181.52  Scale est. = 177.07    n = 1000\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Error in eval(expr, envir, enclos) : object 'TCF' not found\n",
      "\n",
      "  res = super(Function, self).__call__(*new_args, **new_kwargs)\n",
      "/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: 3: \n",
      "  res = super(Function, self).__call__(*new_args, **new_kwargs)\n",
      "/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: 4: \n",
      "  res = super(Function, self).__call__(*new_args, **new_kwargs)\n",
      "/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: In `names<-.data.table`(`*tmp*`, value = c(\"VCFF\", \"MAR\", \"MSSM\",  :\n",
      "  res = super(Function, self).__call__(*new_args, **new_kwargs)\n",
      "/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: 5: \n",
      "  res = super(Function, self).__call__(*new_args, **new_kwargs)\n",
      "/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: 6: \n",
      "  res = super(Function, self).__call__(*new_args, **new_kwargs)\n",
      "/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: 7: \n",
      "  res = super(Function, self).__call__(*new_args, **new_kwargs)\n"
     ]
    },
    {
     "ename": "RRuntimeError",
     "evalue": "Error in eval(expr, envir, enclos) : object 'TCF' not found\n",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mRRuntimeError\u001b[0m                             Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-8-47e675601ff4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      2\u001b[0m     \u001b[0mgam_1000subsample_ea_east\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataforr_ea_east\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m     \u001b[0mgam_1000subsample_ea_west\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataforr_ea_west\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m<ipython-input-3-d531a11d3fa4>\u001b[0m in \u001b[0;36mgam_1000subsample_ea_west\u001b[0;34m(dataforr_ea_west)\u001b[0m\n\u001b[1;32m     97\u001b[0m     \u001b[0mr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'names(sub_ea_west) <- c(\"VCFF\", \"MAR\", \"MSSM\", \"MTmin\", \"PZI\", \"FF\", \"GDD0\", \"PTD\", \"ST\")'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     98\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 99\u001b[0;31m     \u001b[0mr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'mod_gam_sub <- gam(TCF ~ s(MAR), data = sub_ea_west)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    100\u001b[0m     \u001b[0;32mprint\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'summary(mod_gam_sub)'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# print full summary\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    101\u001b[0m     \u001b[0;31m# to print on txt use the following\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python2.7/site-packages/rpy2/robjects/__init__.pyc\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, string)\u001b[0m\n\u001b[1;32m    317\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m__call__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstring\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    318\u001b[0m         \u001b[0mp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_rparse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mStrSexpVector\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstring\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 319\u001b[0;31m         \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meval\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    320\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mconversion\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mri2py\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mres\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    321\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.pyc\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m    176\u001b[0m                 \u001b[0mv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    177\u001b[0m                 \u001b[0mkwargs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mr_k\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 178\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mSignatureTranslatedFunction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__call__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    179\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    180\u001b[0m \u001b[0mpattern_link\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mre\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcompile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mr'\\\\link\\{(.+?)\\}'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python2.7/site-packages/rpy2/robjects/functions.pyc\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m    104\u001b[0m         \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    105\u001b[0m             \u001b[0mnew_kwargs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconversion\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpy2ri\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 106\u001b[0;31m         \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mFunction\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__call__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mnew_args\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mnew_kwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    107\u001b[0m         \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconversion\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mri2ro\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mres\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    108\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mRRuntimeError\u001b[0m: Error in eval(expr, envir, enclos) : object 'TCF' not found\n"
     ]
    }
   ],
   "source": [
    "n_samples = 30 # number of samples to be taken\n",
    "for i in range(n_samples):\n",
    "    gam_1000subsample_ea_east(dataforr_ea_east)\n",
    "    gam_1000subsample_ea_west(dataforr_ea_west)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.5072    56.9   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(MAR) 7.604  8.526 140.8  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.545   Deviance explained = 54.9%\n",
      "GCV = 259.51  Scale est. = 257.27    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.5572    51.8   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(MSSM) 8.302  8.867 92.84  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.451   Deviance explained = 45.6%\n",
      "GCV = 313.35  Scale est. = 310.44    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.3981    72.5   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 6.049  7.225 354.2  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =   0.72   Deviance explained = 72.2%\n",
      "GCV =  159.6  Scale est. = 158.48    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.4073   70.86   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PZI) 2.472  2.992 804.7  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.707   Deviance explained = 70.8%\n",
      "GCV = 166.46  Scale est. = 165.88    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.7308   39.49   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(FF) 7.071  8.039 7.913 2.1e-10 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.0559   Deviance explained = 6.26%\n",
      "GCV = 538.48  Scale est. = 534.13    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.4158   69.41   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(GDD0) 7.502   8.44 268.9  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.694   Deviance explained = 69.7%\n",
      "GCV = 174.37  Scale est. = 172.88    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PTD)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.5629   51.27   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PTD) 8.954  8.999 88.14  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =   0.44   Deviance explained = 44.5%\n",
      "GCV = 320.05  Scale est. = 316.87    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.5477    52.7   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(ST) 8.778  8.981 98.59  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =   0.47   Deviance explained = 47.4%\n",
      "GCV = 302.94  Scale est. = 299.98    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.4904   58.85   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df      F  p-value    \n",
      "s(MAR)  7.681  8.572 34.556  < 2e-16 ***\n",
      "s(MSSM) 7.980  8.730  8.367 1.05e-11 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.575   Deviance explained = 58.2%\n",
      "GCV = 244.59  Scale est. = 240.52    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin) + s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.3852   74.92   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MTmin) 7.069  8.151 20.699  < 2e-16 ***\n",
      "s(GDD0)  7.119  8.189  8.417 2.91e-11 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.738   Deviance explained = 74.1%\n",
      "GCV = 150.69  Scale est. = 148.4     n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI) + s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.4024   71.72   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df       F  p-value    \n",
      "s(PZI) 2.308  2.809 827.628  < 2e-16 ***\n",
      "s(FF)  5.767  6.833   4.123 0.000217 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.714   Deviance explained = 71.6%\n",
      "GCV = 163.43  Scale est. = 161.95    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM) + s(MTmin) + s(PZI) + s(FF) + s(GDD0) + \n",
      "    s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  28.8620     0.3304   87.36   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   8.407  8.897 12.686  < 2e-16 ***\n",
      "s(MSSM)  8.049  8.758  2.377 0.012635 *  \n",
      "s(MTmin) 8.078  8.775  3.798 0.000126 ***\n",
      "s(PZI)   1.000  1.000  5.284 0.021733 *  \n",
      "s(FF)    6.237  7.288  5.141 7.15e-06 ***\n",
      "s(GDD0)  7.185  8.258 13.428  < 2e-16 ***\n",
      "s(ST)    8.562  8.923  5.320 4.74e-07 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.807   Deviance explained = 81.6%\n",
      "GCV = 114.71  Scale est. = 109.14    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.5804   38.61   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(MAR) 7.303  8.315 50.04  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.293   Deviance explained = 29.8%\n",
      "GCV = 339.72  Scale est. = 336.9     n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.6318   35.47   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(MSSM) 6.426  7.607 25.82  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.162   Deviance explained = 16.8%\n",
      "GCV = 402.16  Scale est. = 399.17    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.5612   39.93   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df    F p-value    \n",
      "s(MTmin) 7.951  8.722 58.7  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.339   Deviance explained = 34.4%\n",
      "GCV = 317.79  Scale est. = 314.94    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   22.408      0.569   39.38   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PZI) 4.932  5.945 79.38  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =   0.32   Deviance explained = 32.4%\n",
      "GCV = 325.66  Scale est. = 323.73    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.6579   34.06   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(FF) 7.637  8.449 12.35  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.0916   Deviance explained = 9.85%\n",
      "GCV = 436.57  Scale est. = 432.8     n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.6087   36.81   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(GDD0) 7.569  8.506 33.72  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.222   Deviance explained = 22.8%\n",
      "GCV = 373.78  Scale est. = 370.58    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PTD)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.6111   36.67   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PTD) 8.664  8.969 30.94  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.216   Deviance explained = 22.3%\n",
      "GCV = 377.13  Scale est. = 373.49    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.6434   34.83   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "      edf Ref.df     F p-value    \n",
      "s(ST) 8.1  8.613 17.93  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.131   Deviance explained = 13.8%\n",
      "GCV =  417.8  Scale est. = 413.99    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.5801   38.63   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df      F p-value    \n",
      "s(MAR)  7.247  8.274 26.387  <2e-16 ***\n",
      "s(MSSM) 1.000  1.000  2.261   0.133    \n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.294   Deviance explained =   30%\n",
      "GCV = 339.62  Scale est. = 336.48    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin) + s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.5318   42.13   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 8.159   8.80 35.13  <2e-16 ***\n",
      "s(GDD0)  8.263   8.84 13.32  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.406   Deviance explained = 41.6%\n",
      "GCV = 287.85  Scale est. = 282.83    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI) + s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.5598   40.03   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df      F  p-value    \n",
      "s(PZI) 4.653  5.627 67.267  < 2e-16 ***\n",
      "s(FF)  8.024  8.684  4.421 1.61e-05 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.342   Deviance explained =   35%\n",
      "GCV = 317.77  Scale est. = 313.42    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM) + s(MTmin) + s(PZI) + s(FF) + s(GDD0) + \n",
      "    s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.4080     0.4545    49.3   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   6.846  7.963  6.735 1.42e-08 ***\n",
      "s(MSSM)  1.000  1.000  0.117   0.7325    \n",
      "s(MTmin) 7.519  8.459 11.568 2.28e-16 ***\n",
      "s(PZI)   4.985  6.041 31.230  < 2e-16 ***\n",
      "s(FF)    3.493  4.317  2.915   0.0181 *  \n",
      "s(GDD0)  7.794  8.598  7.181 1.09e-09 ***\n",
      "s(ST)    8.110  8.643  9.353 3.80e-13 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.566   Deviance explained = 58.4%\n",
      "GCV = 215.37  Scale est. = 206.6     n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.5074   52.98   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(MAR) 5.264  6.448 186.5  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.546   Deviance explained = 54.9%\n",
      "GCV = 259.07  Scale est. = 257.45    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.5443   49.39   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df   F p-value    \n",
      "s(MSSM) 7.968  8.719 105  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.478   Deviance explained = 48.2%\n",
      "GCV = 298.94  Scale est. = 296.26    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.3853   69.76   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 6.339  7.503 374.4  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.738   Deviance explained =   74%\n",
      "GCV = 149.59  Scale est. = 148.49    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.3932   68.36   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PZI) 3.231  3.921 679.8  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.727   Deviance explained = 72.8%\n",
      "GCV = 155.29  Scale est. = 154.64    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.7101   37.86   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(FF) 8.478  8.906 14.45  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.111   Deviance explained = 11.9%\n",
      "GCV = 509.05  Scale est. = 504.22    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.3813   70.51   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(GDD0) 8.305  8.863 327.3  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.744   Deviance explained = 74.6%\n",
      "GCV = 146.74  Scale est. = 145.38    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PTD)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   26.883      0.546   49.23   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(PTD) 8.96      9 100.6  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.474   Deviance explained = 47.9%\n",
      "GCV = 301.16  Scale est. = 298.16    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.5354   50.21   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(ST) 8.694  8.954 109.6  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.495   Deviance explained = 49.9%\n",
      "GCV = 289.45  Scale est. = 286.64    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.4765   56.41   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(MAR)  6.881  8.022 38.84  <2e-16 ***\n",
      "s(MSSM) 7.424  8.392 15.35  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =    0.6   Deviance explained = 60.5%\n",
      "GCV = 230.62  Scale est. = 227.09    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin) + s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.3583   75.02   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 8.062  8.767 15.33  <2e-16 ***\n",
      "s(GDD0)  8.135  8.802 18.27  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.774   Deviance explained = 77.7%\n",
      "GCV = 130.65  Scale est. = 128.41    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI) + s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.3901   68.92   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df       F p-value    \n",
      "s(PZI) 3.287  4.006 574.471 < 2e-16 ***\n",
      "s(FF)  8.311  8.840   2.669 0.00496 ** \n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.732   Deviance explained = 73.5%\n",
      "GCV =  154.1  Scale est. = 152.16    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM) + s(MTmin) + s(PZI) + s(FF) + s(GDD0) + \n",
      "    s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  26.8830     0.3208    83.8   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   8.345  8.868  5.577 2.07e-07 ***\n",
      "s(MSSM)  4.226  5.284  3.231  0.00588 ** \n",
      "s(MTmin) 6.820  7.981  4.581 1.74e-05 ***\n",
      "s(PZI)   5.160  6.285  3.530  0.00158 ** \n",
      "s(FF)    7.947  8.646  3.844  0.00012 ***\n",
      "s(GDD0)  8.487  8.909 19.993  < 2e-16 ***\n",
      "s(ST)    5.917  6.871  4.596 5.55e-05 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.819   Deviance explained = 82.7%\n",
      "GCV = 108.09  Scale est. = 102.91    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.5822   37.81   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(MAR) 8.094  8.774 32.88  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.221   Deviance explained = 22.7%\n",
      "GCV =  342.1  Scale est. = 338.99    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.6199   35.52   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df     F p-value    \n",
      "s(MSSM) 7.604  8.514 15.96  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.117   Deviance explained = 12.4%\n",
      "GCV = 387.61  Scale est. = 384.28    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.5448   40.41   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df     F p-value    \n",
      "s(MTmin) 7.846  8.667 53.78  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.318   Deviance explained = 32.3%\n",
      "GCV = 299.51  Scale est. = 296.86    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   22.016      0.554   39.74   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PZI) 6.148  7.248 58.01  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.295   Deviance explained = 29.9%\n",
      "GCV = 309.08  Scale est. = 306.88    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.6182   35.61   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df    F p-value    \n",
      "s(FF) 7.589  8.414 16.8  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.122   Deviance explained = 12.9%\n",
      "GCV =  385.5  Scale est. = 382.19    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.5836   37.72   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df    F p-value    \n",
      "s(GDD0) 8.418  8.909 31.8  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.217   Deviance explained = 22.4%\n",
      "GCV = 343.86  Scale est. = 340.62    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PTD)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.5906   37.28   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df     F p-value    \n",
      "s(PTD) 7.542  8.482 29.45  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.199   Deviance explained = 20.5%\n",
      "GCV = 351.81  Scale est. = 348.81    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.6265   35.14   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "        edf Ref.df     F p-value    \n",
      "s(ST) 8.008  8.652 12.91  <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.0981   Deviance explained = 10.5%\n",
      "GCV =  396.1  Scale est. = 392.53    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.5761   38.21   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "          edf Ref.df      F p-value    \n",
      "s(MAR)  7.977  8.721 18.428 < 2e-16 ***\n",
      "s(MSSM) 7.700  8.579  3.055 0.00165 ** \n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.237   Deviance explained = 24.9%\n",
      "GCV = 337.58  Scale est. = 331.95    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MTmin) + s(GDD0)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.5273   41.75   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F p-value    \n",
      "s(MTmin) 7.581  8.501 27.908 < 2e-16 ***\n",
      "s(GDD0)  5.710  6.920  9.853 9.2e-12 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.361   Deviance explained =   37%\n",
      "GCV = 282.12  Scale est. = 278.09    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(PZI) + s(FF)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)   22.016      0.543   40.54   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "         edf Ref.df      F p-value    \n",
      "s(PZI) 5.508  6.580 45.247 < 2e-16 ***\n",
      "s(FF)  7.530  8.373  5.445 6.7e-07 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.323   Deviance explained = 33.1%\n",
      "GCV = 299.07  Scale est. = 294.87    n = 1000\n",
      "\n",
      "\n",
      "Family: gaussian \n",
      "Link function: identity \n",
      "\n",
      "Formula:\n",
      "TCF ~ s(MAR) + s(MSSM) + s(MTmin) + s(PZI) + s(FF) + s(GDD0) + \n",
      "    s(ST)\n",
      "\n",
      "Parametric coefficients:\n",
      "            Estimate Std. Error t value Pr(>|t|)    \n",
      "(Intercept)  22.0160     0.4583   48.04   <2e-16 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "Approximate significance of smooth terms:\n",
      "           edf Ref.df      F  p-value    \n",
      "s(MAR)   7.123  8.167  4.617 1.33e-05 ***\n",
      "s(MSSM)  6.862  7.961  1.589  0.12425    \n",
      "s(MTmin) 5.815  7.116  9.380 2.15e-11 ***\n",
      "s(PZI)   7.330  8.296 19.399  < 2e-16 ***\n",
      "s(FF)    6.769  7.756  2.595  0.00919 ** \n",
      "s(GDD0)  5.173  6.346  4.748 6.65e-05 ***\n",
      "s(ST)    8.006  8.659  5.265 8.88e-07 ***\n",
      "---\n",
      "Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n",
      "\n",
      "R-sq.(adj) =  0.517   Deviance explained =   54%\n",
      "GCV = 220.64  Scale est. = 210.03    n = 1000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for i in range(n_samples):\n",
    "    gam_1000subsample_na_east(dataforr_na_east)\n",
    "    gam_1000subsample_na_west(dataforr_na_west)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
