gjamCensorY: Censor gjam response data

View source: R/gjamCensorY.r

gjamCensorYR Documentation

Censor gjam response data

Description

Returns a list with censored values, intervals, and censored response matrix y.

Usage

  gjamCensorY(values, intervals, y, type='CA', whichcol = c(1:ncol(y)))

Arguments

values

Values in y that are censored, specified by intervals

intervals

matrix having two rows and one column for each value in values. The first row holds lower bounds. The second row holds upper bounds. See Examples.

y

Response matrix, n rows by S columns. All values within intervals will be replaced with values

type

Response type, see typeNames in gjam

whichcol

Columns in y that are censored (often not all responses are censored)

Details

Any values in y that fall within censored intervals are replaced with censored values. The example below simulates data collected on an 'octave scale': 0, 1, 2, 4, 8, ..., an approach to accelerate data collection with approximate bins.

Value

Returns a list containing two elements.

y

n by S matrix updated with censored values substituted for those falling within intervals.

censor

list containing $columns that are censored and $partition, a matrix with 3 rows used in gjam and gjamPlot, one column per censor interval. Rows are values, followed by lower and upper bounds.

Author(s)

James S Clark, jimclark@duke.edu

References

Clark, J.S., D. Nemergut, B. Seyednasrollah, P. Turner, and S. Zhang. 2017. Generalized joint attribute modeling for biodiversity analysis: Median-zero, multivariate, multifarious data. Ecological Monographs 87, 34-56.

See Also

gjamSimData simulates data gjam analyzes data

A more detailed vignette is can be obtained with:

browseVignettes('gjam')

website 'http://sites.nicholas.duke.edu/clarklab/code/'.

Examples

## Not run: 
# data in octaves
v  <- up <- c(0, 2^c(0:4), Inf)         
dn <- c(-Inf, v[-length(v)])
i  <- rbind( dn, up )  # intervals

f  <- gjamSimData(n = 2000, S = 15, Q = 3, typeNames='CA')
y  <- f$y
cc <- c(3:6)                                                # censored columns
g  <- gjamCensorY(values = v, intervals = i, y = y, whichcol = cc)
y[,cc] <- g$y                                               # replace columns
ml     <- list(ng = 500, burnin = 100, censor = g$censor, typeNames = f$typeNames)
output <- gjam(f$formula, xdata = f$xdata, ydata = y, modelList = ml)

#repeat with ng = 2000, burnin = 500, then:
pl  <- list(trueValues = f$trueValues, width = 3, height = 3)   
gjamPlot(output, pl)

# upper detection limit
up <- 5
v  <- up
i  <- matrix(c(up,Inf),2)
rownames(i) <- c('down','up')

f   <- gjamSimData(typeNames='CA')   
g   <- gjamCensorY(values = v, intervals = i, y = f$y)
ml  <- list(ng = 500, burnin = 100, censor = g$censor, typeNames = f$typeNames)
out <- gjam(f$formula, xdata = f$xdata, ydata = g$y, modelList = ml)

#repeat with ng = 2000, burnin = 500, then:
pl  <- list(trueValues = f$trueValues, width = 3, height = 3)           
gjamPlot(out, pl)

# lower detection limit
lo        <- .001
values    <- upper <- lo
intervals <- matrix(c(-Inf,lo),2)
rownames(intervals) <- c('lower','upper')

## End(Not run)

gjam documentation built on May 24, 2022, 1:06 a.m.