# Example with an adjacency matrix (autoregressive model):
# see 'adjacency' documentation page
#### Matérn correlation using only the Matern() syntax
if (spaMM.getOption("example_maxtime")>2) {
data(Loaloa)
HLCor(cbind(npos,ntot-npos)~elev1+elev2+elev3+elev4+maxNDVI1+seNDVI
+Matern(1|longitude+latitude),data=Loaloa,
family=binomial(),ranPars=list(nu=0.5,rho=1/0.7))
}
#### Using a corrMatrix (not necessarily Matérn)
data(blackcap)
## Here we manually reconstruct the correlation matrix
## of the ML fit produced by corrHLfit:
MLcorMat <- MaternCorr(proxy::dist(blackcap[,c("latitude","longitude")]),
nu=0.6285603,rho=0.0544659)
# simple but easily misunderstood syntax:
HLCor(migStatus ~ means+ corrMatrix(1|latitude+longitude),data=blackcap,
corrMatrix=MLcorMat,HLmethod="ML")
# An equivalent syntax worth understanding (see Details):
bcdummy <- cbind(blackcap,dummy=sample(nrow(blackcap)))
HLCor(migStatus ~ means+ corrMatrix(1|dummy),data=bcdummy,
corrMatrix=MLcorMat,HLmethod="ML")
#### Matérn correlation using a distMatrix
MLdistMat <- as.matrix(proxy::dist(blackcap[,c("latitude","longitude")]))
HLCor(migStatus ~ means+ Matern(1|latitude+longitude),data=blackcap,
distMatrix=MLdistMat,HLmethod="ML",ranPars=list(nu=0.6285603,rho=0.0544659))
Run the code above in your browser using DataLab