Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional changes for graphical hypothesis testing and clustering range estimation #2

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
1ccd4c1
Authors@R replaces Author and Maintainer field as machine readable.
t-pollington Feb 7, 2020
350c6f7
Add ORCID and multiple cre as R allows only 1.
t-pollington Feb 7, 2020
774ada3
Add formatting style to improve UX
t-pollington Feb 7, 2020
42e940f
Add contribution instructions to save time when inspect. pull request
t-pollington Feb 7, 2020
25321a0
Add function styling to differentiate from var names
t-pollington Feb 7, 2020
b8407f9
Add citations.
t-pollington Feb 8, 2020
b879d98
Add NEWS. Update version no in DESCRIPTION as major version occurring.
t-pollington Feb 8, 2020
e7c5c9c
Remove dupl words. Add code{fun}
t-pollington Feb 12, 2020
1c861d4
Update get.pi.ci documentation and example.
t-pollington Feb 12, 2020
283ce35
Apply coxed::bca
t-pollington Feb 13, 2020
7b6436f
Remove code as already warned that it would be deprecated last time.
t-pollington Feb 13, 2020
e1033b4
Add get.pi.ci() changes to NEWS.
t-pollington Feb 13, 2020
99fa3cb
Add imports for coxed as needed by get.pi.ci()
t-pollington Feb 13, 2020
ca51451
Add coxed import
t-pollington Mar 4, 2020
2033692
Update refs
t-pollington Mar 11, 2020
e84fcec
Partly fix get.pi.bootstrap() tests
t-pollington Mar 12, 2020
d9d1b37
Fix: [,-(1:2)] removed as already run from get.pi.bootstrap()
t-pollington Mar 12, 2020
76d6c16
Apply to get.pi.ci() complete. Now apply to get.theta.ci().
t-pollington Mar 15, 2020
aa6f12d
Unnest applyBCa() so available to all functions.
t-pollington Mar 15, 2020
215ea85
get.theta.ci() implemented. Except for mention of this in its help file.
t-pollington Mar 15, 2020
64ee741
get.theta.ci(): update args
t-pollington Mar 15, 2020
85ce856
Update: get.tau.ci() with BCa
t-pollington Mar 15, 2020
949c4a7
Update other quantile() methods where applicable.
t-pollington Mar 15, 2020
04c379c
Update: commented in getthetapermute.r that coxed::bca() is unavailab…
t-pollington Mar 15, 2020
eabb8fe
Replace quantile() with coxed::bca where possible. Removed previously…
t-pollington Mar 17, 2020
5ed7d42
Fix test() and test_file() giving different results by removing conte…
t-pollington Mar 17, 2020
72fd8aa
Delete context() on first line as test_that says "We no longer recomm…
t-pollington Mar 17, 2020
9373cd6
deprecated is_true replacement
t-pollington Mar 17, 2020
855c10b
Fix expect_true bug
t-pollington Mar 17, 2020
b7126a4
Incorporate tau class
t-pollington Mar 17, 2020
e402598
Fix bugs assoc with new tau class.
t-pollington Mar 17, 2020
5c1d680
Updates
t-pollington Mar 17, 2020
c518ed7
plot.tau() method added
t-pollington Mar 17, 2020
1c53c39
Correction to previous commit. It was print.tau that was added, not p…
t-pollington Mar 17, 2020
3294b6e
U-turn: print.tau not required as print() sufficient
t-pollington Mar 17, 2020
d5b4d49
plot.tau: axis labels, legend, midpoint/endpoint, units.
t-pollington Mar 19, 2020
84068b1
plot.tau(): CIs added.
t-pollington Mar 19, 2020
7cd27a3
Merge pull request #1 from t-pollington/plotpointwise
t-pollington Mar 19, 2020
6b7dd2b
Implement get.tau.GET. Note plot method embedded within. Now needs to…
t-pollington Mar 23, 2020
f7c93ae
Add commented out code ready for get.tau.D.param.est. Next stage is t…
t-pollington Mar 23, 2020
25b73d0
Merge pull request #2 from t-pollington/globalhypotest
t-pollington Mar 23, 2020
c8162cb
Get ciIntercept working
t-pollington Mar 24, 2020
91bfd82
Integrate tauparamest with plot.tau()
t-pollington Mar 24, 2020
6d9111c
Continue to insert D.param.est plotting methods inside plot.tau(). No…
t-pollington Mar 24, 2020
3082c64
Now going to test the implementation of D.param.est in plot.tau
t-pollington Mar 24, 2020
2cd885b
Completion of incorporation of d.param.est in plot.tau()
t-pollington Mar 25, 2020
fed4d88
Merge pull request #3 from t-pollington/Dparamest
t-pollington Mar 25, 2020
295746a
Start documentation update
t-pollington Mar 25, 2020
20d8ffb
Indent trial
t-pollington Mar 25, 2020
092e443
NEWS.md nearly finished
t-pollington Mar 25, 2020
38c96fa
greek letter trial
t-pollington Mar 25, 2020
9cc35f1
News news news
t-pollington Mar 25, 2020
5572c4a
NEWS complete
t-pollington Mar 25, 2020
af47153
Img test
t-pollington Mar 25, 2020
15cf883
make img bigger
t-pollington Mar 25, 2020
6b3cf92
img test
t-pollington Mar 25, 2020
8856b49
Text wrap
t-pollington Mar 25, 2020
9a28132
Page restructure
t-pollington Mar 25, 2020
798d20d
Add structure
t-pollington Mar 25, 2020
8675b97
restructure
t-pollington Mar 25, 2020
713d2b6
Update help files. Example files next!
t-pollington Mar 26, 2020
7172ad6
Updating get_tau.Rd with new plot.tau() example but fixing bugs I hav…
t-pollington Mar 26, 2020
ae6601f
Fix plot.tau() example in get_tau.R
t-pollington Mar 26, 2020
f8cb823
Restructure get_tau.R
t-pollington Mar 26, 2020
39a583d
apply(... bug fix
t-pollington Mar 26, 2020
f3b169a
Another bug fixed!
t-pollington Mar 26, 2020
02a2f01
NEWS update
t-pollington Mar 26, 2020
10f2797
fix test file due to res[x,], res[,x] bug
t-pollington Mar 27, 2020
231750f
update get_tau_ci and get_tau_bootstrap
t-pollington Mar 27, 2020
2782821
GET_tau_GET done
t-pollington Mar 27, 2020
cbc9922
Fix warnings and bugs after running Check.
t-pollington Mar 27, 2020
2e9e70b
Typo
t-pollington Jul 5, 2021
51dbb4c
Merge branch 'master' of https://github.com/HopkinsIDD/IDSpatialStats
t-pollington Jul 21, 2021
749c7a9
Moving so that devtools::test() works.
t-pollington Jul 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
src/*.o
src/*.so
src/*.dll
21 changes: 15 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
Package: IDSpatialStats
Version: 0.3.11
Date: 2019-11-13
Version: 1.0.0
Date: 2021-07-21
Title: Estimate Global Clustering in Infectious Disease
Author: John Giles <[email protected]>, Henrik Salje <[email protected]>, Justin Lessler <[email protected]>
Maintainer: Justin Lessler <[email protected]>
Authors@R: c(person(given = "Justin Lessler", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9741-8109", "Co-creator & maintainer"),
email = "[email protected]"),
person(given = "Henrik Salje", role = "aut", comment = c(ORCID = "0000-0003-3626-4254", "Co-creator"),
email = "[email protected]"),
person(given = "John Giles", role = "aut", comment = c(ORCID = "0000-0002-0954-4093", "Author & maintainer"),
email = "[email protected]"),
person(given = "Timothy M Pollington", role = "aut", comment = c(ORCID = "0000-0002-9688-5960", "Author"),
email = "[email protected]"))
License: GPL (>=2)
Description: Implements various novel and standard
clustering statistics and other analyses useful for understanding the
spread of infectious disease.
RoxygenNote: 7.1.1
Encoding: UTF-8
LazyData: true
Imports: igraph, spatstat.core, spatstat.geom
Imports: igraph, spatstat.core, spatstat.geom, coxed, GET, scales
Depends: doParallel, foreach, parallel, R (>= 2.10)
Suggests: knitr, testthat
Suggests: knitr, testthat, rmarkdown
VignetteBuilder: knitr
URL: https://github.com/HopkinsIDD/IDSpatialStats
BugReports: https://github.com/HopkinsIDD/IDSpatialStats/issues
17 changes: 17 additions & 0 deletions IDSpatialStats.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 1
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
24 changes: 15 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import("coxed")
import("parallel")
import("doParallel")
import("foreach")
import("stats")
import("graphics")
importFrom("igraph", "graph.data.frame") # for get.transdist.theta
importFrom("igraph", "shortest.paths") # for get.transdist.theta
importFrom("igraph", "E") # for get.transdist.theta
importFrom("spatstat.geom", "bounding.box.xy") # for est.transdist
importFrom("spatstat.geom", "as.ppp") # for est.transdist
importFrom("spatstat.geom", "ppp") # for est.transdist
importFrom("spatstat.geom", "crossdist") # for est.transdist
importFrom("spatstat.core", "Kcross") # for get.cross.K
importFrom("spatstat.core", "pcf") # for get.cross.PCF
import("scales")
import("GET")
importFrom("igraph", "graph.data.frame") # for get.transdist.theta()
importFrom("igraph", "shortest.paths") # for get.transdist.theta()
importFrom("igraph", "E") # for get.transdist.theta()
importFrom("spatstat.geom", "bounding.box.xy") # for est.transdist()
importFrom("spatstat.geom", "as.ppp") # for est.transdist()
importFrom("spatstat.geom", "ppp") # for est.transdist()
importFrom("spatstat.geom", "crossdist") # for est.transdist()
importFrom("spatstat.core", "Kcross") # for get.cross.K()
importFrom("spatstat.core", "pcf") # for get.cross.PCF()
export(get.pi)
export(get.pi.ci)
export(get.pi.bootstrap)
Expand All @@ -22,6 +25,8 @@ export(get.theta.bootstrap)
export(get.theta.permute)
export(get.tau)
export(get.tau.bootstrap)
export(get.tau.GET)
export(get.tau.D.param.est)
export(get.tau.permute)
export(get.pi.typed)
export(get.pi.typed.bootstrap)
Expand All @@ -33,6 +38,7 @@ export(get.tau.typed)
export(get.tau.ci)
export(get.tau.typed.bootstrap)
export(get.tau.typed.permute)
S3method(plot, tau)
export(sim.epidemic)
export(sim.plot)
export(est.wt.matrix)
Expand Down
48 changes: 48 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# News on IDSpatialStats 1.0.0 release

## Changes (top of list are most important)
These changes mostly concern the tau statistic functions and have resulted in a major change revision from 0.3.9 to 1.0.0: these are big changes and we may have introduced bugs so please send us a `reprex()` example. We also note where function outputs are likely to have changed.

# Specific changes
Percentile confidence intervals (CIs) replaced with BCa (bias-corrected and accelerated) CIs
* `get.pi.ci()`, `get.theta.ci()`, `get.tau.ci()`: `quantile` method replaced with `coxed::bca`. This will change CI results.

* `quantile` method also updated to `coxed::bca` where possible in `inst/tests/`. At times the `coxed::bca()` method gives slightly different test results if it is applied to asymmetric distributions.

* New function `get.tau.GET()` performs graphical hypothesis tests with the tau statistic using the `GET` package, while `get.tau.D.param.est()` estimates the range of spatiotemporal clustering.

* `plot.tau()` is a new method that can produce three types of tau(y-axis)-distance(x-axis) plots [[1: see Graphical abstract](https://doi.org/10.1016/j.spasta.2020.100438 "Developments in statistical inference when assessing spatiotemporal disease clustering with the tau statistic")]:
* Diagnostic to indicate the structure or magnitude of spatiotemporal clustering. Requires `tau` object; `tauCI` object optional to draw pointwise CIs. In this version we use piecewise error bars rather than continuous envelope lines. This reminds the user that this graph should not be used as a graphical hypothesis test for the whole distance range observed. It is only suitable for the purpose of a graphical hypothesis test for a specific distance band if that band is decided prior to graph creation.
* Graphical hypothesis tests to assess the evidence against the Null hypothesis (no spatiotemporal clustering nor inhibition). Requires `tau` and `tauGET` objects.
* Estimation of the clustering range (the distribution of the places on the horizontal tau=1 line, where decreasing bootstrap simulations first intercept). Requires `tau` and `tauparamest` objects; prior to this `get.tau.D.param.est()` requires a `taubstrap` object.

* New S3 classes have been added to the return objects from the following functions. The purpose of the new classes is to encourage the use of functions in an ordered and principled way, in keeping with good practices of statistical inference [[1](https://doi.org/10.1016/j.spasta.2020.100438 "Developments in statistical inference when assessing spatiotemporal disease clustering with the tau statistic")]. It also means that the objects inputted as function arguments are of a known format:
* `get.tau()` returns a `tau` class
* `get.tau.ci()` returns a `tauCI` class
* `get.tau.GET()` returns a `tauGET` class
* `get.tau.bootstrap()` returns a `taubstrap` class
* `get.tau.D.param.est()` returns a `tauparamest` class. Requires a `taubstrap` object. Also requires a `tauGET` class to ensure the user has performed a graphical hypothesis test first, before considering parameter estimation.

* CITATION file added
* README.md formatting updated
* `get.tau$tau` renamed to `get.tau$tau.pt.est`
* Previously deprecated tests (already commented out in `inst/tests/`) have now been removed.
* NEWS.md file added, but as you're reading this you probably knew that already :wink:

# Generic changes
* distance units can be defined on `r` and `r.low` and will be automatically feature in the x-axis label of `plot.tau()`
* help files added/updated for `get.tau()`, `get.tau.ci()`, `get.tau.bootstrap()`, `get.tau.GET()`, `get.tau.d.param.est()` & `plot.tau()`
* example files added/updated for `get_tau.R`, `get_tau_bootstrap.R`, `get_tau_ci.R`, `get_tau_GET.R`, `get_D_param_est.R` and `plot_tau.R`.

## Bug fixes (top of list are most important)
`get_tau.R`: using `geno.tau.R02$tau.pt.est` now allows the object to be accessed and the example run.

# Release contributors
Timothy M Pollington would like to thank the co-authors of the paper that informed this update[[1](https://doi.org/10.1016/j.spasta.2020.100438 "Developments in statistical inference when assessing spatiotemporal disease clustering with the tau statistic")] and the *essential* contribution of Peter J. Diggle (Lancaster) who advised on this principled inferential approach.

# Next changes
* The *Modified Marked Point Spatial Bootstrap* [[1](https://doi.org/10.1016/j.spasta.2020.100438 "Developments in statistical inference when assessing spatiotemporal disease clustering with the tau statistic")] has not yet been
applied. In [[2](https://doi.org/10.5281/zenodo.2552850 "t-pollington/tau-statistic-speedup: First release of tau statistic speedup")] it was applied to the tau odds estimator however for consistency we have decided to delay its implementation so that we can apply it also to the tau prevalence estimator. So please note that `get.tau.bootstrap()` and `get.tau.D.param.est()` values are still likely to change.
* `tau.GET()` examples increased to 2,500 permutations once speedups introduced.
* Enable `plot.tau()` to accept `tauCI` objects alone, without need for `tau()` object.
* Changes to the un-typed tau functions also applied to the typed tau functions.
41 changes: 21 additions & 20 deletions R/examples/get_pi_ci.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
\donttest{
\donttest{# Simulate cases (type = 2, Normally-distributed points) and
# simulated non-cases (type = 1, Uniformally-distributed)
X <- cbind(1, runif(100,-100,100), runif(100,-100,100))
X <- rbind(X, cbind(2,rnorm(100,0,20), rnorm(100,0,20)))
colnames(X) <- c("type","x","y")

#compare normally distributed with uniform points
x<-cbind(1,runif(100,-100,100), runif(100,-100,100))
x<-rbind(x, cbind(2,rnorm(100,0,20), rnorm(100,0,20)))
colnames(x) <- c("type","x","y")

fun<-function(a,b) {
if(a[1]!=2) return(3)
if (b[1]==2) return(1)
return(2)
fun <- function(a,b) {
# possible 'ab' pair types {'11'; '12'; '21'; '22'}
if(a[1]!=2) return(3) # it's {'11' or '12'} so ignore
if(b[1]==2) return(1) # it's '22' so count as a case-case pair in numerator and denominator
# else it's a '21' ie a case-non-case pair
return(2) # so count in denominator
}

r.max<-seq(10,100,10)
r.min<-seq(0,90,10)
r.mid <- (r.max+r.min)/2

# define distance band set
r.max <- seq(10,100,10)
r.min <- seq(0,90,10)
r.mid <- (r.max + r.min)/2

pi<-get.pi(x,fun,r=r.max,r.low=r.min)
pi.ci<-get.pi.ci(x,fun,r=r.max,r.low=r.min,boot.iter=100)
# compute the pi point estimate and its 95% BCa CI
pi <- get.pi(X, fun, r=r.max, r.low = r.min)
pi.ci <- get.pi.ci(X, fun, r = r.max, r.low = r.min, boot.iter = 100)

# plot the pi point estimate with its CI, at the midpoints of each distance band
plot(r.mid, pi$pi, type="l")
lines(r.mid, pi.ci[,2] , lty=2)
lines(r.mid, pi.ci[,3] , lty=2)

}
lines(r.mid, pi.ci$ci.low, lty=2)
lines(r.mid, pi.ci$ci.high, lty=2)}
65 changes: 37 additions & 28 deletions R/examples/get_tau.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,24 @@ data(DengueSimRepresentative)
r.max<-seq(20,1000,20)
r.min<-seq(0,980,20)
r.mid<-(r.max+r.min)/2

sero.type.func<-function(a,b,tlimit=20){
if(a[5]==b[5]&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{rc=2}
return(rc)
if(a[5]==b[5]&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{rc=2}
return(rc)
}

geno.type.func<-function(a,b,tlimit=20){
if(a[4]==b[4]&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{rc=2}
return(rc)
}

sero.type.rep.func<-function(a,b,tlimit=20){
if(a[5]==1&b[5]==1&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{if(a[5]==1&b[5]==-999){rc=2}else{rc=3}}
return(rc)
if(a[4]==b[4]&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{rc=2}
return(rc)
}

sero.tau.R01 <- get.tau(DengueSimR01, sero.type.func, r=r.max, r.low=r.min,
comparison.type="independent")
geno.tau.R01 <- get.tau(DengueSimR01, geno.type.func, r=r.max, r.low=r.min,
comparison.type="independent")

sero.tau.R02 <- get.tau(DengueSimR02, sero.type.func, r=r.max, r.low=r.min,
comparison.type="independent")
geno.tau.R02 <- get.tau(DengueSimR02, geno.type.func, r=r.max, r.low=r.min,
comparison.type="independent")

sero.tau.representative <- get.tau(DengueSimRepresentative, sero.type.rep.func,
r=r.max, r.low=r.min, comparison.type="representative")

## R0 of 1
data(DengueSimulationR01)
sero.tau.R01 <- get.tau(DengueSimR01, sero.type.func, r=r.max, r.low=r.min,
comparison.type="independent")
geno.tau.R01 <- get.tau(DengueSimR01, geno.type.func, r=r.max, r.low=r.min,
comparison.type="independent")

plot(r.mid,sero.tau.R01$tau,ylim=c(0.3,max(geno.tau.R01$tau)),log="y",
cex.axis=1.25,col=rgb(t(col2rgb("blue")/255),alpha=0.6),
xlab="Distance (m)",ylab="Tau",cex.main=0.9,lwd=2,type="l",las=1,cex.axis=0.75)
Expand All @@ -57,7 +42,13 @@ legend("topright",
lty=c(1,1,2,1),bty="n")

## R0 of 2
plot(r.mid,sero.tau.R02$tau,ylim=c(0.3,max(geno.tau.R02)),log="y",
data(DengueSimulationR02)
sero.tau.R02 <- get.tau(DengueSimR02, sero.type.func, r=r.max, r.low=r.min,
comparison.type="independent")
geno.tau.R02 <- get.tau(DengueSimR02, geno.type.func, r=r.max, r.low=r.min,
comparison.type="independent")

plot(r.mid,sero.tau.R02$tau,ylim=c(0.3,max(geno.tau.R02$tau.pt.est)),log="y",
cex.axis=1.25,col=rgb(t(col2rgb("blue")/255),alpha=0.6),
xlab="Distance (m)",ylab="Tau",cex.main=0.9,lwd=2,type="l",las=1,cex.axis=0.75)
abline(h=1,lty=2)
Expand All @@ -69,4 +60,22 @@ legend("topright",
"Maximum transmission distance"),
lwd=1,col=c("dark green","blue","black"),lty=1,bty="n")

## Obtaining a diagnostic plot using plot.tau() with pointwise CIs
data(DengueSimRepresentative)
sero.type.rep.func<-function(a,b,tlimit=20){
if(a[5]==1&b[5]==1&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{if(a[5]==1&b[5]==-999){rc=2}else{rc=3}}
return(rc)
}

# get point estimate
Dengue.tau = get.tau(DengueSimRepresentative, sero.type.rep.func, r.max, r.min,
"representative", data.frame = TRUE)

# get 95% BCa CI
CIs = get.tau.ci(DengueSimRepresentative, sero.type.rep.func, r.max, r.min, 25,
"representative", ci.level = 0.95, data.frame = TRUE)

#plot point estimate with CI
plot.tau(x = Dengue.tau, r.mid = TRUE, ptwise.CI = CIs)
}
38 changes: 38 additions & 0 deletions R/examples/get_tau_D_param_est.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
\donttest{
# Load data
r.max<-seq(20,1000,20)
r.min<-seq(0,980,20)
r.mid<-(r.max+r.min)/2
sero.type.func<-function(a,b,tlimit=20){
if(a[5]==b[5]&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{rc=2}
return(rc)
}

data(DengueSimRepresentative)
sero.type.rep.func<-function(a,b,tlimit=20){
if(a[5]==1&b[5]==1&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{if(a[5]==1&b[5]==-999){rc=2}else{rc=3}}
return(rc)
}

# get point estimate
Dengue.tau = get.tau(DengueSimRepresentative, sero.type.rep.func, r.max, r.min, "representative",
data.frame = TRUE)

# perform graphical hypothesis test using a global envelope test
Dengue.GET = get.tau.GET(DengueSimRepresentative, sero.type.rep.func, r.max,r.min,
permutations = 50, "representative")

# plot point estimate with global envelope and simulation of the null distribution
plot.tau(x = Dengue.tau, r.mid = TRUE, GET.res = Dengue.GET)

# if the graphical hypothesis test and p-value interval suggests evidence against H_0,
# and the graph suggests clustering, the range of this can be estimated
tausim = get.tau.bootstrap(DengueSimRepresentative, sero.type.rep.func, r.max, r.min, 100,
"representative", data.frame = FALSE)
Dengue.dparam = get.tau.D.param.est(r = r.max, tausim = tausim, Dengue.GET)
median(Dengue.dparam$envelope) # median estimate for the clustering endpoint
Dengue.dparam$envelope # 95% BCa CI
plot.tau(Dengue.tau, tausim = tausim, d.param.est = Dengue.dparam)
}
29 changes: 29 additions & 0 deletions R/examples/get_tau_GET.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
\donttest{
# Load data
r.max<-seq(20,1000,20)
r.min<-seq(0,980,20)
r.mid<-(r.max+r.min)/2
sero.type.func<-function(a,b,tlimit=20){
if(a[5]==b[5]&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{rc=2}
return(rc)
}

data(DengueSimRepresentative)
sero.type.rep.func<-function(a,b,tlimit=20){
if(a[5]==1&b[5]==1&(abs(a[3]-b[3])<=tlimit)){rc=1}
else{if(a[5]==1&b[5]==-999){rc=2}else{rc=3}}
return(rc)
}

# get point estimate
Dengue.tau = get.tau(DengueSimRepresentative, sero.type.rep.func, r.max, r.min, "representative",
data.frame = TRUE)

# perform graphical hypothesis test using a global envelope test
Dengue.GET = get.tau.GET(DengueSimRepresentative, sero.type.rep.func, r.max,r.min,
permutations = 50, "representative")

#plot point estimate with global envelope and simulation of the null distribution
plot.tau(x = Dengue.tau, r.mid = TRUE, GET.res = Dengue.GET)
}
Loading