Skip to content

Commit

Permalink
Add extra details and clean
Browse files Browse the repository at this point in the history
clean comments
  • Loading branch information
LukeChrisEvans committed Mar 13, 2022
1 parent 47fab69 commit 86790ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion H1ResponseAnomaly.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ book.plot.field(
inla.space1b$summary.random$s$mean ,
mesh = cmesh)

plot(inla.space1b$summary.linear.predictor$mean,butterfly.dt$n_change,col = alpha("grey", 0.4),xlab="Pred",ylab="obs")
# Pred vs obs - similar to the first model
plot(inla.space1b$summary.fitted.values$mean[1:1504],butterfly.dt$n_change,col = alpha("grey", 0.4),xlab="Pred",ylab="obs")
abline(0,1)

# plots
Expand Down
9 changes: 9 additions & 0 deletions H2CommunityAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ inla.m4 <- inla(ICOV ~ 1 + rangescore + rangescore_2 + meanpopsize + sppnum,
summary(inla.m4)
bri.fixed.plot(inla.m4,together = F)

# check obs vs pred - not brilliant but figure below shows better
library(scales)
plot(inla.m4$summary.linear.predictor$mean,stability$ICOV,col = alpha("grey", 0.4),xlab="Pred",ylab="obs")
abline(0,1)


# -------- Fit spatial barrier model ----------

library(sf)
Expand Down Expand Up @@ -169,6 +175,9 @@ book.plot.field(

epoints[,1] <- epoints[,1] + inla.space1c$summary.fixed$mean[1]

# observed vs predicted
plot(inla.space1c$summary.linear.predictor$mean,stability$ICOV,col = alpha("grey", 0.4),xlab="Pred",ylab="obs")
abline(0,1)


# -------- Plot spatial model marginal fit ----------
Expand Down
4 changes: 0 additions & 4 deletions H3_H4Mechanisms.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ stackd <- inla.stack(
speciesname1= speciesstability$speciesname1 ,
speciesname3= speciesstability$speciesname1 ,
speciesname2= speciesstability$speciesname2 )) # spatial random effect
#iidx=1:nrow(df), # iid random effect
,
tag= "data"
)
Expand All @@ -160,7 +159,6 @@ inla.space1d<- inla(y~0+Intercept + rangepositionspring+ rangepositionspring_2+
f(speciesname3,rangepositionspring,model="iid",hyper=rand_prior) +f(speciesname4,rangepositionspring_2,model="iid",hyper=rand_prior)
,
data = inla.stack.data(stackd),family="Gaussian",
# control.inla =list(int.strategy ="eb",tolerance=1e-6,reordering ="metis",strategy="gaussian"),
control.compute = list(config=TRUE,waic = TRUE,dic=TRUE),
control.predictor = list(A = inla.stack.A(stackd),compute=TRUE),
control.fixed = list(
Expand Down Expand Up @@ -254,7 +252,6 @@ simpop<-cbind.data.frame(simpop,estimP,estimlP,estimuP)
#tiff("fit3_2.tif", res=600, compression = "lzw", height=6, width=6.5, units="in")
ggplot(data=ptdt2,aes(meanpop,resid,color=country,group=country))+
geom_point(size=4,alpha=0.7)+
# xlim(0,1)+
scale_color_npg()+
theme_cowplot() +
geom_line(data=simpop,aes(simpop,estimP), size=2,alpha=0.9,inherit.aes = F) +
Expand Down Expand Up @@ -345,7 +342,6 @@ synchdat<-synchdat[complete.cases(synchdat),]
# -------- Fit model ----------
inla.m6<- inla(avgcor ~ 1 + rangescore+ rangescore_2 + nspp +varcor,
data=synchdat,
# control.inla =list(int.strategy ="eb",tolerance=1e-6,reordering ="metis",strategy="gaussian"),
control.compute = list(config=TRUE,waic = TRUE,dic=TRUE),
control.fixed = list(
mean=0, prec= 0.25, # fixed effect priors
Expand Down

0 comments on commit 86790ca

Please sign in to comment.