## Tables

Primary programmer: John Fieberg | Secondary programmer: Althea A. ArchMiller

Date: 20160805

Tables in: Fieberg et al. Species distribution models: Predictive snipers or shots in the dark?

## Preamble

remove(list=ls())
library(xtable)

## Table 1. Missing predictor example

# Scenario 1
train.correct.corr00 <- train.correct
train.missingprecip.corr00 <- train.missingprecip

# Scenario 2
train.correct.corrNN <- train.correct
train.missingprecip.corrNN <- train.missingprecip

# Scenario 3
train.correct.corrPN <- train.correct
train.missingprecip.corrPN <- train.missingprecip

Create coefficient Table

coeftab<-matrix(NA, 3, 8)
coeftab[1:3,1]<-c(0, -0.3, 0.3)
coeftab[1,2:3]<-summary(train.missingprecip.corr00)$coefficients[2,1:2] coeftab[2,2:3]<-summary(train.missingprecip.corrNN)$coefficients[2,1:2]
coeftab[3,2:3]<-summary(train.missingprecip.corrPN)$coefficients[2,1:2] coeftab[1,5:6]<-summary(train.correct.corr00)$coefficients[2,1:2]
coeftab[1,7:8]<-summary(train.correct.corr00)$coefficients[3,1:2] coeftab[2,5:6]<-summary(train.correct.corrNN)$coefficients[2,1:2]
coeftab[2,7:8]<-summary(train.correct.corrNN)$coefficients[3,1:2] coeftab[3,5:6]<-summary(train.correct.corrPN)$coefficients[2,1:2]
coeftab[3,7:8]<-summary(train.correct.corrPN)$coefficients[3,1:2] coeftab<-round(coeftab,3) xtable::xtable(coeftab) ## % latex table generated in R 3.3.1 by xtable 1.8-2 package ## % Thu Aug 11 08:39:48 2016 ## \begin{table}[ht] ## \centering ## \begin{tabular}{rrrrrrrrr} ## \hline ## & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ ## \hline ## 1 & 0.00 & 0.42 & 0.05 & & 0.42 & 0.06 & -1.04 & 0.07 \\ ## 2 & -0.30 & 0.80 & 0.06 & & 0.53 & 0.06 & -0.99 & 0.07 \\ ## 3 & 0.30 & 0.27 & 0.05 & & 0.57 & 0.06 & -0.97 & 0.06 \\ ## \hline ## \end{tabular} ## \end{table} ## Table 2. Non-linear example load("uhcplots/Regmods/Regmods_T.R") Create coefficient Table coeftab<-matrix(NA, 2, 4) coeftab[1,1:2]<-summary(train.misspec)$coefficients[2,1:2]
coeftab[2,1:2]<-summary(train.correct)$coefficients[2,1:2] coeftab[2,3:4]<-summary(train.correct)$coefficients[3,1:2]

coeftab<-round(coeftab,3)
xtable::xtable(coeftab)
## % latex table generated in R 3.3.1 by xtable 1.8-2 package
## % Thu Aug 11 08:39:48 2016
## \begin{table}[ht]
## \centering
## \begin{tabular}{rrrrr}
##   \hline
##  & 1 & 2 & 3 & 4 \\
##   \hline
## 1 & 0.24 & 0.05 &  &  \\
##   2 & 2.21 & 0.35 & -1.05 & 0.17 \\
##    \hline
## \end{tabular}
## \end{table}

## Table 3. MN moose example

Create coefficient Table

stargazer::stargazer(ssf.train.full, ssf.train.reduc1, ssf.train.reduc2,
star.cutoffs=NA, table.layout="#tn" )
##
## % Table created by stargazer v.5.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
## % Date and time: Thu, Aug 11, 2016 - 08:39:48
## \begin{table}[!htbp] \centering
##   \caption{}
##   \label{}
## \begin{tabular}{@{\extracolsep{5pt}}lccc}
## \\[-1.8ex]\\[-1.8ex] & (1) & (2) & (3)\\
##  decid50 & 0.489 & $-$0.598 &  \\
##   & (0.329) & (0.189) &  \\
##   & & & \\
##  mixed50 & 1.382 &  & 1.026 \\
##   & (0.328) &  & (0.158) \\
##   & & & \\
##  conif50 & $-$0.296 & $-$1.365 &  \\
##   & (0.377) & (0.266) &  \\
##   & & & \\
##  treedwet50 & 0.396 & $-$0.696 &  \\
##   & (0.313) & (0.160) &  \\
##   & & & \\
##  step & $-$6.326 & $-$6.436 & $-$6.385 \\
##   & (0.248) & (0.248) & (0.248) \\
##   & & & \\
## \textit{Note:}  & \multicolumn{3}{r}{NA} \\
## \end{tabular}
## \end{table}

### Footer

Session Information

sessionInfo()
## R version 3.3.1 (2016-06-21)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: OS X 10.10.5 (Yosemite)
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base
##
## other attached packages:
## [1] xtable_1.8-2       dplyr_0.5.0        survival_2.39-5
## [4] KernSmooth_2.23-15 ggplot2_2.1.0      MASS_7.3-45
## [7] knitr_1.13         ezknitr_0.4
##
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.6       magrittr_1.5      splines_3.3.1
##  [4] munsell_0.4.3     colorspace_1.2-6  lattice_0.20-33
##  [7] R6_2.1.2          stringr_1.0.0     plyr_1.8.4
## [10] tools_3.3.1       grid_3.3.1        gtable_0.2.0
## [13] R.oo_1.20.0       DBI_0.4-1         stargazer_5.2
## [16] lazyeval_0.2.0    assertthat_0.1    tibble_1.1
## [19] Matrix_1.2-6      formatR_1.4       R.utils_2.3.0
## [22] evaluate_0.9      mime_0.5          stringi_1.1.1
## [25] scales_0.4.0      R.methodsS3_1.7.1 markdown_0.7.7

Spun with: ezspin(file = “uhcplots/tables.R”, out_dir =“uhcplots/output”, fig_dir = “figures”, keep_md = FALSE)