## Install the package using the following command # do not forget to change the "packagepos" for the path # packagepos = "GeoCopula_1.0.tgz" # install.packages(pkgs=packagepos,repos=NULL,type="binary") ## library(GeoCopula) #help(GeoCopula) my.seed = 2015 model = "binary" para = list(beta=c(1,1,-1),alpha=2.0,rho=0.8,nu=1.5) numOfClusters= 100 numOfSubjects = rep(4,length=numOfClusters) spatialGrids=expand.grid(1:20,1:20) sigmaX=3 ### Simulate Data dat = geoCopula.simulate.data(numOfClusters=numOfClusters, numOfSubjects = numOfSubjects, spatialGrids = spatialGrids,model=model,para=para,seed=my.seed,sigmaX=sigmaX) trucdist=4.0 between.indices = geoCopula.compute.between.cluster.indices(dat$dist,dat$clusterPairIndices,dat$numOfClusters,dat$clusterSubjIndices,trucdist) within.indices = geoCopula.compute.within.cluster.indices(dat$numOfClusters,dat$clusterSubjIndices) ### Sample Subregions sub.region.size = 4 numOfSubRegions = 20 subregion.indices=geoCopula.sample.subregion(dat$locations,sub.region.size=sub.region.size, numOfSubRegions=numOfSubRegions,my.seed=my.seed) subregion=geoCopula.subregion.index.pair(subregion.indices,dat$subjClusterIndices,within.indices,between.indices) ### Compute initial parameter estimates nu = 1.5 para0 = geoCopula.initial.parameter(dat=dat,model=model,nu=nu,between.indices=between.indices, within.indices=within.indices) ### Estimate parameter using GeoCopula given pre-specified nu approach = "simple" weighted = TRUE method="Nelder-Mead" reltol=1e-3 trace=TRUE maxit=5000 ### Profile QIF estimate nulist = seq(0.5,3.0,by=0.5) res = geoCopula.parameter.estimate.nu(dat=dat,model=model,nulist=nulist,between.indices=between.indices,within.indices=within.indices,method=method,reltol=reltol,trace=trace,maxit=maxit,weighted=weighted,approach=approach,subregion=subregion) plot(nulist,res$nuQfun,type="b",xlab=expression(nu),ylab="Q") print(res$para.est) ## Make inference on the model parameters se.approach="sub.sample" numOfBootstrap=200 se.numOfSubRegions=100 se.sub.region.size=4 inference=geoCopula.inference(dat=dat, model=model, para.est=para.est, se.approach=se.approach,se.numOfSubRegions=se.numOfSubRegions,se.sub.region.size=se.sub.region.size,numOfBootstrap=numOfBootstrap,between.indices=between.indices,within.indices=within.indices, method=method,reltol =reltol, trace=trace,maxit=maxit,weighted=weighted,my.seed=my.seed,approach="simple",subregion=NULL) print(geoCopula.summary.inference(inference))