Skip to content

Commit

Permalink
Uploading CRAN version 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rudeboybert committed Jul 2, 2016
1 parent f8e1be2 commit 26eecb0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 45 deletions.
13 changes: 11 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Package: SpatialEpi
Title: Methods and Data for Spatial Epidemiology
Version: 1.2.3
Version: 1.2.2
Depends: R (>= 3.0.2), sp
Imports: Rcpp, MASS, maptools, spdep, methods, grDevices, graphics, stats
Imports: Rcpp, MASS, maptools, spdep, methods, grDevices, graphics,
stats
LinkingTo: Rcpp, RcppArmadillo
Authors@R: c(
person("Cici", "Chen", email = "[email protected]", role = "ctb"),
Expand All @@ -15,3 +16,11 @@ Description:
Methods and data for cluster detection and disease mapping.
License: GPL-2
LazyData: true
NeedsCompilation: yes
Packaged: 2016-01-28 20:33:39 UTC; rudeboybert
Author: Cici Chen [ctb],
Albert Y. Kim [aut, cre],
Michelle Ross [ctb],
Jon Wakefield [aut]
Repository: CRAN
Date/Publication: 2016-01-29 01:02:40
8 changes: 0 additions & 8 deletions R/kulldorff.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ cluster <- cluster[1:which(cluster == end)]
# Simulate cases under null hypothesis of no area effects i.e. conditioned on E
perm <- rmultinom(n.simulations, round(sum(cases)), prob=denominator)

# Ensure that # of cases is less than population size of each area. If not,
# resample
for(i in 1:ncol(perm)){
while(any(perm[,i] > population))
perm[,i] <- rmultinom(1, round(sum(cases)), prob=denominator)
}


# Compute simulated lambda's: max log-lkhd in region
sim.lambda <- kulldorffMC(perm, denominator, nearest.neighbors, n.zones, type)

Expand Down
4 changes: 2 additions & 2 deletions R/plotmap.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plotmap <-
function(values, map, log=FALSE, nclr=7, include.legend=TRUE, lwd=0.5, round=3,
brks=NULL, legend=NULL, location='topright', rev=FALSE, leg.cex=1){
brks=NULL, legend=NULL, location='topright', rev=FALSE){

# create colors, each based on quantiles of data
plotclr <- grey(1-seq(0, 1, by=1/(nclr-1)))
Expand Down Expand Up @@ -44,7 +44,7 @@ if(is.null(legend)){

plot(map, axes=TRUE, col=colcode, lwd=lwd)
if(include.legend) {
legend(location, legend=legend, fill=plotclr, bty="n", cex=leg.cex)
legend(location, legend=legend, fill=plotclr, bty="n")
}

}
2 changes: 1 addition & 1 deletion SpatialEpi.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ LaTeX: pdfLaTeX
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace,vignette
PackageRoxygenize: vignette
3 changes: 1 addition & 2 deletions man/plotmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\description{Plot levels of a variable in a colour-coded map.}
\usage{
plotmap(values, map, log = FALSE, nclr = 7, include.legend = TRUE, lwd = 0.5,
round = 3, brks = NULL, legend = NULL, location = "topright", rev = FALSE, leg.cex = 1)
round = 3, brks = NULL, legend = NULL, location = "topright", rev = FALSE)
}
\arguments{
\item{values}{variable to plot}
Expand All @@ -18,7 +18,6 @@ round = 3, brks = NULL, legend = NULL, location = "topright", rev = FALSE, leg.c
\item{legend}{if desired, a pre-specified legend}
\item{location}{location of legend}
\item{rev}{boolean of whether to reverse colour scheme (darker colours for smaller values)}
\item{leg.cex}{factor for legend font size}
}
\value{A map colour-coded to indicate the different levels of \code{values}.}
\seealso{
Expand Down
44 changes: 14 additions & 30 deletions src/cluster_detection.cpp
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
#include <Rcpp.h>
using namespace Rcpp;
using namespace Rcpp;


// [[Rcpp::export]]
double binomialLogLkhd(double cz, double nz, double N, double C) {
double logLkhd = 0;

if(cz / nz <= (C - cz)/(N - nz)) {
logLkhd = 0;
} else if (cz == nz){
// Special case: log(0)*0 should = 0, so remove last term
logLkhd =
log(N-nz-C+cz) * (N-nz-C+cz) +
log(N-C) * (C-N) +
log(N-nz) * (nz-N) +
log(C) * (-C) +
log( nz ) *(-nz) +
log(N) * N +
log(cz) * cz +
log(C-cz) *(C-cz);
} else {
logLkhd =
log(N-nz-C+cz) * (N-nz-C+cz) +
log(N-C) * (C-N) +
log(N-nz) * (nz-N) +
log(C) * (-C) +
log( nz ) *(-nz) +
log(N) * N +
log(cz) * cz +
log(C-cz) *(C-cz) +
log(nz-cz)*(nz-cz);
}

return logLkhd;
double logLkhd = 0;

if(cz / nz <= (C - cz)/(N - nz)) {
logLkhd = 0;
} else {
logLkhd =
N * ( log( N-nz-C+cz ) - log( N-C ) + log( N ) - log( N-nz ) ) +
nz * ( log( nz-cz ) - log( N-nz-C+cz ) + log( N-nz ) - log( nz ) )+
cz * ( log( cz ) - log( nz-cz ) + log( N-nz-C+cz ) - log( C-cz ) )+
C * ( log( C-cz ) - log( C ) + log( N-C ) - log( N-nz-C+cz ) );
}

return logLkhd;
}


Expand Down

0 comments on commit 26eecb0

Please sign in to comment.