These data are from mpg ranch located in SW Montana. The ranch is dedicated to conservation. Investigating invasive species, such as Potentilla recta, is part of their conservation goals. The data I have are a species matrix of ~360 species in ~ 430 plots and an environmental variable set extracted from a digital elevation model.
1.Is there spatial structure to the occurrence of Potentilla recta “POTREC”
2.Can P. recta be predicted by its relatives “POTGLA” & “POTGRA”?
3.Can P. recta be predicted by variables from a DEM?
4.How do the DEM variables relate to the species composition of MPG?
View the spatial structure of the potentillas by using variograms, Moran’s I, and spline correlogs.
View linear models of P. recta as a function of its relatives.
View linear models of P. recta as a function of the environmental variables.
Ordinate the species matrix.
library(gstat)
library(sp)
library(spatstat)
## Loading required package: nlme
## Loading required package: rpart
##
## spatstat 1.45-2 (nickname: 'Caretaker Mode')
## For an introduction to spatstat, type 'beginner'
##
## Attaching package: 'spatstat'
## The following object is masked from 'package:gstat':
##
## idw
setwd("E:/mpg")
library(rgdal)
## rgdal: version: 1.1-10, (SVN revision 622)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.0.1, released 2015/09/15
## Path to GDAL shared files: C:/Users/Faythe/Documents/R/win-library/3.3/rgdal/gdal
## Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
## Path to PROJ.4 shared files: C:/Users/Faythe/Documents/R/win-library/3.3/rgdal/proj
## Linking to sp version: 1.2-3
library(raster)
##
## Attaching package: 'raster'
## The following objects are masked from 'package:spatstat':
##
## area, rotate, shift
## The following object is masked from 'package:nlme':
##
## getData
library(vegan)
## Loading required package: permute
## Loading required package: lattice
##
## Attaching package: 'lattice'
## The following object is masked from 'package:spatstat':
##
## panel.histogram
## This is vegan 2.3-5
load("matrices/threeMatrices.Rdata")
spp.pot <- spp.df[,277:279]
spp.pot$x <- xy.df$x
spp.pot$y <- xy.df$y
coordinates(spp.pot) <- ~x+y
spp.pot$elev<-env.df$elev
spp.pot$twi<-env.df$twi
spp.pot$slope<-env.df$slope
spp.pot$aspect<-env.df$aspect
spp.pot$southness<-env.df$southness
spp.pot$westness<-env.df$westness
spp.pot$tri<-env.df$tri
spp.pot$tpi<-env.df$tpi
p.recta.Var <- variogram(POTREC~1, spp.pot, cloud = F)
plot(p.recta.Var,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (m)",main = "Potentilla recta abundance")
library(ncf)
##
## Attaching package: 'ncf'
## The following object is masked from 'package:vegan':
##
## mantel.correlog
library(spdep)
## Loading required package: Matrix
w <- knn2nb(knearneigh(spp.pot,k=8))
p.rec.I=moran.test(spp.pot$POTREC,nb2listw(w))
p.rec.I
##
## Moran I test under randomisation
##
## data: spp.pot$POTREC
## weights: nb2listw(w)
##
## Moran I statistic standard deviate = 0.68634, p-value = 0.2462
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0123726928 -0.0023419204 0.0004596387
recta <- spline.correlog(x=coordinates(spp.pot)[,1], y=coordinates(spp.pot)[,2],
z=spp.pot$POTREC, resamp=100, quiet=TRUE)
plot(recta)
2.These linear regressions use untransformed data and have show no relationship. I may try them again with some transforms.
lm.rectaxgla=lm(POTREC~POTGLA, spp.pot)
summary(lm.rectaxgla)
##
## Call:
## lm(formula = POTREC ~ POTGLA, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.174 -0.720 -0.720 -0.720 38.780
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7202 0.1825 3.946 9.29e-05 ***
## POTGLA 0.3231 0.5676 0.569 0.57
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.725 on 426 degrees of freedom
## Multiple R-squared: 0.00076, Adjusted R-squared: -0.001586
## F-statistic: 0.324 on 1 and 426 DF, p-value: 0.5695
spp.pot$lmrecXglaResids <- residuals(lm.rectaxgla)
bubble(spp.pot, zcol = 'lmrecXglaResids')
w <- knn2nb(knearneigh(spp.pot, k=8))
recXgla.resids=moran.test(spp.pot$lmrecXglaResids, nb2listw(w))
recXgla.resids
##
## Moran I test under randomisation
##
## data: spp.pot$lmrecXglaResids
## weights: nb2listw(w)
##
## Moran I statistic standard deviate = 0.72045, p-value = 0.2356
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0130995659 -0.0023419204 0.0004593841
lm.rectaxgra=lm(POTREC~POTGRA, spp.pot)
summary(lm.rectaxgra)
##
## Call:
## lm(formula = POTREC ~ POTGRA, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.344 -0.723 -0.723 -0.723 38.777
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7225 0.1813 3.986 7.91e-05 ***
## POTGRA 0.4633 0.6763 0.685 0.494
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.724 on 426 degrees of freedom
## Multiple R-squared: 0.0011, Adjusted R-squared: -0.001245
## F-statistic: 0.4692 on 1 and 426 DF, p-value: 0.4937
lm.rectaxgra=lm(POTREC~POTGRA, spp.pot)
summary(lm.rectaxgra)
##
## Call:
## lm(formula = POTREC ~ POTGRA, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.344 -0.723 -0.723 -0.723 38.777
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7225 0.1813 3.986 7.91e-05 ***
## POTGRA 0.4633 0.6763 0.685 0.494
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.724 on 426 degrees of freedom
## Multiple R-squared: 0.0011, Adjusted R-squared: -0.001245
## F-statistic: 0.4692 on 1 and 426 DF, p-value: 0.4937
lm.rectaxelev=lm(POTREC~elev,spp.pot)
summary(lm.rectaxelev)
##
## Call:
## lm(formula = POTREC ~ elev, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.998 -0.850 -0.701 -0.497 38.641
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.7668244 1.1411402 1.548 0.122
## elev -0.0007972 0.0008724 -0.914 0.361
##
## Residual standard error: 3.723 on 426 degrees of freedom
## Multiple R-squared: 0.001956, Adjusted R-squared: -0.0003867
## F-statistic: 0.8349 on 1 and 426 DF, p-value: 0.3614
lm.rectaxtwi=lm(POTREC~twi,spp.pot)
summary(lm.rectaxtwi)
##
## Call:
## lm(formula = POTREC ~ twi, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.971 -0.824 -0.746 -0.580 38.776
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.37235 0.80205 1.711 0.0878 .
## twi -0.09343 0.11496 -0.813 0.4168
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.723 on 426 degrees of freedom
## Multiple R-squared: 0.001548, Adjusted R-squared: -0.0007958
## F-statistic: 0.6605 on 1 and 426 DF, p-value: 0.4168
lm.rectaxslope=lm(POTREC~slope,spp.pot)
summary(lm.rectaxslope)
##
## Call:
## lm(formula = POTREC ~ slope, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.526 -0.902 -0.640 -0.446 38.650
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.28299 0.36202 0.782 0.435
## slope 0.02822 0.01953 1.445 0.149
##
## Residual standard error: 3.717 on 426 degrees of freedom
## Multiple R-squared: 0.004878, Adjusted R-squared: 0.002542
## F-statistic: 2.088 on 1 and 426 DF, p-value: 0.1492
lm.rectaxaspect=lm(POTREC~aspect,spp.pot)
summary(lm.rectaxaspect)
##
## Call:
## lm(formula = POTREC ~ aspect, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.762 -0.741 -0.733 -0.727 38.775
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7619550 0.5210514 1.462 0.144
## aspect -0.0001087 0.0021426 -0.051 0.960
##
## Residual standard error: 3.726 on 426 degrees of freedom
## Multiple R-squared: 6.042e-06, Adjusted R-squared: -0.002341
## F-statistic: 0.002574 on 1 and 426 DF, p-value: 0.9596
lm.rectaxS=lm(POTREC~southness,spp.pot)
summary(lm.rectaxS)
##
## Call:
## lm(formula = POTREC ~ southness, data = spp.pot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.782 -0.763 -0.730 -0.691 38.813
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7336 0.1813 4.047 6.16e-05 ***
## southness 0.0483 0.2743 0.176 0.86
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.726 on 426 degrees of freedom
## Multiple R-squared: 7.276e-05, Adjusted R-squared: -0.002274
## F-statistic: 0.031 on 1 and 426 DF, p-value: 0.8603