data(countryside)
if (FALSE) {
#Fit the countryside SAR model (power form) to the data,
#which contrains 3 habitat types and 4 species groups.
#Use the function’s starting parameter value selection procedure.
#Abbreviations: AG = agricultural land, SH = shrubland, F =
#oak forest, UB = ubiquitous species.
s3 <- sar_countryside(data = countryside, modType = "power",
gridStart = "partial", habNam = c("AG", "SH",
"F"), spNam = c("AG_Sp", "SH_Sp", "F_Sp", "UB_Sp"))
#Predict the richness of a site which comprises 1000 area units
#of agricultural land, 1000 of shrubland and 1000 of forest.
countryside_extrap(s3, area = c(1000, 1000, 1000))
#Generate a plot of the countryside model’s predicted total
#richness vs. the observed total richness, and include the
#predictions of the Arrhenius power model
plot(s3, type = 1, powFit = TRUE)
#Generate Type 2 & 3 plots providing set line colours, plot
#titles, and modifying other aspects of the plot using the
#standard #ase R plotting commands. See ?plot.habitat for more
#info
plot(s3, type = 2, lcol = c("black", "aquamarine4",
"#CC661AB3" , "darkblue"), pLeg = TRUE, lwd = 1.5,
ModTitle = c("Agricultural land", "Shrubland", "Forest"))
plot(s3, type = 3, lcol = c("black", "aquamarine4",
"#CC661AB3" , "darkblue"), pLeg = TRUE, lwd = 1.5,
ModTitle = c("Agricultural land", "Shrubland", "Forest"))
#Calculate AIC for a component model and compare with the
#power model
AIC(s3$fits$AG_Sp)
SA <- rowSums(countryside[,1:3])#total site area
SR <- countryside[,4] #agriculture column
SP <- sar_power(data.frame(SA, SR))
SP$AIC
#Provide starting parameter estimates for the component models
#instead of using gridStart.
M2 <- matrix(c(3.061e+08, 2.105e-01, 1.075e+00, 1.224e-01,
3.354e-08, 5.770e+05, 1.225e+01, 1.090e-01,
6.848e-01, 1.054e-01, 4.628e+05, 1.378e-01,
0.20747, 0.05259, 0.49393, 0.18725), nrow = 4,
byrow = TRUE)
#Provide column numbers rather than names
s4 <- sar_countryside(data = countryside,
modType = "power",
startPar = M2,
habNam = 1:3, spNam = 4:7)
#Speed up by trying gridStart = "none"
s5 <- sar_countryside(data = countryside, modType = "power",
gridStart = "none", habNam = c("AG", "SH",
"F"), spNam = c("AG_Sp", "SH_Sp", "F_Sp", "UB_Sp"))
}
Run the code above in your browser using DataLab