Herd or population sensitivity for varying unit sensitivity
Input Values
This utility calculates cluster (herd ) or population-level sensitivity when individual unit sensitivity varies. It is useful for example when different units are tested with tests with different sensitivities for some reason, or when cluster-sensitivity varies among herds when calculating overall population-level sensitivity.
If the population size is not specified the binomial method is used, otherwise the hypergeometric approximation is used.
Inputs
Inputs are:
- design prevalence, as either a proportion or as an integer number of units;
- population size, if known;
- prior confidence of freedom; and
- 2 columns of data, including a header row. The first column is an identifier for each unit tested and the second is the sensitivity (test or herd) for that unit.
Outputs
Outputs from the analysis include:
- Herd or population-level sensitivity for the given data; and
- Confidence of freedom of the herd or population from disease (at the specified design prevalences.
No results
No example available
No references available
###################################### # Program to calculate Seh/SSe for verying unit sensitivity ###################################### # uses RSurveillance package rm(list = ls()) # cat("
Test:",length(commandArgs())) test<- ifelse(length(commandArgs()) < 3, TRUE, FALSE) fpath<- ifelse(test, "webRootUrl", "rtoolsPath") # load header scripts source(paste(fpath, "R/epi_head.R", sep = "")) source(paste(fpath, "R/HTMLStream.R", sep = "")) source(paste(fpath, "R/epitools_functions.r", sep = "")) # extract command arguments # 1 = design prevalence, 2 = dp.a format (0=proportion, 1=number), # 3 = no herds specified, # 4 = prior probability of freedom, a1<- type.convert(a0[8:10]) # cat(a1) dp.a<- a1[1] dp.a.int<- ifelse(dp.a < 1, F, T) n.herds<- a1[2] prior.pfree<- a1[3] heading<- "Cluster or population sensitivity for varying unit sensitivity" digits<- 4 filename<- digest(Sys.time) tmp.path<- paste(fpath, "tmp/", sep = "") tmp.file<- paste(fpath, "tmp/", filename, sep = "") sinkfile<- paste(fpath, "tmp/", filename, ".txt", sep="") # fpath, # cat("
", data.file) data.file<- ifelse(test, paste(fpath, "docs/VaryingSeDemo.txt", sep = ""), a0[length(a0)]) #test name dat<- read.csv(data.file) # first clumn = unit id, 2nd = sensitivity # cat(colnames(dat)) # cat(dat[,1]) # check for valid sample size if (nrow(dat) > n.herds & n.herds > 0) { cat("Sample size exceeds Population size. Please try again.") quit() } # set up table of inputs inputs<- array("", dim = c(length(a1), 1)) rownames(inputs)<- c("Design prevalence", "Population size", "Prior confidence of freedom") inputs[1, 1]<- ifelse(dp.a.int, paste(dp.a, " unit(s)"), paste(dp.a*100, "%", sep = "")) inputs[2, 1]<- ifelse(n.herds <= 0, "Unknown", n.herds) inputs[3, 1]<- a1[3] n.herds<- ifelse(n.herds <= 0, NA, n.herds) # cat(dat[1,2]) SSe<- sep.var.se(N=n.herds, se=na.omit(dat[,2]), pstar=dp.a) # Calculate probability of freedom PFree<- pfree.1(SSe, p.intro = 0, prior.pfree)[4] # PFree<- pfree.1(SSe, prior.pfree)[4] results<- rbind(nrow(dat), round(mean(dat[,2]), digits), round(SSe, digits), round(PFree, digits)) rownames(results)<- c("Number of units sampled", "Mean unit sensitivity", "Cluster/population sensitivity", "Confidence of freedom") colnames(results)<- "" # write to html and file subheadings<- "" result.txt<- "" output<- html.output(heading, subheadings, inputs = inputs, results = list(results), graphs = "", graph.headings = "", show.inputs = T, show.graphs = F, tmp.file, result.txt = result.txt) write.html(output, tmp.file) cat(output)