## See examples in help("HLCor"), help("Loaloa"), help("make_scaled_dist"), etc.
## Matern correlations in 4-dimensional space:
set.seed(123)
randpts <- matrix(rnorm(20),nrow=5)
distMatrix <- as.matrix(proxy::dist(randpts))
MaternCorr(distMatrix,nu=2)
## Group-specific random effects
if (spaMM.getOption("example_maxtime")>1.6) {
data("blackcap")
# grouped effect using the '%in%' syntax:
fm <- cbind(blackcap,sex=c(rep(TRUE,7),rep(FALSE,7)))
fitme(migStatus ~ 1 + Matern(1|longitude+latitude %in% sex),data=fm)
# Superficially similar aim for distinct random effects for each sex,
# but here with distinct covariance parameters for each of them:
fm$female <- fm$sex; fm$male <- ! fm$female
fitme(migStatus ~ 1 + Matern(female|longitude+latitude)+
Matern(male|longitude+latitude),data=fm)
# Although the results of these fits do not explicitly call for it,
# adding a group-specific intercept may make more sense, as in e.g.
fitme(migStatus ~ sex + Matern(1|longitude+latitude %in% sex), data=fm)
}
Run the code above in your browser using DataLab