code
stringlengths 1
13.8M
|
---|
leave_var_out_formulas <- function(formula, data, full_model = TRUE, ...) {
trms <- attr(model.frame(formula, data, ...), "terms")
x_vars <- attr(trms, "term.labels")
if (length(x_vars) < 2) {
rlang::abort("There should be at least 2 predictors in the formula.")
}
y_vars <- as.character(formula[[2]])
form_terms <- purrr::map(x_vars, rm_vars, lst = x_vars)
form <- purrr::map_chr(form_terms, ~ paste(y_vars, "~", paste(.x, collapse = " + ")))
form <- purrr::map(form, as.formula)
form <- purrr::map(form, rm_formula_env)
names(form) <- x_vars
if (full_model) {
form$everything <- formula
}
form
}
rm_vars <- function(x, lst) {
remaining_terms(x, lst)
}
remaining_terms <- function(x, lst) {
has_x <- purrr::map_lgl(lst, ~ x %in% all_terms(.x))
is_x <- lst == x
lst[!has_x & !is_x]
}
rm_formula_env <- function (x) {
attr(x, ".Environment") <- rlang::base_env()
x
}
all_terms <- function(x) {
y <- paste("~", x)
y <- as.formula(y)
all.vars(y)
}
|
multinom.spls.aux <- function(sXtrain, sXtrain.nosvd=NULL, Ytrain, lambda.ridge, lambda.l1, ncomp, sXtest, sXtest.nosvd=NULL,
adapt=TRUE, maxIter=100, svd.decompose=TRUE,
meanXtrain, sigma2train,
center.X=TRUE, scale.X=FALSE, weighted.center=TRUE) {
sXtrain <- as.matrix(sXtrain)
ntrain <- nrow(sXtrain)
p <- ncol(sXtrain)
index.p <- c(1:p)
Ytrain <- as.matrix(Ytrain)
q <- ncol(Ytrain)
one <- matrix(1,nrow=1,ncol=ntrain)
ntest <- nrow(sXtest)
r <- p
G <- max(Ytrain)
Z <- cbind(rep(1,ntrain),sXtrain)
Zbloc <- matrix(0,nrow=ntrain*G,ncol=G*(r+1))
Zt <- cbind(rep(1,ntest),sXtest)
Ztestbloc <- matrix(0,nrow=ntest*G,ncol=G*(r+1))
for (g in 1:G) {
row <- (0:(ntrain-1))*G+g
col <- (r+1)*(g-1)+1:(r+1)
Zbloc[row,col] <- Z
row <- (0:(ntest-1))*G+g
Ztestbloc[row,col] <- Zt
}
rm(Z)
Zt <- NULL
fit <- mwirrls(Y=Ytrain, Z=Zbloc, Lambda=lambda.ridge, NbrIterMax=maxIter, WKernel=diag(rep(1,ntrain*G)))
converged=fit$Cvg
if (converged==0) {
warning("Message from multinom.spls.aux : Ridge IRLS did not converge; try another lambda.ridge value")
}
if (ncomp==0) {
BETA <- fit$Coefficients
}
if (ncomp!=0) {
Eta <- Zbloc %*% fit$Coefficients
if(svd.decompose) {
p <- ncol(sXtrain.nosvd)
r <- p
sXtrain = sXtrain.nosvd
sXtest = sXtest.nosvd
Z <- cbind(rep(1,ntrain),sXtrain)
Zbloc <- matrix(0,nrow=ntrain*G,ncol=G*(r+1))
Zt <- cbind(rep(1,ntest),sXtest)
Ztestbloc <- matrix(0,nrow=ntest*G,ncol=G*(r+1))
for (g in 1:G) {
row <- (0:(ntrain-1))*G+g
col <- (r+1)*(g-1)+1:(r+1)
Zbloc[row,col] <- Z
row <- (0:(ntest-1))*G+g
Ztestbloc[row,col] <- Zt
}
rm(Z)
Zt <- NULL
}
mu <- rep(0, length(Eta))
V <- matrix(0, length(mu), length(mu))
Vinv <- matrix(0, length(mu), length(mu))
for (kk in 1:ntrain) {
mu[G*(kk-1)+(1:G)] <- exp(Eta[G*(kk-1)+(1:G)])/(1+sum(exp(Eta[G*(kk-1)+(1:G)])))
Blocmu <- mu[G*(kk-1)+(1:G)]
BlocV <- -Blocmu %*% t(Blocmu)
BlocV <- BlocV + diag(Blocmu)
V[G*(kk-1)+(1:G), G*(kk-1)+(1:G)] <- BlocV
Vinv[G*(kk-1)+(1:G), G*(kk-1)+(1:G)] <- tryCatch(solve(BlocV), error = function(e) return(ginv(BlocV)))
}
Psi <- fit$Ybloc - mu
col.intercept <- seq(from=1, to=G*(p+1), by=(p+1))
index <- 1:(G*(p+1))
Xbloc <- Zbloc[,-col.intercept]
Cte <- Zbloc[,col.intercept]
H <- t(Cte) %*% V %*% Cte
VMeanPseudoVar <- solve(H, t(Cte) %*% (V %*% Eta + Psi))
VCtrPsi <- Psi
VCtrEta <- Eta - Cte %*% VMeanPseudoVar
VMeansXtrain <- solve(H, t(Cte) %*% V %*% Xbloc)
VCtrsXtrain <- Xbloc - Cte %*% VMeansXtrain
rm(H)
pseudoVar = Eta + Vinv %*% Psi
pseudoVar = pseudoVar - Cte %*% VMeanPseudoVar
if(center.X && weighted.center) {
sXtrain <- VCtrsXtrain
} else {
sXtrain <- Xbloc
}
resSPLS = spls.in(Xtrain=sXtrain, Ytrain=pseudoVar, ncomp=ncomp, weight.mat=V, lambda.l1=lambda.l1, adapt=adapt,
center.X=FALSE, center.Y=FALSE, scale.X=FALSE, scale.Y=FALSE, weighted.center=FALSE)
BETA <- matrix(0, nrow=G*(r+1), ncol=1)
BETA[-col.intercept,] <- resSPLS$betahat
BETA[col.intercept,] <- VMeanPseudoVar - VMeansXtrain %*% BETA[-col.intercept,]
}
hatYtest <- numeric(ntest)
Eta.test <- matrix(0, nrow=G+1, ncol=1)
proba.test <- matrix(0, nrow=ntest, ncol=G+1)
Eta.test <- cbind(rep(0,ntest),matrix(Ztestbloc%*%BETA,nrow=ntest,byrow=TRUE))
proba.test <- t(apply(exp(Eta.test), 1, function(x) x/sum(x)))
hatYtest <- as.matrix(apply(proba.test,1,which.max)-1)
Beta <- t(matrix(BETA,nrow=G,byrow=TRUE))
Coefficients <- t(matrix(0, nrow=G, ncol=(p+1)))
if(p > 1) {
Coefficients[-1,] <- diag(c(1/sqrt(sigma2train))) %*% Beta[-1,]
} else {
Coefficients[-1,] <- (1/sqrt(sigma2train))%*%Beta[-1,]
}
Coefficients[1,] <- Beta[1,] - meanXtrain %*% Coefficients[-1,]
result <- list(Coefficients=Coefficients, hatYtest=hatYtest, converged=converged, lenA=resSPLS$lenA)
class(result) <- "multinom.spls.aux"
return(result)
}
|
SL.nnls <- function(Y, X, newX, family, obsWeights, ...) {
.SL.require("nnls")
fit.nnls <- nnls::nnls(sqrt(obsWeights)*as.matrix(X), sqrt(obsWeights)*Y)
initCoef <- coef(fit.nnls)
initCoef[is.na(initCoef)] <- 0
if (sum(initCoef) > 0) {
coef <- initCoef/sum(initCoef)
} else {
warning("All algorithms have zero weight", call. = FALSE)
coef <- initCoef
}
pred <- crossprod(t(as.matrix(newX)), coef)
fit <- list(object = fit.nnls)
class(fit) <- "SL.nnls"
out <- list(pred = pred, fit = fit)
return(out)
}
predict.SL.nnls <- function(object, newdata, ...) {
initCoef <- coef(object$object)
initCoef[is.na(initCoef)] <- 0
if (sum(initCoef) > 0) {
coef <- initCoef/sum(initCoef)
} else {
warning("All algorithms have zero weight", call. = FALSE)
coef <- initCoef
}
pred <- crossprod(t(as.matrix(newdata)), coef)
return(pred)
}
|
NULL
.trinv = function(x)
{
.Call(R_trinv, x, 'U')
}
qr_R = function(x)
{
check.is.shaq(x)
cp = cp.shaq(x)
R = chol(cp)
R
}
qr_Q = function(x, R)
{
check.is.shaq(x)
if (missing(R))
R = qr_R(x)
else
check.is.matrix(R)
Q.local = Data(x) %*% .trinv(R)
shaq(Q.local, nrow(x), ncol(x), checks=FALSE)
}
|
test_that("A Brainvoyager mesh can be written and re-read from a Brainvoyager SRF file.", {
fsasc_surface_file = system.file("extdata", "lh.tinysurface.asc", package = "freesurferformats", mustWork = TRUE);
orig_surf = read.fs.surface(fsasc_surface_file);
bvsrf_file = tempfile(fileext = '.srf');
write.fs.surface.bvsrf(bvsrf_file, orig_surf$vertices, orig_surf$faces);
surf = read.fs.surface.bvsrf(bvsrf_file);
expect_true(is.fs.surface(surf));
known_vertex_count = 5L;
known_face_count = 3L;
expect_equal(nrow(orig_surf$vertices), known_vertex_count);
expect_equal(nrow(orig_surf$faces), known_face_count);
expect_equal(nrow(surf$vertices), known_vertex_count);
expect_equal(ncol(surf$vertices), 3);
expect_equal(typeof(surf$vertices), "double");
expect_equal(nrow(surf$faces), known_face_count);
expect_equal(ncol(surf$faces), 3);
expect_equal(typeof(surf$faces), "integer");
num_faces_with_index_zero = sum(surf$faces==0);
expect_equal(num_faces_with_index_zero, 0);
expect_equal(min(surf$faces), 1L);
})
test_that("A bvsmp instance for writing Brainvoyager morph data can be created.", {
data_length = 100L;
morph_data = rnorm(data_length, 3.0, 1.0);
bv = bvsmp(morph_data);
expect_equal(bv$smp_version, 3L);
expect_true(is.bvsmp(bv));
expect_equal(bv$num_mesh_vertices, data_length);
expect_equal(bv$num_maps, 1L);
expect_equal(length(bv$vertex_maps[[1]]$data), data_length);
expect_equal(bv$vertex_maps[[1]]$data, morph_data, tolerance = 1e-5);
})
test_that("Morphometry data can be written to and re-read from a Brainvoyager v3 SMP file.", {
data_length = 100L;
morph_data = rnorm(data_length, 3.0, 1.0);
bvsmp_file = tempfile(fileext = '.smp');
write.fs.morph.smp(bvsmp_file, morph_data, smp_version = 3L);
bvsmp = read.smp.brainvoyager(bvsmp_file);
expect_equal(bvsmp$smp_version, 3L);
expect_equal(bvsmp$num_mesh_vertices, 100L);
morph_data_reread = read.fs.morph(bvsmp_file);
expect_equal(length(morph_data_reread), data_length);
expect_equal(morph_data_reread, morph_data, tolerance = 1e-3);
})
test_that("Morphometry data can be written to and re-read from a Brainvoyager v2 SMP file.", {
data_length = 100L;
morph_data = rnorm(data_length, 3.0, 1.0);
bvsmp_file = tempfile(fileext = '.smp');
write.fs.morph.smp(bvsmp_file, morph_data, smp_version = 2L);
bvsmp = read.smp.brainvoyager(bvsmp_file);
expect_equal(bvsmp$smp_version, 2L);
expect_equal(bvsmp$num_mesh_vertices, 100L);
morph_data_reread = read.fs.morph(bvsmp_file);
expect_equal(length(morph_data_reread), data_length);
expect_equal(morph_data_reread, morph_data, tolerance = 1e-3);
})
test_that("Morphometry data can be read from Brainvoyager SMP files by map index and name.", {
data_length = 100L;
morph_data = rnorm(data_length, 3.0, 1.0);
bvsmp_file = tempfile(fileext = '.smp');
write.fs.morph.smp(bvsmp_file, morph_data);
morph_data_reread_by_index = read.fs.morph.bvsmp(bvsmp_file, map_index = 1L);
morph_data_reread_by_name = read.fs.morph.bvsmp(bvsmp_file, map_index = "data");
expect_equal(length(morph_data_reread_by_index), data_length);
expect_equal(morph_data_reread_by_index, morph_data, tolerance = 1e-3);
expect_equal(length(morph_data_reread_by_name), data_length);
expect_equal(morph_data_reread_by_name, morph_data, tolerance = 1e-3);
expect_error(read.fs.morph.bvsmp(bvsmp_file, map_index = 3L));
})
|
lemna <- function(...) {
UseMethod("lemna")
}
lemna.default <- function(init=c("BM"=0, "M_int"=0), times, param, envir, ode_mode=c("r", "c"), nout=2, ...) {
ode_mode <- match.arg(ode_mode)
init_missing <- setdiff(c("BM", "M_int"), names(init))
if(length(init_missing) > 0) {
stop(paste("init vector elements missing:", paste(init_missing, collapse=",")))
}
if(length(init) != 2) {
stop("init vector has invalid length")
}
if(length(times) < 2) {
stop("times vector must have at least two elements")
} else if(length(times) == 2) {
times <- seq(min(times) ,max(times), 0.01)
}
param <- as.list(param)
param_missing <- setdiff(names(param_defaults()), names(param))
if(length(param_missing) > 0) {
stop(paste("model parameters missing:", paste(param_missing, collapse=",")))
}
envir_missing <- setdiff(c("conc","tmp","irr","P","N"), names(envir))
if(length(envir_missing) > 0) {
stop(paste("environmental factor(s) missing:",paste(envir_missing,collapse=",")))
}
envir$conc <- prepare_envir("conc", envir)
envir$tmp <- prepare_envir("tmp", envir)
envir$irr <- prepare_envir("irr", envir)
envir$P <- prepare_envir("P", envir)
envir$N <- prepare_envir("N", envir)
if(ode_mode == "r") {
for(nm in names(envir)) {
v <- envir[[nm]]
if(is.function(v)) {
param[[paste0("ts_",nm)]] <- v
} else if(nrow(v)==1) {
param[[paste0("ts_",nm)]] <- local({ c <- v[[1,2]]; function(t) c })
} else {
param[[paste0("ts_",nm)]] <- approxfun(x=v[, 1], y=v[, 2], method="linear", f=0, rule=2, ties="ordered")
}
}
rm(nm, v)
out <- as.data.frame(ode(y=init, times=times, func=lemna_ode, parms=param, ...))
if(nout > 0) {
out$C_int <- ifelse(out$BM <= 0, 0, out$M_int * param$r_FW_V / (out$BM * param$r_FW_DW))
}
if(nout > 1) {
out$FrondNo <- out$BM / param$r_DW_FN
}
if(nout > 2) {
warning("additional outputs (nout > 2) only available for compiled ODE")
}
}
else if(ode_mode == "c") {
param_order <- names(param_new())
param <- unlist(param[param_order])
envir <- envir[c("conc","tmp","irr","P","N")]
outnames <- c("C_int", "FrondNo", "f_loss", "f_photo", "fT_photo", "fI_photo",
"fP_photo", "fN_photo", "fBM_photo", "fCint_photo", "C_int_unb",
"C_ext", "Tmp", "Irr", "Phs", "Ntr", "dBM", "dM_int")
fcontrol <- list(method="linear", rule=2, f=0, ties="ordered")
out <- ode(y=init, times=times, parms=param, forcings=envir,
dllname="lemna", initfunc="lemna_init", func="lemna_func",
initforc="lemna_forc", fcontrol=fcontrol, nout=nout,
outnames=outnames, ...)
out <- as.data.frame(out)
}
else {
stop("unknown ode mode")
}
class(out) <- c("lemna_result", class(out))
attr(out, "r_DW_FN") <- param[["r_DW_FN"]]
attr(out, "exposure") <- envir$conc
out
}
lemna.lemna_scenario <- function(x, init, times, param, envir, ...) {
if("init" %in% names(x) & missing(init)) {
init <- x$init
}
if("times" %in% names(x) & missing(times)) {
times <- x$times
}
if("param" %in% names(x) & missing(param)) {
param <- x$param
}
if("envir" %in% names(x) & missing(envir)) {
envir <- x$envir
}
lemna.default(init=init, times=times, param=param, envir=envir, ...)
}
lemna_desolve <- function(...) {
outnames <- c("C_int", "FrondNo", "f_loss", "f_photo", "fT_photo", "fI_photo",
"fP_photo", "fN_photo", "fBM_photo", "fCint_photo", "C_int_unb",
"C_ext", "Tmp", "Irr", "Phs", "Ntr", "dBM", "dM_int")
ode(dllname="lemna", initfunc="lemna_init", func="lemna_func",
initforc="lemna_forc", outnames=outnames, ...)
}
prepare_envir <- function(key, envir) {
if(!(key %in% names(envir))) {
stop(paste("environmental factor missing:", key))
}
envir <- as.list(envir)
data <- envir[[key]]
if(is.function(data)) {
return(data)
}
if(is.character(data)) {
data <- read.csv(data, stringsAsFactors=FALSE)
}
if(is.numeric(data)) {
if(length(data) > 1) {
stop(paste("environmental factor", key, "has length > 1"))
}
data <- data.frame(t=0, V1=data)
}
if(is.data.frame(data)) {
if(length(data) != 2) {
stop(paste("environmental factor",key,"time series must have exactly two columns"))
}
} else {
stop(paste("unknown data type for environmental factor", key))
}
data
}
|
FileFormat <- R6Class("FileFormat",
inherit = ArrowObject,
active = list(
type = function() dataset___FileFormat__type_name(self)
)
)
FileFormat$create <- function(format, schema = NULL, ...) {
opt_names <- names(list(...))
if (format %in% c("csv", "text") || any(opt_names %in% c("delim", "delimiter"))) {
CsvFileFormat$create(schema = schema, ...)
} else if (format == c("tsv")) {
CsvFileFormat$create(delimiter = "\t", schema = schema, ...)
} else if (format == "parquet") {
ParquetFileFormat$create(...)
} else if (format %in% c("ipc", "arrow", "feather")) {
dataset___IpcFileFormat__Make()
} else {
stop("Unsupported file format: ", format, call. = FALSE)
}
}
as.character.FileFormat <- function(x, ...) {
out <- x$type
ifelse(out == "ipc", "feather", out)
}
ParquetFileFormat <- R6Class("ParquetFileFormat", inherit = FileFormat)
ParquetFileFormat$create <- function(...,
dict_columns = character(0)) {
options <- ParquetFragmentScanOptions$create(...)
dataset___ParquetFileFormat__Make(options, dict_columns)
}
IpcFileFormat <- R6Class("IpcFileFormat", inherit = FileFormat)
CsvFileFormat <- R6Class("CsvFileFormat", inherit = FileFormat)
CsvFileFormat$create <- function(...,
opts = csv_file_format_parse_options(...),
convert_options = csv_file_format_convert_opts(...),
read_options = csv_file_format_read_opts(...)) {
dataset___CsvFileFormat__Make(opts, convert_options, read_options)
}
csv_file_format_parse_options <- function(...) {
opts <- list(...)
convert_opts <- names(formals(CsvConvertOptions$create))
read_opts <- names(formals(CsvReadOptions$create))
opts[convert_opts] <- NULL
opts[read_opts] <- NULL
opts[["schema"]] <- NULL
opt_names <- names(opts)
unsup_readr_opts <- setdiff(
names(formals(read_delim_arrow)),
names(formals(readr_to_csv_parse_options))
)
is_unsup_opt <- opt_names %in% unsup_readr_opts
unsup_opts <- opt_names[is_unsup_opt]
if (length(unsup_opts)) {
stop(
"The following ",
ngettext(length(unsup_opts), "option is ", "options are "),
"supported in \"read_delim_arrow\" functions ",
"but not yet supported here: ",
oxford_paste(unsup_opts),
call. = FALSE
)
}
arrow_opts <- names(formals(CsvParseOptions$create))
readr_opts <- names(formals(readr_to_csv_parse_options))
is_arrow_opt <- !is.na(pmatch(opt_names, arrow_opts))
is_readr_opt <- !is.na(pmatch(opt_names, readr_opts))
unrec_opts <- opt_names[!is_arrow_opt & !is_readr_opt]
if (length(unrec_opts)) {
stop(
"Unrecognized ",
ngettext(length(unrec_opts), "option", "options"),
": ",
oxford_paste(unrec_opts),
call. = FALSE
)
}
is_ambig_opt <- is.na(pmatch(opt_names, c(arrow_opts, readr_opts)))
ambig_opts <- opt_names[is_ambig_opt]
if (length(ambig_opts)) {
stop("Ambiguous ",
ngettext(length(ambig_opts), "option", "options"),
": ",
oxford_paste(ambig_opts),
". Use full argument names",
call. = FALSE
)
}
if (any(is_readr_opt)) {
if (!all(is_readr_opt)) {
stop("Use either Arrow parse options or readr parse options, not both",
call. = FALSE
)
}
do.call(readr_to_csv_parse_options, opts)
} else {
do.call(CsvParseOptions$create, opts)
}
}
csv_file_format_convert_opts <- function(...) {
opts <- list(...)
arrow_opts <- names(formals(CsvParseOptions$create))
readr_opts <- names(formals(readr_to_csv_parse_options))
read_opts <- names(formals(CsvReadOptions$create))
opts[arrow_opts] <- NULL
opts[readr_opts] <- NULL
opts[read_opts] <- NULL
opts[["schema"]] <- NULL
do.call(CsvConvertOptions$create, opts)
}
csv_file_format_read_opts <- function(schema = NULL, ...) {
opts <- list(...)
arrow_opts <- names(formals(CsvParseOptions$create))
readr_opts <- names(formals(readr_to_csv_parse_options))
convert_opts <- names(formals(CsvConvertOptions$create))
opts[arrow_opts] <- NULL
opts[readr_opts] <- NULL
opts[convert_opts] <- NULL
if (!is.null(schema)) {
opts[["column_names"]] <- names(schema)
}
do.call(CsvReadOptions$create, opts)
}
FragmentScanOptions <- R6Class("FragmentScanOptions",
inherit = ArrowObject,
active = list(
type = function() dataset___FragmentScanOptions__type_name(self)
)
)
FragmentScanOptions$create <- function(format, ...) {
if (format %in% c("csv", "text", "tsv")) {
CsvFragmentScanOptions$create(...)
} else if (format == "parquet") {
ParquetFragmentScanOptions$create(...)
} else {
stop("Unsupported file format: ", format, call. = FALSE)
}
}
as.character.FragmentScanOptions <- function(x, ...) {
x$type
}
CsvFragmentScanOptions <- R6Class("CsvFragmentScanOptions", inherit = FragmentScanOptions)
CsvFragmentScanOptions$create <- function(...,
convert_opts = csv_file_format_convert_opts(...),
read_opts = csv_file_format_read_opts(...)) {
dataset___CsvFragmentScanOptions__Make(convert_opts, read_opts)
}
ParquetFragmentScanOptions <- R6Class("ParquetFragmentScanOptions", inherit = FragmentScanOptions)
ParquetFragmentScanOptions$create <- function(use_buffered_stream = FALSE,
buffer_size = 8196,
pre_buffer = TRUE) {
dataset___ParquetFragmentScanOptions__Make(use_buffered_stream, buffer_size, pre_buffer)
}
FileWriteOptions <- R6Class("FileWriteOptions",
inherit = ArrowObject,
public = list(
update = function(table, ...) {
if (self$type == "parquet") {
dataset___ParquetFileWriteOptions__update(
self,
ParquetWriterProperties$create(table, ...),
ParquetArrowWriterProperties$create(...)
)
} else if (self$type == "ipc") {
args <- list(...)
if (is.null(args$codec)) {
dataset___IpcFileWriteOptions__update1(
self,
get_ipc_use_legacy_format(args$use_legacy_format),
get_ipc_metadata_version(args$metadata_version)
)
} else {
dataset___IpcFileWriteOptions__update2(
self,
get_ipc_use_legacy_format(args$use_legacy_format),
args$codec,
get_ipc_metadata_version(args$metadata_version)
)
}
} else if (self$type == "csv") {
dataset___CsvFileWriteOptions__update(
self,
CsvWriteOptions$create(...)
)
}
invisible(self)
}
),
active = list(
type = function() dataset___FileWriteOptions__type_name(self)
)
)
FileWriteOptions$create <- function(format, ...) {
if (!inherits(format, "FileFormat")) {
format <- FileFormat$create(format)
}
options <- dataset___FileFormat__DefaultWriteOptions(format)
options$update(...)
}
|
design_effect <- function(n, icc = 0.05) {
1 + (n - 1) * icc
}
|
context("topTexts")
test_that("topTexts", {
load("data/test-k3i20b70s24601alpha0.33eta0.33.RData")
M <- matrix(c(
"I","H","E",
"C","D","G",
"A","B","B",
"H","G","D",
"B","A","A"
),5,3,byrow=TRUE)
colnames(M) <- c("T1.culpa", "T2.ut", "T3.aliqua")
M2 <- matrix(c(
"I","G",
"C","A",
"A","B",
"H","E",
"F","D",
"B","H",
"D","C",
"E","F",
"G","I"),9,2,byrow=TRUE)
colnames(M2) <- c("T1.culpa", "T3.aliqua")
expect_equal(M,topTexts(ldaresult=result, ldaID=ldaID, limit = 5L, rel = TRUE, minlength=30L))
expect_equal(M2,topTexts(ldaresult=result, ldaID=ldaID, limit = 0L, rel = FALSE, select = c(1,3), minlength=1L))
})
|
create_build_directory <- function(appName,
description,
productName,
semanticVersion,
appPath,
functionName){
}
|
"balancedtwostage" <-
function(X,selection,m,n,PU,comment=TRUE,method=1)
{
N=dim(X)[1]
p=dim(X)[2]
str=cleanstrata(PU)
M=max(PU)
res1=balancedcluster(X,m,PU,method,comment)
if(selection==2)
{
pik2=rep(n/N*M/m,times=N);
if(n/N*M/m>1) stop("at the second stage, inclusion probabilities larger than 1");
}
if(selection==1)
{
pik2=inclusionprobastrata(str,rep(n/m ,times=max(str)));
if(max(pik2)>1) stop("at the second stage, inclusion probabilities larger than 1");
}
liste=(res1[,1]==1)
sf=rep(0,times=N)
sf[liste]=balancedstratification(array(X[liste,]/res1[,2][liste],c(sum(as.integer(liste)),p)),cleanstrata(str[liste]),pik2[liste],comment,method)
x=cbind(sf,res1[,2]*pik2,res1[,1],res1[,2],pik2)
colnames(x)=c("second_stage","final_pik", "primary","pik_first_stage", "pik_second_stage")
x
}
|
print.info <- function(info, args.only = F){
.info <- unclass(info)
.haplin.vers <- .info$misc$orig.call[[1]]
if(args.only){
.names <- names(formals(eval(.haplin.vers)))
for(i in 2:length(.info)){
.info[[i]] <- .info[[i]][is.element(names(.info[[i]]), .names)]
}
.ind <- sapply(.info, function(x) length(x) > 0)
.info <- .info[.ind]
}
f.printlist(.info)
return(invisible(.info))
}
|
stat.tauKrPartial <- function(X, Y, Z, omitDiag = TRUE) {
Tauxyz <- 0
Txy <- tauSD(X, Y, NULL, omitDiag)
Txz <- tauSD(X, Z, NULL, omitDiag)
Tyz <- tauSD(Y, Z, NULL, omitDiag)
if (is.nan(Txy$tau) || is.nan(Txz$tau) || is.nan(Tyz$tau)) {
return(list(Tauxy = NA, Tauxz = NA, Tauyz = NA, Tauxyz = NA))
}
else {
Tauxyz <- (Txy$tau - (Txz$tau * Tyz$tau)) / (sqrt((1 - (Txz$tau^2))) * sqrt((1 - (Tyz$tau^2))))
return(list(Tauxy = Txy$tau, Tauxz = Txz$tau, Tauyz = Tyz$tau, Tauxyz = Tauxyz))
}
}
|
library(h2o)
h2oServer <- h2o.init(max_mem_size="60g", nthreads=-1)
dx_train <- h2o.importFile(h2oServer, path = "train-1m.csv")
dx_test <- h2o.importFile(h2oServer, path = "test.csv")
Xnames <- names(dx_train)[which(names(dx_train)!="dep_delayed_15min")]
system.time({
md <- h2o.glm(x = Xnames, y = "dep_delayed_15min", data = dx_train,
family = "binomial", alpha = 1, lambda = 0)
})
system.time({
phat <- h2o.predict(md, dx_test)[,"Y"]
})
h2o.performance(phat, dx_test[,"dep_delayed_15min"])@model$auc
|
MC_Gauss<-function(compBdg,problem,delta=0.1,type="M",trmvrnorm=trmvrnorm_rej_cpp,typeReturn=0,verb=0,params=NULL){
sizeX<-length(problem$muEq)
sizeY<-length(problem$muEmq)
if(type=="M"){
upperTmvn = rep(problem$threshold,sizeX)
lowerTmvn = rep(-Inf,sizeX)
gg = function(x){return(max(x)>problem$threshold)}
}else{
upperTmvn = rep(Inf,sizeX)
lowerTmvn = rep(problem$threshold,sizeX)
gg = function(x){return(min(x)<problem$threshold)}
}
if(verb>0)
cat("Starting MC... \n")
if(is.null(params)){
if(verb>1)
cat("Initialize parameters... ")
timeInPart1<-get_chronotime()
simsX<-trmvrnorm(n = 1,mu = problem$muEq,sigma = problem$sigmaEq, upper = upperTmvn, lower = lowerTmvn, verb=(verb-1))
time1SimX<-(get_chronotime()-timeInPart1)*1e-9
ttX<-rep(0,20)
ii<-seq(from=1,length.out=20,by=max(1,floor((compBdg*delta*0.4/time1SimX-20)/190)))
for(i in seq(20)){
timeIn<-get_chronotime()
temp<-trmvrnorm(n = ii[i],mu = problem$muEq,sigma = problem$sigmaEq,upper = upperTmvn,lower = lowerTmvn,verb=(verb-1))
ttX[i]<-(get_chronotime()-timeIn)*1e-9*1.03
simsX<-cbind(simsX,temp)
}
Cx0<-unname(lm(ttX~ii+0)$coefficients[1])
timeIn<-get_chronotime()
muYcondX<- problem$muEmq + problem$wwCondQ%*%(simsX[,1]-problem$muEq)
simsYcX<- mvrnormArma(n=1,mu = muYcondX,sigma=problem$sigmaCondQChol,chol=1)
time1SimYcX<-(get_chronotime()-timeIn)*1e-9
tt<-rep(0,20)
ii<-seq(from=1,length.out=20,by=max(1,floor((compBdg*delta*0.5/time1SimYcX-20)/190)))
for(i in seq(20)){
timeIn<-get_chronotime()
muYcondX<- problem$muEmq + problem$wwCondQ%*%(simsX[,1]-problem$muEq)
temp<- mvrnormArma(n=ii[i],mu = muYcondX,sigma=problem$sigmaCondQChol,chol=1)
tt[i]<-(get_chronotime()-timeIn)*1e-9*1.03
simsYcX<-cbind(simsYcX,temp)
}
lmmYcX<-lm(tt[2:20]~ii[2:20])
alpha<-unname(lmmYcX$coefficients[1])
beta0<-unname(lmmYcX$coefficients[2])
timeG=rep(NA,154)
for(i in seq(154)){
iniT<-get_chronotime()
gg(1)
timeG[i]<-(get_chronotime()-iniT)
}
tEvalG<-quantile(sort(timeG)[-c(1,2,154,155)],probs = 0.99,names = F)*1e-9
C_adj<-compBdg*delta -time1SimX - sum(ttX) - sum(tt)-time1SimYcX - sum(timeG)*1e-9
if(verb>1){
cat("Time passed:",compBdg*delta-C_adj,"\n",
"tEvalG:",tEvalG,"\n",
"beta0: ",beta0,"\n",
"Cx0: ",Cx0,"\n",
"alpha: ",alpha,"\n")
}
n0<-ncol(simsX)
}else{
if(verb>1)
cat("Parameters already initialized. ")
timeInPart1<-get_chronotime()
Cx0<-params$Cx
alpha<-params$alpha
beta0<-params$beta
tEvalG<-params$evalG
}
if(verb>1)
cat("Done.\n")
nStar<-round(compBdg/(Cx0+(beta0+tEvalG)))
timePart1<-(get_chronotime()-timeInPart1)*1e-9
if(verb>1){
cat("Computational parameters: \n")
cat("Cx0: ",Cx0,", beta0: ",beta0, ", nStar: ",nStar, "Time Part 1: ",timePart1,"(compBdg assigned: ",compBdg*delta,")\n")
}
simsYcondXfull<-matrix(0,nrow = sizeY,ncol = 1)
if(is.null(params)){
if(nStar>n0){
simsXfull<-cbind(simsX,trmvrnorm(n = (nStar-n0),mu = problem$muEq,sigma = problem$sigmaEq,upper = upperTmvn,lower = lowerTmvn,verb=(verb-1)))
}else{
simsXfull<-simsX
nStar<-n0
}
}else{
simsXfull<-trmvrnorm(n = nStar,mu = problem$muEq,sigma = problem$sigmaEq,upper = upperTmvn,lower = lowerTmvn,verb=(verb-1))
}
estim<-0
expYcondXfull<-rep(0,nStar)
gEval<-rep(0,nStar)
for(j in seq(nStar)){
muYcondX<- problem$muEmq + problem$wwCondQ%*%(simsXfull[,j]-problem$muEq)
simsYcondXfull[,1]<-mvrnormArma(n=1,mu = muYcondX,sigma=problem$sigmaCondQChol,chol=1)
gEval[j]<-gg(simsYcondXfull[,1])
if(j%%100==0){
if((get_chronotime()-timeInPart1)*1e-9 >= compBdg*0.96)
break
}
}
nStar<-j
gEval<-gEval[1:nStar]
estim<-mean(gEval)
timeTot<-(get_chronotime()-timeInPart1)*1e-9
if(verb>=1){
cat("MC computation finished.\n")
cat("Total time: ",timeTot,"(compBdg: ",compBdg,")\n")
}
if(typeReturn==0){
return(estim)
}else{
varHatG<-var(gEval)/nStar
params<-list(n=nStar,Cx=Cx0,alpha=alpha,beta=beta0,evalG=tEvalG)
results<-list(estim=estim,varEst=varHatG,params=params)
results$times = list(part1=timePart1,total=timeTot)
return(results)
}
return("fail")
}
|
ISOElementSequence <- R6Class("ISOElementSequence",
inherit = ISOAbstractObject,
lock_objects = FALSE,
private = list(
xmlElement = "ElementSequence",
xmlNamespacePrefix = "GCO"
),
public = list(
initialize = function(xml = NULL, ...){
super$initialize(xml = xml)
if(is.null(xml)){
fields <- list(...)
if(!is.null(names(fields))){
for(fieldName in names(fields)){
self[[fieldName]] <- fields[[fieldName]]
}
}else{
self[["_internal_"]] <- fields
}
}
}
)
)
|
compute_R2mtch <- function(dataPoints,reference,weights=NULL,nWeight = 100){
nObj <- nrow(dataPoints)
if(is.null(weights)) {
weights <- createWeightsSobol(nDim=nObj,nWeights = nWeight)
}
sumR2 <- 0
nWeight <- ncol(weights)
nPoints <- ncol(dataPoints)
for(weightIndex in 1:nWeight){
pointAchievementVector <- NULL
for(pointIndex in 1:nPoints){
pointAchievementVector <- append(pointAchievementVector,
gmtch(dataPoints[,pointIndex],reference,weights[,weightIndex])
)
}
sumR2 <- sumR2+(max(pointAchievementVector))
}
return(sumR2/nWeight)
}
compute_R2HV <- function(dataPoints,reference,weights=NULL,nPoints = 100){
nObj <- nrow(dataPoints)
if(is.null(weights)) {
weights <- createWeightsSobol(nDim=nObj,nWeights = nPoints)
}
sumR2 <- 0
nWeight <- ncol(weights)
nPoints <- ncol(dataPoints)
for(weightIndex in 1:nWeight){
pointAchievementBest <- -Inf
for(pointIndex in 1:nPoints){
this.gmtch <- gmtch(dataPoints[,pointIndex],reference,weights[,weightIndex])^nObj
if(pointAchievementBest< this.gmtch)
pointAchievementBest <- this.gmtch
}
sumR2 <- sumR2+pointAchievementBest
}
return(sumR2/nWeight)
}
compute_R2HVC <- function(dataPoints,reference,weights=NULL,alpha=1,nWeight = 300,indexOfInterest = 1:ncol(dataPoints)){
nObj <- nrow(dataPoints)
if(is.null(weights)) {
weights <- createWeightsSobol(nDim=nObj,nWeights = nWeight)
}
sumR2 <- 0
R2contrib <- NULL
log_R2 <- NULL
logsd_R2 <- NULL
skew_R2 <- NULL
nWeight <- ncol(weights)
nPoints <- ncol(dataPoints)
for(sIndex in indexOfInterest){
sumR2 <- 0
minRset <- NULL
for(weightIndex in 1:nWeight){
minimumStar <- Inf
pointAchievementToBoundary <- gmtch(reference,dataPoints[,sIndex],weights[,weightIndex])
for(secondaryPointIndex in 1:nPoints){
if( secondaryPointIndex != sIndex){
new_g2tch <- g2tch_star(dataPoints[,secondaryPointIndex],dataPoints[,sIndex],weights[,weightIndex])
if(minimumStar > new_g2tch ){
minimumStar <- new_g2tch
}
}
}
minR <- min(c(minimumStar,pointAchievementToBoundary))
minR <- minR^alpha
minRset <- append(minRset,minR)
}
skew_R2 <- append(skew_R2,skewness(log(minRset)))
R2contrib <- append(R2contrib,mean(minRset))
log_R2 <- append(log_R2,mean(log(minRset)))
logsd_R2 <- append(logsd_R2,stats::sd(log(minRset)))
}
return(list(R2=R2contrib,log_R2=log_R2,logsd_R2=logsd_R2,skew_R2=skew_R2))
}
gmtch <- function(point, reference, weight){
nObj <- nrow(point)
achievement_vector <- abs(point-reference)/weight
return(min(achievement_vector))
}
g2tch <- function(point, ref, weight){
nObj <- nrow(point)
achievement_vector <- abs(point-ref)/weight
return(max(achievement_vector))
}
g2tch_star <- function(a, s, weight){
nObj <- nrow(a)
achievement_vector <- (a-s)/weight
return(max(achievement_vector))
}
createWeights <- function(nDim,axisDivision = nDim+2,noZero=FALSE){
nRefPoint <- choose(nDim+axisDivision-1,axisDivision)
referencePoint <- matrix(,nrow = nDim,ncol = nRefPoint)
referenceCombination <- gtools::combinations(nDim,axisDivision,1:nDim,repeats.allowed = TRUE)
for(objectiveIndex in 1:nDim){
this.objective <- as.integer(referenceCombination==objectiveIndex)
this.objective <- matrix(this.objective,nrow = nRefPoint,ncol = axisDivision)
for(referencePointIndex in 1:nRefPoint)
referencePoint[objectiveIndex,referencePointIndex] <- sum(this.objective[referencePointIndex,])
}
if(noZero){
if(axisDivision <= nDim){
stop('Number of axis division must be larger than problem dimension, otherwise no internal point will be created.')
}
removeCol <- NULL
for(refIndex in 1:nRefPoint){
if(min(referencePoint[,refIndex])==0){
removeCol <- append(removeCol,refIndex)
}
}
referencePoint <- referencePoint[,-removeCol]
}
nRefPoint <- ncol(referencePoint)
for(refIndex in 1:nRefPoint){
referencePoint[,refIndex] <- referencePoint[,refIndex]/norm(referencePoint[,refIndex,drop=FALSE],'F')
}
return(referencePoint)
}
createWeightsSobol <- function(nWeights, nDim,seed=4177){
weights <- randtoolbox::sobol(nWeights, dim = nDim,scrambling=3,seed = seed)
weights <- t(weights)
for(pointIndex in 1:nWeights){
weights[,pointIndex] <- weights[,pointIndex]/norm(weights[,pointIndex,drop=FALSE],'F')
}
return(weights)
}
|
test_that("mapkey", {
m <- leaflet() %>%
addMapkeyMarkers(data = breweries91,
icon = makeMapkeyIcon(icon = "mapkey",
iconSize = 30,
boxShadow = FALSE,
background = "transparent"),
group = "mapkey",
label = ~state, popup = ~village)
expect_is(m, "leaflet")
deps <- findDependencies(m)
expect_equal(deps[[length(deps)]]$name, "lfx-mapkeyicon")
iconSet = mapkeyIconList(
red = makeMapkeyIcon(icon = "boundary_stone",
color = "
background = '
iconSize = 30,
boxShadow = FALSE),
blue = makeMapkeyIcon(icon = "traffic_signal",
color = "
iconSize = 12,
boxShadow = FALSE,
background = "transparent"),
buddha = makeMapkeyIcon(icon = "buddhism",
color = "red",
iconSize = 12,
boxShadow = FALSE,
background = "transparent"))
expect_is(iconSet, "leaflet_mapkey_icon_set")
m <- leaflet() %>%
addMapkeyMarkers(data = breweries91, icon = iconSet,
group = "mapkey",
label = ~state, popup = ~village)
expect_is(m, "leaflet")
m <- leaflet() %>%
addMapkeyMarkers(data = breweries91, icon = iconSet,
group = "mapkey",
clusterOptions = markerClusterOptions(),
label = ~state, popup = ~village)
expect_is(m, "leaflet")
deps <- findDependencies(m)
expect_equal(deps[[length(deps) - 1]]$name, "lfx-mapkeyicon")
expect_equal(deps[[length(deps)]]$name, "leaflet-markercluster")
m <- mapkeyIcons()
expect_is(m, "list")
m <- leaflet() %>%
addMapkeyMarkers(data = breweries91,
icon = m)
expect_is(m, "leaflet")
cities <- structure(list(
City = structure(1:6, .Label = c("Boston", "Hartford", "New York City",
"Philadelphia", "Pittsburgh",
"Providence"), class = "factor"),
Lat = c(42.3601, 41.7627, 40.7127, 39.95, 40.4397, 41.8236),
Long = c(-71.0589, -72.6743, -74.0059, -75.1667, -79.9764, -71.4222),
Pop = c(645966L, 125017L, 8406000L, 1553000L, 305841L, 177994L)),
class = "data.frame", row.names = c(NA, -6L))
icon.pop <- mapkeyIcons(color = ifelse(cities$Pop < 500000, "blue", "red"),
iconSize = ifelse(cities$Pop < 500000, 20, 50))
m <- leaflet(cities) %>% addTiles() %>%
addMapkeyMarkers(lng = ~Long, lat = ~Lat,
label = ~City,
icon = icon.pop)
expect_is(m, "leaflet")
cities$PopCat <- "blue"
cities[cities$Pop > 500000,]$PopCat <- "red"
iconSet = mapkeyIconList(
blue = makeMapkeyIcon(icon = "traffic_signal",
color = "
iconSize = 12,
boxShadow = FALSE,
background = "transparent"),
red = makeMapkeyIcon(icon = "buddhism",
color = "red",
iconSize = 12,
boxShadow = FALSE,
background = "transparent")
)
m <- leaflet(cities) %>% addTiles() %>%
addMapkeyMarkers(lng = ~Long, lat = ~Lat,
label = ~City,
labelOptions = rep(labelOptions(noHide = T), nrow(cities)),
icon = ~iconSet[PopCat] )
expect_is(m, "leaflet")
m <- leaflet(cities) %>% addTiles() %>%
addMapkeyMarkers(lng = ~Long, lat = ~Lat,
label = ~City,
labelOptions = rep(labelOptions(noHide = T), nrow(cities)),
icon = ~iconSet[as.factor(PopCat)])
m <- leaflet(cities) %>% addTiles() %>%
addMapkeyMarkers(lng = ~Long, lat = ~Lat,
label = ~City,
clusterOptions = markerClusterOptions(),
icon = ~iconSet[PopCat] )
expect_is(m, "leaflet")
expect_error(
leaflet(cities) %>% addTiles() %>%
addMapkeyMarkers(lng = ~Long, lat = ~Lat, label = ~City,
icon = ~iconSet[list()])
)
})
test_that("mapkey-error", {
expect_error(
mapkeyIconList(
red = list(icon = "boundary_stone",
color = "
background = '
iconSize = 30,
boxShadow = FALSE))
)
})
|
EE_SBM = function(A,B,K,fun = c("DPmatching", "EEpost"),rep = NULL,tau = NULL,d = NULL){
n = dim(A)[1]
if(!isSymmetric(A)) stop("Error! A is not symmetric!");
if(!isSymmetric(B)) stop("Error! B is not symmetric!");
if(dim(A)[1] != dim(B)[1]) stop("Error! A and B have different sizes");
if(K %% 1 != 0) stop("Error! K is not an integer!");
if(K > n) stop("Error! More communities than nodes!");
est.SC.A = SCORE(A, K);
est.SC.B = SCORE(B, K);
temp = 1:K;
perm = permn(1:K)
all_matching = vector("list", K);
matched = rep(0, length(perm));
conv = rep(0, length(perm));
if (fun == "DPmatching"){
for (i in 1: length(perm)){
matching = rep(NA, n);
for (k in 1: K){
A_com = A[which(est.SC.A == k), which(est.SC.A == k)];
n.A = dim(A_com)[1];
temp1 = which(est.SC.A == k);
temp2 = which(est.SC.B == unlist(perm[i])[k]);
B_com = B[which(est.SC.B == unlist(perm[i])[k]), which(est.SC.B == unlist(perm[i])[k])];
n.B = dim(B_com)[1];
result = DPmatching(A_com, B_com);
matching[temp1[which(!is.na(result$match), arr.ind = TRUE)]] = temp2[na.omit(result$match)];
matched[i] = matched[i] + length(which(!is.na(matched)));
}
all_matching[[i]] = matching;
}
}
if (fun == "EEpost"){
if (is.null(rep)) stop("Error! Please input rep!");
if (rep %% 1 != 0) stop("Error! rep is not an integer!");
if (rep <= 0) stop("Error! rep is nonpositive!");
if (is.null(d)) stop("Error! Please input d!");
if (d %% 1 != 0) stop("Error! d is not an integer!");
if (d <= 0) stop("Error! d is nonpositive!");
if (is.null(tau)) tau = ceiling(rep/10);
if(!is.null(tau)){
if (tau <= 0) stop("Error! tau is nonpositive!")
}
for (i in 1: length(perm)){
matching = rep(NA, n);
for (k in 1: K){
A_com = A[which(est.SC.A == k), which(est.SC.A == k)];
n.A = dim(A_com)[1];
temp1 = which(est.SC.A == k);
temp2 = which(est.SC.B == unlist(perm[i])[k]);
B_com = B[which(est.SC.B == unlist(perm[i])[k]), which(est.SC.B == unlist(perm[i])[k])];
n.B = dim(B_com)[1];
result = EEpost(A = A_com, B = B_com, rep = rep, tau = tau, d = d);
matching[temp1[which(!is.na(result$match), arr.ind = TRUE)]] = temp2[na.omit(result$match)];
conv[i] = conv[i] + result$converged.size;
}
all_matching[[i]] = matching;
}
}
if (fun == "DPmatching") matching_old = all_matching[[which.max(matched)]];
if (fun == "EEpost") matching_old = all_matching[[which.max(conv)]];
result = EEpost(A = A, B = B, rep = rep, matching = matching_old);
return(list(match = result$match, FLAG = result$FLAG))
}
|
print.AcrossTic <- function (x, ...)
{
cat ("AcrossTic object\n")
if (x$X.supplied) {
cat (paste0 ("Data is ", x$nrow.X, " x ", x$ncol.X, ", r = ", x$r, "\n"))
} else {
cat (paste0 ("Dist of size ", x$nrow.X, ", r = ", x$r, "\n"))
}
if (any (names (x) == "cross.count"))
cat (paste0 ("Solution ", signif (x$total.dist, 4),
", cross-count ", signif (x$cross.count, 4), "\n"))
else
cat (paste0 ("Solution ", signif (x$total.dist, 4), "\n"))
}
|
ordinalRR.control<-function (mu.mu.alpha = 0.8, tau.mu.alpha = 0.4, mu.tau.alpha = 4,
tau.tau.alpha = 0.4, mu.lambda = 2, tau.lambda = 0.2, rjags.B = 10000L,
rjags.Burn = 1000L, rjags.n.chains = 1L, rjags.n.adapt = 5000L,r.seed=10L,rjags.seed=10L)
{
if (!(is.numeric(mu.mu.alpha) && mu.mu.alpha > 0)) {stop("mu.mu.alpha>0")}
if (!(is.numeric(tau.mu.alpha) && tau.mu.alpha > 0)) {stop("tau.mu.alpha>0")}
if (!(is.numeric(mu.tau.alpha) && mu.tau.alpha > 0)) {stop("mu.tau.alpha>0")}
if (!(is.numeric(tau.tau.alpha) && tau.tau.alpha > 0)) {stop("tau.tau.alpha>0")}
if (!(is.numeric(mu.lambda) && mu.lambda > 0)) {stop("mu.lambda>0")}
if (!(is.numeric(tau.lambda) && tau.lambda > 0)) {stop("tau.lambda>0")}
if (!(is.numeric(rjags.B) && rjags.B >= 1)) {stop("rjags.B>=1")}
if (!(is.numeric(rjags.Burn) && rjags.Burn > 0)) {stop("rjags.Burn>0")}
if (!(is.numeric(rjags.n.chains) && rjags.n.chains == 1)) {stop("rjags.n.chains==1")}
if (!(is.numeric(rjags.n.adapt) && rjags.n.adapt >= 1)) {stop("rjags.n.adapt>=1")}
if (!(is.numeric(r.seed) && r.seed > 0)) {stop("r.seed>0")}
if (!(is.numeric(rjags.seed) && rjags.seed > 0)) {stop("rjags.seed>0")}
return(list(mu.mu.alpha = mu.mu.alpha, tau.mu.alpha = tau.mu.alpha,
mu.tau.alpha = mu.tau.alpha, tau.tau.alpha = tau.tau.alpha,
mu.lambda = mu.lambda, tau.lambda = tau.lambda, rjags.B = rjags.B,
rjags.Burn = rjags.Burn, rjags.n.chains = rjags.n.chains,
rjags.n.adapt = rjags.n.adapt,r.seed=r.seed,rjags.seed=rjags.seed))
}
ordinalRR<-function (x, random = TRUE, control = ordinalRR.control())
{
cl <- match.call(expand.dots = TRUE)
cl[[1]] <- as.name("ordinalRR")
if (!is.list(x)) {stop("x must be a list")}
if (is.null(x$preprocess)) {stop("x must be from call .....")}
if (!x$preprocess) {stop("x must be from call .....")}
dat <- list()
dat[[1]] = x$I
dat[[2]] = x$J
dat[[3]] = x$K
dat[[4]] = x$H
dat[[5]] = x$R
if(random){
dat[[6]] = control$mu.mu.alpha
dat[[7]] = control$tau.mu.alpha
dat[[8]] = control$mu.tau.alpha
dat[[9]] = control$tau.tau.alpha
dat[[10]] = control$mu.lambda
dat[[11]] = control$tau.lambda
names(dat) <- c("I", "J", "K", "H", "R", "mu.mu.alpha", "tau.mu.alpha",
"mu.tau.alpha", "tau.tau.alpha", "mu.lambda", "tau.lambda")
}else{names(dat) <- c("I", "J", "K", "H", "R")}
if (random) {
modelString = "
model{
for(j in 1:J){
alpha[j]~dlnorm(mu.alpha,tau.alpha)
pi[j,1:H]~ddirch(lambda)
for(h in 1:(H-1)){delta[j,h]<-qnorm(sum(pi[j,1:h]),0,1)}
}
for(i in 1:I){
X[i]~dnorm(0,1)
for(j in 1:J){
p[i,j,1]<-1
for(h in 2:H){p[i,j,h]<-exp(sum(alpha[j]*(X[i]-delta[j,1:(h-1)])))}
R[i,j,1:H]~dmulti(p[i,j,1:H]/sum(p[i,j,1:H]),K)
}
}
mu.alpha ~dnorm( mu.mu.alpha, tau.mu.alpha)
tau.alpha~dlnorm(mu.tau.alpha,tau.tau.alpha)
for(h in 1:H){lambda[h]~dlnorm(mu.lambda,tau.lambda)}
}"
}
else {
modelString = "
model{
for(j in 1:J){
alphainv[j]~dgamma(.001,.5)
alpha[j]<-1/alphainv[j]
pi[j,1:H]~ddirch(lambda)
for(h in 1:(H-1)){delta[j,h]<-qnorm(sum(pi[j,1:h]),0,1)}
}
for(i in 1:I){
X[i]~dnorm(0,1)
for(j in 1:J){
p[i,j,1]<-1
for(h in 2:H){p[i,j,h]<-exp(sum(alpha[j]*(X[i]-delta[j,1:(h-1)])))}
R[i,j,1:H]~dmulti(p[i,j,1:H]/sum(p[i,j,1:H]),K)
}
}
for(h in 1:H){lambda[h]<-1/2}
}"
}
temp=textConnection(modelString)
jfit = jags.model(temp, data = dat, n.chains = control$rjags.n.chains,
n.adapt = control$rjags.n.adapt,
inits=list(.RNG.name = "base::Mersenne-Twister",.RNG.seed=control$rjags.seed))
close(temp)
update(jfit, control$rjags.Burn)
obj <- NULL
obj$dat=x
obj$call <- cl
obj$control <- control
obj$random <- random
if (random) {
obj$post <- coda.samples(jfit, c("alpha", "delta", "mu.alpha",
"tau.alpha", "lambda", "X"), n.iter = control$rjags.B)
obj$x=obj$post[[1]][,1:x$I]
obj$a=obj$post[[1]][,x$I+1:x$J]
obj$d=obj$post[[1]][,x$I+x$J+1:((x$H-1)*x$J)]
temp=seq(from=0,by=x$J,length=x$H-1)
permute=NULL
for(i in 1:x$J) permute=c(permute,temp+i)
obj$d=obj$d[,permute]
obj$lambda=obj$post[[1]][,x$I+x$J*x$H+1:x$H]
hyper.a=obj$post[[1]][,x$I+(x$J+1)*x$H+1:2]
obj$mu.a=hyper.a[,1]
obj$sigma.a=1/sqrt(hyper.a[,2])
set.seed(control$r.seed)
obj$dnew=cbind(rdelta(obj$lambda),rdelta(obj$lambda))
obj$anew=cbind(rlnorm(control$rjags.B,obj$mu.a,obj$sigma.a),
rlnorm(control$rjags.B,obj$mu.a,obj$sigma.a))
}
else {
obj$post <- coda.samples(jfit, c("alpha","delta","X"),n.iter=control$rjags.B)
obj$x=obj$post[[1]][,1:x$I]
obj$a=obj$post[[1]][,x$I+1:x$J]
obj$d=obj$post[[1]][,x$I+x$J+1:((x$H-1)*x$J)]
temp=seq(from=0,by=x$J,length=x$H-1)
permute=NULL
for(i in 1:x$J) permute=c(permute,temp+i)
obj$d=obj$d[,permute]
}
structure(obj, class = "ordinalRR")
}
preprocess<-function (x, J = 3, K = 2, H = 4)
{
if (!is.data.frame(x)) {stop("x must be a data frame.")}
if (!(is.numeric(J) && J>=1)) {stop("Number of operators must be J>=1.")}
if (!(is.numeric(K) && K>=1)) {stop("Number of repetitions must be K>=1.")}
if (!(is.numeric(H) && H>=2)) {stop("Number of ordinal categories must be H>=2.")}
if (J * K != ncol(x)){stop("The number of columns in x must be J*K.")}
I = nrow(x)
R = array(0, c(I, J, H))
for (i in 1:I) {
for (j in 1:J) {
for (k in 1:K) {
if(!sum(x[i,(j - 1) * K + k]==1:H)){stop("Entries of x must be from {1,...,H}.")}
R[i, j, x[i, (j - 1) * K + k]] = R[i, j, x[i,(j - 1) * K + k]] + 1
}
}
}
list(I = I, J = J, K = K, H = H, x=x, R = R, preprocess = TRUE)
}
ordinalRR.sim=function(H=4L,I=30L,J=3L,K=2L,mu.a=2.6,sigma.a=.2,lambda=c(11,44,29,40),seed=10L)
{
set.seed(seed)
dataset=matrix(0,nrow=I,ncol=J*K)
a=rlnorm(J,mu.a,sigma.a)
d=matrix(0,nrow=J,ncol=H-1)
for(j in 1:J)
{
temp=rgamma(H,lambda)
temp=temp/sum(temp)
temp=cumsum(temp)[-H]
d[j,]=qnorm(temp)
}
temp=paste("Simulated parameters for operator 1 are: alpha1=", round(a[1],2), " and delta1=(", sep="")
for(j in 1:(H-2)) temp=paste(temp,round(d[1,j],2),",",sep="")
temp=paste(temp,round(d[1,H-1],2),").",sep="")
print(temp)
x=rnorm(I)
for(i in 1:I)
for(j in 1:J)
{
p=1
for(h in 2:H)
p=c(p,exp(sum(a[j]*(x[i]-d[j,1:(h-1)]))))
p=p/sum(p)
dataset[i,(j-1)*K+1:K]=sample(1:H,K,replace=TRUE,p)
}
preprocess(as.data.frame(dataset),J,K,H)
}
make.rater=function(alpha,cutpoints)
{
obj=list(alpha,cutpoints)
names(obj)=c("alpha","cutpoints")
structure(obj, class = "rater")
}
compute.q=function(rater,x)
{
if (class(rater) != "rater") stop("Object must be of class `rater'")
a=rater$alpha
d=rater$cutpoints
H=length(d)+1
p=sapply(1:(H-1),function(h)a*(x-d[h]))
if(is.vector(p)) p=matrix(p,nrow=1)
p=t(apply(p,1,cumsum))
p=cbind(0,p)
p=exp(p-apply(p,1,max))
p=p/as.vector(apply(p,1,sum))
p
}
plot.rater=function(x,y,plt.type=c("rater","measure"),m=0,lwd=1.2,...)
{
glen=10^3
if(plt.type=="rater")
{
if (class(x) != "rater") stop("Object x must be of class `rater'")
alpha=rep(x$alpha,glen)
cuts=x$cutpoints
delta=matrix(rep(cuts,glen),nrow=glen,byrow=TRUE)
xgrid=seq(-3,3,length=glen)
p=computep(alpha,xgrid,delta)
plot(0,.5,ylim=c(0,1),xlim=c(-3,3),xaxt="n",yaxt="n",type="n",...)
box(lwd=lwd)
axis(1,-3:3,lwd=lwd)
axis(2,(0:4)/4,c("0","","0.5","","1"),lwd=lwd)
for(i in 1:4) lines(xgrid,p[,i],lwd=lwd)
abline(v=cuts,lty=2)
}
if(plt.type=="measure")
{
if (class(x) != "rater") stop("Object x must be of class `rater'")
if (class(y) != "rater") stop("Object y must be of class `rater'")
if (length(x$cutpoints)!=length(y$cutpoints)) stop("Rater must have same number of cutpoints.")
H=length(x$cutpoints)+1
m=m+1
Bm=toeplitz(c(rep(1,m),rep(0,H-m)))
xgrid=matrix(seq(-3,3,length=glen),ncol=1)
alpha=rep(x$alpha,glen)
delta=matrix(rep(x$cutpoints,glen),nrow=glen,byrow=TRUE)
p1=computep(alpha,xgrid,delta)
alpha=rep(y$alpha,glen)
delta=matrix(rep(y$cutpoints,glen),nrow=glen,byrow=TRUE)
p2=computep(alpha,xgrid,delta)
repeat1=rowSums(p1%*%Bm*p1)
repeat2=rowSums(p2%*%Bm*p2)
rr=rowSums(p1%*%Bm*p2)
prop=rr^2/(repeat1*repeat2)
plot(0,.5,ylim=c(0,1),xlim=c(-3,3),xaxt="n",yaxt="n",type="n",...)
box(lwd=lwd)
axis(1,-3:3,lwd=lwd)
axis(2,(0:4)/4,c("0","","0.5","","1"),lwd=lwd)
lines(xgrid,rr,lwd=lwd)
lines(xgrid,prop,lty=2,lwd=lwd)
}
}
hist.ordinalRR=function(x,x.low=-4,x.high=4,col="grey",...)
{
if (class(x) != "ordinalRR") stop("Object must be of class `ordinalRR'")
den=list()
denmax=0
n<-x$dat$I+1
for(i in 1:n)
{
if(i<=x$dat$I) den[[i]]=density(x$x[,i],from=x.low,to=x.high)
if(i>x$dat$I){den[[i]]=den[[i-1]]; den[[i]]$x=seq(x.low,x.high,length=10^3); den[[i]]$y=dnorm(den[[i]]$x)}
denmax=max(c(denmax,den[[i]]$y))
}
plot(den[[i]]$x,den[[i]]$y, type="n",xlim=c(x.low,x.high),ylim=c(0,denmax),col=col,...)
if(length(col)==1)col<-rep(col,n)
if(length(col)<n){
col<-c(col,rep("grey",n-length(col)+1))
warning("Color length mismatch, grey's added")
}
for(i in 1:(x$dat$I+1))lines(den[[i]]$x,den[[i]]$y,col=col[i])
}
density.ordinalRR<-function(x,plt.type=c("repeat","rr","prop","all"),m=0,...){
if(class(x)!="ordinalRR")stop("error")
I=ncol(x$x)
J=ncol(x$a)
B=nrow(x$a)
if(missing(plt.type)){
plt.type="repeat"
}
final<-list()
k1<-1
for(j1 in 1:(J-1)){
for(j2 in (j1+1):J){
RRavg=matrix(0,nrow=B,ncol=4)
for(i in 1:I){
RRavg=RRavg+RR(x,j1,j2,i=i,m=m)
}
final[[k1]]<-RRavg/I
k1<-k1+1
}
}
if(x$random)
{
RRnew=matrix(0,nrow=B,ncol=4)
for(i in 1:I) RRnew=RRnew+RR(x,J+1,J+2,i=i,m=m)
RRnew=RRnew/I
}
if(plt.type=="all")par(mfrow=c(3,1))
if(plt.type=="repeat"||plt.type=="all"){
temp<-list()
temp[[1]]<-density(final[[1]][,1],from=0,to=1)
ymax<-max(temp[[1]]$y)
for(i in 2:J){
temp[[i]]<-density(final[[i-1]][,2],from=0,to=1)
ymax=max(c(ymax,temp[[i]]$y))
}
if(plt.type=="all") plot(temp[[1]]$x,temp[[1]]$y,ylim=c(0,ymax),xlab="Repeatability",ylab="",...)
else plot(temp[[1]]$x,temp[[1]]$y,ylim=c(0,ymax),...)
lapply(temp,function(i){lines(i,col="grey")})
if(x$random)lines(density(RRnew[,1],from=0,to=1),lwd=2)
}
if(plt.type=="rr"||plt.type=="all"){
temp<-list()
temp[[1]]<-density(final[[1]][,3],from=0,to=1)
ymax<-max(temp[[1]]$y)
for(i in 2:(choose(J,2))){
temp[[i]]<-density(final[[i]][,3],from=0,to=1)
ymax=max(c(ymax,temp[[i]]$y))
}
if(plt.type=="all") plot(temp[[1]]$x,temp[[1]]$y,ylim=c(0,ymax),xlab="R&R",ylab="Density",...)
else plot(temp[[1]]$x,temp[[1]]$y,ylim=c(0,ymax),...)
lapply(temp,function(i){lines(i,col="grey")})
if(x$random)lines(density(RRnew[,3],from=0,to=1),lwd=2)
}
if(plt.type=="prop"||plt.type=="all"){
temp<-list()
temp[[1]]<-density(final[[1]][,4],from=0,to=1)
ymax<-max(temp[[1]]$y)
for(i in 2:(choose(J,2))){
temp[[i]]<-density(final[[i]][,4],from=0,to=1)
ymax=max(c(ymax,temp[[i]]$y))
}
if(plt.type=="all") plot(temp[[1]]$x,temp[[1]]$y,ylim=c(0,ymax),xlab="Proportion",ylab="",...)
else plot(temp[[1]]$x,temp[[1]]$y,ylim=c(0,ymax),...)
lapply(temp,function(i){lines(i,col="grey")})
if(x$random)lines(density(RRnew[,4],from=0,to=1),lwd=2)
}
invisible(x)
}
print.ordinalRR<-function (x, ...){
if (class(x) != "ordinalRR")
stop("Object must be of class `ordinalRR'.")
if (!is.null(cl <- x$call)) {
names(cl)[2] <- ""
cat("Call:\n")
dput(cl)
}
cat("\nData:", x$dat$I, "parts,", x$dat$J, "operators,", x$dat$K, "repetitions with", x$dat$H, "ordinal categories.\n")
txt <- "fixed-effects"; if (x$random) {txt <- "random-effects"}
cat("\nA single MCMC chain of the", txt, "ordinal model was fit:", x$control$rjags.Burn, "burn-in and", x$control$rjags.B, "retained.\n")
invisible(x)
}
summary.ordinalRR<-function (object, decimals=1,...){
if (class(object) != "ordinalRR")
stop("Object must be of class `ordinalRR'.")
if (!is.null(cl <- object$call)) {
names(cl)[2] <- ""
cat("Call:\n")
dput(cl)
}
cat("\nData:", object$dat$I, "parts,", object$dat$J, "operators,", object$dat$K, "repetitions with", object$dat$H, "ordinal categories.\n")
txt <- "Fixed-effects"; if (object$random) {txt <- "Random-effects"}
cat(txt, "model MCMC chain:", object$control$rjags.Burn, "burn-in and", object$control$rjags.B, "retained.\n")
I=object$dat$I
J=object$dat$J
K=object$dat$K
H=object$dat$H
x=object$dat$x
a=object$a
d=object$d
matches=rep(0,J)
for(j in 1:J)
for(k1 in 1:(K-1))
for(k2 in (k1+1):K)
matches[j]=matches[j]+sum(x[,K*(j-1)+k1]==x[,K*(j-1)+k2])
matches=round(matches/(I*choose(K,2)),decimals+2)
dat=cbind(apply(a,2,median),t(matrix(apply(d,2,median),H-1)))
dat=cbind(1:dim(dat)[1],matches,round(dat,decimals))
dimnames(dat)[[2]]=c("Rater j","Repeatability","a_j",paste0("d_{j,",1:(H-1),"}"))
cat("\nSimple repeatability and model parameter estimates by rater:\n")
print(as.data.frame(dat),row.names=FALSE)
matches=rep(0,choose(J,2))
r1=rep(0,choose(J,2))
r2=rep(0,choose(J,2))
b=0
for(j1 in 1:(J-1))
for(j2 in (j1+1):J)
{
b=b+1
r1[b]=j1
r2[b]=j2
for(k1 in 1:K)
for(k2 in 1:K)
matches[b]=matches[b]+sum(x[,K*(j1-1)+k1]==x[,K*(j2-1)+k2])
}
matches=round(matches/(K^2*I),decimals+2)
matches=cbind(r1,r2,matches)
dimnames(matches)[[2]]=c("Rater j","Rater j\'","(R&R)_{j,j\'}")
cat("\nSimple repeatability and reproducibility (R&R) point estimates for pairs of raters:\n")
print(as.data.frame(matches),row.names=FALSE)
invisible(object)
}
rdelta=function(lambda)
{
B=nrow(lambda)
H=ncol(lambda)
p=matrix(rgamma(B*H,lambda),nrow=B,ncol=H)
p=p/apply(p,1,sum)
delta=t(apply(p,1,cumsum))[,-H]
delta[delta>1]=1
delta=qnorm(delta)
delta
}
computep=function(a,x,d)
{
H=ncol(d)+1
p=sapply(1:(H-1),function(h)a*(x-d[,h]))
if(is.vector(p)) p=matrix(p,nrow=1)
p=t(apply(p,1,cumsum))
p=cbind(0,p)
p=exp(p-apply(p,1,max))
p=p/as.vector(apply(p,1,sum))
p
}
RR=function(g,j1,j2,i=1,m=0)
{
if(class(g)!="ordinalRR"){stop("some error")}
I=ncol(g$x)
B=nrow(g$a)
J=ncol(g$a)
a=g$a
d=g$d
x=g$x
H=ncol(d)/J+1
m=m+1
Bm=toeplitz(c(rep(1,m),rep(0,H-m)))
if(j1>j2){temp=j1; j1=j2; j2=temp}
same=0; if(j1==j2) same=1
if(j1>J){J=J+1; j1=J; d=cbind(d,g$dnew); a=cbind(a,g$anew)}
if(same==1) j2=j1
if(j2>J){J=J+1; j2=J;}
p1=computep(a[,j1],x[,i],d[,(j1-1)*(H-1)+1:(H-1)])
if(same==1){p2=p1} else {p2=computep(a[,j2],x[,i],d[,(j2-1)*(H-1)+1:(H-1)])}
repeat1=rowSums(p1%*%Bm*p1)
repeat2=rowSums(p2%*%Bm*p2)
rr=rowSums(p1%*%Bm*p2)
prop=rr^2/(repeat1*repeat2)
cbind(repeat1,repeat2,rr,prop)
}
|
addGlPolylines = function(map,
data,
color = cbind(0, 0.2, 1),
opacity = 0.6,
group = "glpolylines",
popup = NULL,
weight = 1,
layerId = NULL,
src = FALSE,
...) {
if (isTRUE(src)) {
m = addGlPolylinesSrc(
map = map
, data = data
, color = color
, opacity = opacity
, group = group
, popup = popup
, weight = weight
, layerId = layerId
, ...
)
return(m)
}
opacity = opacity[1]
if (is.null(group)) group = deparse(substitute(data))
if (inherits(data, "Spatial")) data <- sf::st_as_sf(data)
stopifnot(inherits(sf::st_geometry(data), c("sfc_LINESTRING", "sfc_MULTILINESTRING")))
if (inherits(sf::st_geometry(data), "sfc_MULTILINESTRING"))
stop("Can only handle LINESTRINGs, please cast your MULTILINESTRING to LINESTRING using sf::st_cast",
call. = FALSE)
bounds = as.numeric(sf::st_bbox(data))
args <- list(...)
palette = "viridis"
if ("palette" %in% names(args)) {
palette <- args$palette
args$palette = NULL
}
color <- makeColorMatrix(color, data, palette = palette)
if (ncol(color) != 3) stop("only 3 column color matrix supported so far")
color = as.data.frame(color, stringsAsFactors = FALSE)
colnames(color) = c("r", "g", "b")
cols = jsonify::to_json(color, digits = 3)
if (is.null(popup)) {
geom = sf::st_geometry(data)
data = sf::st_sf(id = 1:length(geom), geometry = geom)
} else if (isTRUE(popup)) {
data = data[, popup]
} else {
htmldeps <- htmltools::htmlDependencies(popup)
if (length(htmldeps) != 0) {
map$dependencies = c(
map$dependencies,
htmldeps
)
}
popup = makePopup(popup, data)
popup = jsonify::to_json(popup)
geom = sf::st_geometry(data)
data = sf::st_sf(id = 1:length(geom), geometry = geom)
}
if (length(args) == 0) {
geojsonsf_args = NULL
} else {
geojsonsf_args = try(
match.arg(
names(args)
, names(as.list(args(geojsonsf::sf_geojson)))
, several.ok = TRUE
)
, silent = TRUE
)
if (inherits(geojsonsf_args, "try-error")) geojsonsf_args = NULL
if (identical(geojsonsf_args, "sf")) geojsonsf_args = NULL
}
data = do.call(geojsonsf::sf_geojson, c(list(data), args[geojsonsf_args]))
map$dependencies = c(
glifyDependencies()
, map$dependencies
)
map = leaflet::invokeMethod(
map
, leaflet::getMapData(map)
, 'addGlifyPolylines'
, data
, cols
, popup
, opacity
, group
, weight
, layerId
)
leaflet::expandLimits(
map,
c(bounds[2], bounds[4]),
c(bounds[1], bounds[3])
)
}
addGlPolylinesSrc = function(map,
data,
color = cbind(0, 0.2, 1),
opacity = 0.8,
group = "glpolygons",
popup = NULL,
weight = 1,
layerId = NULL,
...) {
if (is.null(group)) group = deparse(substitute(data))
if (is.null(layerId)) layerId = paste0(group, "-lns")
if (inherits(data, "Spatial")) data <- sf::st_as_sf(data)
stopifnot(inherits(sf::st_geometry(data), c("sfc_LINESTRING", "sfc_MULTILINESTRING")))
if (inherits(sf::st_geometry(data), "sfc_MULTILINESTRING"))
stop("Can only handle LINESTRINGs, please cast your MULTILINESTRING ",
"to LINESTRING using e.g. sf::st_cast")
bounds = as.numeric(sf::st_bbox(data))
dir_data = tempfile(pattern = "glify_polylines_dat")
dir.create(dir_data)
dir_color = tempfile(pattern = "glify_polylines_col")
dir.create(dir_color)
dir_popup = tempfile(pattern = "glify_polylines_pop")
dir.create(dir_popup)
dir_weight = tempfile(pattern = "glify_polylines_wgt")
dir.create(dir_weight)
data_orig <- data
geom = sf::st_geometry(data)
data = sf::st_sf(id = 1:length(geom), geometry = geom)
ell_args <- list(...)
fl_data = paste0(dir_data, "/", layerId, "_data.js")
pre = paste0('var data = data || {}; data["', layerId, '"] = ')
writeLines(pre, fl_data)
jsonify_args = try(
match.arg(
names(ell_args)
, names(as.list(args(geojsonsf::sf_geojson)))
, several.ok = TRUE
)
, silent = TRUE
)
if (inherits(jsonify_args, "try-error")) jsonify_args = NULL
if (identical(jsonify_args, "sf")) jsonify_args = NULL
cat('[', do.call(geojsonsf::sf_geojson, c(list(data), ell_args[jsonify_args])), '];',
file = fl_data, sep = "", append = TRUE)
map$dependencies = c(
map$dependencies,
glifyDependenciesSrc(),
glifyDataAttachmentSrc(fl_data, layerId)
)
palette = "viridis"
if ("palette" %in% names(ell_args)) {
palette <- ell_args$palette
}
color <- makeColorMatrix(color, data_orig, palette = palette)
if (ncol(color) != 3) stop("only 3 column color matrix supported so far")
color = as.data.frame(color, stringsAsFactors = FALSE)
colnames(color) = c("r", "g", "b")
if (nrow(color) > 1) {
fl_color = paste0(dir_color, "/", layerId, "_color.js")
pre = paste0('var col = col || {}; col["', layerId, '"] = ')
writeLines(pre, fl_color)
cat('[', jsonify::to_json(color), '];',
file = fl_color, append = TRUE)
map$dependencies = c(
map$dependencies,
glifyColorAttachmentSrc(fl_color, layerId)
)
color = NULL
}
if (!is.null(popup)) {
htmldeps <- htmltools::htmlDependencies(popup)
if (length(htmldeps) != 0) {
map$dependencies = c(
map$dependencies,
htmldeps
)
}
popup = makePopup(popup, data_orig)
fl_popup = paste0(dir_popup, "/", layerId, "_popup.js")
pre = paste0('var popup = popup || {}; popup["', layerId, '"] = ')
writeLines(pre, fl_popup)
cat('[', jsonify::to_json(popup), '];',
file = fl_popup, append = TRUE)
map$dependencies = c(
map$dependencies,
glifyPopupAttachmentSrc(fl_popup, layerId)
)
}
if (length(unique(weight)) > 1) {
fl_weight = paste0(dir_weight, "/", layerId, "_weight.js")
pre = paste0('var wgt = wgt || {}; wgt["', layerId, '"] = ')
writeLines(pre, fl_weight)
cat('[', jsonify::to_json(weight), '];',
file = fl_weight, append = TRUE)
map$dependencies = c(
map$dependencies,
glifyRadiusAttachmentSrc(fl_weight, layerId)
)
weight = NULL
}
map = leaflet::invokeMethod(
map
, leaflet::getMapData(map)
, 'addGlifyPolylinesSrc'
, color
, weight
, opacity
, group
, layerId
)
leaflet::expandLimits(
map,
c(bounds[2], bounds[4]),
c(bounds[1], bounds[3])
)
}
|
read_version <- function(path, version_flag = "--version") {
if (!file.exists(path)) {
return(NA_character_)
}
if (!file_test('-x', path)) {
return(NA_character_)
}
info <- try(system2(path, args = version_flag,
stderr = TRUE, stdout = TRUE, timeout = 20), silent = TRUE)
if(inherits(info, "try-error")) {
message(catch_error(path, version_flag))
info <- NA_character_
}
info
}
catch_error <- function(path, version_flag){
cmd <- tempfile(fileext = ".sh")
log <- tempfile(fileext = ".log")
writeLines(text = paste(path, version_flag, ">", log, "2>&1"), cmd)
Sys.chmod(cmd, mode = "755")
suppressWarnings(try(system2(cmd, timeout = 20), silent = TRUE))
message("The following command failed: ", paste(path, version_flag))
message("with following log:")
paste0(readLines(log), collapse = "\n")
}
|
"aspect_conv"
|
n_offs<- function(df=NULL, N=NULL, Tier=NULL){
n<-.<-Date<-tier<-home<-visitor<-hgoal<-vgoal<-goaldif<-FT<-Season<-division<-result<-maxgoal<-mingoal<-absgoaldif<-NULL
if(is.null(Tier))
df %>%
dplyr::mutate(goaldif = hgoal-vgoal,
result = ifelse(hgoal>vgoal, "H", ifelse(hgoal<vgoal, "A", "D"))) %>%
dplyr::group_by(FT)%>%
dplyr::tally() %>%
dplyr::filter(n==N) %>%
dplyr::select(FT) %>%
dplyr::left_join(df) %>%
dplyr::select(Date, Season, home, visitor, FT, division, tier, result)%>%
dplyr::arrange(FT, Season)
else
{ dfTier<-df %>%
dplyr::mutate(goaldif = hgoal-vgoal,
result = ifelse(hgoal>vgoal, "H", ifelse(hgoal<vgoal, "A", "D"))) %>%
dplyr::filter(tier==Tier)
dfTier %>%
dplyr::group_by(FT)%>%
dplyr::tally() %>%
dplyr::filter(n==N) %>%
dplyr::select(FT) %>%
dplyr::left_join(dfTier) %>%
dplyr::select(Date, Season, home, visitor, FT, division, tier, result)%>%
dplyr::arrange(FT, Season)
}
}
|
expected <- eval(parse(text="FALSE"));
test(id=0, code={
argv <- eval(parse(text="list(structure(list(`1` = c(2, 1, 4, 3), `2` = c(3, 1.5, 5, 4, 1.5), `3` = c(6.5, 1.5, 9, 8, 1.5, 6.5, 4, 4, 4), `4` = c(7, 1.5, 10, 9, 1.5, 7, 4, 4, 4, 7)), .Dim = 4L, .Dimnames = list(c(\"1\", \"2\", \"3\", \"4\"))), TRUE)"));
.Internal(islistfactor(argv[[1]], argv[[2]]));
}, o=expected);
|
'cssSpectrum' <- function(listOfFiles = NULL, optLogFilePath = NULL,
beginTime = 0.0, centerTime = FALSE,
endTime = 0.0, resolution = 40.0,
fftLength = 0, windowShift = 5.0,
window = 'BLACKMAN', numCeps = 0,
toFile = TRUE, explicitExt = NULL,
outputDirectory = NULL, forceToLog = useWrasspLogger,
verbose = TRUE){
if (is.null(listOfFiles)) {
stop(paste("listOfFiles is NULL! It has to be a string or vector of file",
"paths (min length = 1) pointing to valid file(s) to perform",
"the given analysis function."))
}
if (is.null(optLogFilePath) && forceToLog){
stop("optLogFilePath is NULL! -> not logging!")
}else{
if(forceToLog){
optLogFilePath = path.expand(optLogFilePath)
}
}
if(!isAsspWindowType(window)){
stop("WindowFunction of type '", window,"' is not supported!")
}
if (!is.null(outputDirectory)) {
outputDirectory = normalizePath(path.expand(outputDirectory))
finfo <- file.info(outputDirectory)
if (is.na(finfo$isdir))
if (!dir.create(outputDirectory, recursive=TRUE))
stop('Unable to create output directory.')
else if (!finfo$isdir)
stop(paste(outputDirectory, 'exists but is not a directory.'))
}
listOfFiles <- prepareFiles(listOfFiles)
if(length(listOfFiles)==1 | !verbose){
pb <- NULL
}else{
if(toFile==FALSE){
stop("length(listOfFiles) is > 1 and ToFile=FALSE! ToFile=FALSE only permitted for single files.")
}
cat('\n INFO: applying cssSpectrum to', length(listOfFiles), 'files\n')
pb <- utils::txtProgressBar(min = 0, max = length(listOfFiles), style = 3)
}
externalRes = invisible(.External("performAssp", listOfFiles,
fname = "spectrum", beginTime = beginTime,
centerTime = centerTime, endTime = endTime,
spectrumType = 'CSS',
resolution = resolution,
fftLength = as.integer(fftLength),
windowShift = windowShift, window = window,
numCeps = as.integer(numCeps),
toFile = toFile, explicitExt = explicitExt,
progressBar = pb, outputDirectory = outputDirectory,
PACKAGE = "wrassp"))
if (forceToLog){
optionsGivenAsArgs = as.list(match.call(expand.dots = TRUE))
wrassp.logger(optionsGivenAsArgs[[1]], optionsGivenAsArgs[-1],
optLogFilePath, listOfFiles)
}
if(!is.null(pb)){
close(pb)
}else{
return(externalRes)
}
}
|
cluster_call <- function(pairs, fun, ...) {
res <- clusterCall(pairs$cluster, function(name, fun, ...) {
env <- reclin_env[[name]]
pairs <- env$pairs
x <- attr(pairs, "x")
y <- attr(pairs, "y")
fun(pairs, x, y, ...)
}, pairs$name, fun, ...)
if (all(sapply(res, function(x) is.null(x) || length(x) == 0)))
invisible(res) else res
}
|
gpLogLikeGradients <-
function(model, X=model$X, M, X_u, gX_u.return=FALSE, gX.return=FALSE, g_beta.return=FALSE) {
if (missing(X_u)) {
X_u = list()
if ("X_u" %in% names(model))
X_u = model$X_u
if (missing(M) && (!"S" %in% names(model)))
M = model$m
}
gX_u = list()
gX = list()
g_scaleBias = gpScaleBiasGradient(model)
g_meanFunc = list()
if ("meanFunction" %in% names(model) && length(model$meanFunction)>0)
g_meanFunc = gpMeanFunctionGradient(model)
if (model$approx == "ftc") {
if (gX_u.return && gX.return) {
gKX = kernGradX(model$kern, X, X)
gKX = gKX*2
dgKX = kernDiagGradX(model$kern, X)
for (i in 1:model$N)
gKX[i, , i] = dgKX[i, ]
gX = matrix(0, model$N, model$q)
}
g_param = matrix(0, 1, model$kern$nParams)
g_beta = list()
if ("beta" %in% names(model))
g_beta = 0
if ("S" %in% names(model)) {
gK = localSCovarianceGradients(model)
if (gX_u.return && gX.return) {
counter = 0
for (i in 1:model$N) {
counter = counter + 1
for (j in 1:model$q)
gX[i, j] = gX[i, j] + t(gKX[, j, i,drop=FALSE]) %*% gK[, counter,drop=FALSE]
}
}
g_param = g_param + kernGradient(model$kern, X, gK)
} else {
for (k in 1:model$d) {
gK = localCovarianceGradients(model, M[, k], k)
if (gX_u.return && gX.return) {
ind = gpDataIndices(model, k)
counter = 0
for (i in ind) {
counter = counter + 1
for (j in 1:model$q)
gX[i, j] = gX[i, j] + gKX[ind, j, i,drop=FALSE]%*%gK[, counter,drop=FALSE]
}
}
if (model$isMissingData){
g_param = g_param
+ kernGradient(model$kern, X[model$indexPresent[[k]], ], gK)
} else
g_param = g_param + kernGradient(model$kern, X, gK)
}
if ("beta" %in% names(model) && model$optimiseBeta) {
model$beta = as.matrix(model$beta)
if (dim(model$beta)[1] == 1)
g_beta = g_beta + sum(diag(gK))
else if (dim(model$beta)[2]==1 && dim(model$beta)[1]==model$N)
g_beta = g_beta + diag(gK)
else if (dim(model$beta)[2]==model$d && dim(model$beta)[1]==model$N)
g_beta[, k] = diag(gK)
else
stop('Unusual dimensions for model$beta.')
}
}
} else if (model$approx %in% c("dtc", "dtcvar", "fitc", "pitc")) {
gK = gpCovGrads(model, M)
gK_uu=gK$gK_uu; gK_uf=gK$gK_uf; gK_star=gK$g_Lambda; g_beta=gK$gBeta
gParam_u = kernGradient(model$kern, X_u, gK_uu)
gParam_uf = kernGradient(model$kern, X_u, X, gK_uf)
g_param = gParam_u + gParam_uf
gKX = kernGradX(model$kern, X_u, X_u)
gKX = gKX*2
dgKX = kernDiagGradX(model$kern, X_u)
for (i in 1:model$k)
gKX[i, , i] = dgKX[i, ]
if (!model$fixInducing || gX_u.return || gX.return || g_beta.return) {
gX_u = matrix(0, model$k, model$q)
for (i in 1:model$k) {
for (j in 1:model$q)
gX_u[i, j] = t(gKX[, j, i]) %*% gK_uu[, i,drop=FALSE]
}
gKX_uf = kernGradX(model$kern, X_u, X)
for (i in 1:model$k) {
for (j in 1:model$q)
gX_u[i, j] = gX_u[i, j] + t(gKX_uf[, j, i]) %*% t(gK_uf[i, ,drop=FALSE])
}
}
if (gX_u.return && gX.return) {
gX = matrix(0, model$N, model$q)
gKX_uf = kernGradX(model$kern, X, X_u)
for (i in 1:model$N) {
for (j in 1:model$q)
gX[i, j] = t(gKX_uf[, j, i,drop=FALSE]) %*% gK_uf[, i,drop=FALSE]
}
}
} else
stop("Unknown model approximation.")
if (model$approx == "ftc") {
} else if (model$approx == "dtc") {
} else if (model$approx %in% c("fitc","dtcvar")) {
if (gX_u.return && gX.return) {
gKXdiag = kernDiagGradX(model$kern, X)
for (i in 1:model$N)
gX[i, ] = gX[i, ] + gKXdiag[i, ]%*%gK_star[i]
}
g_param = g_param + kernDiagGradient(model$kern, X, gK_star)
} else if (model$approx == "pitc") {
if (gX_u.return && gX.return) {
startVal = 1
for (i in 1:length(model$blockEnd)) {
endVal = model$blockEnd[i]
ind = startVal:endVal
gKXblock = kernGradX(model$kern, X[ind, ,drop=FALSE], X[ind, ,drop=FALSE])
gKXblock = gKXblock*2
dgKXblock = kernDiagGradX(model$kern, X[ind, ,drop=FALSE])
for (j in 1:length(ind))
gKXblock[j, , j] = dgKXblock[j, ]
for (j in ind) {
for (k in 1:model$q) {
subInd = j - startVal + 1
gX[j, k] = gX[j, k] + t(gKXblock[, k, subInd,drop=FALSE]) %*% gK_star[[i]][, subInd,drop=FALSE]
}
}
startVal = endVal + 1
}
}
for (i in 1:length(model$blockEnd)) {
ind = gpBlockIndices(model, i)
g_param = g_param + kernGradient(model$kern, X[ind, ,drop=FALSE], gK_star[[i]])
}
} else
stop("Unrecognised model approximation")
if (!(gX_u.return && gX.return && g_beta.return)) {
if ((!"optimiseBeta" %in% names(model) && model$approx!="ftc") || model$optimiseBeta)
gParam = unlist(c(g_param, g_meanFunc, g_scaleBias, g_beta))
else
gParam = unlist(c(g_param, g_meanFunc, g_scaleBias))
} else
gParam = unlist(c(g_param, g_meanFunc, g_scaleBias))
if (!(gX_u.return || gX.return || g_beta.return))
gParam = c(gX_u, gParam)
return (as.numeric(gParam))
}
|
feem <- function(x, ...) UseMethod('feem')
feem.character <- feem.connection <- function(x, format, ...) {
stopifnot(length(x) == 1)
switch(
match.arg(format, c('table', 'panorama')),
table = read.matrix,
panorama = read.panorama,
)(x, ...)
}
feem.matrix <- function(x, emission, excitation, scale = 1, ...) {
stopifnot(
length(list(...)) == 0, is.numeric(x),
length(emission) == nrow(x),
length(excitation) == ncol(x)
)
structure(
x,
emission = emission,
excitation = excitation,
scale = unname(scale),
dimnames = list(emission = emission, excitation = excitation),
class = 'feem'
)
}
feem.data.frame <- function(
x, scale = 1, emission = 'emission', excitation = 'excitation',
intensity = 'intensity', ...
) {
stopifnot(
length(list(...)) == 0, ncol(x) == 3,
is.numeric(x[,emission]),
is.numeric(x[,excitation]),
is.numeric(x[,intensity])
)
ret <- reshape(
x, direction = 'wide', v.names = intensity,
idvar = emission, timevar = excitation
)
feem(as.matrix(ret[,-1]), ret[,1], attr(ret, 'reshapeWide')$times)
}
as.data.frame.feem <- function(x, row.names = NULL, optional = FALSE, ...)
data.frame(
emission = attr(x, 'emission')[row(x)][!is.na(x)],
excitation = attr(x, 'excitation')[col(x)][!is.na(x)],
intensity = x[!is.na(x)],
row.names = row.names,
...
)
plot.feem <- function(
x, xlab = quote(lambda[em]*', nm'), ylab = quote(lambda[ex]*', nm'),
cuts = 128, col.regions = marine.colours(256), ...
)
levelplot(
x = intensity ~ emission + excitation, data = as.data.frame(x),
xlab = xlab, ylab = ylab, cuts = cuts, col.regions = col.regions, ...
)
`[.feem` <- function(x, i, j, drop = TRUE) {
ret <- NextMethod()
if (!is.matrix(ret)) return(ret)
feem(
ret,
emission = attr(x, 'emission')[i],
excitation = attr(x, 'excitation')[j],
scale = attr(x, 'scale')
)
}
`[<-.feem` <- function(x, i, j, value) {
if (inherits(value, 'feem')) {
stopifnot(
attr(x, 'emission')[i] == attr(value, 'emission'),
attr(x, 'excitation')[j] == attr(value, 'excitation')
)
if (attr(x, 'scale') != attr(value, 'scale')) warning(
'Assigning from FEEM with different scale: LHS(',
attr(x, 'scale'), ') != RHS(', attr(value, 'scale'), ')'
)
}
NextMethod()
}
|
put_object <-
function(
what,
object,
bucket,
multipart = FALSE,
acl = NULL,
file,
headers = list(),
verbose = getOption("verbose", FALSE),
show_progress = getOption("verbose", FALSE),
partsize = 10e7,
...
) {
if (missing(what) && missing(file))
stop("Either `what' or `file' must be specified")
if (!missing(what) && !missing(file))
stop("`what' and `file' are mutually exclusive")
if (!missing(what) && is.character(what) && length(what) == 1L && file.exists(what)) {
warning("The use of first argument in `put_object()' as filename is was ambiguous and is deprecated, please use file=")
file <- what
}
size <- NA
if (!missing(file)) {
if (inherits(file, "connection"))
what <- file
else {
size <- file.size(file)
what <- file(file, raw=TRUE)
}
}
what.info <- if (inherits(what, "connection")) summary(what) else NULL
if (missing(object) && inherits(what, "connection") && what.info$class == "file") {
if (missing(bucket))
stop("`bucket' must be specified if `object' is missing")
object <- what.info$description
} else if (missing(object)) {
stop("input is not a file connection, you must specify `object'")
} else {
if (missing(bucket)) {
bucket <- get_bucketname(object)
}
object <- get_objectkey(object)
}
if (inherits(what, "connection")) {
if (isOpen(what, "w") && !isOpen(what, "r"))
stop("Input connection is already open for writing only, cannot use as input.")
if (isOpen(what,"r") && what.info$text == "text") {
if (multipart && (is.na(size) || size > partsize))
stop("Input connection is already open in text mode, multipart uploads are only possible in binary mode.")
warning("Input connection is already open in text mode, have to fall back to reading lines which is inefficient and result will be platform-dependent.")
con <- what
what <- readLines(what)
close(con)
if (length(what))
what <- c(what, "")
}
}
if (is.character(what)) {
if (length(what) > 1)
what <- paste(what, collapse=if (.Platform$OS.type == "unix") "\n" else "\r\n")
what <- if (length(what)) charToRaw(what) else raw()
}
if (!(inherits(what, "connection") || is.raw(what)))
stop("Invalid payload of `what' - must be a raw vector, character vector or a connection")
if (is.na(size)) {
if (inherits(what, "connection") && summary(what)$class == "file") {
size <- file.size(summary(what)$description)
} else if (is.raw(what)) {
size <- length(what)
}
}
if (multipart && !is.na(size) && size <= partsize) {
if (verbose)
message("Content too small, uploading as single part")
multipart <- FALSE
}
if (!"x-amz-acl" %in% names(headers)) {
if (!is.null(acl)) {
acl <- match.arg(acl, c("private", "public-read", "public-read-write", "aws-exec-read", "authenticated-read", "bucket-owner-read", "bucket-owner-full-control"))
headers <- c(headers, list(`x-amz-acl` = acl))
} else {
headers <- c(headers, list(`x-amz-acl` = "private"))
}
}
if (isTRUE(multipart)) {
if (!is.finite(partsize))
stop("partsize must be finite for multipart uploads")
if (is.raw(what)) {
what <- rawConnection(what, "rb")
} else if (!isOpen(what, "r")) {
open(what, "rb")
}
on.exit(close(what))
if (isTRUE(verbose)) {
message("Initializing multi-part upload")
}
initialize <- post_object(file = raw(0),
object = object,
bucket = bucket,
query = list(uploads = ""),
headers = headers,
...)
id <- initialize[["UploadId"]]
abort.upload <- function(id) delete_object(object = object, bucket = bucket, query = list(uploadId = id), ...)
on.exit(abort.upload(id), TRUE)
partlist <- list()
i <- 0L
n <- ceiling(size / partsize)
repeat {
i <- i + 1L
if (verbose || show_progress) {
if (is.na(n))
message("Uploading part ", i)
else
message("Uploading part ", i, " of ", n)
}
data <- readBin(what, raw(), n=partsize)
if (length(data) == 0)
break
r <- s3HTTP(verb = "PUT",
bucket = bucket,
path = paste0('/', object),
query = list(partNumber = i, uploadId = id),
request_body = data,
verbose = verbose,
show_progress = show_progress,
...)
if (inherits(r, "try-error")) {
stop("Multi-part upload failed")
} else {
partlist[[i]] <- list(Part = list(PartNumber = list(i), ETag = list(attributes(r)[["etag"]])))
}
}
if (verbose || show_progress) {
message("Completing multi-part upload")
}
finalize <- complete_parts(object = object, bucket = bucket, id = id, parts = partlist, ...)
if (inherits(finalize, "try-error"))
stop("complete_parts() failed with ", finalize)
on.exit(NULL)
close(what)
return(TRUE)
}
if (!is.na(size) && size > partsize)
message("File size is ", size, ", consider setting using multipart=TRUE")
if (inherits(what, "connection")) {
con <- what
if (!isOpen(con, "r"))
open(con, "rb")
on.exit(close(con))
if (!is.na(size)) {
what <- readBin(con, raw(), size)
if (length(what) != size)
stop("Failed to read input, expected ", size, ", got ", length(what))
} else {
what <- raw()
n <- if (is.finite(partsize)) partsize else 10e6
while (length(data <- readBin(con, raw(), partsize))) {
if (length(what) == 0 && length(data) == partsize)
message("Input is larger than partsize, consider using multipart=TRUE")
what <- c(what, data)
}
}
}
r <- s3HTTP(verb = "PUT",
bucket = bucket,
path = paste0('/', object),
headers = headers,
request_body = what,
verbose = verbose,
show_progress = show_progress,
...)
if (!length(r)) TRUE else structure(FALSE, response=r)
}
put_folder <- function(folder, bucket, ...) {
if (!grepl("/$", folder)) {
folder <- paste0(folder, "/")
}
put_object(raw(0), object = folder, bucket = bucket, ...)
}
post_object <- function(file, object, bucket, headers = list(), ...) {
if (missing(object) && is.character(file)) {
object <- basename(file)
} else {
if (missing(bucket)) {
bucket <- get_bucketname(object)
}
object <- get_objectkey(object)
}
if (!"Content-Length" %in% names(headers)) {
headers <- c(headers, list(`Content-Length` = formatSize(calculate_data_size(file))))
}
r <- s3HTTP(verb = "POST",
bucket = bucket,
path = paste0("/", object),
headers = headers,
request_body = file,
...)
structure(r, class = "s3_object")
}
list_parts <- function(object, bucket, id, ...) {
if (missing(bucket)) {
bucket <- get_bucketname(object)
}
object <- get_objectkey(object)
get_object(object = object, bucket = bucket, query = list(uploadId = id), ...)
}
upload_part <- function(part, object, bucket, number, id, ...) {
if (missing(bucket)) {
bucket <- get_bucketname(object)
}
object <- get_objectkey(object)
query <- list(partNumber = number, uploadId = id)
put_object(file = part, object = object, bucket = bucket, query = query, multipart = FALSE, ...)
}
complete_parts <- function(object, bucket, id, parts, ...) {
if (missing(bucket)) {
bucket <- get_bucketname(object)
}
object <- get_objectkey(object)
tmp <- tempfile()
xml2::write_xml(xml2::as_xml_document(list(CompleteMultipartUpload = parts)), tmp, options = "no_declaration")
post_object(file = tmp, object = object, bucket = bucket, query = list(uploadId = id), ...)
}
get_uploads <- function(bucket, ...){
r <- s3HTTP(verb = "GET",
bucket = bucket,
query = list(uploads = ""),
...)
return(r)
}
calculate_data_size <- function(data) {
post_size <- 0
if (is.character(data)) {
if (file.exists(data)) {
post_size <- file.size(data)
} else {
post_size <- nchar(data)
}
} else if (is.null(data)) {
post_size <- 0
} else {
post_size <- length((data))
}
return(as.numeric(post_size))
}
formatSize <- function(size) {
format(size, scientific = FALSE)
}
|
babsimHospital <- function(arrivalTimes = NULL,
conf = list(),
para = list(),
...) {
RNGkind("Wich")
conf$logLevel <- min(1, conf$logLevel)
simRepeats <- conf$simRepeats
Amnt_Normal_Beds <- conf$maxCapacity
Amnt_Intensive_Care_Beds <- conf$maxCapacity
Amnt_Intensive_Care_Beds_Ventilation <- conf$maxCapacity
GammaShapeParameter <- para$GammaShapeParameter
if (!"risk" %in% colnames(arrivalTimes)) {
arrivalTimes$risk <- rep(1, length(arrivalTimes$time))
}
P <- getMatrixP(para = para)
calculateAllPMatrices <- function() {
possibleRisks <- unique(arrivalTimes$risk)
getSingleMatrix <- function(singleRisk) {
updateMatrixP(P = P, u = list(k = singleRisk))
}
possibleMatrices <- lapply(as.list(possibleRisks), getSingleMatrix)
names(possibleMatrices) <- round(possibleRisks, 5)
return(possibleMatrices)
}
Ps <- calculateAllPMatrices()
DurationInfected2Hospital <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysInfectedToHospital, shift = 1.0, alpha = 0.95)
DurationNormal2Healthy <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysNormalToHealthy, alpha = 0.95)
DurationNormal2Intensive <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysNormalToIntensive, alpha = 0.95)
DurationNormal2Ventilation <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysNormalToVentilation, alpha = 0.95)
DurationNormal2Death <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysNormalToDeath, alpha = 0.95)
DurationIntensive2Aftercare <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysIntensiveToAftercare, alpha = 0.95)
DurationIntensive2Ventilation <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysIntensiveToVentilation, alpha = 0.95)
DurationIntensive2Death <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysIntensiveToDeath, alpha = 0.95)
DurationVentilation2IntensiveAfter <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysVentilationToIntensiveAfter, alpha = 0.95)
DurationVentilation2Death <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysVentilationToDeath, alpha = 0.95)
DurationIntensiveAfter2Aftercare <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysIntensiveAfterToAftercare, alpha = 0.95)
DurationIntensiveAfter2Death <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysIntensiveAfterToDeath, alpha = 0.95)
DurationAftercare2Healthy <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysAftercareToHealthy, alpha = 0.95)
DurationIntensiveAfter2Healthy <- function() rtgamma(n = 1, shape = GammaShapeParameter, rate = 1 / para$AmntDaysIntensiveAfterToHealthy, alpha = 0.95)
simFun <- function(i) {
env <- simmer("Simulation", log_level = conf$logLevel)
transferout <- trajectory("No Hospital") %>%
log_("transferout", level = 1) %>%
set_global("No Hospital Required", 1, mod = "+")
healthy <- trajectory("healthy") %>%
log_("healthy", level = 1) %>%
set_global("Healed", 1, mod = "+")
death <- trajectory("death") %>%
log_("death", level = 1) %>%
set_global("Dead", 1, mod = "+")
aftercare <- trajectory("aftercare") %>%
log_("aftercare", level = 1) %>%
seize("bed", 1) %>%
join(
trajectory() %>%
timeout(DurationAftercare2Healthy) %>%
release_all("bed"),
healthy
)
intensiveAfter <- join(
trajectory("intensiveAfter") %>%
log_("intensiveAfter", level = 1) %>%
seize("intensiveBed", 1) %>%
branch(function() {
r <- get_attribute(env, "risk")
R <- Ps[[as.character(round(r, 5))]]
p <- c(
R[7, 8],
R[7, 9],
R[7, 10]
)
getDecision(p)
},
continue = FALSE,
join(
trajectory() %>% timeout(DurationIntensiveAfter2Death) %>% release_all("intensiveBed"),
death
),
join(
trajectory() %>% timeout(DurationIntensiveAfter2Healthy) %>% release_all("intensiveBed"),
healthy
)
) %>%
timeout(DurationIntensiveAfter2Aftercare) %>% release_all("intensiveBed"),
aftercare
)
ventilation <- join(
trajectory("Intensive Care Ventilation") %>%
log_("ventilation", level = 1) %>%
seize("intensiveBedVentilation", 1) %>%
branch(function() {
r <- get_attribute(env, "risk")
R <- Ps[[as.character(round(r, 5))]]
p <- c(
R[6, 9],
R[6, 7]
)
getDecision(p)
},
continue = FALSE,
join(
trajectory() %>% timeout(DurationVentilation2IntensiveAfter) %>% release_all("intensiveBedVentilation"),
intensiveAfter
)
) %>%
timeout(DurationVentilation2Death) %>% release_all("intensiveBedVentilation"),
death
)
intensive <- join(
trajectory("Intensive Care") %>%
log_("intensive", level = 1) %>%
seize("intensiveBed", 1) %>%
branch(
function() {
r <- get_attribute(env, "risk")
R <- Ps[[as.character(round(r, 5))]]
p <- c(
R[5, 8],
R[5, 6],
R[5, 9]
)
getDecision(p)
},
continue = FALSE,
join(
trajectory() %>% timeout(DurationIntensive2Ventilation) %>% release_all("intensiveBed"),
ventilation
),
join(
trajectory() %>% timeout(DurationIntensive2Death) %>% release_all("intensiveBed"),
death
)
) %>%
timeout(DurationIntensive2Aftercare) %>% release_all("intensiveBed"),
aftercare
)
normalStation <- trajectory("Normal Station") %>%
log_("normalStation", level = 1) %>%
seize("bed") %>%
branch(
function() {
r <- get_attribute(env, "risk")
R <- Ps[[as.character(round(r, 5))]]
p <- c(
R[4, 10],
R[4, 5],
R[4, 9],
R[4, 6]
)
getDecision(p)
},
continue = FALSE,
join(
trajectory() %>% timeout(DurationNormal2Intensive) %>% release_all("bed"),
intensive
),
join(
trajectory() %>% timeout(DurationNormal2Death) %>% release_all("bed"),
death
),
join(
trajectory() %>% timeout(DurationNormal2Ventilation) %>% release_all("bed"),
ventilation
)
) %>%
join(
trajectory() %>% timeout(DurationNormal2Healthy) %>% release_all("bed"),
healthy
)
hospital <- join(
trajectory("hospital") %>%
log_("hospital", level = 1) %>%
branch(
function() {
r <- get_attribute(env, "risk")
R <- Ps[[as.character(round(r, 5))]]
p <- c(
R[3, 4],
R[3, 5],
R[3, 6]
)
getDecision(p)
},
continue = FALSE,
intensive,
ventilation
),
normalStation
)
infected <- join(
trajectory("New Infected") %>%
log_("infected", level = 1) %>%
timeout(DurationInfected2Hospital) %>%
branch(function() {
r <- get_attribute(env, "risk")
R <- Ps[[as.character(round(r, 5))]]
p <- c(
R[1, 2],
R[1, 3]
)
getDecision(p)
},
continue = FALSE,
hospital
),
transferout
)
add_dataframe(
env,
name_prefix = "patient",
trajectory = infected,
data = arrivalTimes,
mon = 1,
col_time = "time",
time = "absolute",
col_attributes = c("risk")
)
env %>%
add_resource("bed", Amnt_Normal_Beds) %>%
add_resource("intensiveBed", Amnt_Intensive_Care_Beds) %>%
add_resource(
"intensiveBedVentilation",
Amnt_Intensive_Care_Beds_Ventilation
) %>%
run() %>%
wrap()
}
switch(Sys.info()[["sysname"]],
Windows = {
messagef("Windows detected. Turning off parallel processing.")
conf$parallel <- FALSE
},
Linux = {
if (conf$verbosity > 1e3) {
messagef("Linux detected. Parallel processing possible.")
}
},
Darwin = {
if (conf$verbosity > 1e3) {
messagef("Mac detected. Parallel processing possible.")
}
}
)
if (conf$verbosity > 1e3) {
messagef("simFun() uses the following %s arrival times:",
length(arrivalTimes$time))
print(arrivalTimes$time)
}
if (conf$parallel) {
nCores <- detectCores(logical = FALSE)
mc.coresN = min(nCores - 1, round(conf$percCores * nCores))
mc.coresN = max(mc.coresN, 1)
if (conf$verbosity > 1e2) {
messagef("BEGIN: babsimHospital() calling parallel simFun() with %s cores:
mc.coresN)
}
envs <- mclapply(1:simRepeats, simFun, mc.cores = getOption("mc.cores", mc.coresN))
} else {
if (conf$verbosity > 1e2) {
messagef("BEGIN: babsimHospital() calling sequential simFun():
}
envs <- lapply(1:simRepeats, simFun)
}
if (conf$verbosity > 1e2) {
printConf(conf)
messagef("END: babsimHospital(): simFun:
}
return(envs)
}
|
input_df1 <- suppressMessages(input_processing(RA_input[1:100, ],
p_val_threshold = 0.05,
pin_name_path = "Biogrid"))
input_df2 <- suppressMessages(input_processing(RA_input[1:2, ],
p_val_threshold = 0.05,
pin_name_path = "Biogrid"))
test_that("`active_snw_search()` returns list object", {
skip_on_cran()
expect_message(snw_list <- active_snw_search(input_for_search = input_df1),
"Found [1-9]\\d* active subnetworks")
expect_is(snw_list, "list")
expect_is(snw_list[[1]], "character")
expect_true(length(snw_list) > 0)
unlink("active_snw_search", recursive = TRUE)
expect_message(snw_list <- active_snw_search(input_for_search = input_df2,
sig_gene_thr = 1),
"Found 0 active subnetworks")
expect_identical(snw_list, list())
unlink("active_snw_search", recursive = TRUE)
dummy_dir <- file.path(tempdir(check = TRUE), "dummy_dir")
dir.create(dummy_dir)
expect_message(snw_list <- active_snw_search(input_for_search = input_df1,
dir_for_parallel_run = dummy_dir),
"Found [1-9]\\d* active subnetworks")
expect_true(file.exists(file.path(dummy_dir, "active_snw_search/active_snws.txt")))
})
test_that("All search methods for `active_snw_search()` work", {
skip_on_cran()
expect_message(snw_list <- active_snw_search(input_for_search = input_df1,
pin_name_path = "Biogrid",
search_method = "GR"),
"Found [1-9]\\d* active subnetworks")
expect_is(snw_list, "list")
expect_is(snw_list[[1]], "character")
unlink("active_snw_search", recursive = TRUE)
skip("will test SA and GA if we can create a suitable (faster and non-empty) test case")
expect_message(snw_list <- active_snw_search(input_for_search = input_df1,
pin_name_path = "Biogrid",
search_method = "SA"),
"Found [1-9]\\d* active subnetworks")
expect_is(snw_list, "list")
expect_is(snw_list[[1]], "character")
unlink("active_snw_search", recursive = TRUE)
expect_message(snw_list <- active_snw_search(input_for_search = input_df1,
pin_name_path = "Biogrid",
search_method = "GA"),
"Found [1-9]\\d* active subnetworks")
expect_is(snw_list, "list")
expect_is(snw_list[[1]], "character")
unlink("active_snw_search", recursive = TRUE)
})
test_that("`active_snw_search()` arg checks work", {
expect_error(snw_list <- active_snw_search(input_for_search = list()),
"`input_for_search` should be data frame")
invalid_input <- input_df2[, 3:4]
cnames <- c("GENE", "P_VALUE")
expect_error(snw_list <- active_snw_search(input_for_search = invalid_input),
paste0("`input_for_search` should contain the columns ",
paste(dQuote(cnames), collapse = ",")))
expect_error(snw_list <- active_snw_search(input_for_search = input_df2,
snws_file = "[/]"),
"`snws_file` may be containing forbidden characters. Please change and try again")
valid_mets <- c("GR", "SA", "GA")
expect_error(active_snw_search(input_for_search = input_df2,
search_method = "INVALID"),
paste0("`search_method` should be one of ",
paste(dQuote(valid_mets), collapse = ", ")))
expect_error(active_snw_search(input_for_search = input_df2,
silent_option = "WRONG"),
"`silent_option` should be either TRUE or FALSE")
expect_error(active_snw_search(input_for_search = input_df2,
use_all_positives = "INVALID"),
"`use_all_positives` should be either TRUE or FALSE")
})
sample_path <- system.file("extdata/resultActiveSubnetworkSearch.txt",
package = "pathfindR")
example_snws_len <- 20
test_that("`filterActiveSnws()` returns list object", {
skip_on_cran()
tmp_filtered <- filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol)
expect_is(tmp_filtered, "list")
expect_length(tmp_filtered, 2)
expect_is(tmp_filtered$subnetworks, "list")
expect_is(tmp_filtered$scores, "numeric")
expect_is(tmp_filtered$subnetworks[[1]], "character")
expect_true(length(tmp_filtered$subnetworks) <= example_snws_len)
empty_path <- tempfile("empty", fileext = ".txt")
file.create(empty_path)
expect_null(suppressWarnings(filterActiveSnws(active_snw_path = empty_path,
sig_genes_vec = RA_input$Gene.symbol)))
})
test_that("`score_quan_thr` in `filterActiveSnws()` works", {
skip_on_cran()
tmp_filtered <- filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
score_quan_thr = -1,
sig_gene_thr = 0)
expect_length(tmp_filtered$subnetworks, example_snws_len)
for (q_thr in seq(.1, 1, by = .1)) {
tmp_filtered <- filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
score_quan_thr = q_thr,
sig_gene_thr = 0)
exp_len <- example_snws_len * (1 - q_thr)
expect_length(tmp_filtered$subnetworks, as.integer(exp_len + .5))
}
})
test_that("`sig_gene_thr` in `filterActiveSnws()` works", {
skip_on_cran()
tmp_filtered1 <- filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
sig_gene_thr = 0.02,
score_quan_thr = -1)
tmp_filtered2 <- filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
sig_gene_thr = 0.1,
score_quan_thr = -1)
expect_true(length(tmp_filtered2$subnetworks) < example_snws_len)
expect_true(length(tmp_filtered1$subnetworks) > length(tmp_filtered2$subnetworks))
})
test_that("`filterActiveSnws()` arg checks work", {
expect_error(filterActiveSnws(active_snw_path = "this/is/not/a/valid/path"),
"The active subnetwork file does not exist! Check the `active_snw_path` argument")
expect_error(filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = list()),
"`sig_genes_vec` should be a vector")
expect_error(filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
score_quan_thr = "INVALID"),
"`score_quan_thr` should be numeric")
expect_error(filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
score_quan_thr = -2),
"`score_quan_thr` should be in \\[0, 1\\] or -1 \\(if not filtering\\)")
expect_error(filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
score_quan_thr = 2),
"`score_quan_thr` should be in \\[0, 1\\] or -1 \\(if not filtering\\)")
expect_error(filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
sig_gene_thr = "INVALID"),
"`sig_gene_thr` should be numeric")
expect_error(filterActiveSnws(active_snw_path = sample_path,
sig_genes_vec = RA_input$Gene.symbol,
sig_gene_thr = -1),
"`sig_gene_thr` should be in \\[0, 1\\]")
})
test_that("`visualize_active_subnetworks()` returns list of ggraph objects", {
empty_path <- tempfile("empty", fileext = ".txt")
file.create(empty_path)
expect_null(visualize_active_subnetworks(active_snw_path = empty_path,
genes_df = RA_input[1:5,]))
skip_on_cran()
input_df <- RA_input[1:10, ]
g_list <- visualize_active_subnetworks(sample_path, input_df)
expect_is(g_list, "list")
expect_is(g_list[[1]], "ggraph")
expect_true(length(g_list) <= example_snws_len)
g_list <- visualize_active_subnetworks(sample_path, input_df, num_snws = 21)
expect_is(g_list, "list")
expect_is(g_list[[1]], "ggraph")
expect_length(g_list, 3)
})
|
"msfd" <-
function(a,b,n) {
if (missing(a)) messagena("a")
if (missing(b)) messagena("b")
if (missing(n)) messagena("n")
nn <- length(a)
m <- ncol(b)
mdb <- nrow(b)
mdc <- n
c <- matrix(double(1),mdc,m)
f.res <- .Fortran("msfzd",
a=as.double(a),
b=as.double(b),
c=as.double(c),
n=to.integer(n),
nn=to.integer(nn),
m=to.integer(m),
mdb=to.integer(mdb),
mdc=to.integer(mdc))
list(c=f.res$c)
}
|
dae.specific.I <-
function(zpre,zpost,mmat,factorno,componentname,effnames,effcodes,effnandc,comcodes,varcodes,cnames,cnamesie,emat,vmat,icol,iecol,gls,ctable)
{
nfactorcodes <- length(effcodes[[factorno]])
k <- 0
kie <- 0
if(any(!is.na(match(componentname,ctable$allindenv)))) {
for ( i in 1:nfactorcodes) {
for( j in 1:nfactorcodes) {
if( i == j) {
k <- k + 1
kie <- kie + 1
specificcomponentname <- paste(varcodes[[factorno]][k],componentname,sep=":")
szpre <- zpre[[effnandc[[factorno]][i]]]
szpost <- zpost[[effnandc[[factorno]][j]]]
zaz <- szpre %*% t(szpost)
emat[,icol] <- as.vector(mmat %*% zaz %*% mmat)
if(gls) {
vmat[,icol] <- as.vector(zaz)
}
cnames[icol] <- specificcomponentname
icol <- icol + 1
}
else {
kie <- kie + 1
specificcomponentname <- paste(comcodes[[factorno]][kie],componentname,sep=":")
cnamesie[iecol] <- specificcomponentname
iecol <- iecol + 1
}
}
}
}
else {
for ( i in 1:nfactorcodes) {
for( j in 1:nfactorcodes) {
k <- k + 1
specificcomponentname <- paste(comcodes[[factorno]][k],componentname,sep=":")
szpre <- zpre[[effnandc[[factorno]][i]]]
szpost <- zpost[[effnandc[[factorno]][j]]]
zaz <- szpre %*% t(szpost)
emat[,icol] <- as.vector(mmat %*% zaz %*% mmat)
if(gls) {
vmat[,icol] <- as.vector(zaz)
}
cnames[icol] <- specificcomponentname
icol <- icol + 1
}
}
}
daelist <- list(cnames=cnames,cnamesie=cnamesie,emat=emat,vmat=vmat,icol=icol,iecol=iecol)
return(daelist)
}
|
library("JointAI")
test_that('extract_id works', {
runs <- list(list(random = ~ 1 | id, ids = 'id'),
list(random = ~ 0 | id, ids = 'id'),
list(random = y ~ a + b + c, ids = NULL),
list(random = y ~ time | id, ids = 'id'),
list(random = ~ a | id/class, ids = c('id', 'class')),
list(random = ~ a | id + class, ids = c('id', 'class')),
list(random = ~(a | id) + (b | id2), ids = c('id', 'id2'))
)
for (i in seq_along(runs)) {
expect_equal(extract_id(runs[[i]]$random), runs[[i]]$ids)
}
expect_warning(extract_id(runs[[3]]$random), "could be identified")
})
test_that('extract_id results in error', {
err <- list(
"text",
NA,
TRUE,
mean
)
for (i in seq_along(err)) {
expect_error(extract_id(err[[i]]))
}
})
test_that('extract_id results in warning', {
rd_warn <- list(~1,
~a + b + c,
~ NULL)
for (i in seq_along(rd_warn)) {
expect_warning(extract_id(rd_warn[[i]]))
}
})
test_that('extract_outcome works', {
ys <- list(list(fixed = y ~ a + b, out = list(y = 'y')),
list(fixed = y ~ 1, out = list(y = 'y')),
list(fixed = Surv(a, b) ~ 1,
out = list('Surv(a, b)' = c('a', 'b'))),
list(fixed = Surv(a, b, d) ~ x + z,
out = list('Surv(a, b, d)' = c('a', 'b', 'd'))),
list(fixed = cbind(a, b, d) ~ x + z,
out = list('cbind(a, b, d)' = c('a', 'b', 'd')))
)
for (i in seq_along(ys)) {
expect_equal(extract_outcome(ys[[i]]$fixed), ys[[i]]$out)
}
})
|
set_node_attr_to_display <- function(graph,
attr = NULL,
nodes = NULL,
default = "label") {
time_function_start <- Sys.time()
fcn_name <- get_calling_fcn()
if (graph_object_valid(graph) == FALSE) {
emit_error(
fcn_name = fcn_name,
reasons = "The graph object is not valid")
}
if (graph_contains_nodes(graph) == FALSE) {
emit_error(
fcn_name = fcn_name,
reasons = "The graph contains no nodes")
}
attr <-
rlang::enquo(attr) %>% rlang::get_expr() %>% as.character()
if (length(attr) == 0) {
attr <- NULL
}
ndf <- graph$nodes_df
if (is.null(nodes)) {
nodes <- get_node_ids(graph)
}
if (!any(nodes %in% ndf$id)) {
emit_error(
fcn_name = fcn_name,
reasons = "One or more node ID values in `nodes` are not present in the graph")
}
if (!is.null(attr)) {
if (!(attr %in% colnames(ndf))) {
emit_error(
fcn_name = fcn_name,
reasons = "The node attribute given in `attr` is not in the graph's ndf")
}
}
if (!("display" %in% colnames(ndf))) {
ndf <-
ndf %>%
dplyr::mutate(display = as.character(default))
}
if (!is.null(attr)) {
attr_to_display <-
dplyr::tibble(
id = as.integer(nodes),
display = as.character(attr))
} else if (is.null(attr)) {
attr_to_display <-
dplyr::tibble(
id = as.integer(nodes),
display = as.character("is_na"))
}
ndf <-
ndf %>%
dplyr::left_join(attr_to_display, by = "id")
x_col <- which(grepl("\\.x$", colnames(ndf)))
y_col <- which(grepl("\\.y$", colnames(ndf)))
if (!is.null(attr)) {
display_col <-
dplyr::coalesce(ndf[, y_col], ndf[, x_col]) %>%
as.data.frame(stringsAsFactors = FALSE)
} else if (is.null(attr)) {
display_col <-
dplyr::coalesce(ndf[, y_col], ndf[, x_col])
display_col <-
dplyr::case_when(
display_col == "is_na" ~ as.character(NA),
TRUE ~ display_col) %>%
as.data.frame(stringsAsFactors = FALSE)
}
colnames(display_col)[1] <- "display"
ndf <- ndf[-which(grepl("\\.x$", colnames(ndf)))]
ndf <- ndf[-which(grepl("\\.y$", colnames(ndf)))]
ndf <-
dplyr::bind_cols(ndf, display_col) %>%
dplyr::select(
id, type, label, display, dplyr::everything())
graph$nodes_df <- ndf
graph$graph_log <-
add_action_to_log(
graph_log = graph$graph_log,
version_id = nrow(graph$graph_log) + 1,
function_used = fcn_name,
time_modified = time_function_start,
duration = graph_function_duration(time_function_start),
nodes = nrow(graph$nodes_df),
edges = nrow(graph$edges_df))
if (graph$graph_info$write_backups) {
save_graph_as_rds(graph = graph)
}
graph
}
|
snof = function(name = NULL,
id = NULL,
par.len = NULL,
par.id = "x",
par.lower = NULL,
par.upper = NULL,
description = NULL,
fn,
vectorized = FALSE,
noisy = FALSE,
fn.mean = NULL,
minimize = TRUE,
constraint.fn = NULL,
tags = character(0),
global.opt.params = NULL,
global.opt.value = NULL,
local.opt.params = NULL,
local.opt.values = NULL) {
assertString(par.id, null.ok = TRUE)
par.len = asCount(par.len)
if (is.null(par.lower))
par.lower = -Inf
if (is.null(par.upper))
par.upper = Inf
assertNumeric(par.lower, min.len = 1L)
assertNumeric(par.upper, min.len = 1L)
makeSingleObjectiveFunction(
name = name,
id = id,
description = description,
fn = fn,
has.simple.signature = TRUE,
vectorized = vectorized,
noisy = noisy,
fn.mean = fn.mean,
minimize = minimize,
constraint.fn = constraint.fn,
par.set = makeNumericParamSet(
len = par.len,
id = par.id,
lower = par.lower,
upper = par.upper,
vector = TRUE
),
tags = tags,
global.opt.params = global.opt.params,
global.opt.value = global.opt.value,
local.opt.params = local.opt.params,
local.opt.values = local.opt.values
)
}
|
get_dataverse <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), check = TRUE, ...) {
if (isTRUE(check)) {
dataverse <- dataverse_id(dataverse, key = key, server = server, ...)
}
u <- paste0(api_url(server), "dataverses/", dataverse)
r <- httr::GET(u, httr::add_headers("X-Dataverse-key" = key), ...)
httr::stop_for_status(r, task = httr::content(r)$message)
out <- jsonlite::fromJSON(httr::content(r, as = "text", encoding = "UTF-8"))
structure(out$data, class = "dataverse")
}
dataverse_contents <- function(dataverse, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) {
dataverse <- dataverse_id(dataverse, key = key, server = server, ...)
u <- paste0(api_url(server), "dataverses/", dataverse, "/contents")
r <- httr::GET(u, httr::add_headers("X-Dataverse-key" = key), ...)
httr::stop_for_status(r, task = httr::content(r)$message)
out <- jsonlite::fromJSON(httr::content(r, as = "text", encoding = "UTF-8"), simplifyDataFrame = FALSE)
structure(lapply(out$data, function(x) {
`class<-`(x, if (x$type == "dataset") "dataverse_dataset" else "dataverse")
}))
}
|
fusedlasso2d <- function(y, X, dim1, dim2, gamma=0, approx=FALSE,
maxsteps=2000, minlam=0, rtol=1e-7, btol=1e-7,
eps=1e-4, verbose=FALSE) {
if (missing(y)) stop("y is missing.")
if (!is.numeric(y)) stop("y must be numeric.")
if (length(y) == 0) stop("There must be at least one data point [must have length(y) > 1].")
if (missing(X)) X = NULL
if (missing(dim1) || missing(dim2)) {
if (is.matrix(y) && is.null(X)) {
dim1 = nrow(y)
dim2 = ncol(y)
}
else {
stop("Both dim1 and dim2 must be specified.")
}
}
else if (dim1<0 || round(dim1)!=dim1 || dim2<0 || round(dim2)<0) {
stop("Both dim1 and dim2 must be nonnegative integers.")
}
if (is.null(X) && length(y)!=dim1*dim2) {
stop("Dimensions don't match [length(y) != dim1*dim2].")
}
if (!is.null(X) && ncol(X)!=dim1*dim2) {
stop("Dimensions don't match [ncol(X) != dim1*dim2].")
}
D = getD2dSparse(dim1,dim2)
out = fusedlasso(y,X,D,NULL,gamma,approx,maxsteps,minlam,rtol,btol,eps,verbose)
out$call = match.call()
return(out)
}
|
matchDatasets = function(data1, data2, flank = 0){
{
chr1 = data1[[1]];
chr2 = data2[[1]];
if(is.numeric(chr1) & is.numeric(chr2)){
chr1ind = chr1;
chr2ind = chr2;
} else {
if(!is.factor(chr1))
chr1 = factor(chr1);
if(is.factor(chr1))
levels(chr1) = gsub('^chr', '', levels(chr1));
if(!is.factor(chr2))
chr2 = factor(chr2);
if(is.factor(chr2))
levels(chr2) = gsub('^chr', '', levels(chr2));
chrsame = (length(levels(chr1)) == length(levels(chr2)));
if( chrsame )
chrsame = all(levels(chr1) == levels(chr2));
if( chrsame ){
chr1ind = as.integer(chr1);
chr2ind = as.integer(chr2);
} else {
chrset = union(levels(chr1), levels(chr2));
as.numeric(chrset)
chr1ind = as.integer(factor(chr1, levels = chrset));
chr2ind = as.integer(factor(chr2, levels = chrset));
rm(chrset);
}
rm(chrsame);
}
rm(chr1, chr2);
}
{
stopifnot(all( data1[[2]] < 1e9 ));
stopifnot(all( data1[[3]] < 1e9 ));
stopifnot(all( data2[[2]] < 1e9 ));
stopifnot(all( data2[[3]] < 1e9 ));
data1l = chr1ind*1e9 + data1[[2]];
data1r = chr1ind*1e9 + data1[[3]];
data2l = chr2ind*1e9 + data2[[2]];
data2r = chr2ind*1e9 + data2[[3]];
rm(chr1ind, chr2ind);
}
{
if( is.unsorted(data2l) ){
ord = order(data2l);
data2l = data2l[ord];
data2r = data2r[ord];
data2 = data2[ord,];
rm(ord);
}
if(is.unsorted(data2r))
stop("Second data set must have non-overlapping regions.");
keep = c(TRUE, (diff(data2l)>0) & (diff(data2r)>0));
if( !all(keep) ){
data2l = data2l[keep];
data2r = data2r[keep];
data2 = data2[keep,];
}
rm(keep);
}
{
data1c = data1l + data1r;
if(is.unsorted(data1c)){
ord = order(data1c);
data1l = data1l[ord];
data1r = data1r[ord];
data1 = data1[ord,];
rm(ord);
}
rm(data1c);
}
{
ind1 = findInterval(data1l, data2r + (1 + flank));
ind2 = findInterval(data1r, data2l - flank);
stopifnot(all(ind1 <= ind2));
index = integer(length(ind1));
set = which((ind2-ind1) == 1);
index[set] = ind2[set];
rm(set);
set = which((ind2-ind1)>1);
if( length(set) > 0L ){
data1c = data1l[set] + data1r[set];
data2c = data2l + data2r;
indL = findInterval(data1c, data2c);
nudge = (2 * data1c > (data2c[indL] + data2c[indL+1L]));
indClose = indL + nudge;
message("Lower bound effect ", mean(indClose <= ind1[set]));
message("Upper bound effect ", mean(indClose > ind2[set]));
indClose = pmax(indClose, ind1[set] + 1L);
indClose = pmin(indClose, ind2[set] );
index[set] = indClose;
rm(data1c, data2c, indL, nudge, indClose);
}
rm(ind1, ind2, set);
}
result = list(
data1 = data.frame(
lapply(data1, `[`, which(index>0L)),
stringsAsFactors = FALSE,
check.rows = FALSE),
data2 = data.frame(
lapply(data2, `[`, index[index>0L]),
stringsAsFactors = FALSE,
check.rows = FALSE));
return(result);
}
|
NULL
model_grm_prob <- function(t, a, b, D=1.702, raw=FALSE){
b <- as.matrix(b)
n_p <- length(t)
n_i <- nrow(b)
n_c <- ncol(b)
if(raw) {
p <- model_grm_prob_rawC(t, a, b, D)
p <- aperm(array(unlist(p), dim=c(n_p, n_c+2, n_i)), c(1, 3, 2))
} else {
p <- model_grm_probC(t, a, b, D)
p <- aperm(array(unlist(p), dim=c(n_p, n_c+1, n_i)), c(1, 3, 2))
}
p
}
model_grm_info <- function(t, a, b, D=1.702){
p <- p_ <- Rirt::model_grm_prob(t, a, b, D)
p_[is.na(p_)] <- 0
p_ <- aperm(apply(p_, c(1, 2), function(x) rev(cumsum(c(0, rev(x))))), c(2, 3, 1))
n_c <- dim(p)[3]
dv1_p_ <- aperm(p_ * (1 - p_), c(2, 3, 1)) * D * a
dv2_p_ <- aperm((1 - 2 * p_) * p_ * (1 - p_), c(2, 3, 1)) * (D * a)^2
dv1_p <- dv1_p_[,1:n_c,,drop=FALSE] - dv1_p_[,-1,,drop=FALSE]
dv1_p <- aperm(dv1_p, c(3, 1, 2))
dv2_p <- dv2_p_[,1:n_c,,drop=FALSE] - dv2_p_[,-1,,drop=FALSE]
dv2_p <- aperm(dv2_p, c(3, 1, 2))
1 / p * dv1_p^2 - dv2_p
}
model_grm_lh <- function(u, t, a, b, D=1.702, log=FALSE){
p <- model_grm_prob(t, a, b, D)
ix <- model_polytomous_3dindex(u)
lh <- array(p[ix], dim=dim(u))
if(log) lh <- log(lh)
lh
}
model_grm_gendata <- function(n_p, n_i, n_c, t=NULL, a=NULL, b=NULL, D=1.702,
t_dist=c(0, 1), a_dist=c(-.1, .2), b_dist=c(0, .8),
t_bounds=c(-3, 3), a_bounds=c(.01, 2.5), b_bounds=c(-3, 3),
missing=NULL, ...){
if(is.null(t)){
t <- rnorm(n_p, mean=t_dist[1], sd=t_dist[2])
t[t < t_bounds[1]] <- t_bounds[1]
t[t > t_bounds[2]] <- t_bounds[2]
}
if(is.null(a)){
a <- rlnorm(n_i, meanlog=a_dist[1], sdlog=a_dist[2])
a[a < a_bounds[1]] <- a_bounds[1]
a[a > a_bounds[2]] <- a_bounds[2]
}
if(is.null(b)) {
b <- matrix(rnorm(n_i * (n_c - 1), mean=b_dist[1], sd=b_dist[2]), nrow=n_i)
b <- t(apply(b, 1, sort))
b <- matrix(b, nrow=n_i, ncol=n_c-1)
}
if(length(t) == 1)
t <- rep(t, n_p)
if(length(a) == 1)
a <- rep(a, n_i)
if(length(t) != n_p)
stop('wrong dimensions for t')
if(length(a) != n_i)
stop('wrong dimensions for a')
if(any(dim(b) != c(n_i, n_c - 1)))
stop('wrong dimensions for b')
p <- model_grm_prob(t, a, b, D)
u <- apply(p, 1:2, function(x) which.max(rmultinom(1, 1, x)[,1]) - 1)
if(!is.null(missing)){
missing <- floor(ifelse(missing < 1, missing * n_p * n_i, missing))
idx <- sample(length(u), missing)
u[cbind(ceiling(idx/n_i), (idx-1)%%n_i+1)] <- NA
}
list(u=u, t=t, a=a, b=b)
}
model_grm_rescale <- function(t, a, b, scale=c("t", "b"), mean=0, sd=1){
scale <- switch(match.arg(scale), "t"=t, "b"=b)
slope <- sd / sd(scale)
intercept <- mean - slope * mean(scale)
t <- slope * t + intercept
b <- slope * b + intercept
a <- a / slope
list(t=t, a=a, b=b)
}
model_grm_plot <- function(a, b, D=1.702, type=c('prob', 'info'), item_level=FALSE, total=FALSE, xaxis=seq(-6, 6, .1), raw=FALSE){
rs <- switch(match.arg(type), "prob"=model_grm_prob(xaxis, a, b, D, raw), "info"=model_grm_info(xaxis, a, b, D))
n_p <- dim(rs)[1]
n_i <- dim(rs)[2]
n_c <- dim(rs)[3]
y <- NULL
for(i in 1:n_i)
y <- rbind(y, data.frame(theta=rep(xaxis, n_c), item=paste('Item', i), category=paste('Category', rep(1:n_c, each=n_p)), x=as.vector(rs[,i,])))
if(item_level) y <- rbind(y, cbind(aggregate(y$x, by=list(theta=y$theta, item=y$item), sum), category='Total'))
if(total) y <- cbind(aggregate(y$x, by=list(theta=y$theta, category=y$category), sum), item='Total')
y <- y[!is.na(y$x),]
ggplot(y, aes_string(x="theta", y="x", color="category")) +
geom_line() + facet_wrap(~item, scales='free') +
xlab(expression(theta)) + ylab(type) +
guides(color=FALSE) + theme_bw() + theme(legend.key=element_blank())
}
model_grm_plot_loglh <- function(u, a, b, D=1.702, xaxis=seq(-6, 6, .1), verbose=FALSE){
n_p <- dim(u)[1]
n_i <- dim(u)[2]
n_t <- length(xaxis)
rs <- array(NA, dim=c(n_p, n_t))
for(i in 1:n_t)
rs[, i] <- rowSums(model_grm_lh(u, rep(xaxis[i], n_p), a, b, D, log=TRUE))
if(verbose)
print(apply(rs, 1, function(x){xaxis[which.max(x)]}))
rs <- data.frame(theta=rep(xaxis, each=n_p), people=rep(1:n_p, n_t), value=as.vector(rs))
rs$people <- factor(rs$people)
ggplot(rs, aes_string(x="theta", y="value", color="people")) +
geom_line() + xlab(expression(theta)) + ylab("Log-likelihood") +
guides(color=FALSE) + theme_bw()
}
|
"quarice" <-
function(f, para, xmax=NULL, paracheck=TRUE) {
if(! check.fs(f)) return()
if(paracheck == TRUE) {
if(! are.parrice.valid(para)) return()
}
V <- para$para[1]
A <- para$para[2]
if(V == 0) {
ray <- vec2par(c(0,A), type="ray")
return(quaray(f,para=ray,paracheck=paracheck))
}
SNR <- V/A
if(SNR > 52) {
xbar <- A * SNR
xvar <- A^2;
nor <- vec2par(c(xbar,sqrt(xvar)), type="nor")
return(quanor(f,para=nor,paracheck=paracheck))
} else if(SNR > 24) {
L05 <- LaguerreHalf(-V^2/(2*A^2))
xbar <- A * sqrt(pi/2) * L05
xvar <- 2*A^2 + V^2 - A^2 * (pi/2) * L05^2
nor <- vec2par(c(xbar,sqrt(xvar)), type="nor")
return(quanor(f,para=nor,paracheck=paracheck))
}
if(is.null(xmax)) {
for(ord in (1:10)) {
test.xmax <- 10^ord*(V+A)
val <- pdfrice(test.xmax, para)
if(val <= 100*.Machine$double.eps) {
xmax <- test.xmax
break
}
ifelse(is.finite(val), xmax <- test.xmax, break)
}
}
Fmax <- cdfrice(xmax, para)
x <- sapply(1:length(f), function(i) {
Fx <- f[i]
if(Fx == 0) return(0)
if(Fx == 1 | Fx >= Fmax) return(xmax)
rt.tmp <- NULL
try(rt.tmp <- uniroot(function(X,...) return(Fx - cdfrice(X,...)),
c(0,xmax), para=para)$root, silent=FALSE)
ifelse(is.null(rt.tmp), return(NA), return(rt.tmp)) })
names(x) <- NULL
return(x)
}
|
`cm.compact` <-
function(n0,n1,M){
K<-n1+n0-M
lowest<- max(0,n1-K)
highest<-min(n1,M)
gvals<-lowest:highest
ng<-length(gvals)
for (g in 1:ng){
if (g==1){
cmout<-chooseMatrix(M,gvals[g])
weight<-rep(dhyper(gvals[g],M,K,n1)/choose(M,gvals[g]),dim(cmout)[1])
}
else{
cm.temp<-chooseMatrix(M,gvals[g])
weight<-c(weight,
rep(dhyper(gvals[g],M,K,n1)/choose(M,gvals[g]),dim(cm.temp)[1]) )
cmout<-rbind(cmout,cm.temp)
}
}
out<-list(weight=weight,cm=cmout)
out
}
|
ll<- function(params, data_u, A_u)
{
data_u<- as.matrix(data_u)
hv_sig<- A_u %*% (params^2)
sig<- matrix(0, ncol(data_u), ncol(data_u))
sig[lower.tri(sig, diag=TRUE)]<- hv_sig
sig[upper.tri(sig)]<- t(sig)[upper.tri(sig)]
mu<- -diag(sig)/2
ll<- -sum(mvtnorm::dmvnorm(data_u, mean = mu, sigma = sig, log = TRUE))
return(ll)
}
llmle2<- function(params, data, obj, subsets, k_ratio, h1, Ubar)
{
sig<- ArgumentD(c(sum(h1),sum(h1)))
sig<- for_u_in_U(obj=sig, obj2=obj, subsets=subsets, k_ratio=k_ratio,
h1=h1, depParams=params, Ubar=Ubar)
mu<- -diag(sig)/2
ll<- -sum(mvtnorm::dmvnorm(data, mean = mu, sigma = sig, log = TRUE))
return(ll)
}
llmleave<- function(params, data, Lambda )
{
d<- ncol(data)
m<- crossprod(t(Lambda), params^2)
lambd<- matrix(m, ncol = d, nrow = d, byrow=TRUE)/4
M<- diag(d) - tcrossprod(rep(1,d), rep(1,d))/d
sig<- -crossprod(t(crossprod(t(M), lambd)), M)
ed<- rep(1,d)/d
gmm<- as.vector(crossprod(t(crossprod(ed, lambd)), ed))
mu<- -as.vector(crossprod(t(lambd), ed)) + gmm*ed*d
ll<- -sum(mvtnorm::dmvnorm(data, mean = mu, sigma = sig+10^(-7)*diag(d), log = TRUE))
return(ll)
}
ll_EngHitz<- function(params, data, MA, Uc, obj)
{
obj<- setParams(obj, params)
nvars<- colnames(data)
u<- nvars[1]
nvars_u<- base::setdiff(nvars, u)
vv<- rep(1, ncol(data))
names(vv)<- nvars
data1<- log(data[,nvars_u]/data[,u])
ff<- - (-2*sum(log(data[,u])) - sum(log(data[,nvars_u])) -
ll(params, data1, MA) - nrow(data)*log(stdf(obj, vv, Ubar=Uc)))
return(ff)
}
|
.Random.seed <-
c(403L, 128L, -864733335L, 1107972764L, -1297845673L, -2119422051L,
2087331776L, 1396422983L, 884474761L, -1286070025L, 1464279785L,
-980831509L, -1293355262L, -1072555261L, 652700135L, -1975764076L,
-797878953L, 1308251934L, -1205500787L, -577669718L, -1828487013L,
-1260899181L, 228258545L, 652425111L, 1823899603L, -530228386L,
1662519181L, 76341365L, 2083213784L, 1926489344L, -89662044L,
-391418152L, -875112255L, -722261348L, -1875635590L, 1412634328L,
1411309954L, -2016866010L, 1871842379L, 1679543416L, 1536060312L,
-950724867L, 1888141506L, -1391938532L, 1361352362L, -1525572310L,
-290844343L, -1303078981L, 891832085L, -1449051312L, 1647017291L,
2061545013L, -366330595L, -1361474169L, 1546569205L, -1253231874L,
-697674601L, 478294032L, 746962301L, -1228172791L, 1547467805L,
-568339793L, 1174844542L, 1896217173L, -466228221L, -953474952L,
-40381223L, 1047539683L, 83070370L, 1254398119L, 750931711L,
552642164L, -1319412143L, 368546308L, -52353665L, 67250819L,
-535380610L, 724016907L, -27336332L, -1963997073L, 909775028L,
-1832628922L, -1077386804L, 1131036916L, -508209244L, 650589732L,
1414416628L, 78238114L, -281948880L, 1113802144L, -1912891393L,
-2006208738L, -204789872L, 1201835147L, 2124727676L, 1161880116L,
779937169L, -506602131L, 843407723L, 347974790L, -1999538761L,
-2082207843L, 1758385702L, 1243568814L, -1156841838L, 751277070L,
-121749250L, -1685160675L, -1055928527L, 109084660L, -852176380L,
-183686495L, -2098730429L, 1606702921L, 1469436785L, 1431876709L,
1270716251L, 1796417516L, 407869472L, 1177088835L, 1503823321L,
1835553999L, -2110033514L, 582099657L, -340319941L, -1501832918L,
349549742L, -1092761127L, -1932261257L, -1963421634L, 1093045184L,
-1789159163L, -1497467101L, 745027028L, 1950928865L, 1992502129L,
1779830713L, 1618777479L, 971758021L, 769171653L, -996187369L,
31762567L, 496575162L, -1235585263L, -1309643684L, 567942528L,
1232346072L, -1300279665L, 734048523L, 1808044533L, -232522377L,
2014764989L, 1872174426L, -1075817598L, -805142628L, -10772900L,
1530239796L, -1317488415L, -309146076L, -2123078799L, 81183309L,
2137886841L, 70450481L, -1860324263L, -268470119L, -973580343L,
1820743129L, -947509115L, -1585116432L, 1319468284L, -252164339L,
1661383811L, 1754261775L, 1380016864L, 1833192232L, 9604867L,
-1102820605L, -375202227L, -566100931L, -1986701175L, -240714152L,
568426986L, 1759341677L, 269537303L, 923402887L, 269766018L,
1495619908L, 1314420793L, -449071962L, 1377030990L, 1034086037L,
234220538L, -519532334L, -794288635L, -922453868L, 1059050588L,
-27759384L, 1687458169L, -1584551000L, 874762836L, -388958648L,
-230164720L, -813913634L, -1178855560L, -1563434119L, -1320454683L,
-550605283L, -1933132517L, -305553408L, 1631464272L, 40591348L,
-1969514169L, 370424458L, -1970328567L, -323494694L, -1322069875L,
-1258895632L, 83401729L, -1384064719L, 511206831L, -544238242L,
1500022834L, -982210412L, 737103827L, 1364763381L, -1863456307L,
-2027326864L, -777618182L, -1945888548L, 1089546895L, -78145852L,
-912468960L, -1672148289L, 1217428591L, 922855067L, 1476816458L,
-743523402L, 938058139L, -1335983829L, -1071802737L, 498646009L,
270041219L, 1132716870L, -1674887995L, 844658239L, 268256152L,
-685710415L, -1940072012L, -436885233L, 1176872301L, -269258922L,
1534453723L, -705570811L, 2126189175L, 1876221661L, -1169664187L,
184994344L, 1633194081L, -728402694L, 1195240510L, 1087244038L,
-72678248L, -542331939L, 1438978699L, 1033086309L, 550060465L,
-46690467L, -1257300029L, -309993745L, 1049763918L, -728843563L,
1985104228L, -827542993L, -157423673L, -1079006611L, 651121972L,
-2135729216L, 2064247277L, 966787212L, 563975005L, 554007840L,
18798313L, 502130048L, -790085600L, -774989936L, -1322946285L,
1107935428L, 244854338L, -2091615140L, -658393722L, -257836556L,
2008892237L, -980777453L, -1992691018L, 130299435L, -1896681339L,
-1436922583L, 1778498284L, -1690752337L, -921556337L, 1974753856L,
1473347720L, 821960633L, 1894607534L, -723132831L, -1780816986L,
667916875L, -115025350L, 392573663L, -1444730171L, 1903192073L,
16185572L, 1019284702L, 1748761498L, -533774701L, -155387676L,
548966621L, -46112424L, -222748538L, 390543658L, 388930897L,
-134674698L, -1220359144L, 746352925L, -1499544847L, -724043157L,
-888064114L, 700507754L, 320801506L, 1222562792L, -632915110L,
1373953152L, -1604209232L, 963273753L, -1062798681L, 596267780L,
-1539052860L, -2138022547L, 1922823523L, 779149782L, -1439427102L,
1732120013L, 1787361343L, -1567292704L, 2142384810L, 1052916875L,
-344414264L, -336760499L, -1743933154L, -2111534165L, 1729078649L,
-664736082L, 1707220311L, -111176171L, 152995207L, 1009202619L,
-209577098L, 1573304396L, 1365812296L, -1152825613L, -582544690L,
1449720278L, 228241434L, -1935085346L, -320784174L, 1482822349L,
-1889799379L, 2101916707L, 254876471L, -554589588L, -2057978167L,
1234810013L, 121255610L, 488412805L, -1720439177L, -1326503572L,
-1896206937L, 809012399L, 333480422L, -814481653L, 1721812214L,
1827718820L, -940965777L, -146606293L, 144815514L, 834980695L,
-126408418L, -2038145934L, -980541837L, 886573970L, 657443071L,
-767647740L, -991164128L, 582922760L, 1606979125L, -1184162834L,
-335847274L, 743134277L, -1386691225L, 1492151831L, 533868658L,
1763564321L, 1926330333L, 955524305L, 1538704988L, 1904258619L,
1020773560L, -1196880119L, 866017305L, -1928786736L, 2029831817L,
-1896011321L, 2046089977L, 461324840L, -1595630127L, -611679982L,
258719075L, -409727301L, -431446134L, -301608983L, -1466160558L,
-210030675L, -1136268280L, 1220663694L, 1652393129L, 769676196L,
-660969468L, 1564690746L, -1175698285L, 551510684L, -1781044503L,
827470664L, 1384697037L, 1539054204L, 485257335L, -1273874136L,
-1751598545L, -376421875L, 1139690075L, -869226324L, -256800548L,
306359969L, 515516510L, 1571003609L, 1956047124L, -701150482L,
1506360487L, 1006612756L, -1451185807L, 1270796610L, -2043245963L,
-33341106L, -520662310L, 29623802L, 225194960L, 1331812174L,
100102633L, -383882580L, -1350722208L, -390540855L, 1134236348L,
875199697L, -729403108L, 719561650L, -1867713881L, 881906988L,
-1779434453L, 711916772L, -1313933377L, -2113157281L, 5851031L,
1622882378L, 470425209L, -487761220L, 879458875L, -552258262L,
-1292311181L, 110482122L, -155857797L, -1082016663L, 1706857809L,
1138377536L, 1241588806L, 1497314067L, -30550403L, -1215541423L,
-1880718340L, 1320737831L, 1876997639L, -2013904808L, -825267993L,
-1390286272L, 1196610435L, 1811235948L, 1181736825L, -1455955218L,
-1064364338L, -283782518L, 853812238L, 337333068L, 1452018392L,
1393166159L, -7864745L, -1453577807L, -1686167855L, -1806564453L,
842508487L, -215476390L, 1236872627L, 1499459394L, -1423253439L,
420583021L, -197941443L, 1201112581L, 1061464162L, -1990413730L,
2063169185L, -1706879782L, 1354324146L, -1308275352L, -462025875L,
117288613L, -7422309L, 137129725L, 852048849L, -1687204710L,
1375411937L, 983455959L, 945142395L, -1614107787L, 410804220L,
775680104L, 1480086242L, -832679710L, -1554883369L, 645537497L,
1269239810L, 631367262L, 137941088L, 1187921445L, -1522569499L,
-448168603L, -875851446L, -1898838814L, -1838625871L, -1630148372L,
767772067L, -716606086L, 1766726959L, -1900687800L, -206478342L,
1368769082L, 697365764L, -1975944511L, 1794815779L, 381942983L,
-1146190309L, -2037500805L, -734003301L, 780840901L, 466120302L,
-1377953957L, -1725215446L, -783716831L, 410781898L, 374383273L,
79670399L, -1433591362L, -488330602L, 1663140293L, -1480494412L,
-1917457110L, 1113675201L, -1770424268L, 186868708L, 614666579L,
567871559L, -1883764559L, -1297866644L, -25742133L, -1997570894L,
-1369377032L, 1257088781L, 1699343360L, -1081910176L, -761726106L,
-482371942L, 1550633580L, 1774650704L, -1398830910L, 568136695L,
1498063393L, 1398930244L, -2144527413L, -1103953434L, -1616588986L,
455082460L, -1662859771L, -170177449L, 1776016314L, -1887271115L,
455524848L, 1959473653L, 574796374L, 1536534830L, -426022425L,
1906468965L, -1775791474L, 1629408134L, 1778649652L, 2107785624L,
1686801817L, -224933247L, -942142513L, -244129449L, 1276929664L,
1015819641L, 304954981L, 687726441L, -173723481L, 1773972183L,
1268382174L, -477612174L, -1287771012L, 1033792559L, 1382739468L
)
|
NULL
dmatnorm <- function(
A,
M,
U,
V,
tol = .Machine$double.eps^0.5,
log = TRUE
) {
n <- nrow(A)
p <- ncol(A)
if (is.data.frame(A)) A <- as.matrix(A)
if (sum(dim(A) == dim(M)) != 2) stop("M must have same dimensions as A.")
check_matnorm(s = 1, M, U, V, tol)
log.dens <- (-n * p / 2) * log(2 * pi) - p / 2 * log(det(U)) - n / 2 * log(det(V)) +
-1 / 2 * tr(solve(U) %*% (A - M) %*% solve(V) %*% t(A - M))
if (log) {
return(log.dens)
} else {
return(exp(log.dens))
}
}
logdet <- function(x) {
2 * sum(log(diag(chol(x))))
}
dmatnorm.logdet <- function(A, M, U, V,
tol = .Machine$double.eps^0.5,
log = TRUE) {
n <- nrow(A)
p <- ncol(A)
if (is.data.frame(A)) A <- as.matrix(A)
if (sum(dim(A) == dim(M)) != 2) stop("M must have same dimensions as A.")
check_matnorm(s = 1, M, U, V, tol)
log.dens <- (-n * p / 2) * log(2 * pi) - p / 2 * logdet(U)
-n / 2 * logdet(V) +
-1 / 2 * tr(solve(U) %*% (A - M) %*% solve(V) %*% t(A - M))
if (log) {
return(log.dens)
} else {
return(exp(log.dens))
}
}
pmatnorm <- function(
Lower = -Inf,
Upper = Inf,
M,
U,
V,
tol = .Machine$double.eps^0.5,
keepAttr = TRUE,
algorithm = mvtnorm::GenzBretz(),
...
) {
if (utils::packageVersion("mvtnorm") < "1.1-2") {
warning("New argument added to `mvtnorm v. 1.1-2`. Please upgrade to avoid error when passing `keepAttr`.")
}
n <- nrow(M)
p <- ncol(M)
check_matnorm(s = 1, M, U, V, tol)
if (is.matrix(Lower)) {
lower <- vec(Lower)
} else {
if (is.vector(Lower) & Lower == -Inf) {
lower <- -Inf
} else {
stop("The lower limit must be a numeric matrix or -Inf.")
}
}
if (is.matrix(Upper)) {
upper <- vec(Upper)
} else {
if (is.vector(Upper) & Upper == Inf) {
upper <- Inf
} else {
stop("The upper limit must be a numeric matrix or Inf.")
}
}
prob <- mvtnorm::pmvnorm(
lower, upper,
mean = vec(M),
corr = NULL,
sigma = kronecker(U, V),
algorithm = algorithm,
...,
keepAttr = keepAttr
)
warning("The covariance matrix is standardized. ")
return(prob)
}
rmatnorm <- function(
s = 1,
M,
U,
V,
tol = .Machine$double.eps^0.5,
method = "chol"
) {
if (utils::packageVersion("mvtnorm") < "1.1-2") {
warning("New argument added to `mvtnorm v. 1.1-2`. Please upgrade to avoid error.")
}
M <- as.matrix(M)
U <- as.matrix(U)
V <- as.matrix(V)
n <- nrow(M)
p <- ncol(M)
check_matnorm(s, M, U, V, tol)
if (utils::packageVersion("matrixNormal") <= "0.0.5") {
warning("The construction of sigma has been found to be incorrect. Please upgrade to new version.")
}
Sigma <- kronecker(V, U)
vec.X <- mvtnorm::rmvnorm(1, vec(M), Sigma, method = method, checkSymmetry = FALSE)
X <- matrix(vec.X,
nrow = n, ncol = p,
dimnames = list(rownames(U), colnames(V))
)
return(X)
}
check_matnorm <- function(s, M, U, V, tol) {
if (!(s > 0)) stop("s must be > 0. s = ", s, call. = FALSE)
if (anyNA(M)) {
stop("M contains missing values.", call. = FALSE)
}
if (anyNA(U)) {
stop("U contains missing values.")
}
if (anyNA(V)) {
stop("V contains missing values.")
}
if (nrow(M) != nrow(U)) {
stop("The mean matrix M has different sample size than the scale sample size
matrix U. M has ", dim(M)[[1]], "rows, and U has ", dim(U)[[1]], ".")
}
if (ncol(M) != nrow(V)) {
stop("The mean matrix M has different number of parameters than scale
parameter matrix V: M -- ", dim(M)[2], "; V -- ", dim(V)[1], ".")
}
if (!is.positive.definite(U, tol)) {
stop("U is not positive definite. Calculation may not be accurate.
Possibly raise tolerance.")
}
if (!is.positive.definite(V, tol)) {
stop("V is not positive definite. Calculation may not be accurate.
Possibly raise tolerance.")
}
return(invisible())
}
|
Test.intersection.ellipse <- function(mean.1, M.1, mean.2, M.2){
A.inv <- solve(M.1)
B.inv <- solve(M.2)
K <- function(s){
1 - t(mean.2 - mean.1) %*% solve(A.inv / (1 - s) + B.inv / s) %*% (mean.2 - mean.1)
}
Ks <- stats::optimize(K, c(0.00001, 0.99999))$objective
if (Ks < 0){
Ind.Overlap <- 0
} else { Ind.Overlap <- 1}
return(Ind.Overlap == 1)
}
|
library(gWidgets2)
WizardPage <- setRefClass("WizardPage",
fields=list(
wizard="ANY",
prev_button="ANY",
next_button="ANY",
widgets="list"
),
methods=list(
initialize=function(wizard=NULL, ...) {
initFields(wizard=wizard)
callSuper(...)
},
can_next=function() {
"Return logical if we can go to next page"
TRUE
},
can_prev=function() {
"Return logical if we can go to previous"
TRUE
},
make_page=function(content_area) {
"Add content here"
},
update_page=function() {
"Called by change handlers in widgets"
wizard$update_page()
},
get_values=function() {
"Return values in a named list"
sapply(widgets, svalue, simplify=FALSE)
}
))
Wizard <- setRefClass("Wizard",
fields=list(
pages="list",
cur_page="ANY",
main_window="ANY",
nb="ANY"
),
methods=list(
initialize=function(title="", ...) {
initFields(pages=list(),
main_window=gwindow(title, visible=FALSE)
)
g <- ggroup(cont=main_window)
g$set_borderwidth(10)
nb <<- gstackwidget(cont=g)
callSuper(...)
},
no_pages=function() length(pages),
add_page=function(page, title="") {
page$wizard <- .self
pages <<- c(pages, page)
box <- ggroup(cont=nb, label=title, horizontal=FALSE)
content_area <- ggroup(container=box, expand=TRUE, fill=TRUE, horizontal=FALSE)
page$make_page(content_area)
button_area <- ggroup(cont=box, horizontal=TRUE)
addSpring(button_area)
page$prev_button <- gbutton("previous", cont=button_area, handler=function(h,...) {
h$action$prev_page()
}, action=.self)
page$next_button <- gbutton("next", cont=button_area, handler=function(h,...) {
h$action$next_page()
}, action=.self)
},
prev_page=function() {
cur_page_no <- Filter(function(i) identical(pages[[i]], cur_page), seq_along(pages))
if(cur_page_no > 1) {
.nb <- nb
svalue(.nb) <- cur_page_no - 1
cur_page <<- pages[[cur_page_no - 1]]
update_page()
}
},
next_page = function() {
cur_page_no <- Filter(function(i) identical(pages[[i]], cur_page), seq_along(pages))
if(cur_page_no < length(pages)) {
.nb <- nb
svalue(.nb) <- cur_page_no + 1
cur_page <<- pages[[cur_page_no + 1]]
update_page()
} else {
call_finalizer()
}
},
call_finalizer=function() {
"replace me in subclass, or make configurable..."
print("Tada, all done")
print(get_values())
close_ui()
},
update_page=function() {
"Update buttons"
p_b <- cur_page$prev_button; n_b <- cur_page$next_button
enabled(p_b) <- cur_page$can_prev()
enabled(n_b) <- cur_page$can_next()
},
make_ui=function() {
.nb <- nb
svalue(.nb) <- 1
cur_page <<- pages[[1]]
update_page()
.main_window <- main_window
visible(.main_window) <- TRUE
},
close_ui=function() {
dispose(main_window)
},
get_values=function() {
"Return values from page"
out <- sapply(pages, function(page) page$get_values(), simplify=FALSE)
unlist(out, recursive=FALSE)
}
))
wizard <- Wizard$new(title="test")
page1 <- setRefClass("Page1",
contains="WizardPage",
methods=list(
can_next = function() {
with(widgets,
nchar(svalue(ed1)) > 0 && nchar(svalue(ed2)) > 0
)
},
can_prev=function() FALSE,
make_page=function(content_area) {
lyt <- gformlayout(cont=content_area)
widgets$ed1 <<- gedit("", initial.msg="Enter some text", cont=lyt, label="Area 1")
widgets$ed2 <<- gedit("", initial.msg="and some more...", cont=lyt, label="And 2")
sapply(widgets, function(obj)
addHandlerKeystroke(obj, handler=function(h,...) h$action$update_page(), action=.self))
}
))$new()
page2 <- setRefClass("Page2",
contains="WizardPage",
methods=list(
can_next = function() {
with(widgets,
svalue(cb)
)
},
can_prev=function() TRUE,
make_page=function(content_area) {
lyt <- gformlayout(cont=content_area)
widgets$rb <<- gradio(state.name[1:4], cont=lyt, label="radio group")
widgets$cb <<- gcheckbox("all ready?", checked=FALSE, cont=lyt, label="checkbox")
sapply(widgets, function(obj)
addHandlerChanged(obj, handler=function(h,...) h$action$update_page(), action=.self))
}
))$new()
wizard$add_page(page1, "Page 1")
wizard$add_page(page2, "Page 2")
wizard$make_ui()
|
context(" Complex mutations")
test_that("Mutating a subset of rows works.", {
expected <- data.table::copy(state)[grepl("^N", region) & grepl("^N", name), abb := paste("N", abb, sep = "-")]
ans <- data.table::copy(state) %>%
start_expr %>%
mutate(abb = paste("N", abb, sep = "-")) %>%
where(grepl("^N", region) & grepl("^N", name)) %>%
end_expr
expect_identical(ans, expected)
ans <- data.table::copy(state) %>%
start_expr %>%
mutate(abb = paste("N", abb, sep = "-")) %>%
where(grepl("^N", region), grepl("^N", name)) %>%
end_expr
expect_identical(ans, expected)
ans <- data.table::copy(state) %>%
where(grepl("^N", region), grepl("^N", name)) %>%
mutate(abb = paste("N", abb, sep = "-"))
expect_identical(ans, expected)
})
test_that("Mutating by group works.", {
expected <- data.table::copy(state)[, abb := paste(.GRP, abb, sep = "-"), by = .(region, division)]
ans <- data.table::copy(state) %>%
start_expr %>%
mutate(abb = paste(.GRP, abb, sep = "-")) %>%
group_by(region, division) %>%
end_expr
expect_identical(ans, expected)
ans <- data.table::copy(state) %>%
group_by(region, division) %>%
mutate(abb = paste(.GRP, abb, sep = "-"))
expect_identical(ans, expected)
})
test_that("Mutating subset by group works.", {
expected <- data.table::copy(state)[area > 50000, abb := paste(.GRP, abb, sep = "-"), by = .(region, division)]
ans <- state %>%
start_expr %>%
mutate(abb = paste(.GRP, abb, sep = "-")) %>%
where(area > 50000) %>%
group_by(region, division) %>%
end_expr(.by_ref = FALSE)
expect_identical(ans, expected)
expect_false(identical(ans, state))
ans <- data.table::copy(state) %>%
group_by(region, division) %>%
where(area > 50000) %>%
mutate(abb = paste(.GRP, abb, sep = "-"))
expect_identical(ans, expected)
expect_false(identical(ans, state))
expected <- data.table::copy(state)[area > 50000, abb := paste(.GRP, abb, sep = "-"), by = .(region, division)
][area <= 50000, abb := paste(0, abb, sep = "-")]
ans <- state %>%
start_expr %>%
mutate(abb = paste(.GRP, abb, sep = "-")) %>%
where(area > 50000) %>%
group_by(region, division) %>%
chain(.by_ref = FALSE) %>%
mutate(abb = paste(0, abb, sep = "-")) %>%
where(area <= 50000) %>%
end_expr
expect_identical(ans, expected)
expect_false(identical(ans, state))
ans <- data.table::copy(state) %>%
group_by(region, division) %>%
where(area > 50000) %>%
mutate(abb = paste(.GRP, abb, sep = "-")) %>%
where(area <= 50000) %>%
mutate(abb = paste(0, abb, sep = "-"))
expect_identical(ans, expected)
expect_false(identical(ans, state))
})
|
"coef.HOF" <-
function (
object,
model,
...
) {
maxNrofParameters <- 5
out <- sapply(object$models, function(x) c(x$par, rep(NA, maxNrofParameters - length(x$par))))
rownames(out) <- letters[1:maxNrofParameters]
if (!missing(model)) {
out <- out[,model]
}
out
}
"deviance.HOF" <-
function (object, model, ...)
{
out <- sapply(object$models, function(x) x$deviance)
if (!missing(model))
out <- out[model]
out
}
"fitted.HOF" <-
function (object, model, ...)
{
out <- sapply(object$models, function(x) x$fitted)
if(!missing(model)) out <- out[,model]
out
}
"predict.HOF" <-
function (object, model, newdata, ...) {
if(missing(model)) model <- pick.model(object, ...)
p <- coef(object, model, ...)
xrange <- object$range
if (missing(newdata)) x <- object$x else x <- newdata
fv <- HOF.fun(x=x, model=as.character(model), p=as.numeric(p), M=1, xrange)
fv
}
|
GetProductsLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "GetProductsLogistic.AC\n\n")
readTime = 0
readSize = 0
p = 0
n = 0
pi = c()
allproducts = rep(list(list()), params$numDataPartners)
allhalfshare = rep(list(list()), params$numDataPartners)
alltags = rep(list(list()), params$numDataPartners)
products = NULL
halfshare = NULL
tags = NULL
allcolmin = allcolrange = allcolsum = allcolnames = NULL
colmin = colrange = colsum = colnames = NULL
party = NULL
for (id in 1:params$numDataPartners) {
readTime = readTime - proc.time()[3]
load(file.path(params$readPathDP[id], "products.rdata"))
load(file.path(params$readPathDP[id], "halfshare.rdata"))
load(file.path(params$readPathDP[id], "colstats.rdata"))
readSize = readSize + sum(file.size(file.path(params$readPathDP[id],
c("products.rdata",
"halfshare.rdata",
"colstats.rdata"))))
readTime = readTime + proc.time()[3]
allproducts[[id]] = products
allhalfshare[[id]] = halfshare
alltags[[id]] = tags
allcolmin = c(allcolmin, colmin)
allcolrange = c(allcolrange, colrange)
allcolsum = c(allcolsum, colsum)
allcolnames = c(allcolnames, colnames)
party = c(party, rep(paste0("dp", id), length(colnames)))
p = p + ncol(halfshare)
pi = c(pi, ncol(halfshare))
if (id == 1) n = nrow(halfshare)
}
M = matrix(0, p, p)
colnames(M) = allcolnames
rownames(M) = allcolnames
offset1 = 1
params$pi = rep(0, params$numDataPartners)
for (id1 in 1:params$numDataPartners) {
p1 = ncol(allhalfshare[[id1]])
params$pi[id1] = p1
offset2 = offset1
for (id2 in id1:params$numDataPartners) {
p2 = ncol(allhalfshare[[id2]])
if (id1 == id2) {
M[offset1:(offset1 + p1 - 1), offset2:(offset2 + p2 - 1)] = allproducts[[id1]][[id2]]
} else {
temp = allproducts[[id1]][[id2]] + allproducts[[id2]][[id1]] +
t(allhalfshare[[id1]]) %*% allhalfshare[[id2]]
M[offset1:(offset1 + p1 - 1), offset2:(offset2 + p2 - 1)] = temp
M[offset2:(offset2 + p2 - 1), offset1:(offset1 + p1 - 1)] = t(temp)
}
offset2 = offset2 + p2
}
offset1 = offset1 + p1
}
params$halfshare = allhalfshare
params$sts = M[2:p, 2:p, drop = FALSE]
params$sty = M[2:p, 1, drop = FALSE]
params$yty = M[1, 1]
params$meansy = allcolsum[1] / n
params$means = allcolsum[-1] / n
params$n = n
params$p = p
params$pi = pi
params$colmin = allcolmin[-1]
params$colrange = allcolrange[-1]
params$colsum = allcolsum[-1]
params$colnames = allcolnames[-1]
params$party = party[-1]
params$tags = alltags
params = AddToLog(params, "GetProductsLogistic.AC", readTime, readSize, 0, 0)
return(params)
}
CheckColinearityLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "CheckColinearityLogistic.AC\n\n")
sts = params$sts
sty = params$sty
nrow = nrow(sts)
indicies = c(1)
for (i in 2:nrow) {
tempIndicies = c(indicies, i)
if (rcond(sts[tempIndicies, tempIndicies]) > 10^8 * .Machine$double.eps) {
indicies = c(indicies, i)
}
}
sts = sts[indicies, indicies, drop = FALSE]
sty = sty[indicies, drop = FALSE]
params$sts = sts
params$sty = sty
params$colmin = params$colmin[indicies]
params$colrange = params$colrange[indicies]
params$colsum = params$colsum[indicies]
params$fullindicies = indicies
params$p = params$p - 1
indicies = indicies + 1
params$indicies = rep(list(list()), params$numDataPartners)
tags = rep(list(list()), params$numDataPartners)
min = 1
for (id in 1:params$numDataPartners) {
max = min + params$pi[id] - 1
idx = indicies[which(min <= indicies & indicies <= max)] - min + 1
params$indicies[[id]] = idx
if (id == 1) {
idx = (idx - 1)[-1]
}
temp = params$tags[[id]]
temp = temp[idx]
tags[[id]] = temp
min = max + 1
}
params$errorMessage = ""
if ((length(unique(tags[[1]])) == 1) | (length(unique(tags[[1]])) >= 2 & !("numeric" %in% names(tags[[1]])))) {
params$failed = TRUE
params$errorMessage = "Data Partner 1 must have no covariates or at least 2 covariates at least one of which is continuous.\n"
}
for (id in 2:params$numDataPartners) {
if (length(unique(tags[[id]])) < 2) {
params$failed = TRUE
params$errorMessage = paste0(params$errorMessage,
paste("After removing colinear covariates, Data Partner", id, "has 1 or fewer covariates.\n"))
} else if (!("numeric" %in% names(tags[[id]]))) {
params$failed = TRUE
params$errorMessage = paste0(params$errorMessage,
paste("After removing colinear covariates, Data Partner", id, "has no continuous covariates.\n"))
}
}
indicies = params$indicies
params$pReduct = c()
for (id in 1:params$numDataPartners) {
params$pReduct = c(params$pReduct, length(indicies[[id]]))
}
for (id in 1:params$numDataPartners) {
params$halfshare[[id]] = params$halfshare[[id]][, indicies[[id]], drop = FALSE]
}
writeTime = proc.time()[3]
save(indicies, file = file.path(params$writePath, "indicies.rdata"))
writeSize = file.size(file.path(params$writePath, "indicies.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "CheckColinearityLogistic.AC", 0, 0, writeTime, writeSize)
return(params)
}
ComputeInitialBetasLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "ComputeInitialBetasLogistic.AC\n\n")
writeTime = 0
writeSize = 0
colsumS = (params$colsum - params$n * params$colmin) / params$colran
beta = 4 * solve(params$sts) %*% (params$sty - 0.5 * colsumS)
u = sum(runif(length(beta), min = 1, max = 5) * abs(beta))
params$u = u
start = 1
for (id in 1:params$numDataPartners) {
end = start + length(params$indicies[[id]]) - 1
betas = beta[start:end]
writeTime = writeTime - proc.time()[3]
save(u, betas, file = file.path(params$writePath, paste0("u_beta_", id, ".rdata")))
writeSize = writeSize + file.size(file.path(params$writePath, paste0("u_beta_", id, ".rdata")))
writeTime = writeTime + proc.time()[3]
start = end + 1
}
params = AddToLog(params, "ComputeInitialBetasLogistic.AC", 0, 0, writeTime, writeSize)
return(params)
}
UpdateParamsLogistic.DP = function(params) {
if (params$trace) cat(as.character(Sys.time()), "UpdateParamsLogistic.DP\n\n")
indicies = NULL
u = NULL
betas = NULL
readTime = proc.time()[3]
load(file.path(params$readPathAC, "indicies.rdata"))
filename = paste0("u_beta_", params$dataPartnerID, ".rdata")
load(file.path(params$readPathAC, filename))
readSize = file.size(file.path(params$readPathAC, "indicies.rdata")) +
file.size(file.path(params$readPathAC, filename))
readTime = proc.time()[3] - readTime
params$u = u
params$betas = betas
params$indicies = indicies
params = AddToLog(params, "UpdateParamsLogistic.DP", readTime, readSize, 0, 0)
return(params)
}
UpdateDataLogistic.DP = function(params, data) {
if (params$trace) cat(as.character(Sys.time()), "UpdateDataLogistic.DP\n\n")
if (params$dataPartnerID == 1) {
data$Y = data$X[, 1, drop = FALSE]
}
idx = params$indicies[[params$dataPartnerID]]
data$X = data$X[, idx, drop = FALSE]
data$colmin = data$colmin[idx]
data$colmax = data$colmax[idx]
data$colsum = data$colsum[idx]
data$colrange = data$colrange[idx]
return(data)
}
ComputeSbetaLogistic.DP = function(params, data) {
if (params$trace) cat(as.character(Sys.time()), "ComputeSbetaLogistic.DP\n\n")
set.seed(params$seed + params$algIterationCounter, kind = "Mersenne-Twister")
V = matrix(rnorm(params$n, mean = runif(n = 1, min = -1, max = 1), sd = 10), ncol = 1)
Vsum = 0
for (id in 1:params$numDataPartners) {
set.seed(params$seeds[id] + params$algIterationCounter, kind = "Mersenne-Twister")
Vsum = Vsum + matrix(rnorm(params$n, mean = runif(n = 1, min = -1, max = 1), sd = 10), ncol = 1)
}
Sbeta = (data$X %*% params$betas + params$u) / (2 * params$u) + V - params$scaler / sum(params$scalers) * Vsum
writeTime = proc.time()[3]
save(Sbeta, file = file.path(params$writePath, "sbeta.rdata"))
writeSize = file.size(file.path(params$writePath, "sbeta.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "ComputeSbetaLogistic.DP", 0, 0, writeTime, writeSize)
return(params)
}
ComputeWeightsLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "ComputeWeightsLogistic.AC\n\n")
Sbeta = 0
readTime = 0
readSize = 0
sbeta = 0
for (id in 1:params$numDataPartners) {
readTime = readTime - proc.time()[3]
load(file.path(params$readPathDP[id], "sbeta.rdata"))
readSize = readSize + file.size(file.path(params$readPathDP[id], "sbeta.rdata"))
readTime = readTime + proc.time()[3]
sbeta = sbeta + Sbeta
}
sbeta = 2 * params$u * sbeta - params$numDataPartners * params$u
pi_ = 1 / (1 + exp(-sbeta))
params$pi_ = pi_
writeTime = proc.time()[3]
save(pi_, file = file.path(params$writePath, "pi.rdata"))
writeSize = file.size(file.path(params$writePath, "pi.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "ComptueWeightsLogistic.AC", readTime, readSize, writeTime, writeSize)
return(params)
}
ComputeStWSLogistic.DP = function(params, data) {
if (params$trace) cat(as.character(Sys.time()), "ComputeStWSLogistic.DP\n\n")
pi_ = NULL
readTime = proc.time()[3]
load(file.path(params$readPathAC, "pi.rdata"))
readSize = file.size(file.path(params$readPathAC, "pi.rdata"))
readTime = proc.time()[3] - readTime
params$pi_ = pi_
W = pi_ * (1 - pi_)
C = rep(list(list()), params$numDataPartners)
idx = params$indicies[[params$dataPartnerID]]
set.seed(params$seed, kind = "Mersenne-Twister")
halfshare = matrix(rnorm(params$n * params$p, sd = 20),
nrow = params$n, ncol = params$p)[, idx, drop = FALSE]
for (id in 1:params$numDataPartners) {
if (id < params$dataPartnerID) {
set.seed(params$seeds[id], kind = "Mersenne-Twister")
idx = params$indicies[[id]]
halfshareDP = matrix(rnorm(params$n * params$ps[id], sd = 20),
nrow = params$n, ncol = params$ps[id])[, idx, drop = FALSE]
C[[id]] = params$scaler / (params$scaler + params$scalers[id]) *
t(halfshareDP) %*% MultiplyDiagonalWTimesX(W, halfshare) +
t(halfshareDP) %*% MultiplyDiagonalWTimesX(W, data$X - halfshare)
} else if (id == params$dataPartnerID) {
C[[id]] = t(data$X) %*% MultiplyDiagonalWTimesX(W, data$X)
} else {
set.seed(params$seeds[id], kind = "Mersenne-Twister")
idx = params$indicies[[id]]
halfshareDP = matrix(rnorm(params$n * params$ps[id], sd = 20),
nrow = params$n, ncol = params$ps[id])[, idx, drop = FALSE]
C[[id]] = params$scaler / (params$scaler + params$scalers[id]) *
t(halfshare) %*% MultiplyDiagonalWTimesX(W, halfshareDP) +
t(data$X - halfshare) %*% MultiplyDiagonalWTimesX(W, halfshareDP)
}
}
writeTime = proc.time()[3]
save(C, file = file.path(params$writePath, "stwsshare.rdata"))
writeSize = file.size(file.path(params$writePath, "stwsshare.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "ComputeStWSLogistic.DP", readTime, readSize, writeTime, writeSize)
return(params)
}
ComputeStWSLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "ComputeStWSLogistic.AC\n\n")
readTime = 0
readSize = 0
C = NULL
W = params$pi_ * (1 - params$pi_)
StWS = matrix(0, sum(params$pReduct), sum(params$pReduct))
for (id1 in 1:params$numDataPartners) {
end = sum(params$pReduct[1:id1])
start = end - params$pReduct[id1] + 1
idx1 = start:end
readTime = readTime - proc.time()[3]
load(file.path(params$readPathDP[id1], "stwsshare.rdata"))
readSize = readSize + file.size(file.path(params$readPathDP[id1], "stwsshare.rdata"))
readTime = readTime + proc.time()[3]
for (id2 in 1:params$numDataPartners) {
end = sum(params$pReduct[1:id2])
start = end - params$pReduct[id2] + 1
idx2 = start:end
if (id1 < id2) {
StWS[idx1, idx2] = StWS[idx1, idx2] + C[[id2]]
StWS[idx2, idx1] = StWS[idx2, idx1] + t(C[[id2]])
} else if (id1 == id2) {
StWS[idx1, idx1] = C[[id1]]
} else {
StWS[idx2, idx1] = StWS[idx2, idx1] + C[[id2]]
StWS[idx1, idx2] = StWS[idx1, idx2] + t(C[[id2]])
}
}
if (id1 < params$numDataPartners) {
for (id2 in (id1 + 1):params$numDataPartners) {
end = sum(params$pReduct[1:id2])
start = end - params$pReduct[id2] + 1
idx2 = start:end
temp = t(params$halfshare[[id1]]) %*% MultiplyDiagonalWTimesX(W, params$halfshare[[id2]])
StWS[idx1, idx2] = StWS[idx1, idx2] + temp
StWS[idx2, idx1] = StWS[idx2, idx1] + t(temp)
}
}
}
I = NULL
tryCatch({I = solve(StWS)},
error = function(err) { I = NULL }
)
if (is.null(I)) {
params$failed = TRUE
params$singularMatrix = TRUE
params$errorMessage =
paste0("The matrix t(X)*W*X is not invertible.\n",
" This may be due to one of two possible problems.\n",
" 1. Poor random initialization of the security matrices.\n",
" 2. Near multicollinearity in the data\n",
"SOLUTIONS: \n",
" 1. Rerun the data analysis.\n",
" 2. If the problem persists, check the variables for\n",
" duplicates for both parties and / or reduce the\n",
" number of variables used. Once this is done,\n",
" rerun the data analysis.")
params = AddToLog(params, "ComputeStWSLogistic.AC", readTime, readSize, 0, 0)
return(params)
}
params$I = I
halfshare = params$halfshare[[1]]
for (id in 2:params$numDataPartners) {
halfshare = cbind(halfshare, params$halfshare[[id]])
}
IDt = I %*% (params$sty - t(halfshare) %*% params$pi_)
Itemp = I
IDttemp = IDt
writeTime = 0
writeSize = 0
start = 1
stop = params$pReduct[1]
for (id in 1:params$numDataPartners) {
I = Itemp[start:stop, , drop = FALSE]
IDt = IDttemp[start:stop, , drop = FALSE]
writeTime = writeTime - proc.time()[3]
save(I, IDt, file = file.path(params$writePath, paste0("ID", id, ".rdata")))
writeSize = writeSize + file.size(file.path(params$writePath, paste0("ID", id, ".rdata")))
writeTime = writeTime + proc.time()[3]
start = stop + 1
stop = stop + params$pReduct[id + 1]
}
params = AddToLog(params, "ComputeStWSLogistic.AC", readTime, readSize, writeTime, writeSize)
return(params)
}
UpdateBetaLogistic.DP = function(params) {
if (params$trace) cat(as.character(Sys.time()), "UpdateBetaLogistic.DP\n\n")
I = IDt = NULL
readTime = proc.time()[3]
load(file.path(params$readPathAC, paste0("ID", params$dataPartnerID, ".rdata")))
readSize = file.size(file.path(params$readPathAC, paste0("ID", params$dataPartnerID, ".rdata")))
readTime = proc.time()[3] - readTime
id = 1
set.seed(params$seeds[id], kind = "Mersenne-Twister")
idx = params$indicies[[id]]
halfshareDP = matrix(rnorm(params$n * params$ps[id], sd = 20),
nrow = params$n, ncol = params$ps[id])[, idx, drop = FALSE]
for (id in 2:params$numDataPartners) {
set.seed(params$seeds[id], kind = "Mersenne-Twister")
idx = params$indicies[[id]]
halfshareDP = cbind(halfshareDP,
matrix(rnorm(params$n * params$ps[id], sd = 20),
nrow = params$n, ncol = params$ps[id])[, idx, drop = FALSE])
}
D0 = t(halfshareDP) %*% params$pi_
deltaBeta = IDt - I %*% D0
params$betas = params$betas + deltaBeta
maxdifference = max(abs(deltaBeta) / (abs(params$betas) + .1))
utemp = sum(runif(length(deltaBeta), min = 1, max = 5) * abs(params$betas))
writeTime = proc.time()[3]
save(utemp, maxdifference, file = file.path(params$writePath, "u_converge.rdata"))
writeSize = file.size(file.path(params$writePath, "u_converge.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "UpdateBetaLogistic.DP", readTime, readSize, writeTime, writeSize)
return(params)
}
ComputeConvergeStatusLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "ComputeConvergeStatusLogistic.AC\n\n")
readTime = 0
readSize = 0
u = 0
converged = TRUE
utemp = NULL
maxdifference = NULL
for (id in 1:params$numDataPartners) {
readTime = readTime - proc.time()[3]
load(file.path(params$readPathDP[id], "u_converge.rdata"))
readSize = readSize + file.size(file.path(params$readPathDP[id], "u_converge.rdata"))
readTime = readTime + proc.time()[3]
u = u + utemp
converged = converged && (maxdifference < params$cutoff)
}
maxIterExceeded = params$algIterationCounter >= params$maxIterations
params$maxIterExceeded = maxIterExceeded
params$u = u
params$converged = converged
writeTime = proc.time()[3]
save(u, converged, maxIterExceeded, file = file.path(params$writePath, "u_converge.rdata"))
writeSize = file.size(file.path(params$writePath, "u_converge.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "ComputeConvergeStatusLogistic.AC", readTime, readSize, writeTime, writeSize)
return(params)
}
GetConvergeStatusLogistic.DP = function(params) {
converged = NULL
if (params$trace) cat(as.character(Sys.time()), "GetconvergeStatusLogistic.DP\n\n")
u = converge = maxIterExceeded = NULL
readTime = proc.time()[3]
load(file.path(params$readPathAC, "u_converge.rdata"))
readSize = file.size(file.path(params$readPathAC, "u_converge.rdata"))
readTime = proc.time()[3] - readTime
params$u = u
params$converged = converged
params$maxIterExceeded = maxIterExceeded
params = AddToLog(params, "GetConvergeStatusLogistic.DP", readTime, readSize, 0, 0)
return(params)
}
SendFinalBetasLogistic.DP = function(params) {
if (params$trace) cat(as.character(Sys.time()), "SendFinalBetasLogistic.DP\n\n")
betas = params$betas
writeTime = proc.time()[3]
save(betas, file = file.path(params$writePath, "finalbetas.rdata"))
writeSize = file.size(file.path(params$writePath, "finalbetas.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "SendFinalBetasLogistic.DP", 0, 0, writeTime, writeSize)
return(params)
}
ComputeFinalSBetaLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "ComputeFinalSBetaLogistic.AC\n\n")
Sbeta = 0
readTime = 0
readSize = 0
sbeta = 0
for (id in 1:params$numDataPartners) {
readTime = readTime - proc.time()[3]
load(file.path(params$readPathDP[id], "sbeta.rdata"))
readSize = readSize + file.size(file.path(params$readPathDP[id], "sbeta.rdata"))
readTime = readTime + proc.time()[3]
sbeta = sbeta + Sbeta
}
sbeta = 2 * params$u * sbeta - params$numDataPartners * params$u
writeTime = proc.time()[3]
save(sbeta, file = file.path(params$writePath, "sbeta.rdata"))
writeSize = file.size(file.path(params$writePath, "sbeta.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "ComputeFinalSBetaLogistic.AC", readTime, readSize, writeTime, writeSize)
return(params)
}
ComputeResultsLogistic.DP = function(params, data) {
if (params$trace) cat(as.character(Sys.time()), "ComputeResultsLogistic.DP\n\n")
sbeta = NULL
readTime = proc.time()[3]
load(file.path(params$readPathAC, "sbeta.rdata"))
readSize = file.size(file.path(params$readPathAC, "sbeta.rdata"))
readTime = proc.time()[3] - readTime
n = params$n
ct = sum(data$Y)
params$FinalFitted = sbeta
resdev = -2 * (sum(data$Y * sbeta) - sum(log(1 + exp(sbeta))))
nulldev = -2 * (ct * log(ct / n) + (n - ct) * log(1 - ct / n))
hoslem = HoslemInternal(params, data)
ROC = RocInternal(params, data)
writeTime = proc.time()[3]
save(resdev, nulldev, hoslem, ROC, file = file.path(params$writePath, "logisticstats.rdata"))
writeSize = file.size(file.path(params$writePath, "logisticstats.rdata"))
writeTime = proc.time()[3] - writeTime
params = AddToLog(params, "ComputeResultsLogistic.DP", readTime, readSize, writeTime, writeSize)
return(params)
}
ComputeResultsLogistic.AC = function(params) {
if (params$trace) cat(as.character(Sys.time()), "ComputeResultsLogistic.AC\n\n")
nulldev = NULL
resdev = NULL
hoslem = NULL
ROC = NULL
readTime = proc.time()[3]
load(file.path(params$readPathDP[1], "logisticstats.rdata"))
readSize = file.size(file.path(params$readPathDP[1], "logisticstats.rdata"))
readTime = proc.time()[3] - readTime
coefficients = c()
p = 0
betas = NULL
for (id in 1:params$numDataPartners) {
readTime = readTime - proc.time()[3]
load(file.path(params$readPathDP[id], "finalbetas.rdata"))
readSize = readSize + file.size(file.path(params$readPathDP[id], "finalbetas.rdata"))
readTime = readTime + proc.time()[3]
coefficients = c(coefficients, betas)
p = p + length(params$indicies[[id]])
}
coefficients[2:p] = coefficients[2:p] / params$colran[2:p]
coefficients[1] = coefficients[1] - sum(coefficients[2:p] * params$colmin[2:p])
serror = rep(0, p)
serror[2:p] = sqrt(diag(params$I)[2:p]) / params$colran[2:p]
d1 = diag(c(1, params$colmin[-1] / params$colran[-1]))
temp = d1 %*% params$I %*% d1
serror[1] = sqrt(temp[1, 1] - 2 * sum(temp[1, 2:p]) + sum(temp[2:p, 2:p]))
stats = params$stats
stats$failed = FALSE
stats$converged = params$converged
stats$party = params$party
stats$coefficients = rep(NA, params$p)
stats$secoef = rep(NA, params$p)
stats$tvals = rep(NA, params$p)
stats$pvals = rep(NA, params$p)
stats$n = params$n
stats$nulldev = nulldev
stats$resdev = resdev
stats$aic = resdev + 2 * sum(params$pReduct)
stats$bic = resdev + sum(params$pReduct) * log(params$n)
stats$nulldev_df = params$n - 1
stats$resdev_df = params$n - sum(params$pReduct)
stats$coefficients[params$fullindicies] = coefficients
stats$secoef[params$fullindicies] = serror
tvals = coefficients / serror
pvals = 2 * pnorm(abs(tvals), lower.tail = FALSE)
stats$tvals[params$fullindicies] = tvals
stats$pvals[params$fullindicies] = pvals
stats$hoslem = hoslem
stats$ROC = ROC
stats$iter = params$algIterationCounter - 1
names(stats$coefficients) = params$colnames
names(stats$party) = params$colnames
names(stats$secoef) = params$colnames
names(stats$tvals) = params$colnames
names(stats$pvals) = params$colnames
writeTime = proc.time()[3]
save(stats, file = file.path(params$writePath, "stats.rdata"))
writeSize = file.size(file.path(params$writePath, "stats.rdata"))
writeTime = proc.time()[3] - writeTime
params$stats = stats
params = AddToLog(params, "ComputeResultsLogistic.AC", readTime, readSize, writeTime, writeSize)
return(params)}
GetResultsLogistic.DP = function(params, data) {
if (params$trace) cat(as.character(Sys.time()), "GetResultsLogistic.DP\n\n")
stats = NULL
readTime = proc.time()[3]
load(file.path(params$readPathAC, "stats.rdata"))
readSize = file.size(file.path(params$readPathAC, "stats.rdata"))
readTime = proc.time()[3] - readTime
if (params$dataPartnerID == 1) {
stats$Y = data$Y
stats$FinalFitted = params$FinalFitted
}
params$stats = stats
params = AddToLog(params, "GetResultsLogistic.DP", readTime, readSize, 0, 0)
return(params)
}
DataPartnerKLogistic = function(data,
yname = NULL,
numDataPartners = NULL,
dataPartnerID = NULL,
monitorFolder = NULL,
sleepTime = 10,
maxWaitingTime = 24 * 60 * 60,
popmednet = TRUE,
trace = FALSE,
verbose = TRUE) {
params = PrepareParams.kp("logistic", dataPartnerID, numDataPartners, ac = FALSE,
popmednet = popmednet, trace = trace, verbose = verbose)
if (params$failed) {
warning(params$errorMessage)
return(invisible(NULL))
}
params = InitializeLog.kp(params)
params = InitializeStamps.kp(params)
params = InitializeTrackingTable.kp(params)
Header(params)
params = PrepareFolder.ACDP(params, monitorFolder)
if (params$failed) {
warning(params$errorMessage)
return(invisible(NULL))
}
if (dataPartnerID == 1) {
data = PrepareDataLinLog.DP1(params, data, yname)
params = AddToLog(params, "PrepareParamsLinLog.DP1", 0, 0, 0, 0)
} else {
data = PrepareDataLinLog.DPk(params, data)
params = AddToLog(params, "PrepareParamsLinLog.DPk", 0, 0, 0, 0)
}
params = AddToLog(params, "PrepareParamsLinear.DP", 0, 0, 0, 0)
if (data$failed) {
params$errorMessage = paste("Error processing data for data partner", params$dataPartnerID, "\n")
MakeErrorMessage(params$writePath, params$errorMessage)
files = "errorMessage.rdata"
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
params$errorMessage = ReadErrorMessage(params$readPathAC)
warning(params$errorMessage)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, waitForTurn = TRUE)
return(params$stats)
}
params = SendBasicInfo.DP(params, data)
files = "n_analysis.rdata"
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
possibleError = ReceivedError.kp(params, from = "AC")
if (possibleError$error) {
params$errorMessage = possibleError$message
warning(possibleError$message)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, waitForTurn = TRUE)
return(params$stats)
}
params = PrepareParamsLinear.DP(params, data)
files = "p_scaler_seed.rdata"
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
params = PrepareSharesLinear.DP(params, data)
files = c("products.rdata", "halfshare.rdata", "colstats.rdata")
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
possibleError = ReceivedError.kp(params, from = "AC")
if (possibleError$error) {
params$errorMessage = possibleError$message
warning(possibleError$message)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, waitForTurn = TRUE)
return(params$stats)
}
params = UpdateParamsLogistic.DP(params)
data = UpdateDataLogistic.DP(params, data)
params = AddToLog(params, "UpdateDataLogistic.DP", 0, 0, 0, 0)
params$algIterationCounter = 1
while (!params$converged && !params$maxIterExceeded) {
BeginningIteration(params)
params = ComputeSbetaLogistic.DP(params, data)
files = "Sbeta.rdata"
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
params = ComputeStWSLogistic.DP(params, data)
files = "stwsshare.rdata"
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
possibleError = ReceivedError.kp(params, from = "AC")
if (possibleError$error) {
params$errorMessage = possibleError$message
warning(possibleError$message)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, waitForTurn = TRUE)
return(params$stats)
}
params = UpdateBetaLogistic.DP(params)
files = "u_converge.rdata"
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
params = GetConvergeStatusLogistic.DP(params)
EndingIteration(params)
params$algIterationCounter = params$algIterationCounter + 1
}
params = ComputeSbetaLogistic.DP(params, data)
params = SendFinalBetasLogistic.DP(params)
files = c("sbeta.rdata", "finalbetas.rdata")
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime, waitForTurn = TRUE)
if (dataPartnerID == 1) {
params = ComputeResultsLogistic.DP(params, data)
files = "logisticstats.rdata"
params = SendPauseContinue.kp(params, filesAC = files, from = "AC",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
}
params = GetResultsLogistic.DP(params, data)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, waitForTurn = TRUE)
return(params$stats)
}
AnalysisCenterKLogistic = function(numDataPartners = NULL,
monitorFolder = NULL,
msreqid = "v_default_0_000",
cutoff = 1E-8,
maxIterations = 25,
sleepTime = 10,
maxWaitingTime = 24 * 60 * 60,
popmednet = TRUE,
trace = FALSE,
verbose = TRUE) {
filesList = rep(list(list()), numDataPartners)
params = PrepareParams.kp("logistic", 0, numDataPartners, msreqid, cutoff, maxIterations, ac = TRUE,
popmednet = popmednet, trace = trace, verbose = verbose)
if (params$failed) {
warning(params$errorMessage)
return(invisible(NULL))
}
params = InitializeLog.kp(params)
params = InitializeStamps.kp(params)
params = InitializeTrackingTable.kp(params)
Header(params)
params = PrepareFolder.ACDP(params, monitorFolder)
if (params$failed) {
warning(params$errorMessage)
return(invisible(NULL))
}
params = PauseContinue.kp(params, from = "DP", maxWaitingTime = maxWaitingTime)
possibleError = ReceivedError.kp(params, from = "DP")
if (possibleError$error) {
params$errorMessage = possibleError$message
warning(possibleError$message)
MakeErrorMessage(params$writePath, possibleError$message)
files = "errorMessage.rdata"
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, job_failed = TRUE)
SummarizeLog.kp(params)
return(params$stats)
}
params = CheckAgreement.AC(params)
if (params$failed) {
MakeErrorMessage(params$writePath, params$errorMessage)
files = "errorMessage.rdata"
warning(params$errorMessage)
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, job_failed = TRUE)
SummarizeLog.kp(params)
return(params$stats)
}
files = "empty.rdata"
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = GetProductsLogistic.AC(params)
params = CheckColinearityLogistic.AC(params)
if (params$failed) {
MakeErrorMessage(params$writePath, params$errorMessage)
files = "errorMessage.rdata"
warning(params$errorMessage)
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, job_failed = TRUE)
SummarizeLog.kp(params)
return(params$stats)
}
params = ComputeInitialBetasLogistic.AC(params)
for (id in 1:numDataPartners) {
filesList[[id]] = c(paste0("u_beta_", id, ".rdata"), "indicies.rdata")
}
params = SendPauseContinue.kp(params, filesDP = filesList, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params$algIterationCounter = 1
while (!params$converged && !params$maxIterExceeded) {
BeginningIteration(params)
params = ComputeWeightsLogistic.AC(params)
files = "pi.rdata"
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = ComputeStWSLogistic.AC(params)
if (params$failed) {
MakeErrorMessage(params$writePath, params$errorMessage)
files = "errorMessage.rdata"
warning(params$errorMessage)
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = SendPauseQuit.kp(params, sleepTime = sleepTime, job_failed = TRUE)
SummarizeLog.kp(params)
return(params$stats)
}
for (id in 1:numDataPartners) {
filesList[[id]] = paste0("id", id, ".rdata")
}
params = SendPauseContinue.kp(params, filesDP = filesList, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = ComputeConvergeStatusLogistic.AC(params)
files = "u_converge.rdata"
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
EndingIteration(params)
params$algIterationCounter = params$algIterationCounter + 1
}
params = ComputeFinalSBetaLogistic.AC(params)
filesList = rep(list(list()), numDataPartners)
filesList[[1]] = "sbeta.rdata"
params = SendPauseContinue.kp(params, filesDP = filesList, from = "DP1",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = ComputeResultsLogistic.AC(params)
files = "stats.rdata"
params = SendPauseContinue.kp(params, filesDP = files, from = "DP",
sleepTime = sleepTime, maxWaitingTime = maxWaitingTime)
params = SendPauseQuit.kp(params, sleepTime = sleepTime)
SummarizeLog.kp(params)
return(params$stats)
}
|
setGeneric("buildPairwiseComparisonMatrix",
function(listOfMatrices) standardGeneric("buildPairwiseComparisonMatrix"))
setMethod(
f="buildPairwiseComparisonMatrix",
signature(listOfMatrices = "list"),
definition=function(listOfMatrices)
{
number = length(listOfMatrices)
size = nrow(listOfMatrices[[1]]@values)
for(i in 1:number){
if (class(listOfMatrices[[i]]) != "PairwiseComparisonMatrix"){
stop(paste0("Element on position ", i, " is not of class PairwiseComparisonMatrix. Its type is ", class(listOfMatrices[[i]]), "."))
}
if (dim(listOfMatrices[[1]]@values)[1] != dim(listOfMatrices[[i]]@values)[1] &&
dim(listOfMatrices[[1]]@values)[2] != dim(listOfMatrices[[i]]@values)[2]){
stop(paste0("PairwiseComparisonMatrices do not have the same sizes: [", dim(listOfMatrices[[1]]@values)[1], ",",
dim(listOfMatrices[[1]]@values)[2], "] != [", dim(listOfMatrices[[i]]@values)[1], ",",
dim(listOfMatrices[[1]]@values)[2], "]."))
}
}
resultMatrix = listOfMatrices[[1]]@values
for (i in 1:size){
for (j in 1:size){
vector = c()
for (k in 1:number){
vector = c(vector, listOfMatrices[[k]]@values[i, j])
}
resultMatrix[i, j] = prod(vector)^(1/number)
}
}
textMatrix = .textMatrixRepresentation(resultMatrix)
return(new("PairwiseComparisonMatrix", valuesChar = textMatrix, values = resultMatrix,
variableNames = listOfMatrices[[1]]@variableNames))
}
)
|
waterfall <- function(xgb_model, new_observation, data, type = "binary", option = "interactions", baseline = 0){
Feature <- intercept <- NULL
col_names <- colnames(new_observation)
trees = xgb.model.dt.tree(col_names, model = xgb_model)
if (option == "interactions") {
tree_list = getStatsForTreesInter(trees, type, base_score = .5)
}
if (option == "variables") {
tree_list = getStatsForTrees(trees, type, base_score = .5)
}
explainer = buildExplainerFromTreeList(tree_list,names(table(rbindlist(tree_list)[,Feature])))
new_observation_DM <- slice(xgb.DMatrix(t(new_observation)), as.integer(1))
breakdown = explainPredictions(xgb_model, explainer, new_observation_DM)
df <- as.data.frame(breakdown)
for (i in colnames(data)) {
indexVariable <- grepl(i, colnames(df)) & !(grepl("\\:", colnames(df)))
if (length(which(indexVariable)) > 1) {
df[, i] = sum(df[, indexVariable])
new_observation[i] <- as.data.frame(data)[, i]
ix <- which(names(new_observation) %in% names(df[, indexVariable]))
new_observation <- new_observation[-ix]
df <- df[, !(indexVariable)]
}
if (length(which(indexVariable)) == 1) {
new_observation[i] <- as.data.frame(data)[, i]
if (i != colnames(df)[indexVariable]) {
df[, i] <- df[, indexVariable]
df <- df[, !(indexVariable)]
}
}
indexInter <- grepl(i, colnames(df)) & (grepl("\\:", colnames(df)))
if (length(which(indexInter)) > 1) {
indexInter1 <- grepl(i, colnames(df)) & (grepl("\\:", colnames(df))) &
(unlist(lapply(gregexpr(pattern = i, colnames(df)), `[[`, 1)) < unlist(lapply(gregexpr(pattern = ":", colnames(df)), `[[`, 1)))
child <- map(strsplit(colnames(df[, indexInter1, drop = FALSE]), "[:]"), 2)
colnames(df)[indexInter1] <- paste(i, child, sep = ":")
indexInter2 <- grepl(i, colnames(df)) & (grepl("\\:", colnames(df)))&
(!(unlist(lapply(gregexpr(pattern = i, colnames(df)), `[[`, 1)) < unlist(lapply(gregexpr(pattern = ":", colnames(df)), `[[`, 1))))
parent <- map(strsplit(colnames(df[, indexInter2, drop = FALSE]), "[:]"), 1)
colnames(df)[indexInter2] <- paste(parent, i, sep = ":")
}
}
prefixes = unique(gsub("\\.+[1-9]", "", colnames(df[, grepl("\\:", colnames(df))])))
interactions <- sapply(prefixes, function(x)sum(df[, startsWith(colnames(df), x)]))
single <- as.vector(t(df[, !grepl("\\:", colnames(df))]))
names(single) <- colnames(df[, !grepl("\\:", colnames(df))])
breakdown <- c(interactions, single)
ilabels <- grep(names(breakdown), pattern = ":", value = TRUE)
for (interact in ilabels) {
vars <- strsplit(interact, split = ":")[[1]]
new_observation[interact] <- paste0(new_observation[vars],collapse = ":")
}
breakdown <- data.table(t(breakdown))
df_intercept <- breakdown[,intercept]
breakdown <- breakdown[,`:=`(intercept = NULL, Leaf = NULL)]
df <- data.frame(
variable = paste(colnames(breakdown), "=",
sapply(new_observation[colnames(breakdown)], as.character)),
contribution = as.numeric(breakdown),
variable_name = colnames(breakdown),
variable_value = sapply(new_observation[colnames(breakdown)], as.character)
)[as.numeric(breakdown) != 0, ]
df <- df[order(abs(df[, 2]), decreasing = TRUE), ]
broken_sorted <- as.data.frame(df)
if (tolower(baseline) == "intercept"){
baseline <- df_intercept
}else{
broken_sorted <- rbind(
data.frame(variable = "intercept",
contribution = df_intercept - baseline,
variable_name = "intercept",
variable_value = 1),
broken_sorted)
}
create.broken(broken_sorted, baseline)
}
create.broken <- function(broken_intercept, baseline = 0) {
broken_cumm <- data.frame(broken_intercept,
cumulative = cumsum(as.numeric(broken_intercept$contribution)),
sign = factor(sign(as.numeric(broken_intercept$contribution)), levels = c(-1, 0, 1)),
position = length(broken_intercept$variable) - seq_along(broken_intercept$variable) + 2,
label = rep("xgboost", nrow(broken_intercept)))
broken_cumm <- rbind(broken_cumm,
data.frame(variable = "prediction",
contribution = sum(broken_cumm$contribution),
variable_name = "",
variable_value = "",
cumulative = sum(broken_cumm$contribution),
sign = "X",
position = 1,
label = "xgboost"))
attr(broken_cumm, "baseline") <- baseline
class(broken_cumm) <- c("break_down", "data.frame")
broken_cumm
}
getStatsForTreesInter = function(trees,type = "binary", base_score = 0.5) {
leaf <- Feature <- H <- Cover <- Yes <- No <- ID <-
weight <- Quality <- previous_weight <- G <- parentsCover <-
name_pair <- childsGain <- uplift_weight <- parentsGain <-
parentsName <- NULL
treeList = copy(trees)
treeList[, leaf := Feature == 'Leaf']
treeList[, H := Cover]
non.leaves = which(treeList[, leaf] == F)
j = 0
for (i in rev(non.leaves)) {
left = treeList[i, Yes]
right = treeList[i, No]
treeList[i, H := treeList[ID == left, H] + treeList[ID == right, H]]
j = j + 1
}
if (type == 'regression') {
base_weight = base_score
} else{
base_weight = log(base_score / (1 - base_score))
}
treeList[leaf == T, weight := base_weight + Quality]
treeList[, previous_weight := base_weight]
treeList[1, previous_weight := 0]
treeList[leaf == T, G := -weight * H]
treeList = split(treeList, as.factor(treeList$Tree))
num_treeList = length(treeList)
treenums = as.character(0:(num_treeList - 1))
for (tree in treeList) {
num_nodes = nrow(tree)
non_leaf_rows = rev(which(tree[, leaf] == F))
for (r in non_leaf_rows) {
left = tree[r, Yes]
right = tree[r, No]
leftG = tree[ID == left, G]
rightG = tree[ID == right, G]
tree[r, G := leftG + rightG]
w = tree[r, -G / H]
tree[r, weight := w]
tree[ID == left, previous_weight := w]
tree[ID == right, previous_weight := w]
if (tree[ID == left, leaf] == F) {
tree[ID == left, `:=`(parentsGain = tree[r, Quality], parentsName = tree[r, Feature])]
tree[ID == left, parentsCover := tree[r, Cover]]
name_pair4 = paste(tree[r, Feature], tree[ID == left, Feature], sep = ":")
tree[ID == left, name_pair := name_pair4]
tree[ID == left, childsGain := Quality]
}
if (tree[ID == right, leaf] == F) {
tree[ID == right, `:=`(parentsGain = tree[r, Quality], parentsName = tree[r, Feature])]
tree[ID == right, parentsCover := tree[r, Cover]]
name_pair1 = paste(tree[r, Feature], tree[ID == right, Feature], sep = ":")
tree[ID == right, name_pair := name_pair1]
tree[ID == right, childsGain := Quality]
}
}
tree[, uplift_weight := weight - previous_weight]
tree[, interaction := ((parentsGain < childsGain) &
(Feature != parentsName))]
tree[interaction == TRUE, Feature := name_pair]
}
return (treeList)
}
getStatsForTrees = function(trees, nodes.train,type = "binary", base_score = 0.5) {
leaf <- Feature <- H <- Cover <- Yes <- No <- ID <-
weight <- Quality <- previous_weight <- G <- uplift_weight <- NULL
tree_list = copy(trees)
tree_list[, leaf := Feature == 'Leaf']
tree_list[, H := Cover]
non.leaves = which(tree_list[, leaf] == F)
for (i in rev(non.leaves)) {
left = tree_list[i, Yes]
right = tree_list[i, No]
tree_list[i, H := tree_list[ID == left, H] + tree_list[ID == right, H]]
}
if (type == 'regression') {
base_weight = base_score
} else{
base_weight = log(base_score / (1 - base_score))
}
tree_list[leaf == T, weight := base_weight + Quality]
tree_list[, previous_weight := base_weight]
tree_list[1, previous_weight := 0]
tree_list[leaf == T, G := -weight * H]
tree_list = split(tree_list, as.factor(tree_list$Tree))
num_tree_list = length(tree_list)
treenums = as.character(0:(num_tree_list - 1))
for (tree in tree_list) {
num_nodes = nrow(tree)
non_leaf_rows = rev(which(tree[, leaf] == F))
for (r in non_leaf_rows) {
left = tree[r, Yes]
right = tree[r, No]
leftG = tree[ID == left, G]
rightG = tree[ID == right, G]
tree[r, G := leftG + rightG]
w = tree[r, -G / H]
tree[r, weight := w]
tree[ID == left, previous_weight := w]
tree[ID == right, previous_weight := w]
}
tree[, uplift_weight := weight - previous_weight]
}
return (tree_list)
}
buildExplainerFromTreeList = function(tree_list, col_names) {
tree_list_breakdown <- vector("list", length(col_names) + 3)
names(tree_list_breakdown) = c(col_names, 'intercept', 'leaf', 'tree')
num_trees = length(tree_list)
for (x in 1:num_trees) {
tree = tree_list[[x]]
tree_breakdown = getTreeBreakdown(tree, col_names)
tree_breakdown$tree = x - 1
tree_list_breakdown = rbindlist(append(list(tree_list_breakdown), list(tree_breakdown)))
}
return (tree_list_breakdown)
}
getTreeBreakdown = function(tree, col_names) {
Node <- NULL
tree_breakdown <- vector("list", length(col_names) + 2)
names(tree_breakdown) = c(col_names, 'intercept', 'leaf')
leaves = tree[leaf == T, Node]
for (leaf in leaves) {
leaf_breakdown = getLeafBreakdown(tree, leaf, col_names)
leaf_breakdown$leaf = leaf
tree_breakdown = rbindlist(append(list(tree_breakdown), list(leaf_breakdown)))
}
return (tree_breakdown)
}
getLeafBreakdown = function(tree, leaf, col_names) {
Node <- Feature <- . <- uplift_weight <- NULL
impacts = as.list(rep(0, length(col_names)))
names(impacts) = col_names
path = findPath(tree, leaf)
reduced_tree = tree[Node %in% path, .(Feature, uplift_weight)]
impacts$intercept = reduced_tree[1, uplift_weight]
reduced_tree[, uplift_weight := shift(uplift_weight, type = 'lead')]
tmp = reduced_tree[, .(sum = sum(uplift_weight)), by = Feature]
tmp = tmp[-nrow(tmp)]
impacts[tmp[, Feature]] = tmp[, sum]
return (impacts)
}
findPath = function(tree, currentnode, path = c()) {
Node <- Yes <- No <- ID <- NULL
while (currentnode > 0) {
path = c(path, currentnode)
currentlabel = tree[Node == currentnode, ID]
currentnode = c(tree[Yes == currentlabel, Node], tree[No == currentlabel, Node])
}
return (sort(c(path, 0)))
}
explainPredictions = function(xgb_model, explainer , data) {
tree <- NULL
nodes = predict(xgb_model, data, predleaf = TRUE)
colnames = names(explainer)[1:(ncol(explainer) - 2)]
preds_breakdown = data.table(matrix(0, nrow = nrow(nodes), ncol = length(colnames)))
setnames(preds_breakdown, colnames)
num_trees = ncol(nodes)
for (x in 1:num_trees) {
nodes_for_tree = nodes[, x]
tree_breakdown = explainer[tree == x - 1]
preds_breakdown_for_tree = tree_breakdown[match(nodes_for_tree, tree_breakdown$leaf), ]
preds_breakdown = preds_breakdown + preds_breakdown_for_tree[, colnames, with =
FALSE]
}
return (preds_breakdown)
}
|
msr.4thcorner <- function(x, listwORorthobasis, phyloORorthobasis, nrepet = x$npermut, method = c("pair", "triplet", "singleton"), ...){
appel <- as.list(x$call)
L <- eval.parent(appel$tabL)
R <- eval.parent(appel$tabR)
if(any(!apply(R, 2, is.numeric)))
stop("Not implemented: table R contains non-numeric variables")
Q <- eval.parent(appel$tabQ)
if(any(!apply(Q, 2, is.numeric)))
stop("Not implemented: table Q contains non-numeric variables")
if(missing(listwORorthobasis)){
Rmsr <- replicate(nrepet, R[sample(nrow(R)),, drop = FALSE], simplify = FALSE)
} else {
Rmsr <- msr(R, listwORorthobasis, nrepet = nrepet, method = method, simplify = FALSE, ...)
}
if(missing(phyloORorthobasis)){
Qmsr <- replicate(nrepet, Q[sample(nrow(Q)),, drop = FALSE], simplify = FALSE)
} else {
if (inherits(phyloORorthobasis, "phylo"))
phyloORorthobasis <- me.phylo(phyloORorthobasis)
Qmsr <- msr(Q, phyloORorthobasis, nrepet = nrepet, method = method, simplify = FALSE, ...)
}
func.4th <- as.character(appel[[1]])
if(func.4th == "fourthcorner")
elems <- c("tabD", "tabD2", "tabG")
else
stop(paste("Not yet implemented for", func.4th))
test.Rrand <- lapply(Rmsr, function(x) do.call(func.4th, list(tabR = as.data.frame(x),
tabL = L, tabQ = Q , modeltype = 2, nrepet = 0)))
test.Qrand <- lapply(Qmsr, function(x) do.call(func.4th, list(tabR = R,
tabL = L, tabQ = as.data.frame(x) , modeltype = 2, nrepet = 0)))
res.R <- vector(mode = "list", length = length(elems))
for(i in 1:length(elems))
res.R[[i]] <- matrix(NA, nrepet, length(test.Rrand[[1]][[elems[i]]]$obs))
names(res.R) <- elems
res.Q <- res.R
for(i in 1:nrepet){
for(j in elems){
res.R[[j]][i,] <- test.Rrand[[i]][[j]]$obs
res.Q[[j]][i,] <- test.Qrand[[i]][[j]]$obs
}
}
fc.R <- fc.Q <- x
for(j in elems){
if(inherits(x[[j]], "krandtest")){
output <- ifelse(inherits(x[[j]], "lightkrandtest"), "light", "full")
fc.R[[j]] <- as.krandtest(sim = res.R[[j]], obs = x[[j]]$obs,
alter = x[[j]]$alter, call = match.call(), names = x[[j]]$names,
p.adjust.method = x[[j]]$adj.method, output = output)
fc.Q[[j]] <- as.krandtest(sim = res.Q[[j]], obs = x[[j]]$obs,
alter = x[[j]]$alter, call = match.call(), names = x[[j]]$names,
p.adjust.method = x[[j]]$adj.method, output = output)
fc.Q[[j]]$statnames <- fc.R[[j]]$statnames <- x[[j]]$statnames
}
}
res <- combine.4thcorner(fc.R, fc.Q)
res$call <- match.call()
res$npermut <- nrepet
res$model <- "msr"
return(res)
}
|
get_oc_BOIN <- function (target, p.true, ncohort, cohortsize, n.earlystop = 100,
startdose = 1, p.saf = 0.6 * target, p.tox = 1.4 * target,
cutoff.eli = 0.95,
extrasafe = FALSE, offset = 0.05, ntrial, seed = 100)
{
if (target < 0.05) {
stop("The target is too low! \n")
return()
}
if (target > 0.6) {
stop("The target is too high! \n")
return()
}
if ((target - p.saf) < (0.1 * target)) {
stop("The probability deemed safe cannot be higher than or too close to the target! \n")
return()
}
if ((p.tox - target) < (0.1 * target)) {
stop("The probability deemed toxic cannot be lower than or too close to the target! \n")
return()
}
if (offset >= 0.5) {
stop("The offset is too large! \n")
return()
}
if (n.earlystop <= 6) {
warning("The value of n.earlystop is too low to ensure good operating characteristics. Recommend n.earlystop = 9 to 18 \n")
return()
}
set.seed(seed)
ndose = length(p.true)
npts = ncohort * cohortsize
Y = matrix(rep(0, ndose * ntrial), ncol = ndose)
N = matrix(rep(0, ndose * ntrial), ncol = ndose)
dselect = rep(0, ntrial)
temp = get_boundary_BOIN(target, ncohort, cohortsize, n.earlystop,
p.saf, p.tox, cutoff.eli, extrasafe, print = FALSE)
b.e = temp[2, ]
b.d = temp[3, ]
b.elim = temp[4, ]
for (trial in 1:ntrial) {
y <- rep(0, ndose)
n <- rep(0, ndose)
earlystop = 0
d = startdose
elimi = rep(0, ndose)
while(sum(n)<cohortsize*ncohort){
y[d] = y[d] + sum(runif(cohortsize) < p.true[d])
n[d] = n[d] + cohortsize
if (n[d] >= n.earlystop)
break
if (!is.na(b.elim[n[d]])) {
if (y[d] >= b.elim[n[d]]) {
elimi[d:ndose] = 1
if (d == 1) {
earlystop = 1
break
}
}
if (extrasafe) {
if (d == 1 && n[1] >= 3) {
if (1 - pbeta(target, y[1] + 1, n[1] - y[1] +
1) > cutoff.eli - offset) {
earlystop = 1
break
}
}
}
}
if (y[d] <= b.e[n[d]] && d != ndose) {
if (elimi[d + 1] == 0&&n[d]>=2) d = d + 1 else d=d
}
else if (y[d] >= b.d[n[d]] && d != 1) {
d = d - 1
}
else {
d = d
}
}
Y[trial, ] = y
N[trial, ] = n
if (earlystop == 1) {
dselect[trial] = 99
}
else {
dselect[trial] = select_mtd_BOIN(target, n, y, cutoff.eli,
extrasafe, offset, print = FALSE)
}
}
selpercent = rep(0, ndose)
nptsdose = apply(N, 2, mean)
ntoxdose = apply(Y, 2, mean)
for (i in 1:ndose) {
selpercent[i] = sum(dselect == i)/ntrial * 100
}
message("selection percentage at each dose level (%):\n")
message(formatC(selpercent, digits = 1, format = "f"), sep = " ",
"\n")
message("number of patients treated at each dose level:\n")
message(formatC(nptsdose, digits = 1, format = "f"), sep = " ",
"\n")
message("number of toxicity observed at each dose level:\n")
message(formatC(ntoxdose, digits = 1, format = "f"), sep = " ",
"\n")
message("average number of toxicities:", formatC(sum(Y)/ntrial,
digits = 1, format = "f"), "\n")
message("average number of patients:", formatC(sum(N)/ntrial,
digits = 1, format = "f"), "\n")
message("percentage of early stopping due to toxicity:", formatC(sum(dselect ==
99)/ntrial * 100, digits = 1, format = "f"), "% \n")
if (length(which(p.true == target)) > 0) {
if (which(p.true==target)==1){underdosing60 =underdosing80 =0}
if (which(p.true==target)==2){underdosing60=mean(N[,1] > 0.6*npts)*100;underdosing80=mean(N[,1] > 0.8*npts)*100}
if (which(p.true==target)>=3){
if(dim(N)[1]>1){
underdosing60=mean(rowSums(N[,1:(which(p.true==target)-1)])> 0.6*npts)* 100;underdosing80=mean(rowSums(N[,1:(which(p.true==target)-1)])> 0.8*npts)* 100;
}else{
underdosing60=mean(sum(N[,1:(which(p.true==target)-1)])> 0.6*npts)* 100;underdosing80=mean(sum(N[,1:(which(p.true==target)-1)])> 0.8*npts)* 100;
}
}
if (which(p.true == target) == ndose - 1) {
overdosing60 = mean(N[, p.true > target] > 0.6 *
npts) * 100
overdosing80 = mean(N[, p.true > target] > 0.8 *
npts) * 100
}
else {
if(ntrial==1){
overdosing60 = mean(sum(N[, p.true > target]) >
0.6 * npts) * 100
overdosing80 = mean(sum(N[, p.true > target]) >
0.8 * npts) * 100
}else{
overdosing60 = mean(rowSums(N[, p.true > target]) >
0.6 * npts) * 100
overdosing80 = mean(rowSums(N[, p.true > target]) >
0.8 * npts) * 100
}
}
message("risk of poor allocation:", formatC(mean(N[, p.true ==
target] < npts/ndose) * 100, digits = 1, format = "f"),
"% \n")
message("risk of overdosing (>60% of patients treated above the MTD):",
formatC(overdosing60, digits = 1, format = "f"),
"% \n")
message("risk of overdosing (>80% of patients treated above the MTD):",
formatC(overdosing80, digits = 1, format = "f"),
"% \n")
message("risk of underdosing (>60% of patients treated under the MTD):",
formatC(underdosing60, digits = 1, format = "f"),
"% \n")
message("risk of underdosing (>80% of patients treated under the MTD):",
formatC(underdosing80, digits = 1, format = "f"),
"% \n")
}
if (length(which(p.true == target)) > 0) {
list(target = target, p.true = p.true,
ncohort = ncohort, cohortsize = cohortsize, startdose = startdose,
p.saf = p.saf, p.tox = p.tox, cutoff.eli = cutoff.eli,
extrasafe = extrasafe, offset = offset, ntrial = ntrial,
dose = 1:ndose, selpercent = selpercent, nptsdose = nptsdose,
ntoxdose = ntoxdose, totaltox = sum(Y)/ntrial, totaln = sum(N)/ntrial,
pctearlystop = sum(dselect == 99)/ntrial * 100, overdose60 = overdosing60,
overdose80 = overdosing80, underdose60 = underdosing60, underdose80=underdosing80)
}
else {
list(target = target, p.true = p.true,
ncohort = ncohort, cohortsize = cohortsize, startdose = startdose,
p.saf = p.saf, p.tox = p.tox, cutoff.eli = cutoff.eli,
extrasafe = extrasafe, offset = offset, ntrial = ntrial,
dose = 1:ndose, selpercent = selpercent, nptsdose = nptsdose,
ntoxdose = ntoxdose, totaltox = sum(Y)/ntrial, totaln = sum(N)/ntrial,
pctearlystop = sum(dselect == 99)/ntrial * 100,overdose60 = overdosing60,
overdose80 = overdosing80, underdose60 = underdosing60, underdose80=underdosing80)
}
}
|
sdiag <- function(x){ if(length(x)<2L) matrix(x) else diag(x) }
|
X = gen_data(n = 300, types = rep("tru", 5))$X
start_time = proc.time()
R_nc_org = latentcor(X = X, types = "tru", method = "original")$R
proc.time() - start_time
start_time = proc.time()
R_nc_approx = latentcor(X = X, types = "tru", method = "approx")$R
proc.time() - start_time
Heatmap_R_nc_approx = latentcor(X = X, types = "tru", method = "approx",
showplot = TRUE)$plotR
X = gen_data()$X
R_nc_org = latentcor(X = X, types = c("ter", "con"), method = "original")$R
R_nc_approx = latentcor(X = X, types = c("ter", "con"), method = "approx")$R
|
slidify_vec <- function(.x, .f, ..., .period = 1, .align = c("center", "left", "right"), .partial = FALSE) {
if (!is.numeric(.x)) rlang::abort("Non-numeric data detected. 'x' must be numeric.")
roll_to_slide(
.slider_fun = slider::slide_vec,
.x = .x,
.period = .period,
.f = .f,
...,
.align = .align,
.partial = .partial
)
}
roll_to_slide <- function(.slider_fun, ..., .period = 1, .align = c("center", "left", "right"), .partial = FALSE) {
.align <- .align[1]
if (.align == "center") {
split_period <- (.period - 1) / 2
before <- floor(split_period)
after <- ceiling(split_period)
} else if (.align == "left") {
before <- 0
after <- .period - 1
} else {
before <- .period - 1
after <- 0
}
vec <- .slider_fun(
...,
.before = before,
.after = after,
.step = 1L,
.complete = FALSE
)
if (!.partial) {
if (before > 0) vec[1:before] <- NA
if (after > 0) vec[(length(vec) - after + 1):length(vec)] <- NA
}
return(vec)
}
|
vcov.diffIRT = function (object, ...) {
if (is.null(object$hessian))
stop("to obtain the covariance matrix of the parameter estimates, you should re-fit the model using 'se = TRUE'.\n")
covmat <- solve(object$hessian)
covmat
}
|
genweibulldata <- function(sample_size, scale1, hazard_ratio, common_shape, censor_value) {
scale2 <- exp(log(scale1) - (1/common_shape) * log(hazard_ratio))
time1 <- stats::rweibull(sample_size, shape = common_shape, scale = scale1)
time2 <- stats::rweibull(sample_size, shape = common_shape, scale = scale2)
if (!is.null(censor_value) == TRUE) {
test1 <- (time1 > censor_value)
test2 <- (time2 > censor_value)
status1 <- rep(1, sample_size)
status2 <- rep(1, sample_size)
time1[test1] <- censor_value
time2[test2] <- censor_value
status1[test1] <- 0
status2[test2] <- 0
}
if (is.null(censor_value) == TRUE) {
status1 <- rep(1, sample_size)
status2 <- rep(1, sample_size)
}
subjid <- seq(from = 1, to = 2 * sample_size)
trt <- c(rep(0, sample_size), rep(1, sample_size))
time <- c(time1, time2)
status <- c(status1, status2)
gendata <- data.frame(subjid, trt, time, status)
colnames(gendata) <- c("id", "treatment", "event_time", "status")
return(gendata)
}
weibullloglike <- function(params, randdata, histdata, a0) {
beta0 <- params[1]
beta1 <- params[2]
v <- params[3]
b_i <- exp((-1 * beta0/v) + (-1 * beta1/v) * randdata$treatment)
ll_r <- randdata$status * stats::dweibull(randdata$event_time, shape = v, scale = b_i, log = TRUE) + (1 - randdata$status) *
stats::pweibull(randdata$event_time, shape = v, scale = b_i, log.p = TRUE, lower.tail = FALSE)
bh_i <- exp(-1 * beta0/v)
ll_h <- histdata$status * stats::dweibull(histdata$event_time, shape = v, scale = bh_i, log = TRUE) + (1 - histdata$status) *
stats::pweibull(histdata$event_time, shape = v, scale = bh_i, log.p = TRUE, lower.tail = FALSE)
ll <- sum(ll_r) + a0 * sum(ll_h)
return(-ll)
}
weibullloglikenohist <- function(params, randdata) {
beta0 <- params[1]
beta1 <- params[2]
v <- params[3]
b_i <- exp((-1 * beta0/v) + (-1 * beta1/v) * randdata$treatment)
ll_r <- randdata$status * stats::dweibull(randdata$event_time, shape = v, scale = b_i, log = TRUE) + (1 - randdata$status) *
stats::pweibull(randdata$event_time, shape = v, scale = b_i, log.p = TRUE, lower.tail = FALSE)
return(sum(-ll_r))
}
weibulltrialsimulator <- function(sample_size_val, histdata, scale1_val, hazard_ratio_val, common_shape_val, censor_value,
a0_val, alpha) {
sampleranddata <- genweibulldata(sample_size = sample_size_val, scale1 = scale1_val, hazard_ratio = hazard_ratio_val,
common_shape = common_shape_val, censor_value = censor_value)
if (sum(sampleranddata$event_time == censor_value) == dim(sampleranddata)[1]) {
stop("Simulated trial data must have at least one observation that is not right censored.")
}
initializemodel <- survival::survreg(survival::Surv(event_time, status) ~ treatment, dist = "weibull", data = sampleranddata)
initialbeta0 <- -1 * initializemodel$coefficients[1]/initializemodel$scale
initialbeta1 <- -1 * initializemodel$coefficients[2]/initializemodel$scale
initialv <- 1/initializemodel$scale
fitmod <- stats::optim(c(initialbeta0, initialbeta1, initialv), weibullloglike, randdata = sampleranddata, histdata = histdata,
a0 = a0_val, method = "Nelder-Mead", hessian = TRUE)
modparm <- fitmod$par
covarmat <- solve(fitmod$hessian)
weibullloghazard_ratio <- modparm[2]
weibullhazard_ratio <- exp(weibullloghazard_ratio)
lower_weibullhazard_ratio <- exp(weibullloghazard_ratio - stats::qnorm(1 - alpha/2) * sqrt(covarmat[2, 2]))
upper_weibullhazard_ratio <- exp(weibullloghazard_ratio + stats::qnorm(1 - alpha/2) * sqrt(covarmat[2, 2]))
reject <- ifelse(((lower_weibullhazard_ratio > 1) | (upper_weibullhazard_ratio < 1)), 1, 0)
output <- c(weibullhazard_ratio, covarmat[2, 2], reject)
names(output) <- c("hazard_ratio", "loghazard_ratio_var", "reject")
return(output)
}
weibulltrialsimulatornohist <- function(sample_size_val, scale1_val, hazard_ratio_val, common_shape_val, censor_value,
alpha) {
sampleranddata <- genweibulldata(sample_size = sample_size_val, scale1 = scale1_val, hazard_ratio = hazard_ratio_val,
common_shape = common_shape_val, censor_value = censor_value)
if (sum(sampleranddata$event_time == censor_value) == dim(sampleranddata)[1]) {
stop("Simulated trial data must have at least one observation that is not right censored.")
}
initializemodel <- survival::survreg(survival::Surv(event_time, status) ~ treatment, dist = "weibull", data = sampleranddata)
initialbeta0 <- -1 * initializemodel$coefficients[1]/initializemodel$scale
initialbeta1 <- -1 * initializemodel$coefficients[2]/initializemodel$scale
initialv <- 1/initializemodel$scale
fitmod <- stats::optim(c(initialbeta0, initialbeta1, initialv), weibullloglikenohist, randdata = sampleranddata, method = "Nelder-Mead",
hessian = TRUE)
modparm <- fitmod$par
covarmat <- solve(fitmod$hessian)
weibullloghazard_ratio <- modparm[2]
weibullhazard_ratio <- exp(weibullloghazard_ratio)
lower_weibullhazard_ratio <- exp(weibullloghazard_ratio - stats::qnorm(1 - alpha/2) * sqrt(covarmat[2, 2]))
upper_weibullhazard_ratio <- exp(weibullloghazard_ratio + stats::qnorm(1 - alpha/2) * sqrt(covarmat[2, 2]))
reject <- ifelse(((lower_weibullhazard_ratio > 1) | (upper_weibullhazard_ratio < 1)), 1, 0)
output <- c(weibullhazard_ratio, covarmat[2, 2], reject)
names(output) <- c("hazard_ratio", "loghazard_ratio_var", "reject")
return(output)
}
weibull_sim <- function(trial_reps=100, subj_per_arm, a0_vals, effect_vals,
rand_control_diff, hist_control_data, censor_value,
alpha=0.05, get_var=FALSE, get_bias=FALSE,
get_mse=FALSE, quietly=TRUE) {
histdata = hist_control_data
hist_model <- survival::survreg(survival::Surv(event_time, status) ~ 1, dist = "weibull", data = histdata)
bparm_histc <- exp(hist_model$coefficients)
aparm_histc <- 1/hist_model$scale
len_val <- length(rand_control_diff) * length(effect_vals) * length(a0_vals) * length(subj_per_arm)
power_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
est_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
if (get_mse == TRUE) {
mse_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
}
if (get_bias == TRUE) {
bias_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
}
if (get_var == TRUE) {
var_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
}
for (diffs in 1:length(rand_control_diff)) {
bparm_randc <- exp(log(bparm_histc) - (1/aparm_histc) * log(rand_control_diff[diffs]))
for (effvals in 1:length(effect_vals)) {
for (a0vals in 1:length(a0_vals)) {
for (sizes in 1:length(subj_per_arm)) {
if (!quietly){
cat("\r", c(subj_per_arm[sizes], a0_vals[a0vals], effect_vals[effvals], rand_control_diff[diffs]))
}
collect <- matrix(rep(0, 3 * trial_reps), ncol = 3)
for (k in 1:trial_reps) {
collect[k, ] <- weibulltrialsimulator(sample_size_val = subj_per_arm[sizes], histdata, scale1_val = bparm_randc,
hazard_ratio_val = effect_vals[effvals], common_shape_val = aparm_histc, censor_value = censor_value,
a0_val = a0_vals[a0vals], alpha = alpha)
}
colnames(collect) <- c("hazard_ratio", "log_hazard_ratio_var", "reject")
power_results[sizes, a0vals, effvals, diffs] <- mean(collect[, 3])
est_results[sizes, a0vals, effvals, diffs] <- mean(collect[, 1])
if (get_bias == TRUE) {
bias_results[sizes, a0vals, effvals, diffs] <- mean(collect[, 1] - effect_vals[effvals])
}
if (get_var == TRUE) {
var_results[sizes, a0vals, effvals, diffs] <- mean((collect[, 1]*sqrt(collect[, 2]))^2)
}
if (get_mse == TRUE) {
mse_results[sizes, a0vals, effvals, diffs] <- mean((collect[, 1] - effect_vals[effvals])^2)
}
if (!quietly){
cat("\r", " ")
}
}
}
}
}
cat("\n")
if (get_bias == FALSE & get_var == FALSE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results)
names(output) <- c("power", "est")
}
if (get_bias == FALSE & get_var == FALSE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, mse_results)
names(output) <- c("power", "est", "mse")
}
if (get_bias == TRUE & get_var == FALSE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, bias_results)
names(output) <- c("power", "est", "bias")
}
if (get_bias == TRUE & get_var == FALSE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, bias_results, mse_results)
names(output) <- c("power", "est", "bias", "mse")
}
if (get_bias == FALSE & get_var == TRUE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results)
names(output) <- c("power", "est", "var")
}
if (get_bias == FALSE & get_var == TRUE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results, mse_results)
names(output) <- c("power", "est", "var", "mse")
}
if (get_bias == TRUE & get_var == TRUE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results, bias_results)
names(output) <- c("power", "est", "var", "bias")
}
if (get_bias == TRUE & get_var == TRUE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results, bias_results, mse_results)
names(output) <- c("power", "est", "var", "bias", "mse")
}
class_out <- list(data = output, subj_per_arm = subj_per_arm, a0_vals = a0_vals, effect_vals = effect_vals, rand_control_diff = rand_control_diff, objtype = 'historic')
class(class_out) <- append("bayes_ctd_array", class(class_out))
return(class_out)
}
simple_weibull_sim <- function(trial_reps=100, subj_per_arm, effect_vals, scale1_value,
common_shape_value, censor_value, alpha=0.05,
get_var=FALSE, get_bias=FALSE, get_mse=FALSE,
quietly=TRUE) {
rand_control_diff <- 1
a0_vals <- 0
len_val <- length(rand_control_diff) * length(effect_vals) * length(a0_vals) * length(subj_per_arm)
power_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
est_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
if (get_mse == TRUE) {
mse_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
}
if (get_bias == TRUE) {
bias_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
}
if (get_var == TRUE) {
var_results <- array(rep(0, len_val), c(length(subj_per_arm), length(a0_vals), length(effect_vals), length(rand_control_diff)))
}
for (diffs in 1:length(rand_control_diff)) {
for (effvals in 1:length(effect_vals)) {
for (a0vals in 1:length(a0_vals)) {
for (sizes in 1:length(subj_per_arm)) {
if (!quietly){
cat("\r", c(subj_per_arm[sizes], a0_vals[a0vals], effect_vals[effvals], rand_control_diff[diffs]))
}
collect <- matrix(rep(0, 3 * trial_reps), ncol = 3)
for (k in 1:trial_reps) {
collect[k, ] <- weibulltrialsimulatornohist(sample_size_val = subj_per_arm[sizes], scale1_val = scale1_value,
hazard_ratio_val = effect_vals[effvals], common_shape_val = common_shape_value, censor_value = censor_value,
alpha = alpha)
}
colnames(collect) <- c("hazard_ratio", "log_hazard_ratio_var", "reject")
power_results[sizes, a0vals, effvals, diffs] <- mean(collect[, 3])
est_results[sizes, a0vals, effvals, diffs] <- mean(collect[, 1])
if (get_bias == TRUE) {
bias_results[sizes, a0vals, effvals, diffs] <- mean(collect[, 1] - effect_vals[effvals])
}
if (get_var == TRUE) {
var_results[sizes, a0vals, effvals, diffs] <- mean((collect[, 1]*sqrt(collect[, 2]))^2)
}
if (get_mse == TRUE) {
mse_results[sizes, a0vals, effvals, diffs] <- mean((collect[, 1] - effect_vals[effvals])^2)
}
if (!quietly){
cat("\r", " ")
}
}
}
}
}
cat("\n")
if (get_bias == FALSE & get_var == FALSE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results)
names(output) <- c("power", "est")
}
if (get_bias == FALSE & get_var == FALSE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, mse_results)
names(output) <- c("power", "est", "mse")
}
if (get_bias == TRUE & get_var == FALSE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, bias_results)
names(output) <- c("power", "est", "bias")
}
if (get_bias == TRUE & get_var == FALSE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, bias_results, mse_results)
names(output) <- c("power", "est", "bias", "mse")
}
if (get_bias == FALSE & get_var == TRUE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results)
names(output) <- c("power", "est", "var")
}
if (get_bias == FALSE & get_var == TRUE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results, mse_results)
names(output) <- c("power", "est", "var", "mse")
}
if (get_bias == TRUE & get_var == TRUE & get_mse == FALSE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results, bias_results)
names(output) <- c("power", "est", "var", "bias")
}
if (get_bias == TRUE & get_var == TRUE & get_mse == TRUE) {
if (length(subj_per_arm) == 1) {
dimnames(power_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(power_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(power_results)[[2]] <- as.character(a0_vals)
dimnames(power_results)[[3]] <- as.character(effect_vals)
dimnames(power_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(est_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(est_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(est_results)[[2]] <- as.character(a0_vals)
dimnames(est_results)[[3]] <- as.character(effect_vals)
dimnames(est_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(bias_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(bias_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(bias_results)[[2]] <- as.character(a0_vals)
dimnames(bias_results)[[3]] <- as.character(effect_vals)
dimnames(bias_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(var_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(var_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(var_results)[[2]] <- as.character(a0_vals)
dimnames(var_results)[[3]] <- as.character(effect_vals)
dimnames(var_results)[[4]] <- as.character(rand_control_diff)
if (length(subj_per_arm) == 1) {
dimnames(mse_results)[[1]] <- list(as.character(subj_per_arm))
}
if (length(subj_per_arm) > 1) {
dimnames(mse_results)[[1]] <- as.character(subj_per_arm)
}
dimnames(mse_results)[[2]] <- as.character(a0_vals)
dimnames(mse_results)[[3]] <- as.character(effect_vals)
dimnames(mse_results)[[4]] <- as.character(rand_control_diff)
output <- list(power_results, est_results, var_results, bias_results, mse_results)
names(output) <- c("power", "est", "var", "bias", "mse")
}
class_out <- list(data = output, subj_per_arm = subj_per_arm, a0_vals = 0, effect_vals = effect_vals, rand_control_diff = 1, objtype = 'simple')
class(class_out) <- append("bayes_ctd_array", class(class_out))
return(class_out)
}
|
library(sclr)
mf_one <- model.frame(status ~ logHI, one_titre_data)
x_one <- model.matrix(mf_one, data = one_titre_data)
y_one <- model.response(mf_one)
test_that("sclr_fit can be used directly", {
fit_one <- sclr_fit(y_one, x_one)
expect_named(
fit_one,
c("parameters", "covariance_mat", "algorithm", "algorithm_return")
)
})
test_that("error with unknown algorithm", {
expect_error(
sclr_fit(y_one, x_one, algorithm = "unknown"),
"`algorithm` should be in:"
)
})
test_that("Parameter matrix initalisation and resetting works", {
init_mat <- get_init_pars_mat(
y_one, x_one, conventional_names = FALSE, seed = 1
)
init_mat2 <- get_init_pars_mat(
y_one, x_one, conventional_names = FALSE, seed = 1
)
init_mat3 <- get_init_pars_mat(
y_one, x_one, conventional_names = FALSE
)
expect_equal(init_mat, init_mat2)
expect_true(all(init_mat2 != init_mat3))
expect_true(all(guess_again(init_mat) != guess_again(init_mat)))
})
test_that("Algorithms work", {
x_coeffs_one <- get_x_coeffs(x_one)
pars_mat_one <- get_init_pars_mat(y_one, x_one, FALSE)
nr <- newton_raphson(
y_one, x_one, pars_mat_one, x_coeffs_one,
max_iter = 1e4, tol = 10^(-7), seed = 20191101
)
ga <- gradient_ascent(
y_one, x_one, pars_mat_one, x_coeffs_one,
max_iter = 1e4, tol = 10^(-7), seed = 20191101
)
nms <- c("init_mat", "found", "cov", "last_iter")
expect_named(nr, nms)
expect_named(ga, nms)
})
test_that("Warning when doesn't converge", {
ss <- sclr_ideal_data(n = 50, seed = 20191101)
x_ss <- model.matrix(status ~ logHI, ss)
y_ss <- model.response(model.frame(status ~ logHI, ss))
x_coeffs_ss <- get_x_coeffs(x_ss)
expect_warning(
sclr_fit(
y_ss, x_ss, nr_iter = 100, algorithm = "newton-raphson", n_conv = 3,
seed = 20191101
),
regexp = "newton-raphson only converged 1 time\\(s\\) out of 3"
)
expect_warning(
sclr_fit(
y_ss, x_ss, nr_iter = 5, algorithm = "newton-raphson", n_conv = 3,
seed = 20191101
),
regexp = paste0(
"newton-raphson did not converge,",
" check for boundary with check_baseline"
)
)
})
test_that("fallback works", {
l1 <- sclr_ideal_data(theta = 1e6, n = 50, seed = 20191102)
x_l1 <- model.matrix(status ~ logHI, l1)
y_l1 <- model.response(model.frame(status ~ logHI, l1))
fit_ga <- suppressWarnings(sclr_fit(
y_l1, x_l1, algorithm = c("newton-raphson", "gradient-ascent"), n_conv = 3,
seed = 20191101
))
expect_named(
fit_ga,
c("parameters", "covariance_mat", "algorithm", "algorithm_return")
)
expect_equal(fit_ga$algorithm, "gradient-ascent")
expect_true(!is.null(fit_ga$parameters))
expect_true(!is.null(fit_ga$covariance_mat))
})
|
library(hgu133plus2.db)
library(tissuesGeneExpression)
data(tissuesGeneExpression)
map <- mapIds(hgu133plus2.db,
keytype="PROBEID",
column="SYMBOL",
keys=rownames(e),
mutliVals = first)
o <- order(tissue)
tissue <- tissue[o]
e <- e[,o]
rownames(e) <- map
colnames(e) <- paste(tissue,
unlist(
sapply(table(tissue), function(n) 1:n)),
sep="_")
ind <- which(!is.na(map) & !duplicated(map))
set.seed(1994)
e <- e[sample(ind, 500), ]
tissue_gene_expression <- list(x = t(e), y = factor(tissue))
save(tissue_gene_expression,
file="data/tissue_gene_expression.rda",
compress = "xz")
if(FALSE){
library(caret)
ind <- which(matrixStats::colSds(tissue_gene_expression$x) > 0.5)
tissue_gene_expression$x <- with(tissue_gene_expression,
sweep(x, 1, rowMeans(x)))
fit <- train(tissue_gene_expression$x[,ind],
tissue_gene_expression$y, method = "knn",
tuneGrid = data.frame(k=seq(1,7,2)))
plot(fit)
}
|
expected <- eval(parse(text="list()"));
test(id=0, code={
argv <- eval(parse(text="list(list(list(2, 2, 6), list(2, 2, 0)), value = 0)"));
do.call(`length<-`, argv);
}, o=expected);
|
mdes.ira1r1 <- function(power=.80, alpha=.05, two.tailed=TRUE,
p=.50, g1=0, r21=0, n){
user.parms <- as.list(match.call())
.error.handler(user.parms)
df <- n-g1-2
SSE <- sqrt((1-r21)/(p*(1-p)*n))
mdes <- .mdes.fun(power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
.summ.mdes(effect = "main", power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed, mdes = mdes)
mdes.out <- list(fun = "mdes.ira1r1",
parms = list(power=power, alpha=alpha, two.tailed=two.tailed,
p=p, r21=r21, g1=g1,
n=n),
df = df,
ncp = mdes[1]/SSE,
mdes = mdes)
class(mdes.out) <- c("main", "mdes")
return(invisible(mdes.out))
}
mdes.ira <- mdes.ira1r1
power.ira1r1 <- function(es=.25, alpha=.05, two.tailed=TRUE,
p=.50, g1=0, r21=0, n){
user.parms <- as.list(match.call())
.error.handler(user.parms)
df <- n-g1-2
SSE <- sqrt((1-r21)/(p*(1-p)*n))
power <- .power.fun(es = es, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
.summ.power(power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed, es = es)
power.out <- list(fun = "power.ira1r1",
parms = list(es=es, alpha=alpha, two.tailed=two.tailed,
p=p, r21=r21, g1=g1,
n=n),
df = df,
ncp = es/SSE,
power = power)
class(power.out) <- c("main", "power")
return(invisible(power.out))
}
power.ira <- power.ira1r1
mrss.ira1r1 <- function(es=.25, power=.80, alpha=.05, two.tailed=TRUE,
n0=10, tol=.10,
p=.50, g1=0, r21=0){
user.parms <- as.list(match.call())
.error.handler(user.parms)
i <- 0
conv <- FALSE
while(i<=100 & conv==FALSE){
df <- n0-g1-2
if(df<= 0 | is.infinite(df)){break}
T1 <- ifelse(two.tailed==TRUE,abs(qt(alpha/2,df)),abs(qt(alpha,df)))
T2 <- abs(qt(power,df))
M <- ifelse(power>=.5,T1+T2,T1-T2)
n1 <- (M/es)^2 * ((1-r21)/(p*(1-p)))
if(abs(n1-n0)<tol){conv <- TRUE}
n0 <- (n1+n0)/2
i <- i+1
}
n <- round(ifelse(df>0,round(n0),NA))
n.out <- list(fun = "mrss.ira1r1",
parms = list(es=es, power=power, alpha=alpha, two.tailed=two.tailed,
n0=n0, tol=tol,
p=p, r21=r21, g1=g1),
df=df,
ncp = M,
n = n)
class(n.out) <- c("main", "mrss")
cat("n =", n, "\n")
return(invisible(n.out))
}
mrss.ira <- mrss.ira1r1
mdes.bira2f1 <- function(power=.80, alpha=.05, two.tailed=TRUE,
p=.50, g1=0, r21=0, n, J){
user.parms <- as.list(match.call())
.error.handler(user.parms)
df <- J * (n - 2) - g1
SSE <- sqrt((1-r21)/(p*(1-p)*J*n))
mdes <- .mdes.fun(power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
.summ.mdes(effect = "main", power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed, mdes = mdes)
mdes.out <- list(fun = "mdes.bira2f1",
parms = list(power=power, alpha=alpha, two.tailed=two.tailed,
p=p, r21=r21, g1=g1,
n=n, J=J),
df = df,
ncp = mdes[1]/SSE,
mdes = mdes)
class(mdes.out) <- c("main", "mdes")
return(invisible(mdes.out))
}
power.bira2f1 <- function(es=.25, alpha=.05, two.tailed=TRUE,
p=.50, g1=0, r21=0, n, J){
user.parms <- as.list(match.call())
.error.handler(user.parms)
df <- J * (n - 2) - g1
SSE <- sqrt((1-r21)/(p*(1-p)*J*n))
power <- .power.fun(es = es, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
.summ.power(power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed, es = es)
power.out <- list(fun = "power.bira2f1",
parms = list(es=es, alpha=alpha, two.tailed=two.tailed,
p=p, r21=r21, g1=g1,
n=n, J=J),
df = df,
ncp = es/SSE,
power = power)
class(power.out) <- c("main", "power")
return(invisible(power.out))
}
mrss.bira2f1 <- function(es=.25, power=.80, alpha=.05, two.tailed=TRUE,
J, n0=10, tol=.10,
p=.50, g1=0, r21=0){
user.parms <- as.list(match.call())
.error.handler(user.parms)
i <- 0
conv <- FALSE
while(i<=100 & conv==FALSE){
df <- J*(n0-2)-g1
if(df<= 0 | is.infinite(df)){break}
T1 <- ifelse(two.tailed==TRUE,abs(qt(alpha/2,df)),abs(qt(alpha,df)))
T2 <- abs(qt(power,df))
M <- ifelse(power>=.5,T1+T2,T1-T2)
n1 <- (M/es)^2 * ((1-r21)/(p*(1-p)*J))
if(abs(n1-n0)<tol){conv <- TRUE}
n0 <- (n1+n0)/2
i <- i+1
}
n <- ifelse(df>0,round(n0),NA)
mrss.out <- list(fun = "mrss.bira2f1",
parms = list(es=es, power=power, alpha=alpha, two.tailed=two.tailed,
J=J, n0=n0, tol=tol,
p=p, r21=r21, g1=g1),
df = df,
ncp = M,
n = n)
class(mrss.out) <- c("main", "mrss")
cat("n =", n, "(per block)\n")
return(invisible(mrss.out))
}
mdes.bira2c1 <- function(power=.80, alpha=.05, two.tailed=TRUE,
p=.50, g1=0, r21=0, n, J){
user.parms <- as.list(match.call())
.error.handler(user.parms)
df <- J * (n - 1) - g1 - 1
SSE <- sqrt((1-r21)/(p*(1-p)*J*n))
mdes <- .mdes.fun(power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
.summ.mdes(effect = "main", power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed, mdes = mdes)
mdes.out <- list(fun = "mdes.bira2c1",
parms = list(power=power, alpha=alpha, two.tailed=two.tailed,
p=p, r21=r21, g1=g1,
n=n, J=J),
df = df,
ncp = mdes[1]/SSE,
mdes = mdes)
class(mdes.out) <- c("main", "mdes")
return(invisible(mdes.out))
}
power.bira2c1 <- function(es=.25, alpha=.05, two.tailed=TRUE,
p=.50, g1=0, r21=0, n, J){
user.parms <- as.list(match.call())
.error.handler(user.parms)
df <- J * (n - 1) - g1 - 1
SSE <- sqrt((1-r21)/(p*(1-p)*J*n))
power <- .power.fun(es = es, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
.summ.power(power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed, es = es)
power.out <- list(fun = "power.bira2c1",
parms = list(es=es, alpha=alpha, two.tailed=two.tailed,
p=p, r21=r21, g1=g1,
n=n, J=J),
df = df,
ncp = es/SSE,
power = power)
class(power.out) <- c("main", "power")
return(invisible(power.out))
}
mrss.bira2c1 <- function(es=.25, power=.80, alpha=.05, two.tailed=TRUE,
J, n0=10, tol=.10,
p=.50, g1=0, r21=0){
user.parms <- as.list(match.call())
.error.handler(user.parms)
i <- 0
conv <- FALSE
while(i<=100 & conv==FALSE){
df <- J*(n0-1)-g1-1
if(df<= 0 | is.infinite(df)){break}
T1 <- ifelse(two.tailed==TRUE,abs(qt(alpha/2,df)),abs(qt(alpha,df)))
T2 <- abs(qt(power,df))
M <- ifelse(power>=.5,T1+T2,T1-T2)
n1 <- (M/es)^2 * ((1-r21)/(p*(1-p)*J))
if(abs(n1-n0)<tol){conv <- TRUE}
n0 <- (n1+n0)/2
i <- i+1
}
n <- ifelse(df>0,round(n0),NA)
mrss.out <- list(fun = "mrss.bira2c1",
parms = list(es=es, power=power, alpha=alpha, two.tailed=two.tailed,
J=J, n0=n0, tol=tol,
p=p, r21=r21, g1=g1),
df = df,
ncp = M,
n = n)
class(mrss.out) <- c("main", "mrss")
cat("n =", n, "(per block)\n")
return(invisible(mrss.out))
}
mdes.ira_pn <- function(power=.80, alpha=.05, two.tailed=TRUE, df=NULL, ratio_tc_var=1,
rho_ic=.20, p=.50, r21=0, n, ic_size=1){
user.parms <- as.list(match.call())
.error.handler(user.parms)
if(!is.null(df) & ratio_tc_var != 1)
warning("'ratio_tc_var' argment is ignored", call. = FALSE)
if(is.null(df)) {
it <- n * p / ic_size
nc <- n * (1 - p)
vt_vc_ratio <- ratio_tc_var*(1 / ic_size + rho_ic / (1 - rho_ic))
df <- (nc-1)*(it-1)*(it + nc*vt_vc_ratio)^2 / ((it-1)*it^2 + (nc-1)*nc^2 * vt_vc_ratio^2)
}
deff_rand_ic <- 1 + rho_ic * (1 - p) * (ic_size - 1) / (1 - p*rho_ic)
SSE <- sqrt(((1 - r21) / (n * p * (1 - p))) * ((1 - p * rho_ic) / (1 - rho_ic)) * deff_rand_ic )
mdes <- .mdes.fun(power = power, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
cat(ifelse(ic_size == 1,"Fixed", "Random"), "intervention cluster effects\n")
.summ.mdes(effect = "main", power = power, alpha = alpha, sse = SSE,
df = round(df,3), two.tailed = two.tailed, mdes = mdes)
mdes.out <- list(fun = "mdes.ira_pn",
parms = list(power=power, alpha=alpha, two.tailed=two.tailed, ratio_tc_var=ratio_tc_var,
rho_ic = rho_ic, r21=r21, p=p, n=n, ic_size = ic_size),
df = df,
ncp = mdes[1]/SSE,
mdes = mdes)
class(mdes.out) <- c("main", "mdes")
return(invisible(mdes.out))
}
power.ira_pn <- function(es=.25,alpha=.05, two.tailed=TRUE, df=NULL, ratio_tc_var=1,
rho_ic=.20, p=.50, r21=0, n, ic_size=1){
user.parms <- as.list(match.call())
.error.handler(user.parms)
if(!is.null(df) & ratio_tc_var != 1)
warning("'ratio_tc_var' argment is ignored for z-test", call. = FALSE)
if(is.null(df)) {
it <- n * p / ic_size
nc <- n * (1 - p)
vt_vc_ratio <- ratio_tc_var*(1 / ic_size + rho_ic / (1 - rho_ic))
df <- (nc-1)*(it-1)*(it + nc*vt_vc_ratio)^2 / ((it-1)*it^2 + (nc-1)*nc^2 * vt_vc_ratio^2)
}
deff_rand_ic <- 1 + rho_ic * (1 - p) * (ic_size - 1) / (1 - p*rho_ic)
SSE <- sqrt(((1 - r21) / (n * p * (1 - p))) * ((1 - p * rho_ic) / (1 - rho_ic)) * deff_rand_ic)
power <- .power.fun(es = es, alpha = alpha, sse = SSE, df = df, two.tailed = two.tailed)
cat(ifelse(ic_size == 1,"Fixed", "Random"), "intervention cluster effects\n")
.summ.power(power = power, alpha = alpha, sse = SSE, df = round(df,3), two.tailed = two.tailed, es = es)
power.out <- list(fun = "power.ira_pn",
parms = list(es=es, alpha=alpha, two.tailed=two.tailed, df=df, ratio_tc_var=ratio_tc_var,
rho_ic = rho_ic, r21=r21, p=p, n=n, ic_size = ic_size),
df = df,
ncp = es/SSE,
power = power)
class(power.out) <- c("main", "power")
return(invisible(power.out))
}
mrss.ira_pn <- function(es=.25, power=.80, alpha=.05, two.tailed=TRUE, ratio_tc_var=1, z.test=FALSE,
rho_ic=.20, p=.50, r21=0, ic_size=1, n0=500, tol=.10){
user.parms <- as.list(match.call())
.error.handler(user.parms)
if(isTRUE(z.test) & ratio_tc_var != 1)
warning("'ratio_tc_var' argment is ignored for z-test", call. = FALSE)
i <- 0
conv <- FALSE
while(i<=100 & conv==FALSE){
it <- n0 * p / ic_size
nc <- n0 * (1 - p)
vt_vc_ratio <- ratio_tc_var*(1 / ic_size + rho_ic / (1 - rho_ic))
df <- (nc-1)*(it-1)*(it + nc*vt_vc_ratio)^2 / ((it-1)*it^2 + (nc-1)*nc^2 * vt_vc_ratio^2)
if(df <= 0) stop("Increase 'n0'", call. = FALSE)
if(df <= 0 | is.infinite(df)){break}
if(z.test) df <- Inf
T1 <- ifelse(two.tailed==TRUE,abs(qt(alpha/2,df)),abs(qt(alpha,df)))
T2 <- abs(qt(power,df))
M <- ifelse(power>=.5,T1+T2,T1-T2)
deff_rand_ic <- 1 + rho_ic * (1 - p) * (ic_size - 1) / (1 - p*rho_ic)
VAR <- ((1 - r21) / (p * (1 - p))) * ((1 - p * rho_ic) / (1 - rho_ic)) * deff_rand_ic
n1 <- (M/es)^2 * VAR
if(abs(n1-n0)<tol){conv <- TRUE}
n0 <- (n1+n0)/2
i <- i+1
}
n <- round(ifelse(df>0,round(n0),NA))
J <- round(ifelse(df>0,round(it),NA))
n.out <- list(fun = "mrss.ira_pn",
parms = list(es=es, power=power, alpha=alpha, two.tailed=two.tailed,
ratio_tc_var=ratio_tc_var, z.test=z.test,
rho_ic = rho_ic, r21=r21, p=p, ic_size = ic_size,
n0=n0, tol=tol),
df=df,
ncp = M,
n = n)
class(n.out) <- c("main", "mrss")
cat("n =", n, "(total)\n")
return(invisible(n.out))
}
|
keyword_cloud = function(tibble_graph,group_no = NULL,top = 50,max_size = 20){
if(is.null(group_no))
tibble_graph %>%
as_tibble() %>%
top_n(top,freq) %>%
mutate(group = as.factor(group)) %>%
ggplot(aes(label = name,size = freq,colour = group,x=group)) +
geom_text_wordcloud_area() +
scale_size_area(max_size = max_size) +
scale_x_discrete(breaks = NULL,name = "") +
theme_minimal()
else{
tibble_graph %>%
as_tibble() %>%
filter(group == group_no) %>%
top_n(top,freq) %>%
ggplot(aes(label = name,size = freq)) +
geom_text_wordcloud_area() +
scale_size_area(max_size = max_size) +
theme_minimal()
}
}
|
context("test-show_colors")
test_that("show_colors retuns gglot", {
x <- show_colors(labels = TRUE)
expect_equal(is(x), "gg")
expect_equal(length(x$layers), 3)
})
|
print.ergmm.model<-function(x,...){
cat("Exponential Random Graph Mixed Model definition\n")
cat("Formula: ")
print(x[["formula"]])
if(!is.null(x[["response"]]) && mode(x[["response"]])=="character")
cat("Attribute of interest:",x[["response"]],"\n")
cat("Family:",x[["family"]],"\n")
cat("Terms:\n")
if(length(x[["coef.names"]])){
cat("- fixed effects:\n")
cat(paste(" - ",x[["coef.names"]],sep="",collapse="\n"),"\n")
}
if(x[["d"]]>0){
cat("- latent space of",x[["d"]],"dimensions")
if(x[["G"]]>0){
cat(" in",x[["G"]],"clusters\n")
}else cat("\n")
}
if(x[["sender"]]) cat("- random sender effects\n")
if(x[["receiver"]]) cat("- random receiver effects\n")
if(x[["sociality"]]) cat("- random sociality effects\n")
if(x[["dispersion"]]) cat("- dispersion parameter\n")
}
|
scacum <- structure(function
(
x,
sc.c = NA,
rf.t = NA
) {
csn. <- FALSE
if(is.data.frame(x)){
csnu <- cClass(x, 'numeric')
csn <- c(cClass(x, 'integer'), cClass(x, 'factor'))
csn. <- length(csn)!=0
csn.. <- csn[!csn%in%'csx']
cd <- x
x <- x[,'x']
names(x) <- cd[,'year']}
if(is.null(names(x)))
stop('NULL labels in x', call. = FALSE)
xcum <- cumsum(x)
if(is.na(rf.t))
rf.t <- max(as.numeric(names(x)))
inc <- 0
if(!is.na(sc.c))
inc <- sc.c - xcum[as.character(rf.t)]
csx <- xcum + inc
if(any(csx < 0,na.rm = TRUE))
csx <- xcum
xd <- data.frame(x,csx)
if(csn.&& length(csnu) > 1){
xd <- cd[,csnu]
xd[,'csx'] <- csx }
if(csn.)
xd <- cbind(xd,cd[,csn..])
return(xd)
} , ex=function() {
x <- c(0.79,0.32,0.53,0.43,0.18)
names(x) <- 1948:1952
scacum(x,sc.c = 4,rf.t = 1951)
max(cumsum(x))
scacum(x,NA,1951)
})
|
prscoring <- function(data, id, block, item, choice, ..., wide = FALSE) {
get_checks(data, id, block, item, choice, nonbibd = TRUE)
out <- lapply(unique(data[[id]]), function(x) {
B <- get_prscores(
get_M(data[data[[id]] == x, ], "b", block, item, choice),
...
)
W <- get_prscores(
get_M(data[data[[id]] == x, ], "w", block, item, choice),
...
)
rowMeans(cbind(scale(B), scale(W) * -1))
})
out <- do.call(rbind, out)
out <- dplyr::as_tibble(cbind(id = unique(data[[id]]), out))
colnames(out)[1] <- id
if (!wide) {
out <- out %>%
tidyr::gather(!!sym(item), "pagerank", -!!sym(id)) %>%
dplyr::arrange(id)
}
return(out)
}
|
library(oce)
file <- file("tide3.dat.gz", "r")
nc <- 146
name <- kmpr <- vector("character", nc)
freq <- ikmpr <- df <-
d1 <- d2 <- d3 <- d4 <- d5 <- d6 <-
semi <- isat <- nsat <- ishallow <- nshallow <- doodsonamp <- doodsonspecies <-
vector("numeric", nc)
doodsonamp <- rep(NA, nc)
doodsonspecies <- rep(NA, nc)
ishallow <- NA
ic <- 1
while (TRUE) {
items <- scan(file, "character", nlines=1, quiet=TRUE)
nitems <- length(items)
if (nitems == 0)
break
if (nitems != 2 && nitems != 3) stop("wrong number of entries on line", ic)
name[ic] <- gsub(" ", "", items[1])
freq[ic] <- as.numeric(items[2])
kmpr[ic] <- if (nitems == 2) "" else gsub(" ", "", items[3])
ic <- ic + 1
}
for (ic in 1:nc) {
if (kmpr[ic] != "") {
ikmpr[ic] <- which(name == kmpr[ic])
df[ic] <- freq[ic] - freq[ikmpr[ic]]
}
}
df[1] <- 0
get.satellite <- function(x, o)
{
ldel <- as.numeric(substr(x,o+01,o+03))
mdel <- as.numeric(substr(x,o+04,o+06))
ndel <- as.numeric(substr(x,o+07,o+09))
ph <- as.numeric(substr(x,o+10,o+13))
ee <- as.numeric(substr(x,o+14,o+20))
ir <- as.numeric(substr(x,o+22,o+22))
c(ldel, mdel, ndel, ph, ee, ir)
}
scan(file, "character", nlines=3, quiet=TRUE)
ns <- 162
deldood <- matrix(NA, ns, 3)
phcorr <- matrix(NA, ns, 1)
amprat <- matrix(NA, ns, 1)
ilatfac <- matrix(NA, ns, 1)
iconst <- matrix(NA, ns, 1)
this.sat <- 1
while (TRUE) {
x <- readLines(file, n=1)
nx <- nchar(x)
if (this.sat > ns || nx < 10) break
kon <- gsub(" ", "", substr(x, 7, 11))
which.constituent <- which(name == kon)
d1[which.constituent] <- ii <- as.numeric(substr(x, 13, 15))
d2[which.constituent] <- jj <- as.numeric(substr(x, 16, 18))
d3[which.constituent] <- kk <- as.numeric(substr(x, 19, 21))
d4[which.constituent] <- ll <- as.numeric(substr(x, 22, 24))
d5[which.constituent] <- mm <- as.numeric(substr(x, 25, 27))
d6[which.constituent] <- nn <- as.numeric(substr(x, 28, 30))
semi[which.constituent] <- as.numeric(substr(x, 31, 35))
nj <- as.numeric(substr(x, 36, 39))
nsat[which.constituent] <- nj
if (nj > 0) {
is <- 1
while (is <= nj) {
xs <- readLines(file, n=1)
nxs <- nchar(xs)
if (nxs != 31 && nxs != 33 && nxs != 39 && nxs != 54 && nxs != 56 && nxs != 77 && nxs != 79) {
cat("GOT BAD LINE AS FOLLOWS:\n12345678901234567890123456789012345678901234567890\n",xs,"\n",sep="")
stop("need 31, 33, 39, 54, 56, 77 or 79 chars, but got ", nxs)
}
s <- get.satellite(xs, 11)
deldood[this.sat, 1:3] <- s[1:3]
phcorr[this.sat] <- s[4]
amprat[this.sat] <- s[5]
ilatfac[this.sat] <- s[6]
iconst[this.sat] <- which.constituent
this.sat <- this.sat + 1
is <- is + 1
if (nxs > 50) {
s <- get.satellite(xs, 34)
deldood[this.sat, 1:3] <- s[1:3]
phcorr[this.sat] <- s[4]
amprat[this.sat] <- s[5]
ilatfac[this.sat] <- s[6]
iconst[this.sat] <- which.constituent
this.sat <- this.sat + 1
is <- is + 1
}
if (nxs > 70) {
s <- get.satellite(xs, 57)
deldood[this.sat, 1:3] <- s[1:3]
phcorr[this.sat] <- s[4]
amprat[this.sat] <- s[5]
ilatfac[this.sat] <- s[6]
iconst[this.sat] <- which.constituent
this.sat <- this.sat + 1
is <- is + 1
}
}
}
}
if ((this.sat - 1) != ns) stop("failed to read all ", ns, " satellite entries. Only got ", this.sat)
sat <- list(deldood=deldood, phcorr=phcorr, amprat=amprat, ilatfac=ilatfac, iconst=iconst)
num.shallow <- 251
iconst <- vector("numeric", num.shallow)
coef <- vector("numeric", num.shallow)
iname <- vector("numeric", num.shallow)
this.shallow <- 1
while(TRUE) {
x <- readLines(file, n=1)
nx <- nchar(x)
if (nx < 10) break
kon <- gsub(" ", "", substr(x, 7, 11))
which.constituent <- which(name == kon)
nj <- as.numeric(substr(x, 12, 12))
nshallow[which.constituent] <- nj
if (nj > 0) {
for (j in 1:nj) {
o <- 15 + (j-1)*15
iconst[this.shallow] <- which.constituent
coef[this.shallow] <- as.numeric(substr(x, o, o+4))
konco <- gsub(" ", "", substr(x, o+5, o+9))
iname[this.shallow] <- which(name == konco)
ishallow[which.constituent] <- this.shallow - j + 1
this.shallow <- this.shallow + 1
}
}
}
close(file)
shallow <- data.frame(iconst=iconst, coef=coef, iname=iname)
efile <- file("t_equilib.dat.gz", "r")
edat <- readLines(efile)
ne <- length(edat)
for (i in 10:ne) {
kon <- gsub(" ", "", substr(edat[i], 1, 4))
which.constituent <- which(name == kon)
if (length(which.constituent) < 1) stop("cannot understand equilibirum constituent", kon)
species <- as.numeric(substr(edat[i], 8, 8))
A <- as.numeric(substr(edat[i], 9, 15))
B <- as.numeric(substr(edat[i], 16, 21))
if (A != 0) {
doodsonamp[which.constituent] <- A / 1e5
doodsonspecies[which.constituent] <- species
} else {
doodsonamp[which.constituent] <- B / 1e5
doodsonspecies[which.constituent] <- -species
}
}
close(efile)
const <- data.frame(name=name,
freq=freq,
kmpr=kmpr,
ikmpr=ikmpr,
df=df,
d1=d1,d2=d2,d3=d3,d4=d4,d5=d5,d6=d6,
semi=semi,
nsat=nsat,
ishallow=ishallow,
nshallow=nshallow,
doodsonamp=doodsonamp,
doodsonspecies=doodsonspecies,
stringsAsFactors=FALSE)
tidedata <- list(const=const, sat=sat, shallow=shallow)
test_that("deldood", {
expect_equal(sum(nsat), ns)
expect_equal(sat$deldood[1,], c(-1, 0, 0))
expect_equal(sat$deldood[2,], c( 0, -1, 0))
expect_equal(sat$deldood[3,], c(-2, -2, 0))
})
test_that("constituents were read correctly", {
expect_equal(name[1], "Z0")
expect_equal(name[2], "SA")
expect_equal(kmpr[2], "SSA")
i <- which(name == "M2")
expect_equal(freq[i], 1/12.4206011981605)
})
test_that("shallow constitutents", {
shallow <- data.frame(iconst=iconst, coef=coef, iname=iname)
expect_equal(tidedata$shallow$iconst[1:5], c(26,26,27,27,30))
expect_equal(tidedata$shallow$coef[1:5], c(2, -1, 1, -1, 2))
expect_equal(tidedata$shallow$iname[1:5], c(19, 13, 57, 13, 48))
expect_equal(df[48], 0.08051140070000)
expect_equal(ishallow[143:146], c(242, 245, 246, 248))
expect_equal(nshallow[143:146], c(3, 1, 2, 4))
})
test_that("doodson", {
expect_equal(tidedata$const$doodsonspecies[c(2,3,10)], c(0,0,-1))
expect_equal(tidedata$const$doodsonamp[c(2,3,10)], c(0.01160000000000,0.07299000000000,0.01153000000000))
})
test_that("ancillary code", {
t <- as.POSIXct("2008-01-22 18:50:24", tz="GMT")
a <- tidemAstron(t)
expect_equal(a$astro, c(1.28861316428, 0.33390620851, 0.83751937277, 0.14234854462, 0.08559663825, 0.78633079279), tolerance=1e-8)
expect_equal(a$ader, c(0.96613680803, 0.03660110127, 0.00273790931, 0.00030945407, 0.00014709388, 0.00000013082), tolerance=1e-8)
vuf <- tidemVuf(t, 48)
expect_equal(vuf$v, c(0.57722632857477), tolerance=1e-8)
expect_equal(vuf$u, c(0), tolerance=1e-8)
expect_equal(vuf$f, c(1), tolerance=1e-8)
vuf <- tidemVuf(t, c(48, 49), 45)
expect_equal(vuf$v, c(0.57722632857477,0.62841490855698), tolerance=1e-8)
expect_equal(vuf$u, c(0.00295677805220,0.00180270946435), tolerance=1e-8)
expect_equal(vuf$f, c(0.96893771510868,0.98142639461951), tolerance=1e-8)
})
|
context("test-check-all.R")
library("tibble")
syn <- attempt_instantiate()
attempt_login(syn)
annots <- tribble(
~key, ~value, ~columnType,
"assay", "rnaSeq", "STRING",
"fileFormat", "fastq", "STRING",
"fileFormat", "txt", "STRING",
"fileFormat", "csv", "STRING",
"species", "Human", "STRING"
)
test_that("check_all() returns a list of check conditions", {
skip_if_not(logged_in(syn = syn))
data <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c("file1", "file2", "file3", "file4"),
species = "human",
assay = "rnaSeq",
file_data = c(
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3)))
)
)
res <- check_all(data, annots, syn)
expect_equal(class(res), "list")
expect_true(all(unlist(
purrr::map(
res,
function(x) {
inherits(x, "check_fail") | inherits(x, "check_pass") | inherits(x, "check_warn")
}
)
)))
})
test_that("check_all() returns NULL for checks with missing data", {
skip_if_not(logged_in(syn = syn))
data1 <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c(NA, NA, NA, NA),
species = "human",
assay = "rnaSeq",
file_data = c(
list(NULL),
list(NULL),
list(NULL),
list(NULL)
)
)
data2 <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c("file1", NA, NA, NA),
species = "human",
assay = "rnaSeq",
file_data = c(
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(NULL),
list(NULL),
list(NULL)
)
)
data3 <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c(NA, "file2", NA, "file4"),
species = "human",
assay = "rnaSeq",
file_data = c(
list(NULL),
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(NULL),
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3)))
)
)
data4 <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c("file1", "file2", "file3", NA),
species = "human",
assay = "rnaSeq",
file_data = c(
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(data.frame(a = c(TRUE, FALSE), b = c(1, 3))),
list(NULL)
)
)
res1 <- check_all(data1, annots, syn)
res2 <- check_all(data2, annots, syn)
res3 <- check_all(data3, annots, syn)
res4 <- check_all(data4, annots, syn)
expect_true(all(purrr::map_lgl(res1, ~ is.null(.x))))
expect_true(sum(purrr::map_lgl(res2, ~ !is.null(.x))) < length(res2))
expect_true(sum(purrr::map_lgl(res3, ~ !is.null(.x))) < length(res3))
expect_true(sum(purrr::map_lgl(res4, ~ !is.null(.x))) < length(res4))
})
test_that("check_all() returns expected conditions", {
skip_if_not(logged_in(syn = syn))
data <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c("file1", "file2", "file3", "file4"),
species = "human",
assay = "rnaSeq",
file_data = c(
list(data.frame(
path = c("file1", "file2", "file3", "file4", NA, NA, NA),
individualID = c(NA, NA, NA, NA, "a", "b", "c"),
specimenID = c(NA, NA, NA, NA, NA, "1", "3"),
stringsAsFactors = FALSE
)),
list(data.frame(
individualID = c("a", "b"),
age = c(27, 32),
stringsAsFactors = FALSE
)),
list(data.frame(
individualID = c("a", "b"),
specimenID = c("1", "3"),
fileFormat = c("xlsx", "tex"),
stringsAsFactors = FALSE
)),
list(data.frame(
specimenID = c("1", "3"),
assay = c("rnaSeq", "rnaSeq"),
stringsAsFactors = FALSE
))
)
)
res <- check_all(data, annots, syn)
expect_true(inherits(res$meta_files_in_manifest, "check_pass"))
expect_equal(
res$individual_ids_indiv_manifest$data$`Missing from individual`[1],
"c"
)
expect_equal(res$annotation_values_biosp$data$fileFormat, c("xlsx", "tex"))
})
test_that("check_all() throws error if not exactly 1 metadata type each", {
skip_if_not(logged_in(syn = syn))
data1 <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"assay"
)
)
data2 <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"assay",
"assay"
)
)
expect_error(check_all(data1, annots, syn))
expect_error(check_all(data2, annots, syn))
})
test_that("check_all runs check_ages_over_90 for human data", {
skip_if_not(logged_in(syn = syn))
data_human <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c("file1", "file2", "file3", "file4"),
species = "human",
assay = "rnaSeq",
file_data = c(
list(data.frame(a = 1)),
list(data.frame(ageDeath = 95)),
list(data.frame(a = 1)),
list(data.frame(a = 1))
)
)
data_animal <- data_human
data_animal$species <- "mouse or other animal model"
data_has_na <- data_human
data_has_na$species <- c(NA, "human", "human", NA)
res1 <- check_all(data_human, annots, syn)
res2 <- check_all(data_animal, annots, syn)
res3 <- check_all(data_has_na, annots, syn)
expect_true(inherits(res1$ages_over_90, "check_warn"))
expect_null(res2$ages_over_90)
expect_true(inherits(res3$ages_over_90, "check_warn"))
})
test_that("check_all catches duplicate file paths in manifest", {
skip_if_not(logged_in(syn = syn))
data <- tibble::tibble(
metadataType = c(
"manifest",
"individual",
"biospecimen",
"assay"
),
name = c("file1", "file2", "file3", "file4"),
species = "human",
assay = "rnaSeq",
file_data = c(
list(data.frame(path = c("/file.txt", "/file.txt"))),
list(data.frame(a = 1)),
list(data.frame(a = 1)),
list(data.frame(a = 1))
)
)
res1 <- check_all(data, annots, syn)
expect_true(inherits(res1$duplicate_file_paths, "check_fail"))
})
|
seg.lm.fit.boot <- function(y, XREG, Z, PSI, w, offs, opz, n.boot=10, size.boot=NULL, jt=FALSE,
nonParam=TRUE, random=FALSE, break.boot=n.boot){
extract.psi<-function(lista){
dev.values<-lista[[1]][-1]
psi.values<-lista[[2]][-1]
dev.ok<-min(dev.values)
id.dev.ok<-which.min(dev.values)
if(is.list(psi.values)) psi.values<-matrix(unlist(psi.values),
nrow=length(dev.values), byrow=TRUE)
if(!is.matrix(psi.values)) psi.values<-matrix(psi.values)
psi.ok<-psi.values[id.dev.ok,]
r<-list(SumSquares.no.gap=dev.ok, psi=psi.ok)
r
}
visualBoot<-opz$visualBoot
opz.boot<-opz
opz.boot$pow=c(1,1)
opz1<-opz
opz1$it.max <-1
n<-length(y)
o0<-try(suppressWarnings(seg.lm.fit(y, XREG, Z, PSI, w, offs, opz, return.all.sol=FALSE)), silent=TRUE)
rangeZ <- apply(Z, 2, range)
if(!is.list(o0)) {
o0<- suppressWarnings(seg.lm.fit(y, XREG, Z, PSI, w, offs, opz, return.all.sol=TRUE))
o0<-extract.psi(o0)
ss00<-opz$dev0
if(!nonParam) {warning("using nonparametric boot");nonParam<-TRUE}
}
if(is.list(o0)){
est.psi00<-est.psi0<-o0$psi
ss00<-o0$SumSquares.no.gap
if(!nonParam) fitted.ok<-fitted(o0)
} else {
if(!nonParam) stop("the first fit failed and I cannot extract fitted values for the semipar boot")
if(random) {
est.psi00<-est.psi0<-apply(rangeZ,2,function(r)runif(1,r[1],r[2]))
PSI1 <- matrix(rep(est.psi0, rep(nrow(Z), length(est.psi0))), ncol = length(est.psi0))
o0<-try(suppressWarnings(seg.lm.fit(y, XREG, Z, PSI1, w, offs, opz1)), silent=TRUE)
ss00<-o0$SumSquares.no.gap
} else {
est.psi00<-est.psi0<-apply(PSI,2,mean)
ss00<-opz$dev0
}
}
n.intDev0<-nchar(strsplit(as.character(ss00),"\\.")[[1]][1])
all.est.psi.boot<-all.selected.psi<-all.est.psi<-matrix(NA, nrow=n.boot, ncol=length(est.psi0))
all.ss<-all.selected.ss<-rep(NA, n.boot)
if(is.null(size.boot)) size.boot<-n
Z.orig<-Z
count.random<-0
id.uguali<-0
k.psi.change<- 1
alpha<-.1
for(k in seq(n.boot)){
n.boot.rev<- 3
diff.selected.ss <- rev(diff(na.omit(all.selected.ss)))
if(length(diff.selected.ss)>=(n.boot.rev-1) && all(round(diff.selected.ss[1:(n.boot.rev-1)],6)==0)){
qpsi<-sapply(1:ncol(Z),function(i)mean(est.psi0[i]>=Z[,i]))
qpsi<-ifelse(abs(qpsi-.5)<.1, alpha, qpsi)
alpha<-1-alpha
est.psi0<-sapply(1:ncol(Z),function(i)quantile(Z[,i],probs=1-qpsi[i],names=FALSE))
}
PSI <- matrix(rep(est.psi0, rep(nrow(Z), length(est.psi0))), ncol = length(est.psi0))
if(jt) Z<-apply(Z.orig,2,jitter)
if(nonParam){
id<-sample(n, size=size.boot, replace=TRUE)
o.boot<-try(suppressWarnings(seg.lm.fit(y[id], XREG[id,,drop=FALSE], Z[id,,drop=FALSE], PSI[id,,drop=FALSE],
w[id], offs[id], opz.boot)), silent=TRUE)
} else {
yy<-fitted.ok+sample(residuals(o0),size=n, replace=TRUE)
o.boot<-try(suppressWarnings(seg.lm.fit(yy, XREG, Z.orig, PSI, weights, offs, opz.boot)), silent=TRUE)
}
if(is.list(o.boot)){
all.est.psi.boot[k,]<-est.psi.boot<-o.boot$psi
} else {
est.psi.boot<-apply(rangeZ,2,function(r)runif(1,r[1],r[2]))
}
PSI <- matrix(rep(est.psi.boot, rep(nrow(Z), length(est.psi.boot))), ncol = length(est.psi.boot))
opz$h<-max(opz$h*.9, .2)
opz$it.max<-opz$it.max+1
o<-try(suppressWarnings(seg.lm.fit(y, XREG, Z.orig, PSI, w, offs, opz, return.all.sol=TRUE)), silent=TRUE)
if(!is.list(o) && random){
est.psi0<-apply(rangeZ,2,function(r)runif(1,r[1],r[2]))
PSI1 <- matrix(rep(est.psi0, rep(nrow(Z), length(est.psi0))), ncol = length(est.psi0))
o<-try(suppressWarnings(seg.lm.fit(y, XREG, Z, PSI1, w, offs, opz1)), silent=TRUE)
count.random<-count.random+1
}
if(is.list(o)){
if(!"coefficients"%in%names(o$obj)) o<-extract.psi(o)
all.est.psi[k,]<-o$psi
all.ss[k]<-o$SumSquares.no.gap
if(o$SumSquares.no.gap<=ifelse(is.list(o0), o0$SumSquares.no.gap, 10^12)) {o0<-o; k.psi.change<- k}
est.psi0<-o0$psi
all.selected.psi[k,] <- est.psi0
all.selected.ss[k]<-o0$SumSquares.no.gap
}
if(visualBoot) {
flush.console()
cat(paste("boot sample = ", sprintf("%2.0f",k),
" opt.dev = ", sprintf(paste("%", n.intDev0+6, ".5f",sep=""), o0$SumSquares.no.gap),
" n.psi = ",formatC(length(unlist(est.psi0)),digits=0,format="f"),
" est.psi = ",paste(formatC(unlist(est.psi0),digits=3,format="f"), collapse=" "),
sep=""), "\n")
}
asss<-na.omit(all.selected.ss)
if(length(asss)>break.boot){
if(all(rev(round(diff(asss),6))[1:(break.boot-1)]==0)) break
}
}
all.selected.psi<-rbind(est.psi00,all.selected.psi)
all.selected.ss<-c(ss00, all.selected.ss)
ris<-list(all.selected.psi=drop(all.selected.psi),all.selected.ss=all.selected.ss, all.psi=all.est.psi, all.ss=all.ss)
if(is.null(o0$obj)){
PSI1 <- matrix(rep(est.psi0, rep(nrow(Z), length(est.psi0))), ncol = length(est.psi0))
o0<-try(suppressWarnings(seg.lm.fit(y, XREG, Z, PSI1, w, offs, opz1)), silent=TRUE)
}
if(!is.list(o0)) return(0)
o0$boot.restart<-ris
rm(.Random.seed, envir=globalenv())
return(o0)
}
|
sc_triangle <- function(x, ...) {
UseMethod("sc_triangle")
}
sc_triangle.default <- function(x, ...) {
sc_triangle(silicate::TRI0(x), ...)
}
sc_triangle.TRI0 <- function(x, ...) {
obj <- sc_object(x)
topol <- obj$topology_
for (i in seq_along(topol)) {
topol[[i]][["object_"]] <- as.character(i)
}
do.call(rbind, topol)
}
sc_triangle.TRI <- function(x, ...) {
x[["triangle"]]
}
sc_triangle.mesh3d <- function(x, ...) {
tri <- x[["it"]]
if (is.null(tri)) stop("no triangles in this model")
tibble::tibble(.vx0 = tri[1L, ],
.vx1 = tri[2L, ],
.vx2 = tri[3L, ])
}
|
NULL
NULL
NULL
tensor.in <- function(X1,X2){
l <- lapply(1:ncol(X1),function(i) {X1[,i]*X2})
do.call(cbind, l)
}
tensor.prod.X <- function (X)
{
m <- length(X)
if(m>1){
T <- tensor.in(X[[1]],X[[2]])
if(m>2){
for (j in 3:m){
T <- tensor.in(T,X[[m]])
}
}
}else{
T <- X[[1]]
}
T
}
tensor.prod.S <- function (S)
{
m <- length(S)
I <- vector("list", m)
for (i in 1:m) {
n <- ncol(S[[i]])
I[[i]] <- diag(n)
}
TS <- vector("list", m)
if (m == 1)
TS[[1]] <- S[[1]]
else for (i in 1:m) {
if (i == 1)
M0 <- S[[1]]
else M0 <- I[[1]]
for (j in 2:m) {
if (i == j)
M1 <- S[[i]]
else M1 <- I[[j]]
M0 <- M0 %x% M1
}
TS[[i]] <- if (ncol(M0) == nrow(M0))
(M0 + t(M0))/2
else M0
}
TS
}
crs <- function(x, knots=NULL,df=10, intercept=TRUE) {
n <- length(x)
if (is.null(knots))
{
if (is.null(df)) {df <- 10}
if(df<3) {stop("Number of knots should be at least 3, 1 interior plus 2 boundaries")}
if(n<2) {stop("Please specify at least 2 values or specify at least 3 knots via knots=...")}
knots <- stats::quantile(unique(x),seq(0,1,length=df))
}
k <- length(knots)
if (k<3) {stop("Please specify at least 3 knots, 1 interior plus 2 boundaries")}
knots <- sort(knots)
h <- diff(knots)
F.P <- crs.FP(knots,h)
F.mat <- F.P$F.mat
F.mat1 <- rbind(rep(0,k),F.mat)
F.mat2 <- rbind(F.mat,rep(0,k))
P.mat <- F.P$P.mat
condition.min <- rep(0,n)
condition.min[x<min(knots)] <- 1
condition.max <- rep(0,n)
condition.max[x>max(knots)] <- 1
x.min <- x[condition.min==1]
x.max <- x[condition.max==1]
len.min <- length(x.min)
len.max <- length(x.max)
x[condition.min==1] <- min(knots)
x[condition.max==1] <- max(knots)
condition <- matrix(0,nrow=n,ncol=k-1)
for (l in 1:(k-1)){
condition[(x >= knots[l]) & (x < knots[l+1]),l] <- 1
}
a.minus <- sapply(1:(k-1),function(l) (knots[l+1]-x)/h[l])
a.plus <- sapply(1:(k-1),function(l) (x-knots[l])/h[l])
c.minus <- 1/6*sapply(1:(k-1),function(l) (knots[l+1]-x)^3/h[l] - h[l]*(knots[l+1]-x))
c.plus <- 1/6*sapply(1:(k-1),function(l) (x-knots[l])^3/h[l] - h[l]*(x-knots[l]))
a.minus <- a.minus*condition
a.plus <- a.plus*condition
c.minus <- c.minus*condition
c.plus <- c.plus*condition
Ident <- diag(k-1)
Mat_j <- cbind(Ident,rep(0,k-1))
Mat_j_1 <- cbind(rep(0,k-1),Ident)
b <- c.minus%mult%F.mat1 + c.plus%mult%F.mat2 + a.minus%mult%Mat_j + a.plus%mult%Mat_j_1
if(any(x == max(knots))) b[x == max(knots), k] <- 1
if (sum(condition.min)>0){
v1 <- (x.min-min(knots))
v2 <- -h[1]/6*F.mat[1,] - 1/h[1]*c(1,rep(0,k-1)) + 1/h[1]*c(0,1,rep(0,k-2))
b[condition.min==1,] <- b[condition.min==1,] +
matrix(v1*rep(v2,each=len.min),nrow=len.min,ncol=k)
}
if (sum(condition.max)>0){
v1 <- (x.max-max(knots))
v2 <- h[k-1]/6*F.mat[k-2,] - 1/h[k-1]*c(rep(0,k-2),1,0) + 1/h[k-1]*c(rep(0,k-1),1)
b[condition.max==1,] <- b[condition.max==1,] +
matrix(v1*rep(v2,each=len.max),nrow=len.max,ncol=k)
}
if(intercept == FALSE) {
return(list(bs=b[,-1],pen=P.mat[-1,-1],knots=knots))
} else {
return(list(bs=b,pen=P.mat,knots=knots))
}
}
crs.FP <- function(knots,h){
k <- length(knots)
if (k<3) {stop("Please specify at least 3 knots, 1 interior plus 2 boundaries")}
B <- matrix(0,nrow=k-2,ncol=k-2)
D <- matrix(0,nrow=k-2,ncol=k)
for (i in 1:(k-2)){
D[i,i] <- 1/h[i]
D[i,i+1] <- -1/h[i]-1/h[i+1]
D[i,i+2] <- 1/h[i+1]
B[i,i] <- (h[i]+h[i+1])/3
if(i<(k-2)){
B[i,i+1] <- B[i+1,i] <- h[i+1]/6
}
}
F.mat <- chol2inv(chol(B))%mult%D
P.mat <- D%cross%F.mat
P.mat <- (P.mat+t(P.mat))*0.5
return(list(F.mat=F.mat,P.mat=P.mat))
}
smf <- function(..., knots=NULL,df=NULL,by=NULL,same.rho=FALSE){
by <- substitute(by)
if(!is.character(by)) by <- deparse(by)
smooth.spec(..., knots=knots,df=df,by=by,option="smf",same.rho=same.rho)
}
tensor <- function(..., knots=NULL,df=NULL,by=NULL,same.rho=FALSE){
by <- substitute(by)
if(!is.character(by)) by <- deparse(by)
smooth.spec(..., knots=knots,df=df,by=by,option="tensor",same.rho=same.rho)
}
tint <- function(..., knots=NULL,df=NULL,by=NULL,same.rho=FALSE){
by <- substitute(by)
if(!is.character(by)) by <- deparse(by)
smooth.spec(..., knots=knots,df=df,by=by,option="tint",same.rho=same.rho)
}
rd <- function(...){
smooth.spec(...,option="rd")
}
smooth.spec <- function(..., knots=NULL,df=NULL,by=NULL,option=NULL,same.rho=FALSE){
if (is.null(option)) {
option <- "smf"
}else{
if (!option %in% c("tensor","smf","tint","rd")) stop("option must be : smf, tensor, tint or rd")
}
if (option!="smf") {
df.def <- 5
}else{
df.def <- 10
}
vars <- as.list(substitute(list(...)))[-1]
dim <- length(vars)
name <- paste0(option,"(",paste(vars,collapse=","),")")
term <- deparse(vars[[1]], backtick = TRUE)
if (dim > 1) {
for (i in 2:dim) term[i] <- deparse(vars[[i]], backtick = TRUE)
}
for (i in 1:dim) term[i] <- attr(stats::terms(stats::reformulate(term[i])), "term.labels")
if (option=="rd"){
spec <- list(term=term,dim=dim,knots=NULL,df=NULL,by=NULL,same.rho=NULL,name=name)
class(spec) <- paste(option,".smooth.spec",sep="")
return(spec)
}
if (is.null(knots)) {
if (is.null(df)) {
df <- rep(df.def,dim)
}else{
if (length(df)!=dim){
df <- rep(df.def,dim)
warning("wrong df length, df put to ",df.def," for each covariate")
}
}
}else{
if(!is.list(knots)) {
if(dim>1) stop("knots must be a list argument")
knots <- list(knots)
}
if (length(knots)!=dim){
df <- rep(df.def,dim)
knots <- NULL
warning("wrong list of knots, df put to ",df.def," for each covariate and quantiles used")
}else{
df.temp <- sapply(knots,FUN=length)
if (is.null(df)) {
df <- df.temp
}else{
if (any(df!=df.temp)){
df <- df.temp
if (all(df>2)) warning("wrong df, df put to ",df.temp)
}
}
}
}
spec <- list(term=term,dim=dim,knots=knots,df=df,by=by,same.rho=same.rho,name=name)
class(spec) <- paste(option,".smooth.spec",sep="")
spec
}
smooth.cons <- function(term, knots, df, by=NULL, option, data.spec, same.rho=FALSE, name){
if (option=="rd"){
dim <- 1
pen <- vector("list", dim)
X <- stats::model.matrix(stats::as.formula(paste0("~",paste(term,collapse=":"),"-1")),data=data.spec)
n.col <- dim(X)[2]
pen[[1]] <- diag(n.col)
colnames(X) <- rep(paste(name,".",1:n.col,sep=""))
lambda.name <- rep(name)
res <- list(X=X,pen=pen,term=term,dim=dim,lambda.name=lambda.name)
return(res)
}
centering <- TRUE
dim <- length(term)
if(!is.character(by)) by <- deparse(by)
by.var <- eval(parse(text=by),envir=as.environment(data.spec))
if (!is.null(by.var)){
if(!is.factor(by.var)) centering <- FALSE
}
all.df <- if(!is.null(knots)){sapply(knots,length)}else{df}
all.df <- all.df+rep(if(option=="smf" & centering){-1}else{0},dim)
sum.df <- sum(all.df)
Base <- vector("list", dim)
bs <- vector("list", dim)
pen <- vector("list", dim)
Z.smf <- vector("list", dim)
Z.tint <- vector("list", dim)
if (option=="smf") sum.temp <- 1
if (!is.null(knots) & is.null(names(knots))) names(knots) <- term
if (is.null(names(df))) names(df) <- term
knots2 <- vector("list", dim)
names(knots2) <- term
for (i in 1:dim){
Base[[i]] <- crs(eval(parse(text=term[i]),envir=as.environment(data.spec)),knots=knots[[term[i]]],df=df[[term[i]]],intercept=TRUE)
bs[[i]] <- Base[[i]]$bs
knots2[[i]] <- Base[[i]]$knots
if (option=="smf") {
if (centering) {
contr.smf <- constraint(bs[[i]],Base[[i]]$pen)
bs[[i]] <- contr.smf$X
pen[[i]] <- matrix(0,nrow=sum.df,ncol=sum.df)
pen[[i]][(sum.temp:(sum.temp+all.df[i]-1)),(sum.temp:(sum.temp+all.df[i]-1))] <- contr.smf$S
sum.temp <- sum.temp+all.df[i]
Z.smf[[i]] <- contr.smf$Z
}else{
pen[[i]] <- matrix(0,nrow=sum.df,ncol=sum.df)
pen[[i]][(sum.temp:(sum.temp+all.df[i]-1)),(sum.temp:(sum.temp+all.df[i]-1))] <- Base[[i]]$pen
sum.temp <- sum.temp+all.df[i]
Z.smf[[i]] <- NULL
}
}else{
if (option=="tint") {
contr.tint <- constraint(bs[[i]],Base[[i]]$pen)
bs[[i]] <- contr.tint$X
pen[[i]] <- contr.tint$S
Z.tint[[i]] <- contr.tint$Z
}else{
pen[[i]] <- Base[[i]]$pen
Z.smf <- NULL
}
}
}
if (option=="smf") {
X <- bs[[1]]
Z.tensor <- NULL
Z.tint <- NULL
}
if (option=="tensor") {
if (centering) {
contr.tensor <- constraint(tensor.prod.X(bs),tensor.prod.S(pen))
X <- contr.tensor$X
pen <- contr.tensor$S
Z.tensor <- contr.tensor$Z
Z.smf <- NULL
Z.tint <- NULL
}else{
X <- tensor.prod.X(bs)
pen <- tensor.prod.S(pen)
Z.tensor <- NULL
Z.smf <- NULL
Z.tint <- NULL
}
}
if (option=="tint") {
X <- tensor.prod.X(bs)
pen <- tensor.prod.S(pen)
Z.smf <- NULL
Z.tensor <- NULL
}
n.col <- NCOL(X)
if (!is.null(by.var)){
if (is.factor(by.var)){
lev <- levels(by.var)
n.lev <- length(lev)
dum = stats::model.matrix(~by.var-1)
colnames(dum) <- gsub("by.var",by,colnames(dum))
if (is.ordered(by.var)) {
ind.level <- 1
position.factor <- (1:n.lev)[-ind.level]
n.lev <- n.lev - 1
}else{
position.factor <- 1:n.lev
}
dim.pen2 <- n.col*n.lev
X <- do.call(cbind,lapply(position.factor,function(i) X*dum[,i]))
colnames(X) <- sapply(position.factor,function(i) rep(paste(name,":",colnames(dum)[i],".",1:n.col,sep="")))
dim2 <- dim*n.lev
pen2 <- vector("list", dim2)
pen.same <- vector("list", dim)
for (i in 1:dim){
pen.same[[i]] <- matrix(0,nrow=dim.pen2,ncol=dim.pen2)
for (j in (n.lev*(i-1)+1):(n.lev*i)){
pen2[[j]] <- matrix(0,nrow=dim.pen2,ncol=dim.pen2)
k <- j - n.lev*(i-1)
position <- (1+n.col*(k-1)):(n.col*k)
pen2[[j]][position,position] <- pen[[i]]
pen.same[[i]] <- pen.same[[i]] + pen2[[j]]
}
}
if (same.rho) {
pen <- pen.same
if (dim==1){
lambda.name <- paste(name,":",by,sep="")
}else{
lambda.name <- rep(paste(name,":",by,".",1:dim,sep=""))
}
}else{
pen <- pen2
if (dim==1){
lambda.name <- sapply(position.factor,function(i) paste(name,":",colnames(dum)[i],sep=""))
}else{
lambda.name <- c(sapply(1:dim,function(j) sapply(position.factor,function(i) paste(name,":",colnames(dum)[i],".",j,sep=""))))
}
}
}else{
X <- X*by.var
colnames(X) <- paste(name,":",by,".",1:n.col,sep="")
if (dim==1){
lambda.name <- paste(name,":",by,sep="")
}else{
lambda.name <- paste(name,":",by,".",1:dim,sep="")
}
}
}else{
colnames(X) <- paste(name,".",1:n.col,sep="")
if (dim==1){
lambda.name <- name
}else{
lambda.name <- paste(name,".",1:dim,sep="")
}
}
list(X=X,pen=pen,term=term,knots=knots2,dim=dim,all.df=all.df,sum.df=sum.df,Z.tensor=Z.tensor,Z.smf=Z.smf,Z.tint=Z.tint,lambda.name=lambda.name)
}
constraint <- function(X,S,Z=NULL){
if (is.null(Z)){
C <- colSums2(X)
qrc <- qr(C)
Z <- qr.Q(qrc,complete=TRUE)[,2:length(C)]
}
XZ <- X%mult%Z
if(is.list(S)){
length.S <- length(S)
SZ <- lapply(1:length.S,function(i) Z%cross%S[[i]]%mult%Z)
}else{
SZ <- Z%cross%S%mult%Z
}
list(X=XZ,S=SZ,Z=Z)
}
smooth.cons.integral <- function(term, knots, df, by=NULL, option, data.spec, Z.smf, Z.tensor, Z.tint, name){
if (option=="rd"){
dim <- length(term)
X <- stats::model.matrix(stats::as.formula(paste0("~",paste(term,collapse=":"),"-1")),data=data.spec)
n.col <- dim(X)[2]
colnames(X) <- rep(paste(name,".",1:n.col,sep=""))
return(X)
}
centering <- TRUE
dim <- length(term)
if(!is.character(by)) by <- deparse(by)
by.var <- eval(parse(text=by),envir=as.environment(data.spec))
if (!is.null(by.var)){
if(!is.factor(by.var)) centering <- FALSE
}
if (!is.null(knots) & is.null(names(knots))) names(knots) <- term
if (is.null(names(df))) names(df) <- term
Base <- vector("list",dim)
bs <- vector("list", dim)
for (i in 1:dim){
Base[[i]] <- crs(eval(parse(text=term[i]),envir=as.environment(data.spec)),knots=knots[[term[i]]],df=df[[term[i]]],intercept=TRUE)
bs[[i]] <- Base[[i]]$bs
if (option=="smf") {
if (centering) bs[[i]] <- bs[[i]]%mult%Z.smf[[i]]
}
if (option=="tint") {
bs[[i]] <- bs[[i]]%mult%Z.tint[[i]]
}
}
if (option=="smf") {
X <- bs[[1]]
}
if (option=="tensor") {
X <- tensor.prod.X(bs)
if (centering) X <- X%mult%Z.tensor
}
if (option=="tint") {
X <- tensor.prod.X(bs)
}
n.col <- NCOL(X)
if (!is.null(by.var)){
if (is.factor(by.var)){
lev <- levels(by.var)
n.lev <- length(lev)
dum = stats::model.matrix(~by.var-1)
colnames(dum) <- gsub("by.var",by,colnames(dum))
if (is.ordered(by.var)) {
ind.level <- 1
position.factor <- (1:n.lev)[-ind.level]
n.lev <- n.lev - 1
}else{
position.factor <- 1:n.lev
}
X <- do.call(cbind,lapply(position.factor,function(i) X*dum[,i]))
colnames(X) <- sapply(position.factor,function(i) rep(paste(name,":",colnames(dum)[i],".",1:n.col,sep="")))
}else{
X <- X*by.var
colnames(X) <- rep(paste(name,":",by,".",1:n.col,sep=""))
lambda.name <- rep(paste(name,":",by,".",1:dim,sep=""))
}
}else{
colnames(X) <- rep(paste(name,".",1:n.col,sep=""))
lambda.name <- rep(paste(name,".",1:dim,sep=""))
}
return(X)
}
instr <- function(str1,str2,startpos=1,n=1){
aa=unlist(strsplit(substring(str1,startpos),str2))
if(length(aa) < n+1 ) return(0);
return(sum(nchar(aa[1:n])) + startpos+(n-1)*nchar(str2) )
}
model.cons <- function(formula,lambda,data.spec,t1,t1.name,t0,t0.name,event,event.name,expected,expected.name,type,n.legendre,cl,beta.ini){
formula <- stats::as.formula(formula)
Terms <- stats::terms(formula)
tmp <- attr(Terms, "term.labels")
if(attr(Terms, "intercept")==0){
intercept <- "-1"
}else{
intercept <- ""
}
ind.smf <- grep("^smf\\(", tmp)
ind.tensor <- grep("^tensor\\(", tmp)
ind.tint <- grep("^tint\\(", tmp)
ind.rd <- grep("^rd\\(", tmp)
Ad <- tmp[ind.smf]
Tens <- tmp[ind.tensor]
Tint <- tmp[ind.tint]
Rd <- tmp[ind.rd]
smooth.smf <- FALSE
smooth.tensor <- FALSE
smooth.tint <- FALSE
smooth.rd <- FALSE
length.Ad <- length(Ad)
length.Tens <- length(Tens)
length.Tint <- length(Tint)
length.Rd <- length(Rd)
if (length.Ad!=0) smooth.smf <- TRUE
if (length.Tens!=0) smooth.tensor <- TRUE
if (length.Tint!=0) smooth.tint <- TRUE
if (length.Rd!=0) smooth.rd <- TRUE
if (smooth.smf | smooth.tensor | smooth.tint | smooth.rd){
Para <- tmp[-c(ind.smf,ind.tensor,ind.tint,ind.rd)]
}else{
Para <- tmp
}
if (length(Para)==0){
formula.para <- stats::as.formula("~1")
}else{
formula.para <- stats::as.formula(paste("~",paste(Para,collapse="+"),intercept,sep=""))
}
X.para <- stats::model.matrix(formula.para,data=data.spec)
df.para <- NCOL(X.para)
X.smf <- NULL
X.tensor <- NULL
X.tint <- NULL
X.rd <- NULL
Z.smf <- NULL
Z.tensor <- NULL
Z.tint <- NULL
S.smf <- NULL
S.tensor <- NULL
S.tint <- NULL
S.rd <- NULL
if (smooth.smf){
X.smf <- vector("list",length.Ad)
S.smf <- vector("list",length.Ad)
Z.smf <- vector("list",length.Ad)
list.smf <- vector("list",length.Ad)
dim.smf <- vector(length=length.Ad)
df.smf <- vector(length=length.Ad)
smooth.name.smf <- vector(length=length.Ad)
lambda.name.smf <- vector("list",length.Ad)
for (i in 1:length.Ad){
list.smf[[i]] <- eval(parse(text=Ad[i]))
if(list.smf[[i]]$dim>1) stop("smf calls must contain only one covariate")
temp <- smooth.cons(list.smf[[i]]$term,list.smf[[i]]$knots,list.smf[[i]]$df,list.smf[[i]]$by,option="smf",data.spec,list.smf[[i]]$same.rho,list.smf[[i]]$name)
X.smf[[i]] <- temp$X
S.smf[[i]] <- temp$pen
Z.smf[[i]] <- temp$Z.smf
list.smf[[i]]$knots <- temp$knots
dim.smf[i] <- length(temp$pen)
df.smf[i] <- NCOL(temp$X)
smooth.name.smf[i] <- list.smf[[i]]$name
lambda.name.smf[[i]] <- temp$lambda.name
}
X.smf <- do.call(cbind, X.smf)
}
if (smooth.tensor){
X.tensor <- vector("list",length.Tens)
S.tensor <- vector("list",length.Tens)
Z.tensor <- vector("list",length.Tens)
list.tensor <- vector("list",length.Tens)
dim.tensor <- vector(length=length.Tens)
df.tensor <- vector(length=length.Tens)
smooth.name.tensor <- vector(length=length.Tens)
lambda.name.tensor <- vector("list",length.Tens)
for (i in 1:length.Tens){
list.tensor[[i]] <- eval(parse(text=Tens[i]))
temp <- smooth.cons(list.tensor[[i]]$term,list.tensor[[i]]$knots,list.tensor[[i]]$df,list.tensor[[i]]$by,option="tensor",data.spec,list.tensor[[i]]$same.rho,list.tensor[[i]]$name)
dim.tensor[i] <- length(temp$pen)
df.tensor[i] <- NCOL(temp$X)
X.tensor[[i]] <- temp$X
S.tensor[[i]] <- temp$pen
Z.tensor[[i]] <- temp$Z.tensor
list.tensor[[i]]$knots <- temp$knots
smooth.name.tensor[i] <- list.tensor[[i]]$name
lambda.name.tensor[[i]] <- temp$lambda.name
}
X.tensor <- do.call(cbind, X.tensor)
}
if (smooth.tint){
X.tint <- vector("list",length.Tint)
S.tint <- vector("list",length.Tint)
Z.tint <- vector("list",length.Tint)
list.tint <- vector("list",length.Tint)
dim.tint <- vector(length=length.Tint)
df.tint <- vector(length=length.Tint)
smooth.name.tint <- vector(length=length.Tint)
lambda.name.tint <- vector("list",length.Tint)
for (i in 1:length.Tint){
list.tint[[i]] <- eval(parse(text=Tint[i]))
temp <- smooth.cons(list.tint[[i]]$term,list.tint[[i]]$knots,list.tint[[i]]$df,list.tint[[i]]$by,option="tint",data.spec,list.tint[[i]]$same.rho,list.tint[[i]]$name)
dim.tint[i] <- length(temp$pen)
df.tint[i] <- NCOL(temp$X)
X.tint[[i]] <- temp$X
S.tint[[i]] <- temp$pen
Z.tint[[i]] <- temp$Z.tint
list.tint[[i]]$knots <- temp$knots
smooth.name.tint[i] <- list.tint[[i]]$name
lambda.name.tint[[i]] <- temp$lambda.name
}
X.tint <- do.call(cbind, X.tint)
}
if (smooth.rd){
X.rd <- vector("list",length.Rd)
S.rd <- vector("list",length.Rd)
Z.rd <- vector("list",length.Rd)
list.rd <- vector("list",length.Rd)
dim.rd <- vector(length=length.Rd)
df.rd <- vector(length=length.Rd)
smooth.name.rd <- vector(length=length.Rd)
lambda.name.rd <- vector("list",length.Rd)
for (i in 1:length.Rd){
list.rd[[i]] <- eval(parse(text=Rd[i]))
temp <- smooth.cons(list.rd[[i]]$term,list.rd[[i]]$knots,list.rd[[i]]$df,list.rd[[i]]$by,option="rd",data.spec,list.rd[[i]]$same.rho,list.rd[[i]]$name)
X.rd[[i]] <- temp$X
S.rd[[i]] <- temp$pen
dim.rd[i] <- length(temp$pen)
df.rd[i] <- NCOL(temp$X)
smooth.name.rd[i] <- list.rd[[i]]$name
lambda.name.rd[[i]] <- temp$lambda.name
}
X.rd <- do.call(cbind, X.rd)
}
X.smooth <- cbind(X.smf,X.tensor,X.tint,X.rd)
X <- cbind(X.para,X.smooth)
df.tot <- NCOL(X)
if (!smooth.smf){
dim.smf <- 0
df.smf <- 0
list.smf <- NULL
lambda.name.smf <- NULL
smooth.name.smf <- NULL
}
if (!smooth.tensor){
dim.tensor <- 0
df.tensor <- 0
list.tensor <- NULL
lambda.name.tensor <- NULL
smooth.name.tensor <- NULL
}
if (!smooth.tint){
dim.tint <- 0
df.tint <- 0
list.tint <- NULL
lambda.name.tint <- NULL
smooth.name.tint <- NULL
}
if (!smooth.rd){
dim.rd <- 0
df.rd <- 0
list.rd <- NULL
lambda.name.rd <- NULL
smooth.name.rd <- NULL
}
sum.df.smf <- sum(df.smf)
sum.df.tensor <- sum(df.tensor)
sum.df.tint <- sum(df.tint)
sum.df.rd <- sum(df.rd)
sum.dim.smf <- sum(dim.smf)
sum.dim.tensor <- sum(dim.tensor)
sum.dim.tint <- sum(dim.tint)
sum.dim.rd <- sum(dim.rd)
df.smooth <- sum.df.smf+sum.df.tensor+sum.df.tint+sum.df.rd
nb.smooth <- sum.dim.smf+sum.dim.tensor+sum.dim.tint+sum.dim.rd
name.smooth <- c(unlist(lambda.name.smf),unlist(lambda.name.tensor),unlist(lambda.name.tint),unlist(lambda.name.rd))
S <- matrix(0,nrow=df.tot,ncol=df.tot)
S.F <- matrix(0,nrow=df.tot,ncol=df.tot)
S.pen <- lapply(1:nb.smooth, function(i) matrix(0,nrow=df.tot,ncol=df.tot))
S.list <- lapply(1:nb.smooth, function(i) matrix(0,nrow=df.tot,ncol=df.tot))
S.F.list <- lapply(1:nb.smooth, function(i) matrix(0,nrow=df.tot,ncol=df.tot))
if (smooth.smf | smooth.tensor | smooth.tint | smooth.rd){
pen <- lapply(1:nb.smooth, function(i) matrix(0,nrow=df.smooth,ncol=df.smooth))
if (smooth.smf){
for (i in 1:length.Ad){
df.plus <- if(i==1){0}else{cumsum(df.smf)[i-1]}
dim.plus <- if(i==1){0}else{cumsum(dim.smf)[i-1]}
position.smf <- (1+df.plus):(df.smf[i]+df.plus)
for (j in 1:dim.smf[i]){
pen[[j+dim.plus]][position.smf,position.smf] <- S.smf[[i]][[j]]
}
}
}
if (smooth.tensor){
for (i in 1:length.Tens){
df.plus <- if(i==1){0}else{cumsum(df.tensor)[i-1]}
dim.plus <- if(i==1){0}else{cumsum(dim.tensor)[i-1]}
position.temp <- sum.df.smf+df.plus
position.tensor <- (position.temp+1):(position.temp+df.tensor[i])
for (j in 1:dim.tensor[i]){
pen[[j+sum.dim.smf+dim.plus]][position.tensor,position.tensor] <- S.tensor[[i]][[j]]
}
}
}
if (smooth.tint){
for (i in 1:length.Tint){
df.plus <- if(i==1){0}else{cumsum(df.tint)[i-1]}
dim.plus <- if(i==1){0}else{cumsum(dim.tint)[i-1]}
position.temp <- sum.df.smf+sum.df.tensor+df.plus
position.tint <- (position.temp+1):(position.temp+df.tint[i])
for (j in 1:dim.tint[i]){
pen[[j+sum.dim.smf+sum.dim.tensor+dim.plus]][position.tint,position.tint] <- S.tint[[i]][[j]]
}
}
}
if (smooth.rd){
for (i in 1:length.Rd){
df.plus <- if(i==1){0}else{cumsum(df.rd)[i-1]}
dim.plus <- if(i==1){0}else{cumsum(dim.rd)[i-1]}
position.temp <- sum.df.smf+sum.df.tensor+sum.df.tint+df.plus
position.rd <- (position.temp+1):(position.temp+df.rd[i])
for (j in 1:dim.rd[i]){
pen[[j+sum.dim.smf+sum.dim.tensor+sum.dim.tint+dim.plus]][position.rd,position.rd] <- S.rd[[i]][[j]]
}
}
}
if (is.null(lambda)) {lambda <- rep(0,nb.smooth)}
if (length(lambda)!=nb.smooth) {
if (length(lambda)==1) {
warning("lambda is of length 1. All smoothing parameters (",nb.smooth,") are set to ",lambda)
lambda <- rep(lambda,nb.smooth)
}else{
stop("lambda should be of length ",nb.smooth)
}
}
names(lambda) <- name.smooth
norm.X <- norm(X,type="I")^2
S.scale <- rep(0,nb.smooth)
for (i in 1:nb.smooth){
S.scale[i] <- norm.X/norm(pen[[i]],type="I")
pen[[i]] <- S.scale[i]*pen[[i]]
S.pen[[i]][(df.para+1):df.tot,(df.para+1):df.tot] <- pen[[i]]
S.list[[i]] <- lambda[i]*S.pen[[i]]
S.F.list[[i]] <- S.pen[[i]]/norm(S.pen[[i]],type="F")
S <- S+S.list[[i]]
S.F <- S.F+S.F.list[[i]]
}
eigen.F <- eigen(S.F,symmetric=TRUE)
U.F <- eigen.F$vectors
vp.F <- eigen.F$values
tol.S.F <- .Machine$double.eps^0.8 * max(vp.F)
pos.S.F.eigen <- vp.F[vp.F >= tol.S.F]
rank.S <- length(pos.S.F.eigen)
} else {
nb.smooth <- 0
S.scale <- 0
S.pen <- NULL
rank.S <- NULL
U.F <- NULL
}
leg <- statmod::gauss.quad(n=n.legendre,kind="legendre")
X.func <- function(t1,t1.name,data,formula,Z.smf,Z.tensor,Z.tint,list.smf,list.tensor,list.tint,list.rd){
data.t <- data
data.t[,t1.name] <- t1
design.matrix(formula,data.spec=data.t,Z.smf=Z.smf,Z.tensor=Z.tensor,Z.tint=Z.tint,list.smf=list.smf,list.tensor=list.tensor,list.tint=list.tint,list.rd=list.rd)
}
tm <- 0.5*(t1-t0)
X.GL <- lapply(1:n.legendre, function(i) X.func(tm*leg$nodes[i]+(t0+t1)/2,t1.name,data.spec,formula,Z.smf,Z.tensor,Z.tint,list.smf,list.tensor,list.tint,list.rd))
return(list(cl=cl,type=type,n.legendre=n.legendre,t0=t0,t0.name=t0.name,t1=t1,t1.name=t1.name,tm=tm,event=event,event.name=event.name,expected=expected,expected.name=expected.name,
n=dim(X)[1],p=dim(X)[2],X.para=X.para,X.smooth=X.smooth,X=X,leg=leg,X.GL=X.GL,S=S,S.scale=S.scale,rank.S=rank.S,S.F=S.F,U.F=U.F,
S.smf=S.smf,S.tensor=S.tensor,S.tint=S.tint,S.rd=S.rd,smooth.name.smf=smooth.name.smf,smooth.name.tensor=smooth.name.tensor,smooth.name.tint=smooth.name.tint,smooth.name.rd=smooth.name.rd,
S.pen=S.pen,S.list=S.list,S.F.list=S.F.list,lambda=lambda,df.para=df.para,df.smooth=df.smooth,df.tot=df.tot,
list.smf=list.smf,list.tensor=list.tensor,list.tint=list.tint,list.rd=list.rd,nb.smooth=nb.smooth,Z.smf=Z.smf,Z.tensor=Z.tensor,Z.tint=Z.tint,beta.ini=beta.ini))
}
design.matrix <- function(formula,data.spec,Z.smf,Z.tensor,Z.tint,list.smf,list.tensor,list.tint,list.rd){
formula <- stats::as.formula(formula)
Terms <- stats::terms(formula)
tmp <- attr(Terms, "term.labels")
if(attr(Terms, "intercept")==0){
intercept <- "-1"
}else{
intercept <- ""
}
ind.smf <- grep("^smf\\(", tmp)
ind.tensor <- grep("^tensor\\(", tmp)
ind.tint <- grep("^tint\\(", tmp)
ind.rd <- grep("^rd\\(", tmp)
Ad <- tmp[ind.smf]
Tens <- tmp[ind.tensor]
Tint <- tmp[ind.tint]
Rd <- tmp[ind.rd]
smooth.smf <- FALSE
smooth.tensor <- FALSE
smooth.tint <- FALSE
smooth.rd <- FALSE
length.Ad <- length(Ad)
length.Tens <- length(Tens)
length.Tint <- length(Tint)
length.Rd <- length(Rd)
if (length.Ad!=0) smooth.smf <- TRUE
if (length.Tens!=0) smooth.tensor <- TRUE
if (length.Tint!=0) smooth.tint <- TRUE
if (length.Rd!=0) smooth.rd <- TRUE
if (smooth.smf | smooth.tensor | smooth.tint | smooth.rd){
Para <- tmp[-c(ind.smf,ind.tensor,ind.tint,ind.rd)]
}else{
Para <- tmp
}
if (length(Para)==0){
formula.para <- stats::as.formula("~1")
}else{
formula.para <- stats::as.formula(paste("~",paste(Para,collapse="+"),intercept,sep=""))
}
X.para <- stats::model.matrix(formula.para,data=data.spec)
df.para <- NCOL(X.para)
X.smf <- NULL
X.tensor <- NULL
X.tint <- NULL
X.rd <- NULL
if (smooth.smf){
X.smf <- vector("list",length.Ad)
for (i in 1:length.Ad){
X.smf[[i]] <- smooth.cons.integral(list.smf[[i]]$term,list.smf[[i]]$knots,list.smf[[i]]$df,list.smf[[i]]$by,option="smf",data.spec,Z.smf=Z.smf[[i]],Z.tensor=NULL,Z.tint=NULL,list.smf[[i]]$name)
}
X.smf <- do.call(cbind, X.smf)
}
if (smooth.tensor){
X.tensor <- vector("list",length.Tens)
for (i in 1:length.Tens){
X.tensor[[i]] <- smooth.cons.integral(list.tensor[[i]]$term,list.tensor[[i]]$knots,list.tensor[[i]]$df,list.tensor[[i]]$by,option="tensor",data.spec,Z.smf=NULL,Z.tensor=Z.tensor[[i]],Z.tint=NULL,list.tensor[[i]]$name)
}
X.tensor <- do.call(cbind, X.tensor)
}
if (smooth.tint){
X.tint <- vector("list",length.Tint)
for (i in 1:length.Tint){
X.tint[[i]] <- smooth.cons.integral(list.tint[[i]]$term,list.tint[[i]]$knots,list.tint[[i]]$df,list.tint[[i]]$by,option="tint",data.spec,Z.smf=NULL,Z.tensor=NULL,Z.tint=Z.tint[[i]],list.tint[[i]]$name)
}
X.tint <- do.call(cbind, X.tint)
}
if (smooth.rd){
X.rd <- vector("list",length.Rd)
for (i in 1:length.Rd){
X.rd[[i]] <- smooth.cons.integral(list.rd[[i]]$term,list.rd[[i]]$knots,list.rd[[i]]$df,list.rd[[i]]$by,option="rd",data.spec,Z.smf=NULL,Z.tensor=NULL,Z.tint=NULL,list.rd[[i]]$name)
}
X.rd <- do.call(cbind, X.rd)
}
X.smooth <- cbind(X.smf,X.tensor,X.tint,X.rd)
X <- cbind(X.para,X.smooth)
return(X)
}
repam <- function(build){
coef.name <- colnames(build$X)
X.ini <- build$X
S.pen.ini <- build$S.pen
build$X <- build$X%mult%build$U.F
colnames(build$X) <- coef.name
if (!is.null(build$beta.ini)) build$beta.ini <- t(build$U.F)%vec%build$beta.ini
build$S.pen <- lapply(1:build$nb.smooth,function(i) build$U.F%cross%build$S.pen[[i]]%mult%build$U.F)
build$S.pen <- lapply(1:build$nb.smooth,function(i) 0.5*(t(build$S.pen[[i]])+build$S.pen[[i]]))
build$S.list <- lapply(1:build$nb.smooth,function(i) build$lambda[i]*build$S.pen[[i]])
build$S <- Reduce("+",build$S.list)
build$X.GL <- lapply(1:build$n.legendre, function(i) build$X.GL[[i]]%mult%build$U.F)
return(list(build=build,X.ini=X.ini,S.pen.ini=S.pen.ini))
}
inv.repam <- function(model,X.ini,S.pen.ini){
U <- model$U.F
T.U <- t(U)
coef.name <- colnames(model$X)
model$coefficients <- U%vec%model$coefficients
model$X <- X.ini
model$S.pen <- S.pen.ini
model$S.list <- lapply(1:model$nb.smooth,function(i) model$lambda[i]*model$S.pen[[i]])
model$S <- Reduce("+",model$S.list)
model$grad.unpen.beta <- U%vec%model$grad.unpen.beta
model$grad.beta <- U%vec%model$grad.beta
model$Hess.unpen.beta <- U%mult%model$Hess.unpen.beta%mult%T.U
model$Hess.unpen.beta <- 0.5*(model$Hess.unpen.beta + t(model$Hess.unpen.beta))
model$Hess.beta <- model$Hess.unpen.beta - model$S
model$Ve <- U%mult%model$Ve%mult%T.U
model$Ve <- 0.5*(model$Ve + t(model$Ve))
model$Vp <- U%mult%model$Vp%mult%T.U
model$Vp <- 0.5*(model$Vp + t(model$Vp))
model$edf <- rowSums(-model$Vp*(model$Hess.beta + model$S))
model$edf1 <- 2*model$edf - rowSums(t(model$Vp%mult%model$Hess.unpen.beta)*(model$Vp%mult%model$Hess.unpen.beta))
rownames(model$Vp) <- colnames(model$Vp) <- rownames(model$Ve) <- colnames(model$Ve) <-
rownames(model$Hess.unpen.beta) <- colnames(model$Hess.unpen.beta) <- rownames(model$Hess.beta) <- colnames(model$Hess.beta) <-
names(model$edf) <- names(model$edf1) <- colnames(model$X) <- names(model$grad.beta) <- names(model$grad.unpen.beta) <- names(model$coefficients) <- coef.name
optim.rho <- !is.null(model$optim.rho)
if (optim.rho){
rownames(model$Hess.rho) <- colnames(model$Hess.rho) <- names(model$grad.rho) <- names(model$lambda)
model$deriv.rho.inv.Hess.beta <- lapply(1:model$nb.smooth,function(i) U%mult%model$deriv.rho.inv.Hess.beta[[i]]%mult%T.U)
model$deriv.rho.beta <- model$deriv.rho.beta%mult%T.U
}
return(model)
}
cor.var <- function(model){
model$deriv.R1 <- deriv_R(model$deriv.rho.inv.Hess.beta,model$p,chol(model$Vp))
eigen.cor <- eigen(model$Hess.rho,symmetric=TRUE)
U.cor <- eigen.cor$vectors
vp.cor <- eigen.cor$values
ind <- vp.cor <= 0
vp.cor[ind] <- 0;vp.cor <- 1/sqrt(vp.cor+1/10)
rV <- (vp.cor*t(U.cor))
inv.Hess.rho <- crossprod(rV)
V.second <- matrix(0,model$p,model$p)
for (l in 1:model$nb.smooth){
for (k in 1:model$nb.smooth){
prod.temp <- (model$deriv.R1[[k]]%cross%model$deriv.R1[[l]])*inv.Hess.rho[k,l]
V.second <- V.second + prod.temp
}
}
model$V.second <- V.second
Vc.approx <- model$Vp + crossprod(rV%mult%model$deriv.rho.beta)
Vc <- Vc.approx + V.second
coef.name <- colnames(model$X)
rownames(Vc.approx) <- colnames(Vc.approx) <- rownames(Vc) <- colnames(Vc) <- coef.name
model$Vc.approx <- Vc.approx
model$Vc <- Vc
model$edf2 <- rowSums(-model$Hess.unpen*model$Vc)
if (sum(model$edf2) >= sum(model$edf1)) model$edf2 <- model$edf1
model$aic2 <- -2*model$ll.unpen + 2*sum(model$edf2)
model
}
survPen <- function(formula,data,t1,t0=NULL,event,expected=NULL,lambda=NULL,rho.ini=NULL,max.it.beta=200,max.it.rho=30,beta.ini=NULL,detail.rho=FALSE,detail.beta=FALSE,n.legendre=20,method="LAML",tol.beta=1e-04,tol.rho=1e-04,step.max=5){
cl <- match.call()
if (missing(formula) | missing(data) | missing(t1) | missing(event)) stop("Must have at least a formula, data, t1 and event arguments")
formula <- stats::as.formula(formula)
if (!(method %in% c("LAML","LCV"))) stop("method should be LAML or LCV")
data <- as.data.frame(unclass(data),stringsAsFactors=TRUE)
factor.term <- names(data)[sapply(data,is.factor)]
for (factor.name in names(data)[names(data)%in%factor.term]){
data[,factor.name]<-factor(data[,factor.name])
}
factor.structure <- lapply(as.data.frame(data[,names(data)%in%factor.term]),attributes)
names(factor.structure) <- factor.term
t1.name <- deparse(substitute(t1))
t1 <- eval(substitute(t1), data)
t1 <- as.numeric(t1)
n <- length(t1)
t0.name <- deparse(substitute(t0))
t0 <- eval(substitute(t0), data)
event.name <- deparse(substitute(event))
event <- eval(substitute(event), data)
expected.name <- deparse(substitute(expected))
expected <- eval(substitute(expected), data)
if (is.null(expected)){
type <- "overall"
expected <- rep(0,n)
}else{
type <- "net"
expected <- as.numeric(expected)
}
if (is.null(t0)){
t0 <- rep(0,n)
}else{
t0 <- as.numeric(t0)
}
if (length(t0) == 1) t0 <- rep(t0,n)
if (is.null(event)){
event <- rep(1,n)
}else{
event <- as.numeric(event)
}
if (any(t0>t1)) stop("some t0 values are superior to t1 values")
if (length(t0) != n) stop("t0 and t1 are different lengths")
if (length(event) != n) stop("event and t1 are different lengths")
if (length(expected) != n) stop("expected and t1 are different lengths")
build <- model.cons(formula,lambda,data,t1,t1.name,t0,t0.name,event,event.name,expected,expected.name,type,n.legendre,cl,beta.ini)
if (is.null(lambda)){
nb.smooth <- build$nb.smooth
if(nb.smooth!=0){
if (is.null(rho.ini)) rho.ini <- rep(-1,nb.smooth)
if (length(rho.ini)!=nb.smooth){
if (length(rho.ini)==1){
rho.ini <- rep(rho.ini,nb.smooth)
}else{
stop("number of initial log smoothing parameters incorrect")
}
}
param <- repam(build)
build <- param$build
X.ini <- param$X.ini
S.pen.ini <- param$S.pen.ini
beta.ini <- build$beta.ini
model <- NR.rho(build,rho.ini=rho.ini,data=data,formula=formula,max.it.beta=max.it.beta,max.it.rho=max.it.rho,beta.ini=beta.ini,
detail.rho=detail.rho,detail.beta=detail.beta,nb.smooth=nb.smooth,tol.beta=tol.beta,tol.rho=tol.rho,step.max=step.max,method=method)
model <- inv.repam(model, X.ini, S.pen.ini)
if (model$method=="LAML") model <- cor.var(model)
model$factor.structure <- factor.structure
model$converged <- !(model$Hess.beta.modif | model$Hess.rho.modif)
return(model)
}else{
build$lambda <- 0
model <- survPen.fit(build,data=data,formula=formula,max.it.beta=max.it.beta,beta.ini=beta.ini,detail.beta=detail.beta,method=method,tol.beta=tol.beta)
model$factor.structure <- factor.structure
model$converged <- !(model$Hess.beta.modif)
return(model)
}
}else{
param <- repam(build)
build <- param$build
X.ini <- param$X.ini
S.pen.ini <- param$S.pen.ini
beta.ini <- build$beta.ini
model <- survPen.fit(build,data=data,formula=formula,max.it.beta=max.it.beta,beta.ini=beta.ini,detail.beta=detail.beta,method=method,tol.beta=tol.beta)
model <- inv.repam(model, X.ini, S.pen.ini)
model$factor.structure <- factor.structure
model$converged <- !(model$Hess.beta.modif)
return(model)
}
}
survPen.fit <- function(build,data,formula,max.it.beta=200,beta.ini=NULL,detail.beta=FALSE,method="LAML",tol.beta=1e-04)
{
formula <- stats::as.formula(formula)
cl <- build$cl
n <- build$n
X <- build$X
S <- build$S
S.smf <- build$S.smf
S.tensor <- build$S.tensor
S.tint <- build$S.tint
S.rd <- build$S.rd
smooth.name.smf <- build$smooth.name.smf
smooth.name.tensor <- build$smooth.name.tensor
smooth.name.tint <- build$smooth.name.tint
smooth.name.rd <- build$smooth.name.rd
S.scale <- build$S.scale
lambda <- build$lambda
rank.S <- build$rank.S
S.list <- build$S.list
S.F <- build$S.F
S.F.list <- build$S.F.list
U.F <- build$U.F
p <- build$p
df.para <- build$df.para
df.smooth <- build$df.smooth
list.smf <- build$list.smf
list.tensor <- build$list.tensor
list.tint <- build$list.tint
list.rd <- build$list.rd
nb.smooth <- build$nb.smooth
t0 <- build$t0
t1 <- build$t1
tm <- build$tm
event <- build$event
expected <- build$expected
type <- build$type
Z.smf <- build$Z.smf
Z.tensor <- build$Z.tensor
Z.tint <- build$Z.tint
leg <- build$leg
n.legendre <- build$n.legendre
X.GL <- build$X.GL
if (is.null(beta.ini)) {beta.ini=c(log(sum(event)/sum(t1)),rep(0,df.para+df.smooth-1))}
if (any(sapply(list.smf,`[`,"by")!="NULL") |
any(sapply(list.tensor,`[`,"by")!="NULL") |
any(sapply(list.tint,`[`,"by")!="NULL") ){
beta.ini=rep(0,df.para+df.smooth)
}
Algo.optim <- NR.beta(build,beta.ini,detail.beta=detail.beta,max.it.beta=max.it.beta,tol.beta=tol.beta)
beta <- Algo.optim$beta
names(beta) <- colnames(X)
ll.unpen <- Algo.optim$ll.unpen
ll.pen <- Algo.optim$ll.pen
haz.GL <- Algo.optim$haz.GL
iter.beta <- Algo.optim$iter.beta
pred1=X%vec%beta
ft1=exp(pred1)
deriv.list <- lapply(1:n.legendre, function(i) X.GL[[i]]*haz.GL[[i]]*tm*leg$weights[i])
deriv.2.list <- lapply(1:n.legendre, function(i) X.GL[[i]]%cross%(deriv.list[[i]]))
f.first <- Reduce("+",deriv.list)
if (type=="net"){
grad.unpen.beta <- colSums2(-f.first + X*event*ft1/(ft1+expected))
}else{
grad.unpen.beta <- colSums2(-f.first + X*event)
}
grad.beta <- grad.unpen.beta-S%vec%beta
f.second <- Reduce("+",deriv.2.list)
if (type=="net"){
Hess.unpen.beta <- -f.second + X%cross%(X*event*expected*ft1/(ft1+expected)^2)
}else{
Hess.unpen.beta <- -f.second
}
neg.Hess.beta <- -Hess.unpen.beta + S
R <- try(chol(neg.Hess.beta),silent=TRUE)
Hess.beta.modif <- FALSE
if(inherits(R,"try-error"))
{
Hess.beta.modif <- TRUE
eigen.temp <- eigen(neg.Hess.beta,symmetric=TRUE)
U.temp <- eigen.temp$vectors
vp.temp <- eigen.temp$values
vp.temp[which(vp.temp<1e-7)] <- 1e-7
R <- try(chol(U.temp%mult%diag(vp.temp)%mult%t(U.temp)),silent=TRUE)
warning("beta Hessian was perturbed at convergence")
}
neg.Hess.beta <- crossprod(R)
Vp <- chol2inv(R)
Ve <- -Vp%mult%Hess.unpen.beta%mult%Vp
rownames(Ve) <- colnames(Ve) <- rownames(Vp) <- colnames(Vp) <- colnames(X)
if(nb.smooth!=0){
edf <- rowSums(-Hess.unpen.beta*Vp)
edf1 <- 2*edf - rowSums(t(Vp%mult%Hess.unpen.beta)*(Vp%mult%Hess.unpen.beta))
LCV <- -ll.unpen+sum(edf)
if(method=="LCV"){
criterion.val <- LCV
}
if (sum(lambda)<.Machine$double.eps) {
log.abs.S <- 0
M.p <- 0
sub.S <- S[1:rank.S,1:rank.S]
}else{
M.p <- p-rank.S
sub.S <- S[1:rank.S,1:rank.S]
qr.S <- qr(sub.S)
log.abs.S <- sum(log(abs(diag(qr.S$qr))))
}
log.det.Hess.beta <- as.numeric(2*determinant(R,logarithm=TRUE)$modulus)
LAML <- -(ll.pen+0.5*log.abs.S-0.5*log.det.Hess.beta+0.5*M.p*log(2*pi))
if(method=="LAML"){
criterion.val <- LAML
}
if (sum(lambda)>.Machine$double.eps) {
S.beta <- lapply(1:nb.smooth,function(i) S.list[[i]]%vec%beta)
deriv.rho.beta <- matrix(0,nrow=nb.smooth,ncol=p)
GL.temp <- vector("list",nb.smooth)
for (i in 1:nb.smooth){
deriv.rho.beta[i,] <- (-Vp)%vec%S.beta[[i]]
GL.temp[[i]] <- lapply(1:n.legendre, function(j) (X.GL[[j]]%vec%deriv.rho.beta[i,])*haz.GL[[j]])
}
if (type=="net"){
temp.deriv3 <- (X*ft1*(-ft1+expected)/(ft1+expected)^3)
temp.deriv4 <- (X*ft1*(ft1^2-4*expected*ft1+expected^2)/(ft1+expected)^4)
}else{
temp.deriv3 <- temp.deriv4 <- matrix(0)
}
if(method=="LCV"){
mat.temp <- -Vp + Ve
temp.LAML <- vector("list", 0)
temp.LAML2 <- vector("list", 0)
inverse.new.S <- matrix(0)
minus.eigen.inv.Hess.beta <- 0
Hess.LCV1 <- matrix(0,nb.smooth,nb.smooth)
}
if(method=="LAML"){
mat.temp <- matrix(0)
eigen.mat.temp <- 0
deriv.mat.temp <- vector("list",0)
deriv.rho.Ve <- vector("list",0)
inverse.new.S <- try(solve.default(sub.S),silent=TRUE)
if(inherits(inverse.new.S,"try-error")){
cat("\n","LU decomposition failed to invert penalty matrix, trying QR","\n",
"set detail.rho=TRUE for details","\n")
inverse.new.S <- try(qr.solve(qr.S))
}
if(inherits(inverse.new.S,"try-error")){
cat("\n","LU and QR decompositions failed to invert penalty matrix, trying Cholesky","\n",
"set detail.rho=TRUE for details","\n")
inverse.new.S <- chol2inv(chol(sub.S))
}
temp.LAML <- lapply(1:nb.smooth,function(i) S.list[[i]][1:rank.S,1:rank.S])
temp.LAML2 <- lapply(1:nb.smooth,function(i) -inverse.new.S%mult%temp.LAML[[i]]%mult%inverse.new.S)
}
grad.list <- grad_rho(X.GL, GL.temp, haz.GL, deriv.rho.beta, leg$weights,
tm, nb.smooth, p, n.legendre, S.list, temp.LAML, Vp, S.beta, beta, inverse.new.S,
X, temp.deriv3, event, expected, type, Ve, mat.temp, method)
grad.rho <- grad.list$grad_rho
if (method == "LCV") grad.rho <- grad.rho + deriv.rho.beta%vec%(-grad.unpen.beta)
deriv.rho.inv.Hess.beta <- grad.list$deriv_rho_inv_Hess_beta
deriv.rho.Hess.unpen.beta <- grad.list$deriv_rho_Hess_unpen_beta
deriv2.rho.beta <- lapply(1:nb.smooth, function(i) matrix(0,nrow=nb.smooth,ncol=p))
for (j in 1:nb.smooth){
for (j2 in 1:nb.smooth){
deriv2.rho.beta[[j2]][j,] <- deriv.rho.inv.Hess.beta[[j2]]%vec%S.beta[[j]] -
Vp%vec%(S.list[[j]]%vec%deriv.rho.beta[j2,])
if (j==j2){
deriv2.rho.beta[[j2]][j,] <- deriv2.rho.beta[[j2]][j,] - Vp%mult%S.beta[[j2]]
}
}
}
if (method=="LCV"){
for (j2 in 1:nb.smooth){
Hess.LCV1[,j2] <- deriv2.rho.beta[[j2]]%vec%(-grad.unpen.beta)+deriv.rho.beta%vec%(-Hess.unpen.beta%vec%deriv.rho.beta[j2,])
}
deriv.rho.Ve <- lapply(1:nb.smooth, function(j2) -( (deriv.rho.inv.Hess.beta[[j2]]%mult%Hess.unpen.beta -
Vp%mult%deriv.rho.Hess.unpen.beta[[j2]] )%mult%(-Vp) - Vp%mult%Hess.unpen.beta%mult%deriv.rho.inv.Hess.beta[[j2]]) )
deriv.mat.temp <- lapply(1:nb.smooth, function(j2) deriv.rho.Ve[[j2]]+deriv.rho.inv.Hess.beta[[j2]] )
eigen2 <- eigen(mat.temp,symmetric=TRUE)
eigen.mat.temp <- eigen2$values
}
if(method=="LAML"){
eigen2 <- eigen(Vp,symmetric=TRUE)
minus.eigen.inv.Hess.beta <- eigen2$values
}
Q <- eigen2$vectors
X.Q <- X%mult%Q
X.GL.Q <- lapply(1:n.legendre, function(i) X.GL[[i]]%mult%Q)
Hess.rho <- Hess_rho(X.GL, X.GL.Q, GL.temp, haz.GL, deriv2.rho.beta, deriv.rho.beta, leg$weights,
tm, nb.smooth, p, n.legendre, deriv.rho.inv.Hess.beta, deriv.rho.Hess.unpen.beta, S.list, minus.eigen.inv.Hess.beta,
temp.LAML, temp.LAML2, Vp, S.beta, beta, inverse.new.S,
X, X.Q, temp.deriv3, temp.deriv4, event, expected, type,
Ve, deriv.rho.Ve, mat.temp, deriv.mat.temp, eigen.mat.temp, method)
if(method=="LCV") Hess.rho <- Hess.rho + Hess.LCV1
}else{
grad.rho <- Hess.rho <- deriv.rho.beta <- deriv.rho.inv.Hess.beta <- NULL
}
}else{
edf <- edf1 <- p
LCV <- LAML <- criterion.val <- grad.rho <- Hess.rho <- deriv.rho.beta <- deriv.rho.inv.Hess.beta <- NULL
}
optim.rho <- iter.rho <- edf2 <- aic2 <- inv.Hess.rho <- Hess.rho.modif <- Vc.approx <- Vc <- NULL
res <- list(call=cl,formula=formula,t0.name=build$t0.name,t1.name=build$t1.name,event.name=build$event.name,expected.name=build$expected.name,
haz=ft1,coefficients=beta,type=type,df.para=df.para,df.smooth=df.smooth,p=p,edf=edf,edf1=edf1,edf2=edf2,aic=2*sum(edf)-2*ll.unpen,aic2=aic2,iter.beta=iter.beta,X=X,S=S,S.scale=S.scale,
S.list=S.list,S.smf=S.smf,S.tensor=S.tensor,S.tint=S.tint,S.rd=S.rd,smooth.name.smf=smooth.name.smf,smooth.name.tensor=smooth.name.tensor,smooth.name.tint=smooth.name.tint,smooth.name.rd=smooth.name.rd,
S.pen=build$S.pen,grad.unpen.beta=grad.unpen.beta,grad.beta=grad.beta,Hess.unpen.beta=Hess.unpen.beta,Hess.beta=-neg.Hess.beta,
Hess.beta.modif=Hess.beta.modif,ll.unpen=ll.unpen,ll.pen=ll.pen,deriv.rho.beta=deriv.rho.beta,deriv.rho.inv.Hess.beta=deriv.rho.inv.Hess.beta,lambda=lambda,
nb.smooth=nb.smooth,iter.rho=iter.rho,optim.rho=optim.rho,method=method,criterion.val=criterion.val,LCV=LCV,LAML=LAML,grad.rho=grad.rho,Hess.rho=Hess.rho,inv.Hess.rho=inv.Hess.rho,
Hess.rho.modif=Hess.rho.modif,Ve=Ve,Vp=Vp,Vc=Vc,Vc.approx=Vc.approx,Z.smf=Z.smf,Z.tensor=Z.tensor,Z.tint=Z.tint,
list.smf=list.smf,list.tensor=list.tensor,list.tint=list.tint,list.rd=list.rd,U.F=U.F)
class(res) <- "survPen"
res
}
predict.survPen <- function(object,newdata,newdata.ref=NULL,n.legendre=50,conf.int=0.95,do.surv=TRUE,type="standard",exclude.random=FALSE,get.deriv.H=FALSE,...){
if (!inherits(object,"survPen")) stop("object is not of class survPen")
factor.structure <- object$factor.structure
for (factor.name in names(newdata)[names(newdata)%in%names(factor.structure)]){
newdata[,factor.name] <- factor(newdata[,factor.name],
levels=factor.structure[[factor.name]]$levels,ordered=factor.structure[[factor.name]]$class[1]=="ordered")
}
qt.norm <- stats::qnorm(1-(1-conf.int)/2)
t1 <- newdata[,object$t1.name]
t0 <- rep(0,length(t1))
tm <- (t1-t0)/2
myMat <- design.matrix(object$formula,data.spec=newdata,Z.smf=object$Z.smf,Z.tensor=object$Z.tensor,Z.tint=object$Z.tint,list.smf=object$list.smf,list.tensor=object$list.tensor,list.tint=object$list.tint,list.rd=object$list.rd)
if (type=="lpmatrix") return(myMat)
beta <- object$coefficients
if (exclude.random){
vec.name <- names(beta)
pos.rd <- which(substr(vec.name,1,3)=="rd(")
if (length(pos.rd)!=0){
beta[pos.rd] <- 0
}
}
if (type=="HR"){
myMat.ref <- design.matrix(object$formula,data.spec=newdata.ref,Z.smf=object$Z.smf,Z.tensor=object$Z.tensor,Z.tint=object$Z.tint,list.smf=object$list.smf,list.tensor=object$list.tensor,list.tint=object$list.tint,list.rd=object$list.rd)
X <- myMat - myMat.ref
log.haz.ratio <- as.vector(X%vec%beta)
haz.ratio <- exp(log.haz.ratio)
if (!is.null(object$Vp)){
std<-sqrt(rowSums((X%mult%object$Vp)*X))
haz.ratio.inf <- as.vector(exp(log.haz.ratio-qt.norm*std))
haz.ratio.sup <- as.vector(exp(log.haz.ratio+qt.norm*std))
}else{
haz.ratio.inf <- NULL
haz.ratio.sup <- NULL
}
return(list(HR=haz.ratio,HR.inf=haz.ratio.inf,HR.sup=haz.ratio.sup))
}
pred.haz <- myMat%vec%beta
haz <- exp(pred.haz)
if (do.surv){
leg <- statmod::gauss.quad(n=n.legendre,kind="legendre")
X.func <- function(t1,data,object){
data.t <- data
data.t[,object$t1.name] <- t1
design.matrix(object$formula,data.spec=data.t,Z.smf=object$Z.smf,Z.tensor=object$Z.tensor,Z.tint=object$Z.tint,list.smf=object$list.smf,list.tensor=object$list.tensor,list.tint=object$list.tint,list.rd=object$list.rd)
}
X.GL <- lapply(1:n.legendre, function(i) X.func(tm*leg$nodes[i]+(t0+t1)/2,newdata,object))
cumul.haz <- lapply(1:n.legendre, function(i) (exp((X.GL[[i]]%vec%beta)))*leg$weights[i])
cumul.haz <- tm*Reduce("+",cumul.haz)
surv=exp(-cumul.haz)
}else{
surv=NULL
}
if (!is.null(object$Vp)){
std <- sqrt(rowSums((myMat%mult%object$Vp)*myMat))
haz.inf <- as.vector(exp(pred.haz-qt.norm*std))
haz.sup <- as.vector(exp(pred.haz+qt.norm*std))
if (do.surv){
cumul.haz[cumul.haz==0] <- 1e-16
deriv.cumul.haz <- lapply(1:n.legendre, function(i) X.GL[[i]]*(exp((X.GL[[i]]%vec%beta)))*leg$weights[i])
deriv.cumul.haz <- tm*Reduce("+",deriv.cumul.haz)
log.cumul.haz <- log(cumul.haz)
deriv.log.cumul.haz <- deriv.cumul.haz/cumul.haz
std.log.cumul <- sqrt(rowSums((deriv.log.cumul.haz%mult%object$Vp)*deriv.log.cumul.haz))
surv.inf=exp(-exp(log.cumul.haz+qt.norm*std.log.cumul))
surv.sup=exp(-exp(log.cumul.haz-qt.norm*std.log.cumul))
}else{
surv.inf=NULL
surv.sup=NULL
deriv.cumul.haz=NULL
}
}else{
haz.inf=NULL
haz.sup=NULL
surv.inf=NULL
surv.sup=NULL
}
if (!get.deriv.H) deriv.cumul.haz <- NULL
res<-list(haz=haz,haz.inf=haz.inf,haz.sup=haz.sup,
surv=surv,surv.inf=surv.inf,surv.sup=surv.sup,deriv.H=deriv.cumul.haz)
class(res) <- "predict.survPen"
res
}
summary.survPen <- function(object,...){
if (!inherits(object,"survPen")) stop("object is not of class survPen")
if (object$nb.smooth==0){
if(object$type=="net"){
type <- "excess hazard model"
}else{
type <- "hazard model"
}
SE.rho <- NULL
TAB.random <- NULL
random <- FALSE
edf.per.smooth <- NULL
}else{
if(object$type=="net"){
type <- "penalized excess hazard model"
}else{
type <- "penalized hazard model"
}
edf.smooth <- object$edf[(object$df.para+1):length(object$edf)]
name.edf <- names(edf.smooth)
list.name <- sapply(1:length(name.edf),function(i) substr(name.edf[i],1,instr(name.edf[i],"\\.")-1))
list.name <- factor(list.name,levels=unique(list.name))
edf.per.smooth <- tapply(edf.smooth, list.name, sum)
if (is.null(object$optim.rho)){
SE.rho <- NULL
TAB.random <- NULL
random <- FALSE
}else{
if (object$nb.smooth==1){
SE.rho <- sqrt(object$inv.Hess.rho)
}else{
SE.rho <- sqrt(diag(object$inv.Hess.rho))
}
random <- any(substr(names(object$lambda),1,2)=="rd")
if (random){
TAB.random <- cbind(Estimate = -0.5*log(object$lambda)-0.5*log(object$S.scale),`Std. Error` = 0.5*SE.rho)
colnames(TAB.random) <- c("Estimate","Std. Error")
TAB.random <- TAB.random[substr(rownames(TAB.random),1,2)=="rd",,drop=FALSE]
}else{
TAB.random <- NULL
}
}
}
if (object$p==1){
SE <- sqrt(object$Vp)
}else{
SE <- sqrt(diag(object$Vp))
}
len <- object$df.para
zvalue <- object$coefficients[1:len]/SE[1:len]
pvalue <- 2 * stats::pnorm(-abs(zvalue))
TAB <- cbind(Estimate = object$coefficients[1:len], `Std. Error` = SE[1:len],
`z value` = zvalue, `Pr(>|z|)` = pvalue)
attrs <- attributes(object$lambda)
res <- list(type = type,
call=object$call,
formula=object$formula,
coefficients=TAB,
edf.per.smooth=edf.per.smooth,
random=random,
random.effects=TAB.random,
likelihood = object$ll.unpen,
penalized.likelihood = object$ll.pen,
nb.smooth = object$nb.smooth,
smoothing.parameter = object$lambda,
parameters = object$p,
edf = sum(object$edf),
method = object$method,
criterion.val = object$criterion.val,
converged = object$converged)
attributes(res$smoothing.parameter) <- attrs
res <- c(res)
class(res) <- "summary.survPen"
res
}
print.summary.survPen <- function(x, digits = max(3, getOption("digits") - 2),
signif.stars = getOption("show.signif.stars"), ...)
{
cat(paste(noquote(x$type),"\n","\n"))
cat("Call:\n")
print(x$call)
cat("\nParametric coefficients:\n")
stats::printCoefmat(x$coefficients, P.value=TRUE, has.Pvalue=TRUE, digits = digits, signif.stars = signif.stars, na.print = "NA", ...)
if (x$random){
cat("\nRandom effects (log(sd)):\n")
print(x$random.effects)
}
if (substr(x$type,1,9)=="penalized"){
cat("\n")
cat(paste0("log-likelihood = ",signif(x$likelihood,digits),","," penalized log-likelihood = ",signif(x$penalized.likelihood,digits)))
cat("\n")
cat(paste0("Number of parameters = ",x$parameters,","," effective degrees of freedom = ",signif(x$edf,digits)))
cat("\n")
cat(paste(x$method,"=",signif(x$criterion.val,digits)),"\n","\n")
cat("Smoothing parameter(s):\n")
print(signif(x$smoothing.parameter,digits))
cat("\n")
cat("edf of smooth terms:\n")
print(signif(x$edf.per.smooth,digits))
}else{
cat("\n")
cat(paste("likelihood =",signif(x$likelihood,digits)))
cat("\n")
cat(paste("Number of parameters =",x$parameters))
}
cat("\n")
cat(paste("converged=",x$converged))
invisible(x)
cat("\n")
}
NR.beta <- function(build,beta.ini,detail.beta,max.it.beta=200,tol.beta=1e-04){
type <- build$type
X <- build$X
X.GL <- build$X.GL
event <- build$event
expected <- build$expected
leg <- build$leg
n.legendre <- build$n.legendre
t1 <- build$t1
t0 <- build$t0
tm <- build$tm
S <- build$S
p <- build$p
k=1
ll.pen=100
ll.pen.old=1
if (length(beta.ini)==1) beta.ini <- rep(beta.ini,p)
if (length(beta.ini)!=p) stop("message NR.beta: the length of beta.ini does not equal the number of regression parameters")
betaold <- beta.ini
beta1 <- betaold
if (detail.beta){
cat("---------------------------------------------------------------------------------------","\n",
"Beginning regression parameter estimation","\n","\n")
}
while(abs(ll.pen-ll.pen.old)>tol.beta|any(abs((beta1-betaold)/betaold)>tol.beta))
{
if(k > max.it.beta)
{
stop("message NR.beta: Ran out of iterations (", k, "), and did not converge ")
}
if(k>=2)
{
ll.pen.old <- ll.pen
betaold <- beta1
}
predold=X%vec%betaold
ftold=exp(predold)
haz.GL.old <- lapply(1:n.legendre, function(i) exp(X.GL[[i]]%vec%betaold))
deriv.list <- lapply(1:n.legendre, function(i) X.GL[[i]]*haz.GL.old[[i]]*leg$weights[i]*tm)
f.first <- Reduce("+",deriv.list)
if (type=="net"){
grad.unpen.beta <- colSums2(-f.first + (event*X*ftold)/(ftold+expected))
}else{
grad.unpen.beta <- colSums2(-f.first + event*X)
}
grad <- grad.unpen.beta-S%vec%betaold
deriv.2.list <- lapply(1:n.legendre, function(i) X.GL[[i]]%cross%(deriv.list[[i]]))
f.second <- Reduce("+",deriv.2.list)
if (type=="net"){
Hess.unpen <- -f.second + X%cross%(event*X*expected*ftold/(ftold+expected)^2)
}else{
Hess.unpen <- -f.second
}
Hess <- Hess.unpen-S
neg.Hess <- -Hess
R <- try(chol(neg.Hess),silent=TRUE)
if(inherits(R,"try-error"))
{
u=0.001
cpt.while <- 0
while(inherits(R,"try-error"))
{
if(cpt.while > 100)
{
stop("message NR.beta: did not succeed in inverting Hessian at iteration ", k)
}
R <- try(chol(neg.Hess+u*diag(p)),silent=TRUE)
u <- 5*u
cpt.while <- cpt.while+1
}
if (detail.beta) {cat("beta Hessian perturbation, ", cpt.while, "iterations","\n","\n")}
}
Vp <- chol2inv(R)
integral <- lapply(1:n.legendre, function(i) haz.GL.old[[i]]*leg$weights[i])
integral <- tm*Reduce("+",integral)
if (type=="net"){
ll.unpenold <- sum(-integral + event*log(ftold+expected))
}else{
ll.unpenold <- sum(-integral + event*predold)
}
ll.pen.old <- ll.unpenold-0.5*sum(betaold*(S%vec%betaold))
if (is.nan(ll.pen.old)) stop("message NR.beta: convergence issues, cannot evaluate log-likelihood")
pas <- Vp%vec%grad
beta1 <- betaold+pas
pred1 <- X%vec%beta1
ft1=exp(pred1)
haz.GL <- lapply(1:n.legendre, function(i) exp(X.GL[[i]]%vec%beta1))
integral <- lapply(1:n.legendre, function(i) haz.GL[[i]]*leg$weights[i])
integral <- tm*Reduce("+",integral)
if (type=="net"){
ll.unpen <- sum(-integral + event*log(ft1+expected))
}else{
ll.unpen <- sum(-integral + event*pred1)
}
ll.pen <- ll.unpen - 0.5*sum(beta1*(S%vec%beta1))
if (is.nan(ll.pen)) {ll.pen <- ll.pen.old - 1}
if (ll.pen < ll.pen.old - 1e-03){
cpt.beta <- 1
while (ll.pen < ll.pen.old - 1e-03){
if(cpt.beta>52) stop("message NR.beta: step has been divided by two 52 times in a row, Log-likelihood could not be optimized")
cpt.beta <- cpt.beta + 1
pas <- 0.5*pas
beta1 <- betaold+pas
pred1 <- X%vec%beta1
ft1=exp(pred1)
haz.GL <- lapply(1:n.legendre, function(i) exp(X.GL[[i]]%vec%beta1))
integral <- lapply(1:n.legendre, function(i) haz.GL[[i]]*leg$weights[i])
integral <- tm*Reduce("+",integral)
if (type=="net"){
ll.unpen <- sum(-integral + event*log(ft1+expected))
}else{
ll.unpen <- sum(-integral + event*pred1)
}
ll.pen <- ll.unpen - 0.5*sum(beta1*(S%vec%beta1))
if (is.nan(ll.pen)) {ll.pen <- ll.pen.old - 1}
}
}
if (detail.beta){
cat("iter beta: ",k,"\n",
"betaold= ", round(betaold,4),"\n",
"beta= ", round(beta1,4),"\n",
"abs((beta-betaold)/betaold)= ", round(abs((beta1-betaold)/betaold),5),"\n",
"ll.pen.old= ", round(ll.pen.old,4),"\n",
"ll.pen= ", round(ll.pen,4),"\n",
"ll.pen-ll.pen.old= ", round(ll.pen-ll.pen.old,5),"\n",
"\n"
)
}
k=k+1
}
if (detail.beta) {
cat("\n",
"Beta optimization ok, ", k-1, "iterations","\n",
"--------------------------------------------------------------------------------------","\n")
}
list(beta=beta1,ll.unpen=ll.unpen,ll.pen=ll.pen,haz.GL=haz.GL,iter.beta=k-1)
}
NR.rho <- function(build,rho.ini,data,formula,max.it.beta=200,max.it.rho=30,beta.ini=NULL,detail.rho=FALSE,detail.beta=FALSE,nb.smooth,tol.beta=1e-04,tol.rho=1e-04,step.max=5,method="LAML"){
df.tot <- build$df.tot
iter.beta <- NULL
k.rho=1
val=1
val.old=100
rho <- rho.ini
rho.old <- rho.ini
grad <- rep(1,length(rho))
if (detail.rho){
cat(
"_______________________________________________________________________________________","\n","\n",
"Beginning smoothing parameter estimation via ",method," optimization","\n",
"______________________________________________________________________________________","\n","\n")
}
while(abs(val-val.old)>tol.rho|any(abs(grad)>tol.rho))
{
if(k.rho > max.it.rho)
{
stop("message NR.rho: Ran out of iterations (", k.rho, "), and did not converge ")
}
if(k.rho>=2)
{
val.old <- val
rho.old <- rho
}
if(k.rho==1)
{
lambda=exp(rho.old)
name.lambda <- names(build$lambda)
build$lambda <- lambda
names(build$lambda) <- name.lambda
build$S <- matrix(0,df.tot,df.tot)
for (i in 1:nb.smooth){
build$S.list[[i]] <- lambda[i]*build$S.pen[[i]]
build$S <- build$S+build$S.list[[i]]
}
if (detail.rho){
cat(
"--------------------","\n",
" Initial calculation","\n",
"-------------------","\n","\n"
)
}
model <- survPen.fit(build,data=data,formula=formula,max.it.beta=max.it.beta,beta.ini=beta.ini,detail.beta=detail.beta,method=method,tol.beta=tol.beta)
beta1 <- model$coefficients
iter.beta <- c(iter.beta,model$iter.beta)
}
val.old=model$criterion.val
grad <- model$grad.rho
Hess <- model$Hess.rho
R <- try(chol(Hess),silent=TRUE)
if(inherits(R,"try-error"))
{
u=0.001
cpt.while <- 0
while(inherits(R,"try-error"))
{
if(cpt.while > 100)
{
stop("message NR.rho : did not succeed in inverting Hessian at iteration ", k.rho)
}
R <- try(chol(Hess+u*diag(nb.smooth)),silent=TRUE)
u <- 5*u
cpt.while <- cpt.while+1
}
if (detail.rho) {cat(method," Hessian perturbation, ", cpt.while, "iterations","\n","\n")}
}
inv.Hess <- chol2inv(R)
pas <- -inv.Hess%vec%grad
norm.pas <- max(abs(pas))
if (norm.pas>step.max){
if (detail.rho) {
cat("\n","\n","new step = ", signif(pas,3),"\n")
}
pas <- (step.max/norm.pas)*pas
if (detail.rho) {
cat("new step corrected = ", signif(pas,3),"\n","\n")
}
}
rho <- rho.old+pas
lambda=exp(rho)
name.lambda <- names(build$lambda)
build$lambda <- lambda
names(build$lambda) <- name.lambda
build$S <- matrix(0,df.tot,df.tot)
for (i in 1:nb.smooth){
build$S.list[[i]] <- lambda[i]*build$S.pen[[i]]
build$S <- build$S+build$S.list[[i]]
}
if (detail.rho){
cat(
"\n","Smoothing parameter selection, iteration ",k.rho,"\n","\n"
)
}
model <- survPen.fit(build,data=data,formula=formula,max.it.beta=max.it.beta,beta.ini=beta1,detail.beta=detail.beta,method=method,tol.beta=tol.beta)
beta1 <- model$coefficients
val <- model$criterion.val
if (is.nan(val)) {val <- val.old+1}
if (val>val.old+1e-03){
cpt.rho <- 1
while (val>val.old+1e-03){
if (detail.rho) {
cat("---------------------------------------------------------------------------------------","\n",
"val= ", val," et val.old= ", val.old,"\n",
method," is not optimized at iteration ", k.rho,"\n",
"Step is divided by 10","\n",
"--------------------------------------------------------------------------------------","\n","\n")
}
if(cpt.rho>16) stop("message NR.rho: step has been divided by ten 16 times in a row, ",method," could not be optimized")
cpt.rho <- cpt.rho+1
pas <- 0.1*pas
rho <- rho.old+pas
lambda=exp(rho)
name.lambda <- names(build$lambda)
build$lambda <- lambda
names(build$lambda) <- name.lambda
build$S <- matrix(0,df.tot,df.tot)
for (i in 1:nb.smooth){
build$S.list[[i]] <- lambda[i]*build$S.pen[[i]]
build$S <- build$S+build$S.list[[i]]
}
model <- survPen.fit(build,data=data,formula=formula,max.it.beta=max.it.beta,beta.ini=beta1,detail.beta=detail.beta,method=method,tol.beta=tol.beta)
beta1 <- model$coefficients
val <- model$criterion.val
if (is.nan(val)) {val <- val.old+1}
}
}
iter.beta <- c(iter.beta,model$iter.beta)
beta1 <- model$coefficients
val <- model$criterion.val
grad <- model$grad.rho
Hess <- model$Hess.rho
if (detail.rho){
cat("_______________________________________________________________________________________","\n",
"\n","iter ",method,": ",k.rho,"\n",
"rho.old= ", round(rho.old,4),"\n",
"rho= ", round(rho,4),"\n",
"val.old= ", round(val.old,4),"\n",
"val= ", round(val,4),"\n",
"val-val.old= ", round(val-val.old,5),"\n",
"gradient= ", signif(grad,2),"\n",
"\n"
)
cat("_______________________________________________________________________________________","\n","\n","\n","\n")
}
k.rho=k.rho+1
}
if (detail.rho) {
cat("Smoothing parameter(s) selection via ",method," ok, ", k.rho-1, "iterations","\n",
"______________________________________________________________________________________","\n")
}
Hess.rho.modif <- FALSE
R <- try(chol(Hess),silent=TRUE)
if(inherits(R,"try-error"))
{
Hess.rho.modif <- TRUE
eigen.temp <- eigen(Hess,symmetric=TRUE)
U.temp <- eigen.temp$vectors
vp.temp <- eigen.temp$values
vp.temp[which(vp.temp<1e-7)] <- 1e-7
R <- try(chol(U.temp%mult%diag(vp.temp)%mult%t(U.temp)),silent=TRUE)
warning("message NR.rho: rho Hessian was perturbed at convergence")
}
model$inv.Hess.rho <- chol2inv(R)
model$Hess.rho <- crossprod(R)
model$Hess.rho.modif <- Hess.rho.modif
model$iter.rho <- k.rho-1
model$iter.beta <- iter.beta
model$optim.rho <- 1
model
}
|
satinPalette <-
function(zmin, zmax, col.sep = 0.1, scheme = "default", visu = FALSE)
{
if (missing(scheme)) scheme <- "default"
if (length(scheme) > 1) {
cols <- scheme
} else {
if (scheme != "default")
stop ("scheme must be either 'default' or a vector of valid color names")
if (scheme == "default")
cols <- c("purple", "blue", "darkblue", "cyan", "green", "darkgreen", "yellow",
"orange", "red", "darkred")
}
fpal <- colorRampPalette(colors = cols)
breaks <- seq(zmin, zmax, by = col.sep)
if ( breaks[length(breaks)] < zmax )
breaks <- c(breaks, zmax)
nbcols = length(breaks) - 1
ans <- list(palette = fpal(nbcols), breaks = breaks)
if (visu == TRUE){
nb <- length(breaks)
xl <- breaks[1:(nb-1)]
xr <- breaks[2:nb]
xlims <- range(breaks)
plot(breaks, rep(0.5, nb), ylim = c(0, 1), bty = "n", xaxt = "n", yaxt = "n",
xlab = "", ylab = "", type = "n" )
rect(xl, 0, xr, 1, col = fpal(nbcols), border = "white")
axis(1, at = breaks, breaks, line = -0.7)
}
ans
}
|
sens_factor <- function(data, .name, prefix = "sens_facet_", digits = 2) {
ux <- sort(unique(data[[.name]]))
new_col <- paste0(prefix,.name)
mutate(
data,
!!new_col := factor(
.data[[.name]],
ux,
paste0(.name, " ", signif(ux,digits))
)
)
}
sens_plot <- function(data,...) UseMethod("sens_plot")
sens_plot.sens_each <- function(data, dv_name, logy = FALSE, ncol = NULL,
lwd = 0.8,
digits = 3, plot_ref = TRUE,
xlab = "time", ylab = dv_name[1],
grid = FALSE, ...) {
pars <- unique(data[["p_name"]])
npar <- length(unique(pars))
group <- sym("p_value")
x <- sym("time")
y <- sym(dv_name)
data <- as_tibble(data)
data <- select_sens(data, dv_name = dv_name)
if(!isTRUE(grid)) {
data <- group_by(data, .data[["p_name"]])
data <- mutate(data, .col = match(!!group, unique(!!group)))
data <- mutate(data, .col = (.data[[".col"]] - 1)/max(.data[[".col"]]-1))
data <- ungroup(data)
p <- ggplot(data=data, aes(!!x,!!y, group=!!group, col = .col))
p <-
p +
theme_bw() + theme(legend.position = "top") +
facet_wrap(~ p_name, scales = "free_y", ncol = ncol) +
xlab(xlab) + ylab(ylab) +
scale_color_viridis_c(
name = NULL,
breaks = c(0,0.5,1),
labels = c("low", "mid", "hi")
)
if(isTRUE(logy)) {
p <- p + scale_y_log10()
}
p <- p + geom_line(lwd = lwd)
if(isTRUE(plot_ref)) {
p <- p + geom_line(
aes(.data[["time"]], .data[["ref_value"]]),
lty = 2, lwd = lwd * 1.1, col = "black"
)
}
return(p)
}
sp <- split(data,data[["p_name"]])
plots <- lapply(sp, function(chunk) {
chunk[["p_value"]] <- signif(chunk[["p_value"]],digits)
chunk[["p_value"]] <- factor(chunk[["p_value"]])
p <- ggplot(data=chunk, aes(!!x,!!sym(y),group=!!group,col=!!group))
p <-
p +
geom_line(lwd=lwd) +
theme_bw() + xlab(xlab) + ylab(ylab) +
facet_wrap(~ p_name, scales = "free_y", ncol = ncol) +
theme(legend.position = "top") +
scale_color_discrete(name = "")
if(isTRUE(logy)) {
p <- p + scale_y_log10()
}
if(isTRUE(plot_ref)) {
p <- p + geom_line(
aes(.data[["time"]],.data[["ref_value"]]),
col="black", lty = 2, lwd = lwd * 1.1
)
}
p
})
if(isTRUE(grid)) {
plots$ncol <- ncol
return(do.call(wrap_plots, plots))
}
return(plots)
}
sens_plot.sens_grid <- function(data, dv_name, digits = 2, ncol = NULL, lwd = 0.8,
logy = FALSE, plot_ref = TRUE, ...) {
pars <- names(attr(data, "pars"))
npar <- length(pars)
if(npar > 3) {
stop(
"found more than 3 parameters in this `sens_grid` object; ",
"please construct your own `ggplot` call to plot these data ",
"or select 3 or fewer parameters for sensitivity analysis",
call. = FALSE
)
}
data <- select_sens(data, dv_name = dv_name)
group <- sym(pars[1])
tcol <- "time"
if(exists("TIME", data)) tcol <- "TIME"
x <- sym(tcol)
y <- sym(dv_name)
formula <- NULL
data[[as_string(group)]] <- signif(data[[as_string(group)]],3)
if(npar==2) {
formula <- as.formula(paste0("~sens_facet_",pars[2]))
data <- sens_factor(data, pars[2], digits = digits)
}
if(npar==3) {
formula <- as.formula(paste0("sens_facet_", pars[3], "~sens_facet_", pars[2]))
data <- sens_factor(data, pars[2], digits = digits)
data <- sens_factor(data, pars[3], digits = digits)
}
p <- ggplot(data = data, aes(!!x, !!y, group=!!group, col=factor(!!group)))
p <- p + geom_line(lwd=lwd) + scale_color_discrete(name = pars[1])
p <- p + theme_bw() + theme(legend.position = "top")
if(npar==2) p <- p + facet_wrap(formula, ncol = ncol)
if(npar==3) p <- p + facet_grid(formula)
if(isTRUE(logy)) p <- p + scale_y_log10()
if(isTRUE(plot_ref)) {
p <- p + geom_line(
aes(.data[["time"]],.data[["ref_value"]]),
col = "black", lty = 2, lwd = lwd
)
}
p
}
sens_plot.sens_each_data <- function(data, ...) {
stop(
"there is no plotting method for objects of this class. ",
"Use 'as_tibble' to coerce to a data frame and then plot with ggplot2."
)
}
|
PosteriorDraw <- function(mdObj, x, n = 1, ...){
UseMethod("PosteriorDraw", mdObj)
}
PosteriorDraw.nonconjugate <- function(mdObj, x, n = 1, ...) {
if (missing(...)) {
start_pos <- PenalisedLikelihood(mdObj, x)
} else {
start_pos <- list(...)$start_pos
}
mh_result <- MetropolisHastings(mdObj, x, start_pos, no_draws = n)
theta <- vector("list", length(mh_result$parameter_samples))
for (i in seq_along(mh_result$parameter_samples)) {
theta[[i]] <- array(mh_result$parameter_samples[[i]],
dim = c(dim(mh_result$parameter_sample[[i]])[1:2], n))
}
return(theta)
}
|
read.prmtop <- function(file) {
cl <- match.call()
if(missing(file)) {
stop("read.pdb: please specify a PDB 'file' for reading")
}
if(!file.exists(file)) {
stop("No input PDB file found: check filename")
}
prmtop <- .read_prmtop(file)
if(!is.null(prmtop$error))
stop(paste("Could not read", file))
else
class(prmtop) <- c("amber", "prmtop")
prmtop$call <- cl
return(prmtop)
}
|
dr.seas <- function(TS, Qdr=0.2, WinSize=30, IntEventDur=10, EventDur=15,
Season=c(4:9)) {
res <- dr.events(TS, Qdr, WinSize, IntEventDur, EventDur)
if (is.na(res$DroughtEvents[1,1])) {
output <- data.frame(StartDay=NA,
MidDay=NA,
EndDay=NA,
Duration=NA,
Severity=NA)
} else {
DroughtEvents <- res[[1]]
DroughtPDS <- res[[2]]
DroughtEvents$StartMonth <- as.numeric(format(DroughtEvents$Start, "%m"))
DroughtEvents$StartDay <- as.numeric(format(DroughtEvents$Start, "%j"))
DroughtEvents$EndDay <- as.numeric(format(DroughtEvents$End, "%j"))
DroughtEvents$MidDay <- NA
DroughtEvents.season <- DroughtEvents[DroughtEvents$StartMonth %in% Season,]
EventList <- unique(DroughtEvents.season$Event)
PDS.season <- DroughtPDS[DroughtPDS$Event %in% EventList,]
if (length(EventList) > 0) {
for (i in 1:length(EventList)) {
MidPoint <- as.numeric(0.5*DroughtEvents.season$Severity[i])
temp <- PDS.season[PDS.season$Event %in% EventList[i],]
HaveMid <- FALSE
j <- 1
mDef <- 0
while (HaveMid == FALSE) {
mDef <- mDef + (temp$Def[j])
if (mDef >= MidPoint) {
HaveMid <- TRUE
DroughtEvents.season$MidDay[i] <- as.numeric(format(temp$Date[j], "%j"))
}
j <- j + 1
}
}
}
output <- data.frame(StartDay=DroughtEvents.season$StartDay,
MidDay=DroughtEvents.season$MidDay,
EndDay=DroughtEvents.season$EndDay,
Duration=DroughtEvents.season$Duration,
Severity=DroughtEvents.season$Severity)
for (k in 1:5) {
attr(output[,k], "times") <- DroughtEvents.season$Start
}
attr(output[,5], "dimnames") <- NULL
}
return(output)
}
|
nTTP.array <- function(wm, toxmax) {
n.tox.grade <- ncol(wm)
n.tox.type <- nrow(wm)
nTTP <- array(NA, c(rep(n.tox.grade, n.tox.type)))
capacity <- n.tox.grade^n.tox.type
for(tt in 1 : capacity) {
index <- vec2array(tt, dim = c(rep(n.tox.grade, n.tox.type)))
nTTP[tt] <- sqrt(sum(wm[t(rbind(1 : n.tox.type, index))]^2)) / toxmax
}
return(nTTP)
}
|
equ4 <- function(temp,rate, augment=F, return_fit=F){
try_test <- try({
R<-0.001987
fit = minpack.lm::nlsLM(rate ~ a*exp(-b/(R*(temp+273.15)))-c*exp(-d/(R*(temp+273.15))),
start = list(a=1.43e10, b=12.3,c=2.13e16,d=21),
control = minpack.lm::nls.lm.control(maxiter = 10^20))
output <- broom::tidy(fit)
a <- output$estimate[output$term=="a"]
b <- output$estimate[output$term=="b"]
c <- output$estimate[output$term=="c"]
d <- output$estimate[output$term=="d"]
f_equ= function(t){a*exp(-b/(R*t))-c*exp(-d/(R*t))}
})
output <- temperatureresponse::amend_output(output,
fit,
f_equ,
temp,
rate,
try_test,
augment,
return_fit)
output$model <- "equ04"
print("equ04")
return(output)
}
|
context("if_na.vector")
suppressWarnings(RNGversion("3.5.0"))
a = 1:4
b = a
expect_identical(if_na(a, 2), b)
a[1] = NA
b[1] = 2
expect_identical(if_na(a, 2), b)
a[1] = NA
val_lab(a) = c(one = 1)
b = a
b[1] = 2
expect_identical(if_na(a, c(two = 2)), b)
expect_identical(if_na(a, 2, label = "Hard to say"), add_val_lab(b, c("Hard to say" = 2)))
a2 = a
if_na(a2, label = "Hard to say") = 2
expect_identical(a2, add_val_lab(b, c("Hard to say" = 2)))
expect_error(if_na(a, 1:4, label = "Error"))
a = 1:4
b = a
a[1] = NA
b[1] = 2
a[3] = NA
b[3] = 2
expect_identical(if_na(a, 2), b)
expect_identical(a %if_na% 2, b)
b[1] = 4
b[3] = 2
expect_identical(if_na(a, 4:1), as.integer(b))
expect_identical(a %if_na% 4:1, as.integer(b))
expect_error(if_na(a, 1:2))
expect_error(if_na(a, t(1:2)))
expect_identical(if_na(numeric(0), 1),numeric(0))
context("if_na.data.frame")
a = data.frame(a = 1:4, b = 5:8, d = 10:13)
val_lab(a$a) = c('aaa' = 1)
b = a
expect_identical(if_na(a, 2), b)
a[1,1] = NA
b[1,1] = 2
expect_equal(if_na(a, 2), b)
a[4,1] = NA
b[4,1] = 2
expect_equal(if_na(a, 2), b)
b[1,1] = 4
b[4,1] = 1
expect_equal(if_na(a, c(4:2,1.0)), b)
a[1,3] = NA
b[1,3] = 4
expect_equal(if_na(a, c(4:2,1.0)), b)
b[1,1] = 3
b[4,1] = 3
b[1,3] = 1
context("if_na.matrix")
a = as.matrix(data.frame(a = 1:4, b = 5:8, d = 10:13))
b = a
expect_identical(if_na(a, 2), b)
a[1,1] = NA
b[1,1] = 2
expect_identical(if_na(a, 2), b)
a[4,1] = NA
b[4,1] = 2
expect_identical(if_na(a, 2), b)
b[1,1] = 4
b[4,1] = 1
expect_equal(if_na(a, rep(4:1, 3)), b)
a[1,3] = NA
b[1,3] = 4
expect_equal(if_na(a, rep(4:1, 3)), b)
context("if_na list")
a = 1:4
b = 4:1
ab = list(a,b)
val_lab(ab) = c("a"=1, "b" = 2)
expect_identical(if_na(ab, 42), ab)
ab[[1]][1] = NA
ab[[2]][4] = NA
ab_no_na = ab
ab_no_na[[1]][1] = 42
ab_no_na[[2]][4] = 42
expect_identical(if_na(ab, 42), ab_no_na)
ab_no_na[[1]][1] = 42
ab_no_na[[2]][4] = 42
expect_error(if_na(ab, list(42,43)))
context("if_na help")
a = c(NA, 2, 3, 4, NA)
if_na(a) = 1
expect_identical(a, c(1, 2, 3, 4, 1))
a = c(NA, 2, 3, 4, NA)
if_na(a) = 1:5
expect_equal(a, 1:5)
set.seed(123)
group = sample(1:3, 30, replace = TRUE)
param = runif(30)
param[sample(30, 10)] = NA
df = data.frame(group, param)
context("if_na add_val_lab")
set.seed(123)
x1 = runif(30)
x2 = runif(30)
x3 = runif(30)
x1[sample(30, 10)] = NA
x2[sample(30, 10)] = NA
x3[sample(30, 10)] = NA
df = data.frame(x1, x2, x3)
df_test = df
if_na(df) = c("h/s" = 99)
df_test = within(df_test, {
x1[is.na(x1)] = 99
x2[is.na(x2)] = 99
x3[is.na(x3)] = 99
})
expect_identical(df, df_test)
context("if_na factor")
fac = factor(c("a","b",NA))
expect_identical(if_na(fac, "c"), factor(c("a","b","c")))
expect_identical(if_na(fac, "a"), factor(c("a","b","a")))
context("if_na POSIXct")
ct = c(as.POSIXct("2016-09-24"), NA)
expect_equal(if_na(ct, "2016-09-25"), as.POSIXct(c("2016-09-24", "2016-09-25")))
ct = c(as.Date("2016-09-24"), NA)
expect_equal(if_na(ct, "2016-09-25"), as.Date(c("2016-09-24", "2016-09-25")))
|
observe({
inFile <- input$file
n <- length(inFile$name)
names <- inFile$name
if (is.null(inFile))
return(NULL)
splits <- list()
for (i in 1:n) {
splits <- base::sub("/tmp/Rtmp[[:alnum:]]{6}/", "", inFile[i, "datapath"])
filenames <- list.files(temp)
oldpath <- file.path(temp, splits[i])
base::file.rename(oldpath[i], file.path(temp, "local_tempdir", inFile[i, "name"]))
base::unlink(dirname(oldpath[i]), recursive = TRUE)
}
uploaded_local <- as.data.frame(list.files(file.path(temp, "local_tempdir")))
names(uploaded_local) <- "Available Files"
Shared.data$local_files <- uploaded_local
})
output$dtfiles <- DT::renderDT({Shared.data$local_files}, selection = 'single', options = list(ordering = F, dom = 'tp'))
observe({
Shared.data$selected_row <- as.character(Shared.data$local_files[input$dtfiles_rows_selected,])
})
observeEvent(input$complete_ingest_lcl, {
tryCatch({
local_dirname <- auto.name.directory(format_name = input$InputFormatName, site_id = inputsList$siteID)
dir.create(file.path(PEcAn_path, local_dirname))
path_to_local_tempdir <- file.path(local_tempdir)
list_of_local_files <- list.files(path_to_local_tempdir)
n <- length(list_of_local_files)
for (i in 1:n){
base::file.copy(file.path(path_to_local_tempdir, list_of_local_files[i]), file.path(PEcAn_path, local_dirname, list_of_local_files[i]))
}
show("local_path_out")
output$LocaldbfilesPath <- renderText({paste0(PEcAn_path, local_dirname)})
},
error = function(e){
toastr_error(title = "Error in Select Local Files", conditionMessage(e))
},
warning = function(e){
toastr_warning(title = "Warning in Select Local Files", conditionMessage(e))
}
)
})
observeEvent(input$nextFromLocal, {
show("input_record_box")
hide("nextFromLocal_div")
})
|
"testRetest" <- function(t1,t2=NULL,keys=NULL,id="id",time= "time",select=NULL,check.keys=TRUE,warnings=TRUE,lmer=TRUE,sort=TRUE) {
cl <- match.call()
x <- t1
y <- t2
if(NCOL(x) ==1) {just.test <-TRUE } else {just.test <- FALSE}
keys.orig <- keys
if(is.null(y)) {n.times <- table(x[time])
if(id %in% colnames(x)) {
if(sort) x <- psychTools::dfOrder(x,c(time,id),) }
y <- x[x[,time] == names(n.times)[2],]
x <- x[x[,time] == names(n.times)[1],]
} else {
if(sort) {x <- psychTools::dfOrder(x,c(time,id),)
y <- psychTools::dfOrder(y,c(time,id),)
}}
if(NROW(x) != NROW(y) ) {warning("The number of subjects in x do not match those in y")
not.missing.x <- x[,id] %in% y[,id]
not.missing.y <- y[,id] %in% x[,id]
missing.idx <- x[!not.missing.x,id]
missing.idy <- y[!not.missing.y,id]
cat("\nThe non-matched subjects were\n",missing.idx, missing.idy,"\n I have deleted them")
x <- x[not.missing.x,]
y <- y[not.missing.y,]
}
n.obs <- NROW(x)
if(!just.test) {
if(!is.null(select)) {items <- select
x <- x[select]
y <- y[select]
}
if(is.null(keys)){ items <- colnames(x) [!colnames(x) %in% c(id,time)]} else {items <- keys }
n.items <- length(items)
if(is.character(items)) {
temp <- rep(1,n.items)
temp [strtrim(items,1)=="-"] <- -1
if(any( temp < 0) ) {items <- sub("-","",items) }
} else {temp <- sign(items)
items <- colnames(x)[abs(items)]
}
if(any( !(items %in% colnames(x)) )) {
cat("\nVariable names in keys are incorrectly specified. Offending items are ", items[which(!(items %in% colnames(x)))],"\n")
stop("I am stopping because of improper input in the scoring keys. See the list above for the bad item(s). ")}
x <- x[,items,drop=FALSE]
y <- y[,items,drop=FALSE]
if(NCOL(x) > 1) {mean.x <- colMeans(x,na.rm=TRUE)
mean.y <- colMeans(y,na.rm=TRUE)
}
min.item <- min(x[items],na.rm=TRUE)
max.item <- max(x[items],na.rm=TRUE)
miny.item <- min(y[items],na.rm=TRUE)
maxy.item <- max(y[items],na.rm=TRUE)
if(any(temp < 0)) {
x[items[temp <0]] <- max.item- x[items[temp < 0]] + min.item
y[items[temp <0]] <- maxy.item- y[items[temp < 0]] + miny.item
}
select <- items
if(any(colnames(x[select]) !=colnames(y[select]))) {stop("Variable names must match across tests")}
p1 <- pca(x)
p2 <- pca(y)
keys <- rep(1,n.items)
if((any(p1$loadings < 0)) | (any(p2$loadings < 0))) {if (check.keys) {if(warnings) message("Some items were negatively correlated with total scale and were automatically reversed.\n This is indicated by a negative sign for the variable name.")
keys[p1$loadings < 0] <- -1 } else {
if(is.null(keys) && warnings ) {message("Some items were negatively correlated with the total scale and probably \nshould be reversed. \nTo do this, run the function again with the 'check.keys=TRUE' option")
if(warnings) cat("Some items (",rownames(p1$loadings)[(p1$loadings < 0)],") were negatively correlated with the total scale and \nprobably should be reversed. \nTo do this, run the function again with the 'check.keys=TRUE' option")
}}
}
if(any(keys < 0)) {
newx <- t(t(x[select]) * keys + (keys < 0)* (max.item + min.item) )
newy <- t(t(y[select]) * keys + (keys < 0)* (maxy.item + miny.item))
} else {
newx <- x[select]
newy <- y[select]
}
xscore <- rowMeans(newx,na.rm=TRUE)
yscore <- rowMeans(newy,na.rm=TRUE)
r12 <- cor(xscore,yscore,use="pairwise")
x.alpha <- alpha.1(cov(newx,use="pairwise"))
y.alpha <- alpha.1(cov(newy,use="pairwise"))
xy.alpha <- rbind(unlist(x.alpha),unlist(y.alpha))
rownames(xy.alpha) <- c("x","y")
colnames(xy.alpha) <- c("raw G3","std G3","G6","av.r","S/N","se","lower","upper","var.r")
dxy <- dist(newx,newy)
rqq <- dxy$rqq
rii <- rep(NA,n.items)
for (j in (1:n.items)) {
if(!(( is.na(sd(x[,items[j]],na.rm=TRUE))) | (is.na(sd(y[,items[j]],na.rm=TRUE))))) {
rii[j] <- cor(x[,items[j]],y[,items[j]],use="pairwise")}
}
n.obs <- min(NROW(newx),NROW(newy))
xy.df <- data.frame(id = rep(1:n.obs,2), time=c(rep(1,n.obs), rep(2,n.obs)), rbind(newx,newy),row.names=1:(2*n.obs))
} else {
xy.df <- data.frame(id=rep(1:n.obs,2),time=c(time=c(rep(1,n.obs), rep(2,n.obs))),rbind(x,y)[,1],row.names=1:(2*n.obs))
no.items <- TRUE
}
if(!just.test) {
if(lmer) {ml <- mlr1(xy.df)} else {ml <- list(n.obs=n.obs,n.items=n.items)}
if(is.null(keys.orig)) keys.orig <- rep(1,n.items)
item.stats <- data.frame(rii=rii,p1=unclass(p1$loadings),p2=unclass(p2$loadings),mean1 = mean.x, mean2=mean.y, keys=keys,keys.orig=keys.orig)
colnames(item.stats)[2:3] <- c("PC1", "PC2")
key <- rownames(item.stats)
key[item.stats$keys < 0] <- paste0("-", key[item.stats$keys < 0])
scores <- data.frame(pca1 = p1$scores,pca2 = p2$scores,t1scores =xscore, t2scores = yscore,rqq=rqq,dxy=dxy$dxy,t1sd=dxy$sdx,t2sd=dxy$sdy)
result <- list(r12=r12,alpha=xy.alpha,rqq=rqq,dxy=dxy,item.stats=item.stats, scores=scores,xy.df=xy.df,key=key,ml=ml,Call=cl) } else {
if(just.test) {r12 = cor(x,y,use="pairwise")
ml <- mlr2(xy.df)
result <- list(r12 =r12,ml=ml, Call=cl)} }
class(result) <- c("psych", "testRetest")
return(result)
}
alpha.1 <- function(C,R=NULL) {
n <- dim(C)[2]
alpha.raw <- (1- tr(C)/sum(C))*(n/(n-1))
if(is.null(R)) R <- cov2cor(C)
sumR <- sum(R)
alpha.std <- (1- n/sumR)*(n/(n-1))
smc.R <- smc(R)
G6 <- (1- (n-sum(smc.R))/sumR)
av.r <- (sumR-n)/(n*(n-1))
R.adj <- R
diag(R.adj) <- NA
var.r <- var(as.vector(R.adj),na.rm=TRUE)
mod1 <- matrix(av.r,n,n)
Res1 <- R - mod1
GF1 = 1- sum(Res1^2)/sum(R^2)
Rd <- R - diag(R)
diag(Res1) <- 0
GF1.off <- 1 - sum(Res1^2)/sum(Rd^2)
sn <- n*av.r/(1-av.r)
Q = (2 * n^2/((n - 1)^2 * (sum(C)^3))) * (sum(C) * (tr(C%*%C) + (tr(C))^2) - 2 * (tr(C) * sum(C%*%C)))
result <- list(raw=alpha.raw,std=alpha.std,G6=G6,av.r=av.r,sn=sn,Q=Q,GF1,GF1.off,var.r = var.r)
return(result)
}
print.psych.testRetest<- function(x,digits=2,short=FALSE,...) {
cat("\nTest Retest reliability ")
cat("\nCall: ")
print(x$Call)
cat('\nNumber of subjects = ',x$ml$n.obs, " Number of items = ", x$ml$n.items)
if(x$ml$n.items > 1) {
cat("\n Correlation of scale scores over time" , round(x$r12,digits))
cat("\n Alpha reliability statistics for time 1 and time 2 \n")
rownames(x$alpha) <- c("Time 1", "Time 2")
print( round(x$alpha,digits))
meanrii <- mean(x$item.stats$rii,na.rm=TRUE)
meanrqq <- mean(x$rqq,na.rm = TRUE)
sdrqq <- sd(x$rqq,na.rm = TRUE)
meandqq <- mean(x$dxy$dxy,na.rm=TRUE)
cat("\n Mean between person, across item reliability = ",round(meanrii,digits))
cat("\n Mean within person, across item reliability = ",round(meanrqq,digits))
cat( "\nwith standard deviation of " ,round(sdrqq,digits) ,"\n")
cat("\n Mean within person, across item d2 = ",round(meandqq,digits))
temp <- x
x <- x$ml
if(!is.null(x$R1F)) cat("\nR1F = ",round(x$R1F,digits) , "Reliability of average of all items for one time (Random time effects)")
if(!is.null(x$RkF)) cat("\nRkF = ",round(x$RkF,digits) , "Reliability of average of all items and both times (Fixed time effects)")
if(!is.null(x$R1R)) cat("\nR1R = ",round(x$R1R,digits),"Generalizability of a single time point across all items (Random time effects)")
if(!is.null(x$R2R)) cat("\nRkR = ",round(x$RkR,digits),"Generalizability of average time points across all items (Fixed time effects)")
if(!is.null(x$Rc)) cat("\nRc = ",round(x$Rc,digits),"Generalizability of change (fixed time points, fixed items) ")
if(!is.null(x$RkRn) ) cat("\nRkRn = ",round(x$RkRn,digits),"Generalizability of between person differences averaged over time (time nested within people)")
if(!is.null(x$Rcn)) cat("\nRcn = ",round(x$Rcn,digits),"Generalizability of within person variations averaged over items (time nested within people)")
x <- temp
if(!is.null(x$ml$components)) {cat("\nMultilevel components of variance\n")
print(round(x$ml$components,digits))}
if(!short) {
cat("\n With Item statistics \n")
print(round(x$item.stats[-7],digits))
} else {cat("\n To see the item.stats, print with short=FALSE. \nTo see the subject reliabilities and differences, examine the 'scores' object.") }
} else { cat("\nTest Retest Reliability of two tests", print(round(x$r12,digits)))
cat("\nMultilevel components of variance\n")
print(round(x$ml$components,digits))
}
}
mlr1 <- function(x,na.action= "na.omit" ) {
long <- NULL
id <- "id"
time <- "time"
n.obs <- NROW(x)/2
items <- colnames(x) [!colnames(x) %in% c("id","time")]
n.items <- length(items)
n.time <- 2
long <- data.frame(id = rep(1:n.obs,2), time=rep(1:2,each = n.obs),stack(x[items]))
colnames(long)[4] <- "items"
mod.lmer <- lme4::lmer(values ~ 1 + (1 | id) + (1 | time) + (1 | items) + (1 | id:time)+ (1 | id:items)+ (1 | items :time),
data=long,na.action=na.action)
vc <- lme4::VarCorr(mod.lmer)
MS_id <- vc$id[1,1]
MS_time <- vc$time[1,1]
MS_items <- vc$items[1,1]
MS_pxt <- vc[["id:time"]][[1]]
MS_pxitem <- vc[["id:items"]][[1]]
MS_txitem <- vc[["items:time"]][[1]]
error <- MS_resid <- (attributes(vc)$sc)^2
s.lmer <- s.aov <- summary(mod.lmer)
MS.df <- data.frame(variance= c(MS_id, MS_time ,MS_items, MS_pxt, MS_pxitem, MS_txitem, MS_resid,NA))
rownames(MS.df) <- c("ID","Time","Items","ID x time", "ID x items", "time x items", "Residual","Total")
MS.df["Total",] <- sum(MS.df[1:7,1],na.rm=TRUE)
MS.df["Percent"] <- MS.df/MS.df["Total",1]
lmer.MS <- MS.df
R1f <- (MS_id + MS_pxitem/n.items)/((MS_id + MS_pxitem/n.items + error/( n.items)))
Rkf <- (MS_id + MS_pxitem/n.items)/((MS_id + MS_pxitem/n.items + error/(n.time * n.items)))
R1r <- (MS_id + MS_pxitem/n.items)/((MS_id + MS_pxitem/n.items + MS_time + MS_pxt + error/( n.items)))
Rkr <- (MS_id + MS_pxitem/n.items)/((MS_id + MS_pxitem/n.items + MS_time/n.time + MS_pxt/n.time + error/( n.time * n.items)))
Rc <- (MS_pxt)/(MS_pxt + error/n.items)
result <- list(n.obs = n.obs, n.items=n.items, components = MS.df,R1F= R1f,RkF =Rkf,R1R = R1r,RkR = Rkr,Rc=Rc)
return(result)
}
mlr2 <- function(x,na.action=na.omit) {
long <- x
n.obs <- NROW(long) /2
n.items <- 1
mod.lmer <- lme4::lmer(values ~ 1 + (1 | id) + (1 | time) ,
data=long,na.action=na.action)
vc <- lme4::VarCorr(mod.lmer)
MS_id <- vc$id[1,1]
error <- MS_resid <- (attributes(vc)$sc)^2
MS.df <- data.frame(variance= c(MS_id, MS_resid,NA))
rownames(MS.df) <- c("ID","Residual","Total")
MS.df["Total",] <- sum(MS.df[1:2,1],na.rm=TRUE)
MS.df["Percent"] <- MS.df/MS.df["Total",1]
Rxx <- MS_id/MS.df["Total",1]
result <- list(n.obs=n.obs,n.items=n.items,components = MS.df)
}
dist <- function(x,y) {
x.level <- rowMeans(x,na.rm=TRUE)
y.level <- rowMeans(y,na.rm=TRUE)
n.obs <- NROW(x)
sdxi <- apply(x,1,function(xx) sd(xx,na.rm=TRUE))
sdyi <- apply(y,1,function(xx) sd(xx,na.rm=TRUE))
dxy <- rowMeans((x - y)^2,na.rm=TRUE)
rxy <- rep(NA,n.obs)
tx <- t(x)
ty <- t(y)
for(i in 1:n.obs) {
if(!( (is.na(sdxi[i])) | (sdxi[i]==0) | (is.na(sdyi[i]) | sdyi[i]==0) ) ) {
rxy[i] <- cor(tx[,i],ty[,i],use="pairwise")}
}
dist.df <- data.frame(x.level=x.level,y.level=y.level,sdx=sdxi,sdy = sdyi,dxy=dxy,rqq=rxy)
return(dist.df)
}
|
library(testthat)
library(rpivotTable)
test_check("rpivotTable")
|
`plot.aspect` <-
function(x, plot.type = "regplot", plot.var = c(1,2), xlab, ylab, main, type, ...)
{
var1 <- plot.var[1]
if (is.numeric(var1)) var1 <- colnames(x$data)[var1]
var2 <- plot.var[2]
if (is.numeric(var2)) var2 <- colnames(x$data)[var2]
tab <- table(x$data[,var1], x$data[,var2])
n <- dim(tab)[1]
m <- dim(tab)[2]
if (plot.type == "regplot") {
if (missing(xlab)) xlab1 = var1 else xlab1 <- xlab
if (missing(ylab)) ylab1 = var2 else ylab1 <- ylab
if (missing(main)) main1 <- "Unscaled Solution" else main1 <- main
if (missing(main)) main2 <- "Scaled Solution" else main2 <- main
if (missing(type)) type <- "b"
tau <- sum(tab)
pr <- tab/tau
r <- rowSums(pr)
c <- colSums(pr)
xave <- as.vector(as.matrix(pr)%*%1:m)/r
yave <- as.vector(1:n%*%as.matrix(pr))/c
z <- c(1:n,1:m)
dev.new()
plot(z, z, type = "n", xlab = paste(xlab1," categories"), ylab = paste(ylab1, " categories"), main = main1,
xaxt = "n", yaxt = "n", xlim = c(1,n), ylim = c(1,m),...)
axis(1, at = 1:n, labels = rownames(tab))
axis(2, at = 1:m, labels = colnames(tab))
points(1:n, xave, type = type, col = "RED")
points(yave, 1:m, type= type, col = "BLUE")
abline(v=1:n, h=1:m, col = "lightgray", lty = 2 )
for (i in 1:n) text(rep((1:n)[i],m),1:m,as.character(tab[i,]),cex=.8, col = "lightgray")
xa <- as.vector(x$catscores[[plot.var[1]]])
names(xa) <- rownames(x$catscores[[plot.var[1]]])
ya <- as.vector(x$catscores[[plot.var[2]]])
names(ya) <- rownames(x$catscores[[plot.var[2]]])
xave <- as.vector(as.matrix(pr)%*%ya)/r
yave <- as.vector(xa%*%as.matrix(pr))/c
z <- c(xa,ya)
dev.new()
plot(z, z, type = "n", xlab = paste(xlab1," scores"), ylab = paste(ylab1," scores"),main = main2,
xlim = range(xa), ylim = range(ya),...)
points(xa[order(xa)], xave[order(xa)], type = type, col = "RED")
points(yave[order(ya)], ya[order(ya)], type = type, col = "BLUE")
abline(v = xa, h = ya, col = "lightgray", lty = 2)
for (i in 1:n) text(rep(xa[i],m),ya,as.character(tab[i,]),cex=.8, col = "lightgray")
axis(3, at = xa[order(xa)], labels = names(xa[order(xa)]), cex.axis = 0.6, col.axis = "lightgray", padj = 1)
axis(4, at = ya[order(ya)], labels = names(ya[order(ya)]), cex.axis = 0.6, col.axis = "lightgray", padj = -1)
}
if (plot.type == "transplot") {
if (missing(type)) type <- "b"
if (missing(xlab)) xlab <- "categories"
if (missing(ylab)) ylab <- "scores"
for (i in 1:dim(x$data)[2])
{
if (((i-1) %% 4) == 0) {
dev.new()
par(mfrow = c(2, 2))
}
if (missing(main)) main1 <- paste("Transformation Plot", colnames(x$data)[i]) else main1 <- main
xa <- x$catscores[[i]]
n <- length(xa)
plot(1:n, xa, type = type, xlab = xlab, ylab = ylab, main = main1, xaxt = "n", pch = 1, ...)
axis(1, at = 1:n, labels = rownames(xa))
abline(v = 1:n, col = "lightgray", lty = 2)
}
}
}
|
setClass("dvinecopula2", contains = "tscopula", slots = list(
name = "character",
modelspec = "list",
pars = "list"
))
dvinecopula2 <- function(family = "gauss",
rotation = 0,
kpacf = "kpacf_arma",
pars = list(ar = 0.1, ma = 0.1),
maxlag = Inf,
negtau = "none") {
if (class(family) != "character")
stop("copula family must be specified by name")
if (is.null(names(pars)))
stop("parameters should be named (p1 and p2 for exp/power)")
fam <- tolower(family)
if (fam %in% c("gauss", "frank", "t"))
negtau <- "none"
modelspec <- list(family = fam,
rotation = rotation,
kpacf = kpacf,
maxlag = maxlag,
npar = length(unlist(pars)),
negtau = negtau)
new("dvinecopula2",
name = paste("type2-d-vine"),
modelspec = modelspec,
pars = pars
)
}
kpacf_arma <- function(k, theta){
if (is.list(theta))
theta <- unlist(theta)
ar <- numeric()
ma <- numeric()
nm <- substring(names(theta), 1, 2)
if ("ar" %in% nm)
ar <- theta[nm == "ar"]
if ("ma" %in% nm)
ma <- theta[nm == "ma"]
if ((non_stat(ar)) | (non_invert(ma)))
return(rep(NA, k))
pacf <- ARMAacf(ar = ar, ma = ma, lag.max = k, pacf = TRUE)
(2/pi)*asin(pacf)
}
acf2pacf <- function(rho){
FitAR::PacfDL(c(1,rho))$Pacf
}
pacf2acf <- function(alpha){
arcoef <- FitAR::PacfToAR(alpha)
rho <- stats::ARMAacf(ar = arcoef, lag.max = length(alpha))
as.numeric(rho[-1])
}
kpacf_arfima <- function(k, theta){
if (is.list(theta))
theta <- unlist(theta)
ar <- numeric()
ma <- numeric()
nm <- substring(names(theta), 1, 2)
if ("ar" %in% nm)
ar <- theta[nm == "ar"]
if ("ma" %in% nm)
ma <- theta[nm == "ma"]
if ("d" %in% nm)
d <- theta[nm == "d"]
if ((non_stat(ar)) | (non_invert(ma)) | (d <= -0.5) | (d >= 0.5))
return(rep(NA, k))
acvf <- arfima::tacvfARFIMA(phi = ar, theta = -ma, dfrac = d, maxlag = k)
acf <- acvf[-1]/acvf[1]
pacf <- acf2pacf(acf)
(2/pi)*asin(pacf)
}
kpacf_fbn <- function(k, theta){
if (is.list(theta))
theta <- unlist(theta)
if ((theta <= 0) | (theta >= 1))
return(rep(NA, k))
acf <- (((1:k) + 1)^{2 * theta[1]} + abs((1:k) - 1)^{2 * theta[1]} - 2 * (1:k)^{2 * theta[1]})/2
pacf <- acf2pacf(acf)
return((2/pi)*asin(pacf))
}
setMethod("coef", c(object = "dvinecopula2"), function(object) {
if (length(object@pars) == 1) {
return(object@pars[[1]])
} else {
return(unlist(object@pars))
}
})
setMethod("show", c(object = "dvinecopula2"), function(object) {
cat("object class: ", is(object)[[1]], "\n", sep = "")
cat("name: ", object@name, "\n", sep = "")
famname <- object@modelspec$family
if (object@modelspec$rotation !=0)
famname <- paste(famname, "with rotation", object@modelspec$rotation)
cat("copula family: ", famname, "\n", sep = "")
if (object@modelspec$negtau != "none")
cat("negative tau treatment: ", object@modelspec$negtau, "\n", sep = "")
kpacf <- object@modelspec$kpacf
if (object@modelspec$maxlag != Inf)
kpacf <- paste(kpacf, "with max lag", object@modelspec$maxlag)
cat("KPACF: ", kpacf,"\n", sep = "")
cat("parameters: \n")
print(coef(object))
})
dvinecopula2_objective <- function(theta, modelspec, u) {
n <- length(u)
kpacf <- eval(parse(text = modelspec$kpacf))
tauvals <- kpacf((n-1), theta)
if (is.na(sum(tauvals)))
return(NA)
k <- 1
largetau <- (abs(tauvals) > .Machine$double.eps)
if (sum(largetau) > 0)
k <- max((1:(n-1))[largetau])
k <- min(k, modelspec$maxlag)
pc_list <- vector("list", k)
for (i in 1:k) {
fam <- tolower(modelspec$family)
rot <- modelspec$rotation
if (tauvals[i] < 0){
if (modelspec$negtau == "right")
rot <- rot + 90
if (modelspec$negtau == "left")
rot <- (rot + 270) %% 360
if (modelspec$negtau %in% c("gauss","frank")){
fam <- modelspec$negtau
rot <- 0
}
if ((modelspec$negtau == "none") & (fam %in% c("gumbel", "joe", "clayton")))
return(NA)
}
coppars <- ktau_to_par(
family = fam,
tau = tauvals[i]
)
if (is.na(coppars))
return(NA)
if (fam == "t")
coppars <- c(coppars, theta["nu"])
pc_list[[i]] <- tryCatch(rvinecopulib::bicop_dist(
family = fam,
rotation = rot,
parameters = coppars
),
error = function(e) {
return(NA)
}
)
if (is.na(pc_list[[i]][[1]])) {
return(NA)
}
}
v <- cbind(u[1:(n - 1)], u[2:n])
LL <- 0
for (j in 1:k) {
LL <- LL + sum(log(rvinecopulib::dbicop(u = v, family = pc_list[[j]])))
if (j == k) {
return(-LL)
}
n <- dim(v)[1]
v <- cbind(
rvinecopulib::hbicop(v[(1:(n - 1)), ], cond_var = 2, family = pc_list[[j]]),
rvinecopulib::hbicop(v[(2:n), ], cond_var = 1, family = pc_list[[j]])
)
}
}
ktau_to_par <- function(family, tau){
if (family == "t")
family <- "gauss"
rvinecopulib::ktau_to_par(family, tau)
}
setMethod("sim", c(object = "dvinecopula2"), function(object, n = 1000) {
pc_list <- mklist_dvine2(object, n-1, truncate = TRUE, tol = 1/3)
simdvine(pc_list, n, innov = NA, start = NA)
})
mklist_dvine2 <- function(x, maxlag, truncate, tol = 1){
k <- min(maxlag, x@modelspec$maxlag)
kpacf <- eval(parse(text = x@modelspec$kpacf))
tauvals <- kpacf(k, x@pars)
if (truncate)
k <- max(c(1, which(abs(tauvals) > .Machine$double.eps^tol)))
pc_list <- vector("list", k)
for (i in 1:k) {
fam <- tolower(x@modelspec$family)
rot <- x@modelspec$rotation
if (tauvals[i] < 0){
if (x@modelspec$negtau == "right")
rot <- rot + 90
if (x@modelspec$negtau == "left")
rot <- (rot + 270) %% 360
if (x@modelspec$negtau %in% c("gauss","frank")){
fam <- x@modelspec$negtau
rot <- 0
}
}
coppars <- ktau_to_par(
family = fam,
tau = tauvals[i]
)
if (fam == "t")
coppars <- c(coppars, x@pars$nu)
pc_list[[i]] <- rvinecopulib::bicop_dist(
family = fam,
rotation = rot,
parameters = coppars)
}
pc_list
}
resid_dvinecopula2 <- function(object, data = NA, trace = FALSE){
n <- length(data)
pc_list <- mklist_dvine2(object, n-1, truncate = TRUE, tol = 1/3)
k <- length(pc_list)
if (trace)
target <- rep(0.5, n)
else
target <- data
res <- rep(NA, n)
res[1] <- target[1]
if (k >1){
for (i in 2:k){
pcs <- lapply(1:(i-1), function(j) {
replicate(i - j, pc_list[[j]], simplify = FALSE)
})
vc_short <- rvinecopulib::vinecop_dist(pcs, rvinecopulib::dvine_structure(i:1))
vals <- c(data[1:(i-1)], target[i])
res[i] <- rvinecopulib::rosenblatt(t(vals), vc_short)[i]
}
}
pcs <- lapply(1:k, function(j) {
replicate(k + 1 - j, pc_list[[j]], simplify = FALSE)
})
vc_short <- rvinecopulib::vinecop_dist(pcs, rvinecopulib::dvine_structure((k + 1):1))
for (i in ((k+1):n)){
vals <- c(data[(i-k):(i-1)], target[i])
res[i] <- rvinecopulib::rosenblatt(t(vals), vc_short)[k+1]
}
qnorm(res)
}
setMethod("kendall", c(object = "dvinecopula2"), function(object, lagmax = 20) {
kpacf <- eval(parse(text = object@modelspec$kpacf))
kpacf(lagmax, object@pars)
}
)
glag_for_dvinecopula2 <- function(copula, data, lagmax, glagplot = FALSE) {
if (glagplot)
lagmax <- min(lagmax, 9)
pc_list <- mklist_dvine2(copula, lagmax, truncate = FALSE)
k <- length(pc_list)
n <- length(data)
data <- cbind(as.numeric(data[1:(n - 1)]), as.numeric(data[2:n]))
if (glagplot){
output <- vector(mode = "list", length = k)
output[[1]] <- data
}
else{
output <- rep(NA, k)
output[1] <- cor(data, method = "kendall")[1, 2]
}
if (k >1){
for (i in 1:(k - 1)) {
n <- dim(data)[1]
data <-
cbind(rvinecopulib::hbicop(data[(1:(n - 1)), ], pc_list[[i]], cond_var = 2),
rvinecopulib::hbicop(data[(2:n), ], pc_list[[i]], cond_var = 1))
if (glagplot)
output[[i+1]] <- data
else
output[i+1] <- cor(data, method = "kendall")[1, 2]
}
}
output
}
|
"wffc" <-
structure(list(length = c(180, 182, 185, 189, 193, 195, 195,
197, 198, 209, 210, 215, 215, 218, 218, 219, 228, 228, 241, 303,
182, 182, 195, 206, 212, 214, 217, 224, 224, 229, 231, 234, 252,
255, 292, 294, 294, 335, 355, 393, 200, 205, 210, 238, 182, 182,
186, 201, 205, 208, 209, 216, 218, 221, 222, 223, 224, 225, 226,
228, 228, 229, 230, 233, 257, 260, 271, 274, 274, 316, 316, 320,
324, 325, 337, 350, 181, 188, 190, 194, 198, 200, 212, 212, 229,
231, 238, 240, 252, 180, 203, 205, 240, 260, 180, 180, 181, 181,
182, 190, 191, 191, 192, 194, 195, 196, 197, 200, 203, 212, 213,
215, 225, 248, 250, 251, 305, 181, 183, 183, 185, 193, 195, 195,
205, 206, 210, 210, 221, 226, 231, 248, 251, 251, 257, 267, 277,
280, 283, 285, 300, 320, 333, 340, 376, 223, 225, 230, 237, 249,
253, 264, 275, 310, 181, 181, 182, 184, 184, 185, 185, 186, 186,
188, 195, 195, 212, 214, 215, 235, 281, 312, 190, 201, 204, 210,
210, 222, 245, 251, 283, 180, 180, 180, 180, 180, 185, 190, 195,
195, 195, 200, 205, 210, 210, 215, 215, 220, 220, 220, 230, 230,
255, 280, 280, 180, 180, 181, 182, 183, 185, 189, 195, 199, 203,
205, 210, 211, 214, 215, 215, 220, 221, 223, 226, 229, 238, 220,
306, 309, 348, 180, 180, 210, 210, 220, 304, 353, 180, 183, 183,
185, 185, 187, 187, 201, 202, 230, 296, 194, 208, 213, 213, 219,
221, 222, 225, 228, 230, 232, 258, 273, 292, 305, 306, 180, 185,
187, 187, 189, 191, 192, 201, 203, 206, 219, 232, 252, 258, 271,
316, 180, 188, 190, 192, 195, 210, 223, 226, 226, 231, 247, 284,
319, 194, 197, 215, 217, 223, 264, 275, 333, 334, 182, 186, 197,
205, 207, 207, 210, 261, 271, 180, 183, 192, 194, 205, 206, 215,
218, 225, 225, 230, 247, 338, 180, 180, 180, 180, 185, 190, 190,
190, 195, 205, 210, 215, 215, 220, 220, 220, 220, 220, 225, 254,
260, 280, 290, 295, 295, 300, 300, 330, 187, 190, 192, 194, 218,
225, 269, 270, 271, 314, 183, 183, 185, 190, 190, 195, 204, 205,
205, 205, 205, 213, 215, 215, 220, 235, 237, 301, 325, 185, 204,
207, 212, 221, 181, 190, 191, 192, 192, 204, 215, 220, 227, 240,
240, 245, 246, 285, 302, 302, 310, 330, 390, 190, 268, 181, 181,
182, 183, 185, 201, 219, 221, 222, 236, 244, 295, 315, 329, 420,
180, 181, 182, 185, 200, 200, 210, 215, 217, 220, 220, 225, 235,
245, 260, 270, 375, 375, 380, 445, 180, 181, 185, 190, 195, 201,
208, 208, 212, 215, 215, 220, 229, 231, 255, 300, 325, 189, 191,
211, 222, 226, 313, 322, 181, 182, 183, 185, 185, 185, 190, 193,
196, 198, 200, 200, 200, 205, 205, 210, 210, 211, 215, 220, 229,
182, 182, 190, 190, 190, 192, 217, 218, 220, 224, 242, 264, 270,
290, 440, 181, 185, 196, 214, 210, 222, 240, 255, 300, 310, 415,
180, 184, 194, 195, 204, 215, 231, 263, 378, 185, 190, 205, 213,
215, 248, 255, 195, 195, 226, 250, 183, 188, 190, 196, 214, 280,
340, 352, 180, 183, 190, 194, 202, 205, 212, 213, 218, 220, 197,
198, 180, 180, 180, 190, 200, 210, 210, 250, 260, 182, 182, 186,
186, 186, 190, 192, 195, 196, 202, 205, 207, 211, 214, 215, 218,
220, 223, 234, 235, 235, 235, 236, 237, 241, 241, 243, 246, 247,
248, 251, 252, 253, 262, 277, 180, 185, 185, 185, 190, 190, 200,
205, 214, 215, 215, 235, 240, 260, 264, 266, 270, 287, 186, 186,
186, 186, 188, 188, 189, 189, 192, 193, 193, 194, 198, 200, 200,
207, 210, 213, 222, 224, 241, 246, 256, 260, 265, 266, 272, 276,
382, 195, 222, 252, 280, 181, 182, 183, 185, 185, 188, 190, 193,
194, 201, 204, 210, 229, 232, 234, 238, 254, 299, 301, 181, 191,
194, 196, 212, 229, 242, 245, 250, 255, 261, 261, 266, 293, 297,
303, 180, 181, 181, 182, 184, 185, 191, 191, 193, 201, 205, 207,
210, 213, 215, 221, 221, 225, 236, 261, 276, 290, 356, 180, 182,
190, 191, 192, 203, 207, 213, 214, 215, 220, 223, 233, 240, 241,
247, 255, 260, 263, 264, 265, 285, 333, 181, 181, 208, 221, 238,
264, 268, 275, 275, 301, 353, 180, 185, 185, 195, 195, 195, 195,
199, 200, 200, 200, 201, 205, 210, 210, 223, 223, 235, 240, 252,
262, 265, 285, 290, 295, 330, 410, 181, 181, 183, 184, 185, 185,
185, 207, 221, 223, 231, 234, 234, 266, 273, 277, 282, 392, 180,
187, 190, 195, 195, 195, 197, 200, 213, 215, 220, 222, 249, 257,
258, 268, 270, 282, 310, 181, 181, 182, 184, 185, 193, 194, 195,
198, 200, 204, 206, 208, 211, 219, 231, 234, 239, 239, 240, 246,
257, 258, 260, 265, 270, 280, 302, 327, 345, 455, 195, 239, 251,
262, 298, 307, 181, 192, 198, 198, 200, 201, 201, 203, 205, 207,
222, 225, 228, 228, 239, 242, 254, 255, 256, 256, 282, 283, 290,
185, 195, 202, 202, 245, 255, 265, 290, 295, 335, 393, 182, 200,
220, 227, 245, 250, 295, 185, 195, 200, 201, 201, 210, 229, 259,
267, 270, 273, 275, 283, 180, 180, 202, 217, 225, 251, 277, 201,
217, 257, 258, 276, 279, 321, 324, 329, 352, 180, 181, 183, 196,
198, 212, 228, 235, 235, 186, 190, 252, 180, 180, 181, 186, 188,
188, 188, 190, 190, 192, 195, 196, 200, 205, 207, 216, 218, 218,
225, 227, 230, 244, 246, 251, 255, 262, 291, 315, 180, 185, 185,
190, 195, 195, 195, 195, 195, 200, 200, 220, 231, 240, 244, 247,
257, 264, 337, 181, 181, 183, 184, 190, 194, 195, 195, 207, 212,
215, 231, 233, 237, 238, 245, 251, 251, 252, 262, 272, 280, 285,
292, 294, 295, 191, 201, 221, 233, 235, 242, 246, 248, 282, 284,
424, 494, 185, 195, 227, 235, 248, 257, 320, 185, 200, 203, 215,
235, 248, 250, 180, 180, 185, 185, 192, 194, 201, 210, 213, 221,
292, 180, 180, 182, 189, 180, 182, 186, 194, 195, 195, 198, 200,
201, 205, 217, 225, 181, 191, 206, 210, 249, 324, 190, 192, 348,
180, 180, 182, 192, 195, 195, 195, 202, 212, 220, 240, 246, 247,
250, 265, 265, 265, 270, 270, 272, 273, 313, 180, 189, 191, 192,
196, 208, 211, 227, 228, 229, 230, 230, 233, 241, 245, 252, 254,
256, 258, 262, 267, 276, 295, 362, 229, 246, 196, 212, 225, 228,
230, 235, 251, 260, 261, 270, 289, 310, 345, 180, 184, 185, 188,
195, 200, 210, 211, 235, 242, 245, 245, 246, 250, 264, 268, 180,
182, 183, 202, 215, 190, 200, 210, 330, 325, 356, 185, 245, 256,
262, 291, 342, 181, 182, 188, 191, 191, 193, 235, 248, 250, 251,
265, 275, 328, 180, 187, 187, 195, 195, 200, 205, 235, 250, 275,
286, 379, 192, 185, 188, 195, 221, 226, 236, 181, 183, 186, 187,
192, 194, 197, 203, 204, 205, 207, 209, 210, 257, 274, 300, 181,
182, 185, 202, 211, 195, 180, 180, 184, 187, 187, 189, 192, 193,
194, 196, 196, 197, 197, 198, 200, 204, 205, 207, 207, 208, 213,
220, 223, 225, 228, 230, 233, 234, 236, 237, 238, 242, 258, 265,
291, 292, 293, 180, 200, 205, 205, 210, 210, 210, 214, 220, 220,
225, 250, 270, 290, 300, 180, 181, 181, 185, 189, 190, 191, 192,
201, 210, 212, 218, 224, 226, 231, 262, 185, 185, 190, 196, 200,
205, 205, 210, 218, 226, 226, 230, 230, 230, 230, 240, 240, 240,
243, 245, 248, 250, 250, 250, 250, 255, 255, 260, 265, 270, 300,
300, 320, 320, 180, 180, 183, 185, 196, 198, 198, 201, 201, 203,
205, 206, 208, 208, 210, 214, 215, 215, 216, 221, 222, 234, 238,
238, 253, 253, 259, 261, 276, 180, 180, 180, 180, 181, 185, 185,
190, 198, 200, 210, 210, 212, 215, 218, 220, 220, 222, 228, 230,
230, 232, 239, 239, 240, 290, 290, 295, 185, 190, 195, 195, 212,
216, 218, 218, 222, 233, 235, 240, 242, 245, 246, 250, 251, 255,
255, 257, 280, 295, 328, 359, 180, 195, 210, 220, 220, 223, 230,
230, 240, 242, 249, 258, 263, 267, 287, 337, 181, 190, 195, 195,
198, 210, 212, 214, 220, 222, 223, 224, 244, 250, 275, 283, 284,
319, 438, 180, 180, 182, 185, 189, 192, 192, 194, 198, 202, 208,
210, 215, 215, 225, 228, 232, 238, 243, 256, 262, 273, 180, 180,
180, 180, 180, 185, 185, 185, 186, 190, 190, 192, 193, 194, 195,
198, 201, 208, 210, 210, 215, 216, 216, 235, 235, 240, 245, 245,
290, 180, 181, 182, 183, 196, 200, 208, 210, 210, 237, 243, 264,
180, 180, 187, 188, 202, 207, 210, 222, 225, 244, 185, 192, 193,
201, 205, 225, 245, 255, 255, 258, 180, 180, 180, 180, 180, 182,
183, 183, 186, 189, 197, 200, 200, 205, 210, 216, 219, 220, 222,
225, 226, 226, 236, 257, 258, 258, 280, 290, 190, 246, 185, 197,
198, 208, 228, 243, 243, 297, 298, 300, 315, 340, 345, 345, 183,
189, 305, 396, 180, 180, 182, 182, 185, 186, 188, 188, 192, 192,
193, 197, 201, 213, 221, 222, 224, 224, 225, 226, 231, 232, 237,
247, 262, 265, 315, 180, 180, 180, 180, 180, 181, 190, 190, 192,
192, 195, 200, 200, 210, 210, 210, 210, 212, 215, 220, 220, 230,
230, 231, 240, 320, 180, 183, 183, 188, 193, 200, 200, 204, 204,
206, 208, 209, 211, 213, 215, 218, 223, 224, 225, 227, 260, 180,
180, 180, 182, 187, 190, 192, 195, 197, 200, 205, 206, 209, 211,
211, 214, 225, 230, 230, 232, 233, 233, 233, 237, 247, 247, 252,
290, 180, 196, 211, 221, 222, 226, 365, 190, 192, 195, 200, 200,
204, 210, 212, 219, 220, 222, 225, 227, 227, 227, 228, 229, 232,
235, 239, 240, 244, 245, 252, 254, 257, 258, 270, 281, 281, 290,
190, 212, 240, 243, 252, 282, 358, 185, 194, 200, 210, 221, 223,
228, 230, 232, 250, 255, 257, 258, 262, 299, 314, 180, 193, 198,
198, 199, 205, 208, 224, 232, 232, 234, 237, 241, 245, 282, 292,
295, 356, 370, 180, 186, 191, 196, 196, 213, 216, 225, 240, 183,
188, 192, 213, 223, 252, 185, 190, 195, 198, 200, 203, 205, 212,
225, 264, 182, 183, 189, 192, 195, 197, 219, 224, 226, 242, 244,
244, 249, 270, 272, 274, 285, 308, 208, 222, 235, 281, 180, 180,
180, 180, 181, 183, 202, 210, 220, 224, 229, 229, 239, 248, 265,
286, 292, 245, 265, 180, 180, 193, 204, 207, 230, 260, 262, 274,
401, 180, 190, 201, 210, 218, 220, 221, 225, 225, 233, 243, 244,
253, 254, 345, 194, 195, 196, 214, 215, 226, 241, 248, 256, 304,
218, 195, 180, 180, 180, 183, 184, 185, 185, 188, 193, 199, 218,
221, 246, 260, 262, 290, 290, 305, 331, 332, 345, 180, 185, 191,
196, 200, 222, 224, 242, 242, 261, 515, 180, 181, 232, 232, 251,
252, 265, 185, 194, 202, 210, 235, 241, 243, 244, 250, 283, 285,
287, 395, 191, 213, 214, 214, 214, 258, 262, 287, 301, 425, 214,
218, 190, 195, 198, 210, 214, 216, 223, 224, 230, 236, 240, 284,
298, 300, 180, 188, 192, 195, 198, 202, 204, 218, 218, 227, 230,
235, 245, 254, 256, 263, 266, 275, 285, 301, 302, 392, 180, 180,
180, 190, 199, 204, 205, 210, 212, 214, 214, 217, 218, 220, 224,
225, 230, 230, 230, 239, 240, 241, 248, 250, 252, 265, 275, 279,
290, 293, 310, 315, 180, 208, 210, 245, 180, 195, 199, 210, 210,
215, 217, 220, 250, 265, 275, 275, 180, 185, 210, 215, 261, 207,
210, 226, 227, 236, 237, 245, 246, 263, 269, 294, 308, 329, 182,
184, 189, 190, 192, 194, 195, 215, 216, 220, 220, 225, 231, 232,
238, 246, 248, 259, 277, 279, 307, 323, 180, 183, 191, 196, 197,
198, 202, 202, 204, 206, 211, 226, 243, 256, 258, 260, 265, 265,
281, 282, 294, 295, 180, 270, 274, 280, 330, 330, 350, 180, 180,
180, 180, 181, 190, 190, 195, 200, 202, 203, 203, 206, 207, 208,
216, 218, 219, 220, 220, 230, 234, 235, 236, 258, 262, 263, 272,
274, 280, 280, 281, 294, 308, 323, 329, 333, 180, 182, 184, 190,
215, 215, 215, 227, 231, 235, 240, 242, 250, 260, 280, 288, 345,
180, 180, 182, 184, 195, 195, 198, 207, 212, 220, 220, 230, 246,
247, 248, 248, 250, 255, 255, 262, 273, 281, 284, 290, 290, 300,
327, 345, 181, 205, 206, 210, 219, 230, 260, 265, 290, 300, 300,
180, 205, 207, 227, 227, 240, 250, 279, 310, 180, 197, 198, 235,
240, 260, 285, 182, 182, 187, 192, 195, 200, 215, 216, 220, 228,
248, 254, 263, 270, 300, 301, 303, 303, 320, 394, 181, 182, 190,
194, 195, 220, 238, 240, 265, 280, 332, 180, 185, 185, 190, 194,
201, 215, 218, 231, 286, 180, 185, 190, 190, 195, 200, 220, 230,
240, 265, 280, 300, 302, 340, 181, 181, 187, 188, 197, 197, 198,
203, 205, 212, 222, 222, 230, 236, 237, 238, 263, 266, 183, 249,
252, 264, 302, 180, 180, 181, 182, 183, 192, 192, 199, 201, 202,
202, 203, 211, 212, 213, 214, 215, 221, 222, 224, 227, 230, 234,
259, 264, 277, 280, 281, 294, 315, 195, 230, 230, 240, 255, 265,
298, 180, 180, 187, 189, 189, 206, 228, 242, 245, 255, 281, 282,
285, 297, 304, 180, 180, 185, 190, 200, 240, 320, 186, 200, 210,
260, 302, 180, 195, 247, 251, 254, 263, 278, 296, 310, 318, 426,
180, 180, 182, 193, 201, 204, 247, 301, 317, 182, 270, 273, 285,
182, 200, 208, 212, 213, 216, 229, 231, 243, 260, 345, 183, 207,
215, 337, 180, 212, 180, 220, 265, 290, 199, 185, 263, 180, 180,
182, 183, 185, 185, 190, 190, 211, 214, 232, 232, 234, 247, 249,
251, 263, 309, 186, 196, 201, 241, 256, 290, 294, 331, 185, 180,
182, 203, 203, 208, 211, 223, 223, 226, 233, 234, 244, 254, 190,
190, 210, 210, 226, 232, 430, 182, 185, 274, 180, 180, 195, 220,
230, 250, 265, 300, 300, 320, 325, 350, 245, 254, 300, 303, 342,
560, 182, 185, 192, 195, 199, 205, 217, 223, 224, 227, 230, 240,
245, 246, 258, 265, 273, 285, 295, 305, 312, 330, 336, 343, 193,
198, 200, 225, 228, 238, 244, 284, 290, 297, 302, 182, 186, 189,
194, 233, 250, 251, 294, 307, 335, 180, 182, 202, 217, 470, 180,
187, 198, 239, 240, 274, 331, 335, 340, 359, 360, 365, 365, 367,
182, 216, 332, 215, 268, 365, 435, 181, 189, 208, 212, 334, 191,
201, 209, 211, 250, 394, 425, 457, 488, 498, 188, 189, 190, 200,
215, 220, 228, 314, 325, 335, 355, 378, 420, 488, 185, 185, 195,
204, 208, 210, 220, 220, 225, 225, 230, 245, 342, 355, 390, 432,
478, 481, 510, 181, 184, 195, 225, 225, 226, 235, 242, 244, 338,
342, 388, 540, 193, 206, 214, 215, 296, 310, 460, 181, 216, 331,
333, 445, 500, 580, 185, 186, 212, 222, 232, 246, 272, 340, 343,
348, 372, 385, 395, 402, 435, 445, 477, 518, 181, 182, 185, 185,
192, 195, 196, 198, 202, 213, 220, 225, 227, 230, 232, 232, 291,
294, 314, 325, 330, 338, 340, 360, 490, 181, 181, 181, 182, 184,
194, 197, 207, 215, 220, 226, 230, 230, 309, 314, 338, 395, 477,
180, 182, 182, 182, 185, 185, 190, 193, 196, 197, 198, 199, 206,
207, 221, 222, 222, 223, 225, 225, 226, 232, 246, 252, 312, 181,
181, 185, 185, 187, 201, 205, 210, 215, 216, 225, 181, 182, 182,
193, 193, 198, 201, 201, 205, 206, 208, 212, 218, 230, 275, 325,
335, 336, 339, 368, 432, 436, 503, 535, 195, 196, 198, 208, 210,
210, 212, 217, 365, 364, 376, 463, 586, 600, 613, 195, 225, 460,
460, 480, 555, 560, 180, 181, 184, 191, 195, 196, 197, 208, 447,
451, 489, 181, 181, 181, 182, 182, 193, 194, 202, 202, 203, 205,
210, 220, 228, 228, 243, 245, 248, 450, 181, 181, 186, 186, 188,
196, 196, 197, 198, 200, 202, 205, 211, 211, 212, 215, 221, 225,
226, 227, 230, 235, 243, 281, 336, 498, 195, 200, 214, 203, 207,
218, 223, 236, 190, 198, 200, 200, 205, 208, 210, 210, 215, 216,
225, 225, 227, 230, 237, 240, 248, 310, 315, 315, 370, 370, 390,
405, 420, 420, 478, 499, 212, 254, 222, 300, 522, 185, 192, 193,
215, 230, 332, 393, 560, 582, 582, 181, 181, 182, 189, 193, 195,
196, 214, 215, 362, 181, 187, 201, 210, 211, 230, 231, 239, 240,
246, 258, 339, 370, 388, 419, 471, 556, 570, 183, 190, 190, 190,
196, 210, 210, 210, 211, 268, 328, 331, 495, 181, 181, 185, 198,
198, 205, 210, 215, 215, 225, 227, 228, 230, 230, 235, 245, 310,
513, 186, 193, 194, 196, 196, 203, 205, 210, 210, 212, 214, 215,
221, 224, 227, 228, 248, 254, 310, 335, 347, 380, 396, 520, 202,
210, 212, 217, 228, 240, 247, 259, 285, 293, 312, 315, 325, 352,
363, 371, 382, 427, 453, 510, 192, 217, 219, 243, 369, 374, 360,
382, 202, 250, 335, 360, 370, 401, 402, 450, 580, 180, 180, 181,
182, 182, 182, 182, 183, 184, 184, 187, 188, 188, 190, 192, 196,
196, 198, 200, 200, 202, 203, 205, 210, 215, 220, 220, 230, 245,
360, 480, 185, 195, 240, 240, 245, 335, 423, 432, 443, 482, 494,
506, 510, 190, 198, 200, 215, 228, 230, 232, 390, 181, 182, 185,
185, 186, 187, 188, 190, 190, 190, 191, 192, 195, 196, 205, 217,
218, 222, 222, 225, 227, 228, 229, 235, 239, 250, 395, 409, 410,
190, 193, 217, 225, 378, 410, 181, 185, 185, 189, 192, 194, 195,
201, 210, 210, 212, 219, 220, 222, 230, 340, 180, 186, 193, 199,
225, 260, 181, 182, 183, 183, 186, 188, 189, 196, 197, 198, 207,
214, 216, 260, 350, 370, 370, 404, 437, 503, 195, 195, 195, 195,
200, 200, 210, 210, 215, 230, 230, 235, 245, 323, 325, 330, 335,
345, 395, 495, 500, 560, 182, 200, 220, 223, 186, 187, 193, 193,
203, 206, 208, 210, 214, 216, 226, 255, 195, 181, 185, 186, 186,
188, 192, 193, 193, 194, 197, 202, 212, 214, 214, 216, 218, 219,
220, 222, 223, 225, 227, 229, 309, 313, 334, 343, 419, 181, 181,
193, 194, 198, 190, 200, 200, 220, 240, 250, 320, 330, 380, 470,
500, 181, 189, 190, 199, 200, 202, 215, 216, 219, 239, 325, 332,
333, 356, 369, 376, 379, 440, 452, 525, 200, 202, 204, 204, 205,
219, 220, 304, 316, 320, 324, 333, 340, 340, 342, 342, 344, 365,
453, 466, 506, 181, 182, 185, 196, 197, 198, 199, 212, 242, 327,
335, 342, 402, 403, 431, 185, 195, 195, 195, 195, 200, 200, 205,
215, 220, 225, 225, 235, 290, 308, 330, 355, 400, 420, 430, 450,
180, 182, 191, 191, 193, 194, 195, 195, 195, 210, 212, 213, 225,
227, 230, 298, 311, 314, 332, 335, 350, 375, 396, 413, 417, 460,
475, 510, 180, 185, 186, 186, 190, 195, 203, 207, 210, 210, 218,
219, 225, 226, 326, 344, 345, 410, 420, 465, 190, 210, 220, 272,
272, 272, 272, 272, 350, 430, 435, 465, 486, 195, 345, 402, 414,
445, 182, 208, 213, 214, 221, 226, 415, 180, 182, 182, 183, 185,
190, 195, 205, 215, 220, 225, 225, 235, 250, 290, 310, 331, 335,
375, 485, 189, 200, 210, 216, 222, 226, 321, 490, 180, 183, 186,
200, 202, 206, 214, 222, 255, 316, 385, 474, 181, 181, 183, 183,
184, 185, 186, 187, 188, 189, 191, 192, 195, 199, 209, 210, 210,
210, 213, 215, 419, 185, 185, 190, 195, 198, 200, 204, 205, 205,
208, 208, 215, 222, 314, 445, 180, 181, 185, 185, 186, 186, 190,
194, 194, 196, 201, 207, 218, 220, 222, 233, 235, 305, 325, 325,
360, 390, 180, 187, 191, 208, 214, 218, 223, 227, 243, 268, 302,
337, 365, 377, 380, 386, 415, 420, 420, 422, 475, 480, 518, 540,
185, 190, 200, 207, 208, 212, 215, 222, 225, 230, 235, 344, 360,
370, 380, 390, 392, 485, 188, 189, 195, 196, 215, 217, 223, 227,
352, 424, 180, 181, 182, 185, 186, 186, 191, 192, 193, 194, 195,
200, 200, 200, 208, 210, 210, 218, 220, 222, 233, 245, 181, 202,
325, 380, 181, 181, 186, 189, 189, 189, 191, 194, 195, 195, 197,
197, 199, 204, 206, 206, 208, 209, 209, 210, 210, 214, 215, 216,
235, 347, 389, 420, 437, 491, 181, 182, 183, 184, 185, 186, 186,
191, 192, 193, 194, 198, 200, 202, 203, 205, 208, 212, 228, 235,
294, 180, 215, 293, 190, 214, 245, 305, 309, 343, 358, 363, 433,
437, 181, 181, 183, 185, 185, 190, 195, 197, 202, 203, 215, 215,
232, 315, 185, 465, 475, 190, 190, 190, 195, 205, 210, 210, 210,
215, 225, 245, 245, 250, 350, 390, 501, 182, 183, 188, 188, 189,
192, 193, 195, 200, 202, 202, 205, 207, 207, 217, 217, 221, 222,
223, 235, 318, 332, 335, 340, 370, 413, 446, 450, 475, 515, 185,
192, 193, 195, 195, 195, 195, 205, 205, 210, 210, 210, 210, 212,
213, 214, 218, 218, 228, 259, 458, 180, 195, 205, 205, 230, 305,
320, 325, 330, 390, 425, 490, 186, 189, 194, 202, 205, 224, 228,
180, 181, 181, 182, 185, 185, 195, 197, 203, 221, 223, 305, 181,
181, 185, 186, 188, 192, 192, 193, 195, 202, 205, 208, 212, 223,
244, 324, 335, 335, 356, 375, 381, 388, 413, 424, 180, 181, 184,
188, 190, 210, 215, 226, 323, 180, 183, 200, 204, 209, 215, 311,
326, 391, 428, 180, 180, 180, 183, 185, 185, 189, 192, 193, 195,
197, 200, 201, 202, 202, 203, 205, 208, 210, 214, 218, 220, 221,
225, 229, 251, 350, 440, 198, 215, 227, 246, 307, 334, 427, 430,
432, 445, 465, 492, 181, 181, 182, 184, 185, 186, 190, 190, 192,
193, 198, 199, 200, 201, 209, 218, 221, 224, 224, 227, 232, 236,
321, 338, 339, 345, 351, 353, 430, 180, 181, 184, 185, 190, 194,
195, 211, 213, 222, 230, 230, 372, 460, 475, 180, 181, 185, 200,
205, 215, 370, 234, 532, 624, 528, 312, 202, 195, 253, 615, 235,
210, 572, 215, 194, 203, 203, 200, 198, 495, 520, 205, 220, 220,
486, 190, 225, 219, 391, 376, 425, 220, 580, 510, 225, 210, 193,
395, 580, 420, 560, 425, 440, 284, 429, 530, 688, 197, 224, 225,
510, 487, 379, 568, 462, 572, 206, 186, 216, 208, 200, 396, 194,
503, 237, 231, 201, 183, 388, 438, 417, 413, 450, 592, 185, 228,
478, 205, 205, 437, 480, 184, 225, 203, 485, 574, 496, 424, 544,
335, 405, 514, 207, 408, 230, 186, 216, 202, 467, 193, 187, 435,
508, 187, 590, 198, 222, 571, 285, 568, 228, 285, 435, 499, 399,
508, 390, 209, 225, 450, 541, 362, 415, 238, 610, 214, 500, 388,
215, 356, 432, 518, 412, 689, 212, 205, 202, 485, 610, 195, 220,
627, 549, 525, 273, 190, 197, 242, 193, 215, 484, 436, 442, 431,
211, 267, 365, 250, 186, 211, 430, 365, 186, 208, 189, 208, 389,
211, 241, 196, 504, 421, 242, 320, 402, 501, 211, 195, 652, 550,
198, 202, 215, 198, 568, 210, 585, 225, 570, 230, 575, 200, 191,
615, 223, 418, 210, 521, 380, 560, 224, 620, 232, 236, 180, 230,
220, 238, 194, 183, 222, 181, 182, 552, 191, 208, 430, 225, 226,
206, 212, 197, 212, 205, 195, 400, 375, 235, 186, 535, 391, 385,
375, 213, 212, 410, 211, 404, 227, 213, 194, 221, 400, 575, 180,
200, 205, 585, 391, 486, 250, 222, 213, 365, 206, 221, 206, 207,
180, 458, 216, 457, 211, 226, 211, 197, 443, 188, 215, 211, 185,
203, 590, 229, 439, 423, 291, 565, 470, 312, 455, 441, 441, 254,
406, 340, 498, 498, 475, 574, 435, 205, 425, 425, 486, 443, 482,
505, 495, 470, 545, 385, 444, 477, 265, 391, 457, 429, 430, 450,
480, 450, 441, 270, 545, 505, 450, 481, 524, 480, 293, 439, 252,
471, 467, 476, 511, 473, 535, 462, 604, 426, 443, 421, 470, 515,
501, 476, 487, 493, 580, 490, 410, 383, 510, 470, 510, 455, 234,
492, 490, 572, 400, 490, 435, 490, 466, 195, 184, 431, 235, 415,
444, 405, 430, 500, 465, 548, 461, 475, 427, 400, 510, 328, 231,
461, 430, 505, 263, 411, 450, 490, 455, 242, 395, 530, 444, 550,
440, 565, 490, 565, 490, 525, 475, 517, 510, 480, 470, 510, 470,
474, 399, 292, 533, 406, 455, 512, 287, 530, 411, 450, 395, 477,
493, 396, 414, 518, 520, 590, 594, 439, 407, 417, 361, 528, 498,
390, 470, 432, 505, 475, 445, 510, 410, 375, 435, 190, 480, 475,
204, 414, 442, 441, 276, 347, 450, 340, 260, 431, 467, 457, 414,
412, 535, 563, 454, 393, 447, 189, 461, 428, 425, 439, 314, 420,
290, 455, 400, 405, 372, 430, 538, 530, 274), water = structure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 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 9, 9, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9,
9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18,
18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
18, 18, 18, 18, 18, 19, 19, 19, 19, 10, 10, 11, 11, 11, 11, 11,
11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13,
13, 13, 13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4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19,
19, 19, 19, 19, 19, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13,
13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18,
18, 18, 18, 18, 19, 19, 19, 19, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 11, 11, 11, 11, 12, 12, 13, 13, 13, 13, 14, 15, 15,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12,
12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14,
14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 1, 1, 1,
1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7,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7, 7, 7, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1,
1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5,
5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14,
14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18,
18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15,
15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 1, 1, 3, 3, 5, 5, 6,
6, 7, 8, 8, 8, 8, 9, 10, 11, 11, 12, 12, 12, 12, 12, 13, 13,
13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16,
17, 17, 19, 19, 19, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7, 7, 9, 9, 10,
10, 11, 11, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15, 15, 15, 15,
15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 1,
2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 6, 7, 8, 8, 9, 9,
9, 9, 11, 11, 11, 11, 11, 12, 13, 13, 15, 15, 16, 16, 16, 16,
16, 17, 18, 18, 18, 18, 18, 18, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3,
4, 4, 4, 4, 5, 5, 5, 5, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 11,
11, 11, 12, 13, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 17,
17, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 7, 7, 7, 7, 7, 7, 8, 9, 10, 10,
11, 11, 11, 12, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,
14, 15, 15, 15, 16, 16, 17, 17, 17, 17, 18, 19, 19, 19, 19, 1,
1, 2, 3, 3, 5, 5, 8, 8, 8, 9, 10, 11, 11, 12, 12, 12, 13, 13,
14, 14, 14, 15, 15, 15, 15, 15, 16, 17, 17, 1, 1, 1, 2, 3, 3,
4, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 9, 10, 10,
10, 11, 11, 12, 12, 13, 14, 14, 14, 14, 14, 14, 15, 15, 17, 17,
17, 17, 17, 17, 18, 18, 19, 19, 19, 19, 1, 2, 2, 2, 3, 3, 3,
3, 4, 4, 5, 5, 5, 8, 8, 9, 9, 9, 10, 11, 11, 11, 12, 12, 13,
13, 14, 14, 15, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 18, 18, 18, 19, 19, 1, 1, 1, 3, 3, 3, 4, 4, 5, 6, 7, 7, 9,
9, 9, 9, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 17, 17,
17, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 2, 2, 4, 5, 5, 7,
7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 13, 14, 14, 14, 14, 15, 15, 15,
15, 17, 18, 18, 19, 19, 19), comid = c(42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 74, 74, 74, 74, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 90, 90, 90, 90,
90, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 88, 88, 88, 88, 88, 88, 88, 88, 88, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 30,
30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
35, 35, 35, 35, 35, 35, 92, 92, 92, 92, 73, 73, 73, 73, 73, 73,
73, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 54, 54, 54, 54, 54, 54, 54,
54, 54, 51, 51, 51, 51, 51, 51, 51, 51, 51, 82, 82, 82, 82, 82,
82, 82, 82, 82, 82, 82, 82, 82, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 89, 89, 89, 89, 89, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 95, 94, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
33, 33, 33, 33, 33, 33, 33, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 65, 65, 65, 65, 65, 65, 65, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 77, 77, 91, 91, 17, 17, 17, 17, 17, 17, 17, 28, 28,
28, 28, 28, 28, 28, 28, 28, 4, 4, 4, 4, 4, 4, 4, 85, 85, 85,
85, 8, 8, 8, 8, 8, 8, 8, 8, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 62, 62, 39, 39, 39, 39, 39, 39, 39, 39, 39, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 98, 98,
98, 98, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
53, 53, 53, 53, 53, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 46, 46, 46, 46,
46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
46, 46, 46, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 47, 47, 47, 47, 47, 47, 47,
47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 81, 81, 81, 81, 81, 81, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 68, 68,
68, 68, 68, 68, 68, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
58, 58, 60, 60, 60, 60, 60, 60, 60, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96, 96, 96, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 59, 59, 59, 59, 59, 59, 59, 84,
84, 84, 84, 84, 84, 84, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 67, 67, 67, 67, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 66, 66, 66, 66, 66, 66, 78, 78, 78, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 43, 43, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
44, 44, 48, 48, 48, 48, 48, 86, 86, 86, 86, 76, 76, 83, 83, 83,
83, 83, 83, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 97, 71, 71, 71,
71, 71, 71, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
37, 37, 37, 87, 87, 87, 87, 87, 49, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 92, 92,
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
58, 58, 58, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
53, 53, 53, 53, 53, 53, 53, 53, 53, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 98, 98, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 74, 74, 74, 74, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 89, 89, 89, 89, 89, 89, 89, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 69, 69, 69, 69, 69,
69, 69, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
84, 84, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
54, 54, 54, 54, 54, 71, 71, 71, 71, 71, 71, 71, 71, 71, 17, 17,
17, 17, 17, 17, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
91, 91, 91, 91, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 75, 75, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 39,
39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 99, 65, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 95, 95, 95, 95, 95, 95,
95, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 77, 77, 60, 60, 60, 60, 60, 60,
60, 60, 60, 60, 60, 60, 60, 60, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 35, 35,
35, 35, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 73, 73,
73, 73, 73, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 41, 41, 41, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 47, 47, 47, 47, 47, 47, 47, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 45, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 55, 55, 55, 55, 55,
55, 55, 55, 55, 46, 46, 46, 46, 46, 46, 46, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
96, 96, 96, 96, 96, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 67, 67, 67, 67,
67, 67, 67, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 64,
64, 64, 64, 64, 64, 64, 82, 82, 82, 82, 82, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 40, 40, 40, 40, 40, 40, 40, 40, 40, 57,
57, 57, 57, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 85, 85,
85, 85, 76, 76, 37, 37, 37, 37, 62, 97, 97, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 8, 8, 8,
8, 8, 8, 8, 8, 49, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 94, 94, 94, 94, 94, 94, 94, 66, 66, 66, 33, 33, 33, 33,
33, 33, 33, 33, 33, 33, 33, 33, 86, 86, 86, 86, 86, 86, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 48, 48, 48, 48, 48, 44, 44, 44, 44, 44, 44, 44, 75,
75, 75, 75, 75, 75, 75, 97, 97, 97, 85, 85, 85, 85, 83, 83, 83,
83, 83, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 39, 39, 39, 39, 39, 39,
39, 39, 39, 39, 39, 39, 39, 76, 76, 76, 76, 76, 76, 76, 96, 59,
59, 59, 59, 59, 59, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
82, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 64, 64, 64, 64, 64, 64, 64, 64, 64, 33, 33, 33,
33, 33, 33, 20, 20, 20, 20, 20, 20, 20, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 66, 66, 66, 77, 77, 77, 77, 77, 44, 44, 44, 44, 44, 44,
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
44, 44, 44, 44, 44, 44, 79, 79, 63, 63, 63, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 53, 53,
53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 42, 42, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 61, 61, 61, 61,
61, 61, 81, 81, 29, 29, 29, 29, 29, 29, 29, 29, 29, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 41, 41, 41, 41, 41, 41, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 30, 30, 30, 30, 30, 30, 30,
30, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 92, 92,
92, 92, 92, 92, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
71, 71, 71, 71, 62, 62, 62, 62, 62, 62, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 91, 91, 91, 91, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 87, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 34, 34, 34, 34, 34,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
54, 54, 54, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 57, 57,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
57, 57, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 89,
89, 89, 89, 89, 69, 69, 69, 69, 69, 69, 69, 36, 36, 36, 36, 36,
36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 94,
94, 94, 94, 94, 94, 94, 94, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 43, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 43, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 48, 48, 48, 48, 48,
48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 86, 86, 86,
86, 86, 86, 86, 86, 86, 86, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 95, 95, 95,
95, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 98, 98, 98, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 74,
74, 74, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
45, 45, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 73, 73, 73, 73, 73, 73,
73, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
58, 58, 58, 58, 58, 58, 58, 58, 58, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 60,
60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 68, 68, 68, 68, 68, 68, 68, 66, 66,
16, 16, 78, 78, 77, 77, 33, 48, 48, 48, 48, 56, 65, 86, 86, 20,
20, 20, 20, 20, 1, 1, 1, 1, 1, 15, 15, 15, 15, 5, 5, 5, 5, 5,
5, 14, 14, 14, 52, 52, 43, 43, 43, 58, 58, 58, 58, 30, 30, 30,
30, 30, 30, 35, 35, 35, 35, 35, 35, 35, 35, 35, 31, 31, 31, 60,
60, 60, 60, 60, 38, 38, 81, 81, 32, 32, 68, 68, 21, 21, 29, 29,
47, 47, 47, 47, 61, 61, 61, 9, 9, 9, 9, 9, 9, 9, 9, 41, 41, 41,
41, 41, 73, 73, 73, 73, 23, 23, 75, 22, 62, 62, 62, 62, 62, 62,
39, 39, 8, 8, 8, 8, 8, 8, 93, 76, 87, 87, 4, 4, 4, 4, 80, 80,
80, 80, 80, 85, 17, 17, 12, 12, 37, 37, 37, 37, 37, 34, 49, 49,
49, 49, 49, 49, 3, 3, 3, 26, 26, 74, 74, 74, 74, 74, 42, 42,
42, 42, 13, 13, 13, 13, 88, 25, 25, 25, 25, 63, 63, 63, 63, 79,
79, 19, 19, 19, 27, 24, 24, 24, 24, 46, 46, 46, 72, 72, 72, 70,
70, 55, 55, 54, 84, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 36, 36, 36, 36, 36, 36, 36, 10, 10, 10, 6, 6, 6, 6,
6, 6, 82, 69, 57, 57, 59, 59, 59, 96, 2, 2, 2, 2, 2, 2, 2, 18,
18, 18, 18, 18, 18, 67, 67, 67, 64, 64, 11, 11, 11, 11, 51, 89,
89, 89, 89, 43, 43, 48, 5, 5, 20, 20, 66, 66, 66, 1, 14, 15,
15, 78, 78, 78, 44, 44, 77, 77, 77, 16, 16, 16, 16, 16, 33, 65,
65, 34, 34, 34, 39, 12, 12, 85, 93, 93, 80, 80, 80, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 91, 37, 49, 49, 49, 62, 62, 76, 76, 22,
17, 17, 17, 17, 17, 17, 87, 87, 28, 28, 28, 28, 28, 28, 75, 75,
8, 8, 8, 8, 50, 61, 61, 61, 30, 30, 30, 30, 32, 32, 81, 81, 81,
9, 9, 73, 73, 73, 60, 68, 68, 68, 47, 47, 29, 29, 92, 92, 35,
21, 21, 21, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 41, 41, 41,
31, 31, 10, 10, 10, 40, 40, 40, 57, 57, 6, 96, 69, 69, 64, 64,
64, 64, 64, 64, 36, 51, 7, 7, 67, 59, 18, 18, 82, 11, 11, 11,
11, 11, 11, 11, 54, 54, 54, 2, 2, 2, 2, 24, 24, 53, 46, 46, 19,
19, 13, 13, 13, 13, 27, 27, 27, 27, 90, 79, 3, 3, 3, 3, 26, 26,
26, 26, 42, 74, 74, 72, 72, 72), iname = c("BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "MichaelHeckler", "MichaelHeckler",
"MichaelHeckler", "MichaelHeckler", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"BoskoBarisic", "BoskoBarisic", "BoskoBarisic", "BoskoBarisic",
"BoskoBarisic", "BoskoBarisic", "BoskoBarisic", "BoskoBarisic",
"BoskoBarisic", "BoskoBarisic", "BoskoBarisic", "BoskoBarisic",
"BoskoBarisic", "AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp",
"AndreSteenkamp", "AndreSteenkamp", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "HansBock", "HansBock", "HansBock", "HansBock",
"HansBock", "HansBock", "HansBock", "HansBock", "HansBock", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"ArturTrzaskos", "VernBarby", "VernBarby", "VernBarby", "VernBarby",
"VernBarby", "VernBarby", "VernBarby", "VernBarby", "VernBarby",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "StefanFlorea", "StefanFlorea",
"StefanFlorea", "StefanFlorea", "JamieHarries", "JamieHarries",
"JamieHarries", "JamieHarries", "JamieHarries", "JamieHarries",
"JamieHarries", "JoseDias", "JoseDias", "JoseDias", "JoseDias",
"JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias",
"JoseDias", "TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "TimRolston", "TimRolston",
"TimRolston", "TimRolston", "TimRolston", "TimRolston", "TimRolston",
"TimRolston", "TimRolston", "TimRolston", "TimRolston", "TimRolston",
"TimRolston", "NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "SimonGrootemaat",
"SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat",
"SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat",
"SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"AlessandroSgrani", "AlessandroSgrani", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "KimTribe", "KimTribe", "KimTribe",
"KimTribe", "KimTribe", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "SabahudinPehadzicBIHI",
"MarinkoPuskaric", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "JoshStephens", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JohnTrench",
"JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench",
"JohnTrench", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "RobertVanRensburg", "RobertVanRensburg", "MisakoIshimura",
"MisakoIshimura", "JohnBell", "JohnBell", "JohnBell", "JohnBell",
"JohnBell", "JohnBell", "JohnBell", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "AntonioRodrigues",
"AntonioRodrigues", "AntonioRodrigues", "AntonioRodrigues", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "TorbjornEriksson", "TorbjornEriksson",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"YoshikoIzumiya", "YoshikoIzumiya", "YoshikoIzumiya", "YoshikoIzumiya",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"StanislawMankou", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"StanislawMankou", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"MarkYelland", "MarkYelland", "MarkYelland", "MarkYelland", "MarkYelland",
"MarkYelland", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ReneKoops",
"ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops",
"ReneKoops", "VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "JouniNeste", "JouniNeste",
"JouniNeste", "JouniNeste", "JouniNeste", "JouniNeste", "JouniNeste",
"JouniNeste", "JouniNeste", "StephenVarga", "StephenVarga", "StephenVarga",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "ScottTucker", "ScottTucker", "ScottTucker",
"ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker", "MiroslavKaticic",
"MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "MiroslavKaticic", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "TakashiKawahara", "TakashiKawahara",
"TakashiKawahara", "TakashiKawahara", "TakashiKawahara", "TakashiKawahara",
"DavidEricDavies", "DavidEricDavies", "DavidEricDavies", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"HowardCroston", "HowardCroston", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "HelderRodrigues",
"HelderRodrigues", "HelderRodrigues", "HelderRodrigues", "RickyLehman",
"RickyLehman", "PeterDindic", "PeterDindic", "PeterDindic", "PeterDindic",
"PeterDindic", "PeterDindic", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja",
"AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja",
"AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja",
"JohnBeaven", "JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton",
"JohnFoxton", "JohnFoxton", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "JanKwisthout",
"JanKwisthout", "JanKwisthout", "JanKwisthout", "JanKwisthout",
"GaryGlenYoung", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "StefanFlorea",
"StefanFlorea", "StefanFlorea", "StefanFlorea", "StefanFlorea",
"StefanFlorea", "StefanFlorea", "StefanFlorea", "StefanFlorea",
"StefanFlorea", "StefanFlorea", "StefanFlorea", "StefanFlorea",
"StefanFlorea", "StefanFlorea", "ReneKoops", "ReneKoops", "ReneKoops",
"ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops",
"ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops",
"ReneKoops", "ReneKoops", "ReneKoops", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"VernBarby", "VernBarby", "VernBarby", "VernBarby", "VernBarby",
"VernBarby", "VernBarby", "VernBarby", "VernBarby", "VernBarby",
"VernBarby", "VernBarby", "VernBarby", "VernBarby", "VernBarby",
"VernBarby", "VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp",
"AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp",
"AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp",
"AndreSteenkamp", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BoskoBarisic", "BoskoBarisic",
"BoskoBarisic", "BoskoBarisic", "BoskoBarisic", "BoskoBarisic",
"BoskoBarisic", "BoskoBarisic", "BoskoBarisic", "BoskoBarisic",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "YoshikoIzumiya",
"YoshikoIzumiya", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"StanislawMankou", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"StanislawMankou", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"StanislawMankou", "StanislawMankou", "StanislawMankou", "MichaelHeckler",
"MichaelHeckler", "MichaelHeckler", "MichaelHeckler", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "ScottTucker",
"ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker",
"ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker",
"ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker",
"ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"KimTribe", "KimTribe", "KimTribe", "KimTribe", "KimTribe", "KimTribe",
"KimTribe", "AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "TimRolston",
"TimRolston", "TimRolston", "TimRolston", "TimRolston", "TimRolston",
"TimRolston", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton",
"JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton",
"JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell",
"PeterDindic", "PeterDindic", "PeterDindic", "PeterDindic", "PeterDindic",
"PeterDindic", "PeterDindic", "PeterDindic", "PeterDindic", "PeterDindic",
"PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "PavelMachan", "MisakoIshimura",
"MisakoIshimura", "MisakoIshimura", "MisakoIshimura", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "BrianJeremiah", "BrianJeremiah", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"DionDavies", "JohnTrench", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "SabahudinPehadzicBIHI",
"SabahudinPehadzicBIHI", "SabahudinPehadzicBIHI", "SabahudinPehadzicBIHI",
"SabahudinPehadzicBIHI", "SabahudinPehadzicBIHI", "SabahudinPehadzicBIHI",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"JoshStephens", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "RobertVanRensburg", "RobertVanRensburg", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "JamieHarries",
"JamieHarries", "JamieHarries", "JamieHarries", "JamieHarries",
"MarkYelland", "MarkYelland", "MarkYelland", "MarkYelland", "MarkYelland",
"MarkYelland", "MarkYelland", "MarkYelland", "MarkYelland", "MarkYelland",
"MarkYelland", "MarkYelland", "MarkYelland", "JoseDias", "JoseDias",
"JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias",
"JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias",
"JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias", "JoseDias",
"JoseDias", "JoseDias", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "MikeTinnion",
"MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"MikeTinnion", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "HansBock", "HansBock",
"HansBock", "HansBock", "HansBock", "HansBock", "HansBock", "HansBock",
"HansBock", "HansBock", "HansBock", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "StephenVarga", "StephenVarga", "StephenVarga",
"StephenVarga", "StephenVarga", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi",
"ToddOishi", "ToddOishi", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JouniNeste", "JouniNeste", "JouniNeste",
"JouniNeste", "JouniNeste", "JouniNeste", "JouniNeste", "SimonGrootemaat",
"SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja",
"AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja",
"AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja", "AntonioRodrigues",
"AntonioRodrigues", "AntonioRodrigues", "AntonioRodrigues", "RickyLehman",
"RickyLehman", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "TorbjornEriksson",
"JohnBeaven", "JohnBeaven", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"GaryGlenYoung", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "MarinkoPuskaric",
"MarinkoPuskaric", "MarinkoPuskaric", "MarinkoPuskaric", "MarinkoPuskaric",
"MarinkoPuskaric", "MarinkoPuskaric", "TakashiKawahara", "TakashiKawahara",
"TakashiKawahara", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "HelderRodrigues", "HelderRodrigues", "HelderRodrigues",
"HelderRodrigues", "HelderRodrigues", "HelderRodrigues", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "HowardCroston",
"HowardCroston", "HowardCroston", "HowardCroston", "HowardCroston",
"HowardCroston", "HowardCroston", "HowardCroston", "HowardCroston",
"HowardCroston", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley",
"JoeRiley", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"BrianJeremiah", "BrianJeremiah", "BrianJeremiah", "BrianJeremiah",
"BrianJeremiah", "BrianJeremiah", "BrianJeremiah", "JohnBeaven",
"JohnBeaven", "JohnBeaven", "AntonioRodrigues", "AntonioRodrigues",
"AntonioRodrigues", "AntonioRodrigues", "PeterDindic", "PeterDindic",
"PeterDindic", "PeterDindic", "PeterDindic", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan", "PavelMachan",
"PavelMachan", "PavelMachan", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek",
"StanislawGuzdek", "StanislawGuzdek", "StanislawGuzdek", "RickyLehman",
"RickyLehman", "RickyLehman", "RickyLehman", "RickyLehman", "RickyLehman",
"RickyLehman", "StephenVarga", "ScottTucker", "ScottTucker",
"ScottTucker", "ScottTucker", "ScottTucker", "ScottTucker", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny",
"ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi",
"ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi",
"ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi",
"ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi",
"ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi", "ToddOishi",
"SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat",
"SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat",
"SimonGrootemaat", "SimonGrootemaat", "SimonGrootemaat", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "JouniNeste",
"JouniNeste", "JouniNeste", "JouniNeste", "JouniNeste", "JouniNeste",
"JouniNeste", "JouniNeste", "JouniNeste", "MichalBenatinsky",
"MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky", "MichalBenatinsky",
"MichalBenatinsky", "JoshStephens", "JoshStephens", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen",
"JarkkoSuominen", "JarkkoSuominen", "JarkkoSuominen", "JohnTrench",
"JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench",
"JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench",
"JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench", "JohnTrench",
"JohnTrench", "JohnTrench", "JohnTrench", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "AaronWest",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "TakashiKawahara",
"TakashiKawahara", "TakashiKawahara", "RobertVanRensburg", "RobertVanRensburg",
"RobertVanRensburg", "RobertVanRensburg", "RobertVanRensburg",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"EricLelouvrier", "EricLelouvrier", "EricLelouvrier", "EricLelouvrier",
"BoskoBarisic", "BoskoBarisic", "JohnBuckley", "JohnBuckley",
"JohnBuckley", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "LloydStruther",
"LloydStruther", "LloydStruther", "LloydStruther", "AndreSteenkamp",
"AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp",
"AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp", "AndreSteenkamp",
"AndreSteenkamp", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "CraigColtman",
"CraigColtman", "CraigColtman", "CraigColtman", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon", "AndrewDixon",
"AndrewDixon", "AndrewDixon", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais", "PauloMorais",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "ArturTrzaskos",
"ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"ArturTrzaskos", "MarkYelland", "MarkYelland", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco", "GianlucaMazzocco",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel", "GeorgeDaniel",
"GeorgeDaniel", "JoseDias", "JoseDias", "JoseDias", "JoseDias",
"JoseDias", "JoseDias", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "VernBarby", "VernBarby",
"VernBarby", "VernBarby", "VernBarby", "VernBarby", "VernBarby",
"VernBarby", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "StefanFlorea", "StefanFlorea",
"StefanFlorea", "StefanFlorea", "StefanFlorea", "StefanFlorea",
"JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton",
"JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton",
"JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton", "JohnFoxton",
"JohnFoxton", "TorbjornEriksson", "TorbjornEriksson", "TorbjornEriksson",
"TorbjornEriksson", "TorbjornEriksson", "TorbjornEriksson", "JohnBell",
"JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell",
"JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell",
"JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell",
"JohnBell", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "JanBartko", "JanBartko",
"JanBartko", "JanBartko", "JanBartko", "MisakoIshimura", "MisakoIshimura",
"MisakoIshimura", "MisakoIshimura", "GaryGlenYoung", "GaryGlenYoung",
"GaryGlenYoung", "GaryGlenYoung", "GaryGlenYoung", "GaryGlenYoung",
"GaryGlenYoung", "GaryGlenYoung", "GaryGlenYoung", "GaryGlenYoung",
"GaryGlenYoung", "GaryGlenYoung", "JanKwisthout", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "AnthonyNaranja", "AnthonyNaranja",
"AnthonyNaranja", "AnthonyNaranja", "AnthonyNaranja", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek", "PeterBienek",
"PeterBienek", "PeterBienek", "PeterBienek", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte", "NunoDuarte",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "BretBishop",
"BretBishop", "BretBishop", "BretBishop", "BretBishop", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani", "AlessandroSgrani",
"MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic", "MiroslavKaticic",
"MiroslavKaticic", "KimTribe", "KimTribe", "KimTribe", "KimTribe",
"KimTribe", "TimRolston", "TimRolston", "TimRolston", "TimRolston",
"TimRolston", "TimRolston", "TimRolston", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "MarinkoPuskaric",
"MarinkoPuskaric", "MarinkoPuskaric", "MarinkoPuskaric", "MarinkoPuskaric",
"MarinkoPuskaric", "MarinkoPuskaric", "MarinkoPuskaric", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "LucaPapandrea",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"PeterElberse", "PeterElberse", "PeterElberse", "PeterElberse",
"HowardCroston", "HowardCroston", "HowardCroston", "HowardCroston",
"HowardCroston", "HowardCroston", "HowardCroston", "HowardCroston",
"HowardCroston", "HowardCroston", "HowardCroston", "HowardCroston",
"HowardCroston", "HowardCroston", "HowardCroston", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucjanBurda", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley",
"JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley",
"JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley",
"HelderRodrigues", "HelderRodrigues", "HelderRodrigues", "HelderRodrigues",
"HelderRodrigues", "HelderRodrigues", "HelderRodrigues", "HelderRodrigues",
"HelderRodrigues", "HelderRodrigues", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"SabahudinPehadzicBIHI", "SabahudinPehadzicBIHI", "SabahudinPehadzicBIHI",
"SabahudinPehadzicBIHI", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"LanceEgan", "LanceEgan", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "YoshikoIzumiya", "YoshikoIzumiya",
"YoshikoIzumiya", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"StanislawMankou", "StanislawMankou", "StanislawMankou", "StanislawMankou",
"StanislawMankou", "StanislawMankou", "StanislawMankou", "HansBock",
"HansBock", "HansBock", "HansBock", "HansBock", "HansBock", "HansBock",
"HansBock", "HansBock", "HansBock", "HansBock", "HansBock", "HansBock",
"HansBock", "MichaelHeckler", "MichaelHeckler", "MichaelHeckler",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri", "YannCaleri",
"YannCaleri", "TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"OlliToivonen", "JamieHarries", "JamieHarries", "JamieHarries",
"JamieHarries", "JamieHarries", "JamieHarries", "JamieHarries",
"MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"MikeTinnion", "MikeTinnion", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic", "IvicaMagdic",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "TerenceCourtoreille",
"TerenceCourtoreille", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar", "CraigFarrar",
"CraigFarrar", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"MiroslavAntal", "MiroslavAntal", "MiroslavAntal", "MiroslavAntal",
"ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops", "ReneKoops",
"ReneKoops", "ReneKoops", "TakashiKawahara", "TakashiKawahara",
"DonaldThom", "DonaldThom", "DavidEricDavies", "DavidEricDavies",
"RobertVanRensburg", "RobertVanRensburg", "MichalBenatinsky",
"JoeRiley", "JoeRiley", "JoeRiley", "JoeRiley", "PeterElberse",
"JohnTrench", "HelderRodrigues", "HelderRodrigues", "JoshStephens",
"JoshStephens", "JoshStephens", "JoshStephens", "JoshStephens",
"MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz", "MartinDroz",
"AaronWest", "AaronWest", "AaronWest", "AaronWest", "LucjanBurda",
"LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda", "LucjanBurda",
"LucaPapandrea", "LucaPapandrea", "LucaPapandrea", "JarkkoSuominen",
"JarkkoSuominen", "HowardCroston", "HowardCroston", "HowardCroston",
"VilleAnttiJaakkola", "VilleAnttiJaakkola", "VilleAnttiJaakkola",
"VilleAnttiJaakkola", "VernBarby", "VernBarby", "VernBarby",
"VernBarby", "VernBarby", "VernBarby", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh",
"WilliamKavenagh", "WilliamKavenagh", "WilliamKavenagh", "TerenceCourtoreille",
"TerenceCourtoreille", "TerenceCourtoreille", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "SeiichiKomatsuzawa", "SeiichiKomatsuzawa",
"SeiichiKomatsuzawa", "GeorgeDaniel", "GeorgeDaniel", "MarkYelland",
"MarkYelland", "MiroslavAntal", "MiroslavAntal", "ReneKoops",
"ReneKoops", "CraigFarrar", "CraigFarrar", "GianlucaMazzocco",
"GianlucaMazzocco", "MikeTinnion", "MikeTinnion", "MikeTinnion",
"MikeTinnion", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam", "TomasAdam",
"TomasAdam", "TomasAdam", "TomasAdam", "JoseDias", "JoseDias",
"JoseDias", "JoseDias", "JoseDias", "JamieHarries", "JamieHarries",
"JamieHarries", "JamieHarries", "ChristopheIdre", "ChristopheIdre",
"BrianJeremiah", "PavelMachan", "TorbjornEriksson", "TorbjornEriksson",
"TorbjornEriksson", "TorbjornEriksson", "TorbjornEriksson", "TorbjornEriksson",
"StanislawGuzdek", "StanislawGuzdek", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"JannePirkkalainen", "AidenHodgins", "RickyLehman", "JanKwisthout",
"JanKwisthout", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"RandyTaylor", "RandyTaylor", "RandyTaylor", "RandyTaylor", "RandyTaylor",
"AntonioRodrigues", "JohnBell", "JohnBell", "JanBartko", "JanBartko",
"ValerioSantiAmantini", "ValerioSantiAmantini", "ValerioSantiAmantini",
"ValerioSantiAmantini", "ValerioSantiAmantini", "AnthonyNaranja",
"GaryGlenYoung", "GaryGlenYoung", "GaryGlenYoung", "GaryGlenYoung",
"GaryGlenYoung", "GaryGlenYoung", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "JohnNishi", "JohnNishi", "MichaelHeckler",
"MichaelHeckler", "MichaelHeckler", "MichaelHeckler", "MichaelHeckler",
"BorisDzurek", "BorisDzurek", "BorisDzurek", "BorisDzurek", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "SandroSoldarini", "HansBock",
"OlliToivonen", "OlliToivonen", "OlliToivonen", "OlliToivonen",
"JohnBuckley", "JohnBuckley", "JohnBuckley", "JohnBuckley", "BoskoBarisic",
"BoskoBarisic", "LloydStruther", "LloydStruther", "LloydStruther",
"MarekWalczyk", "LanceEgan", "LanceEgan", "LanceEgan", "LanceEgan",
"AndrewDixon", "AndrewDixon", "AndrewDixon", "ThibaultGuilpain",
"ThibaultGuilpain", "ThibaultGuilpain", "StanislawMankou", "StanislawMankou",
"CraigColtman", "CraigColtman", "NunoDuarte", "MiroslavKaticic",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "SimonRobinson", "SimonRobinson", "SimonRobinson",
"SimonRobinson", "DamienWalsh", "DamienWalsh", "DamienWalsh",
"DamienWalsh", "DamienWalsh", "DamienWalsh", "DamienWalsh", "PiotrKonieczny",
"PiotrKonieczny", "PiotrKonieczny", "DesArmstrong", "DesArmstrong",
"DesArmstrong", "DesArmstrong", "DesArmstrong", "DesArmstrong",
"SimonGrootemaat", "TimRolston", "AlessandroSgrani", "AlessandroSgrani",
"ScottTucker", "ScottTucker", "ScottTucker", "StephenVarga",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"JulienDaguillanes", "KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa",
"KiyoshiNakagawa", "KiyoshiNakagawa", "KiyoshiNakagawa", "ToddOishi",
"ToddOishi", "ToddOishi", "JouniNeste", "JouniNeste", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "BretBishop",
"KimTribe", "KimTribe", "KimTribe", "KimTribe", "HowardCroston",
"HowardCroston", "JoeRiley", "LucjanBurda", "LucjanBurda", "JoshStephens",
"JoshStephens", "TakashiKawahara", "TakashiKawahara", "TakashiKawahara",
"MartinDroz", "LucaPapandrea", "AaronWest", "AaronWest", "DavidEricDavies",
"DavidEricDavies", "DavidEricDavies", "EricLelouvrier", "EricLelouvrier",
"RobertVanRensburg", "RobertVanRensburg", "RobertVanRensburg",
"DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom", "DonaldThom",
"MichalBenatinsky", "JohnTrench", "JohnTrench", "AnthonyNaranja",
"AnthonyNaranja", "AnthonyNaranja", "StanislawGuzdek", "JanBartko",
"JanBartko", "AntonioRodrigues", "AidenHodgins", "AidenHodgins",
"RandyTaylor", "RandyTaylor", "RandyTaylor", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey", "JohnHorsey",
"JohnHorsey", "JohnHorsey", "JohnHorsey", "MisakoIshimura", "ValerioSantiAmantini",
"GaryGlenYoung", "GaryGlenYoung", "GaryGlenYoung", "TorbjornEriksson",
"TorbjornEriksson", "RickyLehman", "RickyLehman", "PavelMachan",
"JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell", "JohnBell",
"JanKwisthout", "JanKwisthout", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BertrandJacquemin", "BertrandJacquemin",
"BertrandJacquemin", "BrianJeremiah", "BrianJeremiah", "JannePirkkalainen",
"JannePirkkalainen", "JannePirkkalainen", "JannePirkkalainen",
"IvicaMagdic", "ArturTrzaskos", "ArturTrzaskos", "ArturTrzaskos",
"VernBarby", "VernBarby", "VernBarby", "VernBarby", "MiroslavAntal",
"MiroslavAntal", "MarkYelland", "MarkYelland", "MarkYelland",
"TomasAdam", "TomasAdam", "JamieHarries", "JamieHarries", "JamieHarries",
"SeiichiKomatsuzawa", "ReneKoops", "ReneKoops", "ReneKoops",
"MikeTinnion", "MikeTinnion", "GianlucaMazzocco", "GianlucaMazzocco",
"StefanFlorea", "StefanFlorea", "WilliamKavenagh", "CraigFarrar",
"CraigFarrar", "CraigFarrar", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"ChristopheIdre", "ChristopheIdre", "ChristopheIdre", "ChristopheIdre",
"JoseDias", "JoseDias", "JoseDias", "TerenceCourtoreille", "TerenceCourtoreille",
"PiotrKonieczny", "PiotrKonieczny", "PiotrKonieczny", "PeterBienek",
"PeterBienek", "PeterBienek", "AlessandroSgrani", "AlessandroSgrani",
"DesArmstrong", "StephenVarga", "TimRolston", "TimRolston", "JouniNeste",
"JouniNeste", "JouniNeste", "JouniNeste", "JouniNeste", "JouniNeste",
"DamienWalsh", "BretBishop", "SimonRobinson", "SimonRobinson",
"ToddOishi", "ScottTucker", "KiyoshiNakagawa", "KiyoshiNakagawa",
"SimonGrootemaat", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"AntoninPesek", "AntoninPesek", "AntoninPesek", "AntoninPesek",
"NunoDuarte", "NunoDuarte", "NunoDuarte", "JulienDaguillanes",
"JulienDaguillanes", "JulienDaguillanes", "JulienDaguillanes",
"LanceEgan", "LanceEgan", "PauloMorais", "AndrewDixon", "AndrewDixon",
"LloydStruther", "LloydStruther", "SandroSoldarini", "SandroSoldarini",
"SandroSoldarini", "SandroSoldarini", "MarekWalczyk", "MarekWalczyk",
"MarekWalczyk", "MarekWalczyk", "AndreSteenkamp", "BoskoBarisic",
"TomasStarychfojtu", "TomasStarychfojtu", "TomasStarychfojtu",
"TomasStarychfojtu", "JohnNishi", "JohnNishi", "JohnNishi", "JohnNishi",
"BorisDzurek", "MichaelHeckler", "MichaelHeckler", "ThibaultGuilpain",
"ThibaultGuilpain", "ThibaultGuilpain"), country = c("SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "WAL", "WAL", "WAL", "WAL", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "RSA", "RSA", "RSA",
"RSA", "RSA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"ROM", "ROM", "ROM", "ROM", "WAL", "WAL", "WAL", "WAL", "WAL",
"WAL", "WAL", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA",
"RSA", "RSA", "RSA", "RSA", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "WAL", "WAL", "WAL", "WAL", "WAL", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "NDI",
"CRO", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "RSA", "RSA", "JPN",
"JPN", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "POR", "POR", "POR",
"POR", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "SWE", "SWE", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "JPN", "JPN", "JPN", "JPN", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "BUL",
"BUL", "BUL", "BUL", "BUL", "BUL", "BUL", "BUL", "BUL", "BUL",
"BUL", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "RSA", "RSA", "RSA",
"RSA", "RSA", "RSA", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"JPN", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "MAL", "MAL", "MAL", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "JPN", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "JPN", "JPN", "JPN", "JPN",
"JPN", "JPN", "WAL", "WAL", "WAL", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "ENG", "ENG", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "AUS", "AUS", "AUS", "AUS", "AUS", "POR", "POR", "POR",
"POR", "AUS", "AUS", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "CAN", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "NED", "NED", "NED", "NED", "NED", "RSA",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM",
"ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "RSA",
"RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA",
"RSA", "RSA", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "JPN", "JPN", "BUL", "BUL",
"BUL", "BUL", "BUL", "BUL", "BUL", "BUL", "BUL", "BUL", "BUL",
"BUL", "BUL", "BUL", "WAL", "WAL", "WAL", "WAL", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "WAL", "WAL", "WAL", "WAL", "WAL", "WAL", "WAL", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA",
"RSA", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "JPN", "JPN",
"JPN", "JPN", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "WAL", "WAL", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "WAL", "IRE", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"NDI", "NDI", "NDI", "NDI", "NDI", "NDI", "NDI", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "RSA", "RSA", "JPN", "JPN", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"JPN", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "IRE", "IRE", "IRE", "IRE", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "WAL",
"WAL", "WAL", "WAL", "WAL", "RSA", "RSA", "RSA", "RSA", "RSA",
"RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "MAL", "MAL",
"MAL", "MAL", "MAL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "NED",
"NED", "NED", "NED", "NED", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "ITA", "ITA", "ITA",
"ITA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "POR", "POR", "POR", "POR", "AUS", "AUS",
"ITA", "ITA", "ITA", "ITA", "SWE", "CAN", "CAN", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "RSA", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"JPN", "JPN", "JPN", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "POR", "POR", "POR",
"POR", "POR", "POR", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "AUS", "AUS", "AUS", "AUS", "AUS", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "WAL", "WAL", "WAL",
"WAL", "WAL", "WAL", "WAL", "CAN", "CAN", "CAN", "POR", "POR",
"POR", "POR", "CRO", "CRO", "CRO", "CRO", "CRO", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "MAL", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "NED", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "JPN", "JPN", "JPN",
"RSA", "RSA", "RSA", "RSA", "RSA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "CRO", "CRO", "IRE",
"IRE", "IRE", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA",
"RSA", "RSA", "RSA", "RSA", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "POL", "POL",
"POL", "POL", "POL", "POL", "RSA", "RSA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "POR", "POR", "POR", "POR", "POR",
"POR", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "ROM", "ROM", "ROM",
"ROM", "ROM", "ROM", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "JPN", "JPN", "JPN", "JPN", "RSA",
"RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA",
"RSA", "RSA", "NED", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "USA", "USA", "USA", "USA", "USA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CRO", "CRO", "CRO", "CRO", "WAL", "WAL", "WAL", "WAL",
"WAL", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "RSA", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "NED", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "AUS", "POR", "POR", "POR", "POR", "POR",
"POR", "POR", "POR", "POR", "POR", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"NDI", "NDI", "NDI", "NDI", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA",
"USA", "USA", "USA", "USA", "USA", "USA", "USA", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL",
"POL", "JPN", "JPN", "JPN", "BUL", "BUL", "BUL", "BUL", "BUL",
"BUL", "BUL", "BUL", "BUL", "BUL", "NED", "NED", "NED", "NED",
"NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED", "NED",
"NED", "WAL", "WAL", "WAL", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA",
"ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "ITA", "FIN",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "WAL", "WAL", "WAL", "WAL", "WAL", "WAL", "WAL",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN",
"CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO", "CRO",
"CRO", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN",
"CAN", "CAN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"JPN", "JPN", "JPN", "JPN", "JPN", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK",
"SVK", "SVK", "SVK", "SVK", "NED", "NED", "NED", "NED", "NED",
"NED", "NED", "JPN", "JPN", "CAN", "CAN", "WAL", "WAL", "RSA",
"RSA", "SVK", "AUS", "AUS", "AUS", "AUS", "NED", "IRE", "POR",
"POR", "USA", "USA", "USA", "USA", "USA", "CZE", "CZE", "CZE",
"CZE", "CZE", "NZL", "NZL", "NZL", "NZL", "POL", "POL", "POL",
"POL", "POL", "POL", "ITA", "ITA", "ITA", "FIN", "FIN", "ENG",
"ENG", "ENG", "FIN", "FIN", "FIN", "FIN", "AUS", "AUS", "AUS",
"AUS", "AUS", "AUS", "IRE", "IRE", "IRE", "IRE", "IRE", "IRE",
"IRE", "IRE", "IRE", "CAN", "CAN", "CAN", "JPN", "JPN", "JPN",
"JPN", "JPN", "USA", "USA", "RSA", "RSA", "SVK", "SVK", "NED",
"NED", "NZL", "NZL", "ITA", "ITA", "ENG", "ENG", "ENG", "ENG",
"POL", "POL", "POL", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE",
"CZE", "CZE", "POR", "POR", "POR", "POR", "POR", "WAL", "WAL",
"WAL", "WAL", "FRA", "FRA", "WAL", "CZE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "POL", "POL", "FIN", "FIN", "FIN", "FIN",
"FIN", "FIN", "IRE", "AUS", "NED", "NED", "ENG", "ENG", "ENG",
"ENG", "CAN", "CAN", "CAN", "CAN", "CAN", "POR", "NZL", "NZL",
"SVK", "SVK", "ITA", "ITA", "ITA", "ITA", "ITA", "USA", "RSA",
"RSA", "RSA", "RSA", "RSA", "RSA", "CZE", "CZE", "CZE", "CAN",
"CAN", "WAL", "WAL", "WAL", "WAL", "WAL", "SVK", "SVK", "SVK",
"SVK", "ITA", "ITA", "ITA", "ITA", "NED", "FIN", "FIN", "FIN",
"FIN", "IRE", "IRE", "IRE", "IRE", "CRO", "CRO", "NZL", "NZL",
"NZL", "POL", "USA", "USA", "USA", "USA", "ENG", "ENG", "ENG",
"FRA", "FRA", "FRA", "BUL", "BUL", "AUS", "AUS", "POR", "CRO",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "IRE",
"IRE", "IRE", "IRE", "IRE", "IRE", "IRE", "POL", "POL", "POL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NED", "RSA", "ITA",
"ITA", "AUS", "AUS", "AUS", "MAL", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "JPN", "JPN", "JPN", "JPN", "JPN", "JPN",
"CAN", "CAN", "CAN", "FIN", "FIN", "CZE", "CZE", "CZE", "CZE",
"USA", "WAL", "WAL", "WAL", "WAL", "ENG", "ENG", "AUS", "POL",
"POL", "USA", "USA", "JPN", "JPN", "JPN", "CZE", "ITA", "NZL",
"NZL", "WAL", "WAL", "WAL", "FRA", "FRA", "RSA", "RSA", "RSA",
"CAN", "CAN", "CAN", "CAN", "CAN", "SVK", "IRE", "IRE", "USA",
"USA", "USA", "POL", "SVK", "SVK", "POR", "IRE", "IRE", "CAN",
"CAN", "CAN", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG", "ENG",
"ENG", "ENG", "ENG", "JPN", "ITA", "RSA", "RSA", "RSA", "SWE",
"SWE", "AUS", "AUS", "CZE", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NED", "NED", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"WAL", "WAL", "FIN", "FIN", "FIN", "FIN", "CRO", "POL", "POL",
"POL", "AUS", "AUS", "AUS", "AUS", "SVK", "SVK", "RSA", "RSA",
"RSA", "CZE", "CZE", "WAL", "WAL", "WAL", "JPN", "NED", "NED",
"NED", "ENG", "ENG", "ITA", "ITA", "ROM", "ROM", "IRE", "NZL",
"NZL", "NZL", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA", "FRA",
"FRA", "FRA", "FRA", "POR", "POR", "POR", "CAN", "CAN", "POL",
"POL", "POL", "SVK", "SVK", "SVK", "ITA", "ITA", "NZL", "MAL",
"RSA", "RSA", "FIN", "FIN", "FIN", "FIN", "FIN", "FIN", "IRE",
"USA", "ENG", "ENG", "CAN", "AUS", "JPN", "JPN", "NED", "CZE",
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "POR", "POR", "POR",
"FRA", "FRA", "FRA", "FRA", "USA", "USA", "POR", "ENG", "ENG",
"NZL", "NZL", "ITA", "ITA", "ITA", "ITA", "POL", "POL", "POL",
"POL", "RSA", "CRO", "CZE", "CZE", "CZE", "CZE", "CAN", "CAN",
"CAN", "CAN", "SVK", "WAL", "WAL", "FRA", "FRA", "FRA")), .Names = c("length",
"water", "session", "sector", "beatboat", "comid", "iname", "country"
), row.names = c(NA, 4267), class = "data.frame")
|
tabPanel(
title = tagList(
icon("globe-asia"),
i18n$t("感染状況マップ")
),
fluidRow(
column(
width = 5,
tags$div(
fluidRow(
column(
width = 6,
switchInput(
inputId = "switchMapVersion",
value = T,
onLabel = i18n$t("シンプル"),
onStatus = "danger",
offStatus = "danger",
offLabel = i18n$t("詳細"),
label = i18n$t("表示モード"),
inline = T,
size = "small",
width = "300px",
labelWidth = "200px",
handleWidth = "100px"
),
),
column(
width = 6,
uiOutput("echartsMapPlaySetting")
),
),
style = "margin-top:10px;"
),
uiOutput("comfirmedMapWrapper") %>% withSpinner(proxy.height = "550px"),
uiOutput("selectMapBottomButton"),
progressBar(
id = "activePatients",
value = TOTAL_JAPAN - DEATH_JAPAN - 40 - sum(mhlwSummary[日付 == max(日付)]$退院者),
total = TOTAL_JAPAN - DEATH_JAPAN - 40,
title = tagList(
icon("procedures"),
i18n$t("現在患者数")
),
striped = T,
status = "danger",
display_pct = T
),
progressBar(
id = "vaccine_complete_ratio",
value = global_value_for_display[key == "vaccine_complete"]$value,
total = sum(prefecture_master$人口),
title = tagList(
icon("syringe"),
i18n$t("2回目接種済率")
),
striped = TRUE,
status = "success",
display_pct = TRUE
),
helpText(
sprintf(
i18n$t("2021/2/17 接種開始日から %s 日を経ち、2回目接種完了率は %s。直近7日の2回目まで完了した平均毎日の接種完了人数は %s です。"),
as.numeric(Sys.Date() - as.Date("2021-02-17")),
paste0(round(global_value_for_display[key == "vaccine_complete"]$value / sum(prefecture_master$人口) * 100, 2), "%"),
prettyNum(global_value_for_display[key == "average_7_vaccine"]$value, big.mark = ","),
round((75729685 - global_value_for_display[key == "vaccine_complete"]$value) / global_value_for_display[key == "average_7_vaccine"]$value)
)
),
bsTooltip(
id = "activePatients",
placement = "right",
title = i18n$t("分母には死亡者、チャーター便で帰国したクルーズ船の乗客40名は含まれていません。")
),
progressBar(
id = "activeRegions",
value = mhlwSummary[日付 == max(日付) & 分類 == 0 & 都道府県名 != "伊客船" & 入院中 == 0, .N],
total = 47,
title = tagList(
icon("shield-alt"),
i18n$t("感染者ゼロの都道府県")
),
striped = T,
status = "success",
display_pct = T
),
tags$small(i18n$t("回復者数は厚労省発表の数値を使用しているため、メディアの速報より1日遅れる可能性があります。")),
bsTooltip(
id = "activeRegions",
placement = "top",
title = i18n$t("回復者数は厚労省発表の数値を使用しているため、メディアの速報より1日遅れる可能性があります。")
),
uiOutput("saveArea"),
),
column(
width = 7,
boxPad(
fluidRow(
column(
width = 11,
radioGroupButtons(
inputId = "switchTableVersion",
label = NULL,
justified = T,
choiceNames = c(
paste(icon("procedures"), i18n$t("感染")),
paste(icon("vials"), i18n$t("検査")),
paste(icon("hospital"), i18n$t("回復・死亡"))
),
choiceValues = c("confirmed", "test", "discharged"),
status = "danger"
)
),
column(
width = 1,
tags$span(
dropdownButton(
tags$h4(icon("eye"), i18n$t("表示設定")),
tags$hr(),
materialSwitch(
inputId = "tableShowSetting",
label = tagList(icon("object-group"), i18n$t("グルーピング表示")),
status = "danger",
value = FALSE
),
circle = F,
right = T,
inline = T,
status = "danger",
icon = icon("gear"),
size = "sm",
width = "300px",
tooltip = tooltipOptions(title = i18n$t("表示設定"), placement = "top")
),
style = "float:right;"
)
)
),
uiOutput("summaryTable") %>% withSpinner()
)
)
)
)
|
contour.wblr<-function(x, ...) {
plot_contour(x,CL=seq(.1,.9,by=.1), ...)
}
|
find.pK <- function(sweep.stats) {
'%ni%' <- Negate('%in%')
if ("AUC" %ni% colnames(sweep.stats) == TRUE) {
bc.mvn <- as.data.frame(matrix(0L, nrow=length(unique(sweep.stats$pK)), ncol=5))
colnames(bc.mvn) <- c("ParamID","pK","MeanBC","VarBC","BCmetric")
bc.mvn$pK <- unique(sweep.stats$pK)
bc.mvn$ParamID <- 1:nrow(bc.mvn)
x <- 0
for (i in unique(bc.mvn$pK)) {
x <- x + 1
ind <- which(sweep.stats$pK == i)
bc.mvn$MeanBC[x] <- mean(sweep.stats[ind, "BCreal"])
bc.mvn$VarBC[x] <- sd(sweep.stats[ind, "BCreal"])^2
bc.mvn$BCmetric[x] <- mean(sweep.stats[ind, "BCreal"])/(sd(sweep.stats[ind, "BCreal"])^2)
}
par(mar=rep(1,4))
x <- plot(x=bc.mvn$ParamID, y=bc.mvn$BCmetric, pch=16, col="
x <- lines(x=bc.mvn$ParamID, y=bc.mvn$BCmetric, col="
print(x)
return(bc.mvn)
}
if ("AUC" %in% colnames(sweep.stats) == TRUE) {
bc.mvn <- as.data.frame(matrix(0L, nrow=length(unique(sweep.stats$pK)), ncol=6))
colnames(bc.mvn) <- c("ParamID","pK","MeanAUC","MeanBC","VarBC","BCmetric")
bc.mvn$pK <- unique(sweep.stats$pK)
bc.mvn$ParamID <- 1:nrow(bc.mvn)
x <- 0
for (i in unique(bc.mvn$pK)) {
x <- x + 1
ind <- which(sweep.stats$pK == i)
bc.mvn$MeanAUC[x] <- mean(sweep.stats[ind, "AUC"])
bc.mvn$MeanBC[x] <- mean(sweep.stats[ind, "BCreal"])
bc.mvn$VarBC[x] <- sd(sweep.stats[ind, "BCreal"])^2
bc.mvn$BCmetric[x] <- mean(sweep.stats[ind, "BCreal"])/(sd(sweep.stats[ind, "BCreal"])^2)
}
par(mar=rep(1,4))
x <- plot(x=bc.mvn$ParamID, y=bc.mvn$MeanAUC, pch=18, col="black", cex=0.75,xlab=NA, ylab = NA)
x <- lines(x=bc.mvn$ParamID, y=bc.mvn$MeanAUC, col="black", lty=2)
par(new=TRUE)
x <- plot(x=bc.mvn$ParamID, y=bc.mvn$BCmetric, pch=16, col="
axis(side=4)
x <- lines(x=bc.mvn$ParamID, y=bc.mvn$BCmetric, col="
print(x)
return(bc.mvn)
}
}
|
make.lim <- function(int=TRUE, list=NULL, length=10) {
lims <- list()
if(int){
message("Please provide some information, see http://chrisbcole.me/mineR for details. Enter -9 to stop entering at any time.")
i = 1
while(i < length){
lims[[i]] <- as.integer(readline(prompt = paste0("For terms with ", i, " words, type how many matches are required: ")))
if(is.na(lims[[i]])) stop("Please enter a number.")
if(lims[[i]] == -9) {
lims[[i]] <- NULL
break
}
if(lims[[i]] > i) {
message(" \n Number of terms to match exceeds number of words in term. Please try again or -9 to exit. \n")
i = i-1
}
i = i+1
}
message("Thanks! Your input has been saved under lims, which will be used by mineR by default.")
} else if(!int){
lims <- list
message("Your list of constraints has been changed and saved under lims")
}
return(lims)
}
|
library(hamcrest)
expected <- c(0x1.3e0a7a7f4456ep+5 + 0x1.04c516cc104b8p-3i, -0x1.440abb7bce593p+5 + -0x1.e105f3d23e2e8p-4i,
0x1.2f56b89f3b516p+5 + 0x1.b8083354b2e7p-4i, -0x1.08a240f74c482p+5 + -0x1.8e9b4746a604p-4i,
0x1.06a449b533823p+5 + 0x1.64c9a6e54e744p-4i, -0x1.de658ef32b326p+4 + -0x1.3a9de2df0cc88p-4i,
0x1.422b0a57541f9p+5 + 0x1.1022a2a81d88dp-4i, -0x1.6e71052c8811p+4 + -0x1.cac543930ec52p-5i,
0x1.1c634c4624be6p+3 + 0x1.74d15a55ed4efp-5i, -0x1.1d0747d3064e5p+5 + -0x1.1e7f40b06eb2cp-5i,
0x1.4abf00a27cb64p+4 + 0x1.8fc98b0be48bap-6i, -0x1.2a69ce809a8a3p+5 + -0x1.c45f280ca10aep-7i,
0x1.68490deab4443p+5 + 0x1.a2e3c16fcfffep-9i, -0x1.5008780a6af34p+5 + 0x1.e60f78bdbe44dp-8i,
0x1.e9f78cb7f5e35p+5 + -0x1.2745816ca8088p-6i, -0x1.6d11ee6bffd33p+5 + 0x1.d4bc8ba5f612cp-6i,
0x1.e20fbc6634672p+4 + -0x1.40de94e829a34p-5i, -0x1.8bfe0da67755fp+5 + 0x1.970dd365e4f5cp-5i,
0x1.210455517a4b2p+5 + -0x1.ecd63b3729a35p-5i, -0x1.68df38f5ff99bp+5 + 0x1.2111102112905p-4i,
0x1.b4f8e0672501ep+5 + -0x1.4b6dfaf0f35cp-4i, -0x1.5adaa3ba37cb9p+4 + 0x1.75772a2c0db68p-4i,
0x1.a02e3f06944bp+4 + -0x1.9f21ff1ab88fp-4i, -0x1.57808fc7a70ddp+5 + 0x1.c863f2dbaaa6p-4i,
0x1.d3a8a16ce9bdap+5 + -0x1.f132990ccde74p-4i, -0x1.06a9e8def4278p+6 + 0x1.0cc1d136b351cp-3i,
0x1.4f1d755bbdb5dp+5 + -0x1.20a66fbc6dcf5p-3i, -0x1.9850993fd35dep+5 + 0x1.3442217cbc71cp-3i,
0x1.5700cc09fc436p+5 + -0x1.478ff24945404p-3i, -0x1.1cc109b862c61p+5 + 0x1.5a8b01a0925adp-3i,
0x1.37e520cfa0c88p+5 + -0x1.6d2e83e97fa73p-3i, -0x1.ffd2b8a3afd12p+4 + 0x1.7f75c3a95e80bp-3i,
0x1.2d181edc11cd9p+5 + -0x1.915c22b483316p-3i, -0x1.275c59ad17f2cp+4 + 0x1.a2dd1b58efd16p-3i,
0x1.6e4c7c455600bp+4 + -0x1.b3f44182cee7fp-3i, -0x1.ced1153e315e7p+4 + 0x1.c49d43da75fd3p-3i,
0x1.adb3da35d475dp+4 + -0x1.d4d3ecdba72dcp-3i, -0x1.28465149f8c41p+5 + 0x1.e49423e5ca1eep-3i,
0x1.3c7ad98894902p+5 + -0x1.f3d9ee44d9d5ap-3i, -0x1.926424e14cc6p+5 + 0x1.0150b81960ca2p-2i,
0x1.1f0cfd84c0dabp+5 + -0x1.087376e875c57p-2i, -0x1.8877696713e22p+4 + 0x1.0f53660cdee77p-2i,
0x1.663147661139p+5 + -0x1.15eec8e4e5e7dp-2i, -0x1.5a7f677f15cd6p+5 + 0x1.1c43f42040834p-2i,
0x1.4990bb236f2c7p+5 + -0x1.22514e2c0504dp-2i, -0x1.005ed80b7b489p+5 + 0x1.28154f9a245ep-2i,
0x1.1e57913965436p+5 + -0x1.2d8e83844e4c6p-2i, -0x1.9ddd45bbb2432p+5 + 0x1.32bb87ea26a74p-2i,
0x1.3e3472d4debf8p+4 + -0x1.379b0e0ab541bp-2i, -0x1.4ca7ec5fd0208p+4 + 0x1.3c2bdab8f837fp-2i,
0x1.4306dccc60071p+5 + -0x1.406cc6ab8453bp-2i, -0x1.3d81ff61157b6p+5 + 0x1.445cbec71f44p-2i,
0x1.c38dd32cf0e9p+3 + -0x1.47fac4643fe2cp-2i, -0x1.ec0fa041854c3p+4 + 0x1.4b45ed8f651e6p-2i,
0x1.1db181ab40e55p+6 + -0x1.4e3d6544300dfp-2i, -0x1.11b0cada59e11p+5 + 0x1.50e06ba335e0ap-2i,
0x1.fcae71fb086c4p+2 + -0x1.532e56227937ep-2i, -0x1.184890705c7d4p+5 + 0x1.55268fb87f6f1p-2i,
0x1.9131fb56968f5p+5 + -0x1.56c89901f8a4ep-2i, -0x1.8b16787ea61b4p+5 + 0x1.58140861edbc7p-2i,
0x1.ec321c6bc6e78p+4 + -0x1.59088a1c6fb62p-2i, -0x1.46ecabddea68bp+5 + 0x1.59a5e06bbf4b6p-2i,
0x1.09320999ec0ecp+5 + -0x1.59ebe38fe796ap-2i, -0x1.037654b486bfap+5 + 0x1.59da81d8c9832p-2i,
0x1.7bc39be3624a7p+5 + -0x1.5971bfaa932bcp-2i, -0x1.418d877e82d5ep+5 + 0x1.58b1b77ca478ap-2i,
0x1.5085c2592f17cp+5 + -0x1.579a99d2df33p-2i, -0x1.b567825743cfp+4 + 0x1.562cad3164cf7p-2i,
0x1.156d4b89678fcp+5 + -0x1.54684e0ac68ap-2i, -0x1.12d9c8c3a2cfdp+5 + 0x1.524deea8a952cp-2i,
0x1.47b45665a8e59p+5 + -0x1.4fde170ee6da9p-2i, -0x1.8cdc54670a218p+3 + 0x1.4d1964d93081bp-2i,
0x1.2be8cb30ffe1bp+5 + -0x1.4a008b133d60ep-2i, -0x1.c5abd47b45772p+4 + 0x1.4694520b8eee4p-2i,
0x1.8794ed938029ap+5 + -0x1.42d59720d5581p-2i, -0x1.b4fc86c733aa7p+4 + 0x1.3ec54c8a02d8fp-2i,
0x1.6cc58224b2fb7p+5 + -0x1.3a64791919b58p-2i, -0x1.35aeaf6d8fb9ep+5 + 0x1.35b437f8c61fp-2i,
0x1.b52d8657fc138p+4 + -0x1.30b5b864d457fp-2i, -0x1.3ad9c24f2dcf9p+5 + 0x1.2b6a3d5d9426dp-2i,
0x1.246c85e0c72f6p+5 + -0x1.25d31d563f01ep-2i, -0x1.50c235e17cc59p+5 + 0x1.1ff1c1de7375ep-2i,
0x1.51255c710d2eep+5 + -0x1.19c7a746dc9c6p-2i, -0x1.a9685ad12102ap+4 + 0x1.13565c411d336p-2i,
0x1.0bfbdc8995e3ep+5 + -0x1.0c9f817b1531bp-2i, -0x1.29c64134c4b13p+5 + 0x1.05a4c9359cefdp-2i,
0x1.0c24d7349d19ap+5 + -0x1.fccfedad9e75p-3i, -0x1.f87e910b8fdf3p+3 + 0x1.edd5bceffca1dp-3i,
0x1.5e9daf7b63d69p+5 + -0x1.de5ec8dee3617p-3i, -0x1.bd6a5746af916p+5 + 0x1.ce6ef9ac106c6p-3i,
0x1.6bf71747d60cdp+5 + -0x1.be0a5611c15dp-3i, -0x1.84217f41ddc61p+5 + 0x1.ad35024e4b18dp-3i,
0x1.bc9ed06f76126p+4 + -0x1.9bf33f183d4fcp-3i, -0x1.7323b47ffcc77p+4 + 0x1.8a49688b55bd4p-3i,
0x1.09ab20b813ccdp+5 + -0x1.783bf50e84bfp-3i, -0x1.e17945b92c6c8p+5 + 0x1.65cf74335134cp-3i,
0x1.eda2de79fd944p+4 + -0x1.53088d8edde7p-3i, -0x1.c1eff71e81e58p+3 + 0x1.3febff8cde435p-3i,
0x1.901d600fe0ac9p+4 + -0x1.2c7e9e3cc6f4p-3i, -0x1.631a4308b199p+4 + 0x1.18c55219854c4p-3i,
0x1.62fdc00783b22p+4 + -0x1.04c516cc10522p-3i, -0x1.4da1cac88a608p+3 + 0x1.e105f3d23ea6ep-4i,
0x1.5485a42d45f42p+5 + -0x1.b8083354b33e7p-4i, -0x1.a5ddd212ab558p+5 + 0x1.8e9b4746a6ep-4i,
0x1.364c4cf569bc3p+5 + -0x1.64c9a6e54e8bfp-4i, -0x1.a8dec08e41e64p+5 + 0x1.3a9de2df0c85cp-4i,
0x1.d64634c48137ep+4 + -0x1.1022a2a81d6e1p-4i, -0x1.91b7fa2eb439bp+5 + 0x1.cac543930edbep-5i,
0x1.7ddeb319f1c6cp+5 + -0x1.74d15a55eeb84p-5i, -0x1.6b0de972070e7p+5 + 0x1.1e7f40b0700b8p-5i,
0x1.2fd4bb20aa8dap+5 + -0x1.8fc98b0be5e08p-6i, -0x1.a14cd893b7a53p+5 + 0x1.c45f280ca15ep-7i,
0x1.9ccc7e3a96caep+5 + -0x1.a2e3c16fcb5cp-9i, -0x1.fbd830e6fd814p+4 + -0x1.e60f78bdbc5p-8i,
0x1.4d00e63252a0ap+4 + 0x1.2745816ca6c88p-6i, -0x1.2e897dcc498b9p+5 + -0x1.d4bc8ba5f5088p-6i,
0x1.ec446af6e927cp+4 + 0x1.40de94e8288ap-5i, -0x1.58136b242c35ep+4 + -0x1.970dd365e450cp-5i,
0x1.0bcedfb714163p+5 + 0x1.ecd63b372886cp-5i, -0x1.5cd9cd0bfa776p+5 + -0x1.21111021126c6p-4i,
0x1.653003066adeep+5 + 0x1.4b6dfaf0f3bfep-4i, -0x1.141157a249e64p+4 + -0x1.75772a2c0d9d6p-4i,
0x1.d16bfee1438p+4 + 0x1.9f21ff1ab8656p-4i, -0x1.bf32203e38acfp+5 + -0x1.c863f2dba9abap-4i,
0x1.39f6a3f6654dep+5 + 0x1.f132990ccd498p-4i, -0x1.02c92368c4bf1p+5 + -0x1.0cc1d136b34e8p-3i,
0x1.709e48470a4f8p+4 + 0x1.20a66fbc6de2p-3i, -0x1.f3bbb4cc492eap+4 + -0x1.3442217cbc979p-3i,
0x1.1ac0ac3aa4685p+5 + 0x1.478ff2494500dp-3i, -0x1.af3bd0ffb220dp+4 + -0x1.5a8b01a092232p-3i,
0x1.4422f72e18cc3p+5 + 0x1.6d2e83e97f8aep-3i, -0x1.836a8c0ac680bp+5 + -0x1.7f75c3a95e48bp-3i,
0x1.0c5728ca921b6p+5 + 0x1.915c22b483214p-3i, -0x1.f04fe7424906bp+4 + -0x1.a2dd1b58efacap-3i,
0x1.a0589582a020bp+4 + 0x1.b3f44182cede4p-3i, -0x1.b1462cb6581e8p+4 + -0x1.c49d43da76176p-3i,
0x1.59ab4199fd93ap+4 + 0x1.d4d3ecdba705ep-3i, -0x1.3d474b717b1d3p+5 + -0x1.e49423e5c9ee3p-3i,
0x1.ea1ea729690fbp+4 + 0x1.f3d9ee44d958ep-3i, -0x1.f9ca706b9ed7p+4 + -0x1.0150b81960b4ap-2i,
0x1.233743fdc4488p+6 + 0x1.087376e875cefp-2i, -0x1.19eaaf670f9e9p+5 + -0x1.0f53660cdeecep-2i,
0x1.58caea64685dbp+4 + 0x1.15eec8e4e5f7bp-2i, -0x1.3da76c76bd777p+4 + -0x1.1c43f4204061cp-2i,
0x1.98822d8d3b679p+4 + 0x1.22514e2c04d61p-2i, -0x1.59a05b9491da8p+5 + -0x1.28154f9a2449bp-2i,
0x1.4d85c112cbb25p+5 + 0x1.2d8e83844e34ep-2i, -0x1.79b65430a3d79p+5 + -0x1.32bb87ea26a77p-2i,
0x1.0e5aec260e8c2p+5 + 0x1.379b0e0ab53ep-2i, -0x1.04336cfff8145p+5 + -0x1.3c2bdab8f82dp-2i,
0x1.62743ae8526aep+4 + 0x1.406cc6ab84522p-2i, -0x1.0f680b0843e0dp+5 + -0x1.445cbec71f1ep-2i,
0x1.ffd2cf71c2388p+4 + 0x1.47fac4643fcb6p-2i, -0x1.c1698d7369eb2p+4 + -0x1.4b45ed8f64ebp-2i,
0x1.de33217c94422p+4 + 0x1.4e3d65442ffc8p-2i, -0x1.33f8ba226dabbp+5 + -0x1.50e06ba335f9ep-2i,
0x1.802812d1b780cp+5 + 0x1.532e56227931cp-2i, -0x1.4318d58f8547cp+5 + -0x1.55268fb87f6e2p-2i,
0x1.9de5c699e074dp+5 + 0x1.56c89901f8654p-2i, -0x1.53ac6004894a8p+4 + -0x1.58140861ed868p-2i,
0x1.c6561717fe1dfp+4 + 0x1.59088a1c6fa67p-2i, -0x1.395d4ab7ec9dp+5 + -0x1.59a5e06bbf41bp-2i,
0x1.827954ca42b58p+4 + 0x1.59ebe38fe7a5dp-2i, -0x1.cbfdfe4eb79dap+5 + -0x1.59da81d8c966cp-2i,
0x1.635a0e1300a89p+5 + 0x1.5971bfaa93157p-2i, -0x1.99fcb8c0825b3p+5 + -0x1.58b1b77ca46b2p-2i,
0x1.f33e92670ad94p+4 + 0x1.579a99d2df07cp-2i, -0x1.65f1cf2733c2p+5 + -0x1.562cad3164c44p-2i,
0x1.1cfe6701cee4ep+5 + 0x1.54684e0ac65e9p-2i, -0x1.2089e50058706p+5 + -0x1.524deea8a945bp-2i,
0x1.be5fe4818c0e6p+4 + 0x1.4fde170ee6ee5p-2i, -0x1.06ba496827356p+5 + -0x1.4d1964d93074ap-2i,
0x1.8d2528f44d9b4p+5 + 0x1.4a008b133d5p-2i, -0x1.c390535c8074fp+4 + -0x1.4694520b8eadap-2i,
0x1.0a760d5894feap+5 + 0x1.42d59720d533bp-2i, -0x1.27b13fb06c171p+5 + -0x1.3ec54c8a02cd2p-2i,
0x1.8f5ae7270706ap+5 + 0x1.3a64791919b2cp-2i, -0x1.b314ed9e9a53cp+5 + -0x1.35b437f8c6323p-2i,
0x1.99ac286c43403p+5 + 0x1.30b5b864d43e4p-2i, -0x1.3e17ca3920132p+5 + -0x1.2b6a3d5d940b9p-2i,
0x1.6dd3a8decdc02p+5 + 0x1.25d31d563ee74p-2i, -0x1.7aa115995f9b5p+5 + -0x1.1ff1c1de734d2p-2i,
0x1.a2c710deaa31ap+5 + 0x1.19c7a746dc8cp-2i, -0x1.2274fdc4b4bd2p+5 + -0x1.13565c411d176p-2i,
0x1.46a35ebeb48bep+4 + 0x1.0c9f817b152ccp-2i, -0x1.454384becba6ap+5 + -0x1.05a4c9359cf9ep-2i,
0x1.3a7b6b9373eaep+5 + 0x1.fccfedad9e3e9p-3i, -0x1.37241b7e6baa2p+5 + -0x1.edd5bceffc6d9p-3i,
0x1.d8628e4ebd2aep+5 + 0x1.de5ec8dee2dadp-3i, -0x1.8e29f5ce946b3p+5 + -0x1.ce6ef9ac1037p-3i,
0x1.08b1a76596241p+5 + 0x1.be0a5611c1692p-3i, -0x1.ac02af8109866p+5 + -0x1.ad35024e4b1e6p-3i,
0x1.9abfcb17832e3p+5 + 0x1.9bf33f183d70cp-3i, -0x1.540ada560b8f5p+5 + -0x1.8a49688b55588p-3i,
0x1.6a859d72986d8p+5 + 0x1.783bf50e846aep-3i, -0x1.80917c9403eb6p+5 + -0x1.65cf743351052p-3i,
0x1.0a69d076ed7e9p+5 + 0x1.53088d8eddc2bp-3i, -0x1.c8a986025f114p+4 + -0x1.3febff8cde52ap-3i,
0x1.2a40867f1299cp+5 + 0x1.2c7e9e3cc6c9p-3i, -0x1.ea1c0301d54cbp+3 + -0x1.18c55219853e4p-3i
)
assertThat(stats:::fft(inverse=TRUE,z=c(0+0i, -0.026464810582916-0.396427714874034i, -0.028222323270186+0.441792055088923i,
0.600131073825881-0.190585110446351i, -0.417743312320867+0.217275404387287i,
0.137737994599904+0.38254431774271i, 0.207483155817089-0.335392772868322i,
-0.038051352553862-0.326043681440722i, 0.538264973159457+0.202644898827273i,
0.469194063004193-0.301084080589482i, 0.418403874146942+0.63085065772235i,
-0.200666185671905+0.664622470616715i, 0.111731284439878-0.677258207358522i,
-0.141165511939018-0.44762982911044i, 1.30520543299793+0.1090483741253i,
-0.344563244035388+0.064327090649793i, -0.0260586718185722+0.0230176654121559i,
-0.322251612110856-0.090515006153901i, 0.326064363002709+0.741950457593737i,
0.589151616978916-0.673589475484917i, 0.640165086899924-0.44757583612989i,
-0.877864097580919+0.354151840891694i, -0.17379262749062-0.410026964872639i,
-0.480906134606651+0.197730766397825i, -0.197515453547727+0.514948314052644i,
-0.487210113615893+0.674052927271129i, -0.462199361575885+0.216554969919127i,
0.100152760608002+0.298930267969328i, 0.488627301906609+0.239595612282971i,
0.561989623087212+0.052742196966128i, 1.11077126149174+0.03834087734641i,
0.054902945259696+0.641299270444349i, 0.240068680839615-0.19911657359075i,
0.610760945129458-0.175720481127229i, 0.571273469809736+0.436178332423554i,
-0.360193577503248+0.063055349998628i, -0.358692047329879+0.619807673000307i,
0.626915312474487+0.459049653123622i, -0.867927632641154-0.075482553852973i,
-0.084958247272812+0.410146779399985i, -0.361188868571845+0.470475984734662i,
0.263612413908934+0.1499635317914i, -0.8537557474917-1.31631046434687i,
0.37171163344298+0.164952424188131i, -0.106764369650074+0.221612783182605i,
0.484653373100542-0.964046013714323i, -0.811483353541734-0.561520831932708i,
-1.22420051083004+1.07278383626633i, 1.23701927419687+0.46589892238444i,
0.002950354610172-0.551849836918361i, 0.12245572983699-0.672211187596642i,
-0.15328146029697+1.57867330255886i, -0.531275406426444-0.50074364778289i,
0.490804224199969+0.24846280889692i, -1.02507672713753-0.32640031507618i,
-0.11060229753364+0.635042488192128i, 0.776004711048576-0.144452018200291i,
0.184226587770951+0.803024294262923i, 0.404892491770574+0.330542332570912i,
0.417588327041871+0.828576122529115i, 0.503619452101261-0.462796407821273i,
-1.29987958851933+0.05769580775788i, -0.184442011767332-0.126779590657692i,
0.501813074293413-0.79447365148006i, -0.521749227246804+0.48455782117017i,
-0.734401073337973-0.080492214515501i, 0.900504592404853+0.352270955226813i,
0.943216217460486+0.128254071072833i, 0.505059747840383+0.833568668929631i,
0.545397779107476-0.100692762669272i, -0.102037507718455-0.540429086767423i,
0.457208466319646-0.423635267107562i, -1.36985736228749+0.48257469685382i,
1.02389570187393-0.05077279861022i, -0.244412311622217+0.594422126947255i,
-0.713855291312084+0.485738403766214i, -0.823818555184761-0.74003274910767i,
0.7983660215085-0.096608887563268i, -0.113032109790349+0.910680264966514i,
-0.611968766968461-0.399287282887729i, -0.274066125028322-0.006470465183757i,
-0.195851320168394+0.25446523332802i, 0.251788165582682+0.681929485608914i,
0.34204755930203+1.1075063694659i, 0.08474096601301+1.56579689168615i,
0.906257228395766+0.438180612992073i, -0.478617176005439+0.096411911242666i,
0.518820093840973-0.715668524392385i, -1.58783295478389-0.47683175246056i,
0.423055831005869-0.29942707013305i, 0.030578939287039+0.561817154584025i,
0.727199693004515-0.739317119507838i, -0.651224324476472-0.183704212969572i,
0.06689299650915-1.10077848749808i, -0.861597187183488-0.449648303768461i,
-0.821278791689935-0.708314304650526i, -0.816435488919613+0.129389593495371i,
-0.629547587913145-0.467471550654385i, 0.483467082443256-0.453368338736509i,
1.18700657465229+0i, 36.95629+0i, 0.874091626934088+0.127329042532476i,
0.483467082443257+0.453368338736509i, -0.629547587913146+0.467471550654385i,
-0.816435488919613-0.129389593495371i, -0.821278791689936+0.708314304650526i,
-0.861597187183488+0.449648303768461i, 0.06689299650915+1.10077848749808i,
-0.651224324476472+0.183704212969572i, 0.727199693004515+0.739317119507838i,
0.030578939287039-0.561817154584025i, 0.423055831005869+0.29942707013305i,
-1.58783295478389+0.47683175246056i, 0.518820093840973+0.715668524392384i,
-0.478617176005439-0.096411911242666i, 0.906257228395766-0.438180612992073i,
0.08474096601301-1.56579689168615i, 0.34204755930203-1.1075063694659i,
0.251788165582682-0.681929485608914i, -0.195851320168394-0.25446523332802i,
-0.274066125028322+0.006470465183757i, -0.611968766968461+0.399287282887729i,
-0.113032109790349-0.910680264966514i, 0.798366021508499+0.096608887563268i,
-0.823818555184761+0.74003274910767i, -0.713855291312084-0.485738403766214i,
-0.244412311622217-0.594422126947255i, 1.02389570187393+0.05077279861022i,
-1.3698573622875-0.48257469685382i, 0.457208466319646+0.423635267107562i,
-0.102037507718455+0.540429086767423i, 0.545397779107476+0.100692762669272i,
0.505059747840383-0.833568668929631i, 0.943216217460486-0.128254071072833i,
0.900504592404854-0.352270955226813i, -0.734401073337974+0.080492214515501i,
-0.521749227246804-0.48455782117017i, 0.501813074293413+0.794473651480061i,
-0.184442011767332+0.126779590657692i, -1.29987958851933-0.05769580775788i,
0.503619452101262+0.462796407821274i, 0.417588327041871-0.828576122529115i,
0.404892491770574-0.330542332570912i, 0.184226587770951-0.803024294262923i,
0.776004711048576+0.144452018200291i, -0.11060229753364-0.635042488192128i,
-1.02507672713753+0.32640031507618i, 0.490804224199969-0.248462808896921i,
-0.531275406426444+0.50074364778289i, -0.15328146029697-1.57867330255886i,
0.12245572983699+0.672211187596642i, 0.002950354610172+0.55184983691836i,
1.23701927419687-0.46589892238444i, -1.22420051083004-1.07278383626633i,
-0.811483353541734+0.561520831932708i, 0.484653373100542+0.964046013714323i,
-0.106764369650074-0.221612783182605i, 0.37171163344298-0.164952424188131i,
-0.8537557474917+1.31631046434687i, 0.263612413908934-0.1499635317914i,
-0.361188868571845-0.470475984734662i, -0.084958247272812-0.410146779399985i,
-0.867927632641154+0.075482553852973i, 0.626915312474488-0.459049653123622i,
-0.358692047329879-0.619807673000308i, -0.360193577503248-0.063055349998628i,
0.571273469809736-0.436178332423554i, 0.610760945129458+0.175720481127229i,
0.240068680839615+0.19911657359075i, 0.054902945259696-0.641299270444349i,
1.11077126149174-0.03834087734641i, 0.561989623087212-0.052742196966128i,
0.488627301906609-0.239595612282971i, 0.100152760608002-0.298930267969328i,
-0.462199361575885-0.216554969919127i, -0.487210113615893-0.67405292727113i,
-0.197515453547727-0.514948314052644i, -0.480906134606651-0.197730766397825i,
-0.17379262749062+0.410026964872639i, -0.877864097580919-0.354151840891694i,
0.640165086899921+0.447575836129888i, 0.589151616978916+0.673589475484917i,
0.326064363002709-0.741950457593738i, -0.322251612110856+0.090515006153901i,
-0.0260586718185722-0.0230176654121559i, -0.344563244035388-0.064327090649793i,
1.30520543299793-0.1090483741253i, -0.141165511939018+0.44762982911044i,
0.111731284439878+0.677258207358522i, -0.200666185671905-0.664622470616715i,
0.418403874146942-0.63085065772235i, 0.469194063004193+0.301084080589482i,
0.538264973159457-0.202644898827272i, -0.038051352553862+0.326043681440722i,
0.207483155817089+0.335392772868322i, 0.137737994599904-0.38254431774271i,
-0.417743312320867-0.217275404387287i, 0.600131073825881+0.190585110446351i,
-0.028222323270186-0.441792055088923i, -0.026464810582916+0.396427714874034i
))
, identicalTo( expected, tol = 1e-6 ) )
|
fix0106 <-
function (x, alpha = 4, beta = 4, mu = 0, sigma = 1, eta = 0,
kappa = 1)
{
eps <- (x - mu)/sigma
((eps/(2 * beta + eps^2)) * dnorm(x, mean = eta, sd = kappa))
}
|
merge_forests <- function(forest_list, compute.oob.predictions = TRUE) {
validate_forest_list(forest_list)
first_forest <- forest_list[[1]]
big_forest <- merge(forest_list)
class(big_forest) <- class(first_forest)
for (name in names(first_forest)) {
if (!startsWith(name, "_")
&& name != "predictions"
&& name != "debiased.error"
&& name != "excess.error") {
big_forest[[name]] <- first_forest[[name]]
}
}
if (compute.oob.predictions) {
oob.pred <- predict(big_forest)
big_forest[["predictions"]] <- oob.pred$predictions
big_forest[["debiased.error"]] <- oob.pred$debiased.error
big_forest[["excess.error"]] <- oob.pred$excess.error
}
big_forest
}
validate_forest_list <- function(forest_list) {
if (length(forest_list) == 0) {
stop("Length of argument 'forest_list' must be positive.")
}
first_forest <- forest_list[[1]]
if (!methods::is(first_forest, "grf")) {
stop("Argument 'forest_list' must be a list of grf objects.
Be sure to use 'list(forest1, forest2), not 'c(forest1, forest2)'.")
}
classes <- unique(sapply(forest_list, class)[1, ])
if (length(classes) > 1) {
stop(paste(
"All forests in 'forest_list' must be of the same type, but we found:",
paste(classes, collapse = ", ")
))
}
n.cols <- unique(lapply(forest_list, function(x) {ncol(x$X.orig)}))
n.obs <- unique(lapply(forest_list, function(x) {nrow(x$X.orig)}))
if (length(n.cols) != 1 || length(n.obs) != 1) {
stop("All forests in 'forest_list' must be trained on the same data.")
}
}
|
dropImageDimension <- function(img, onlylast=TRUE, warn=TRUE) {
dim_ <- dim_(img)
imgdim <- dim(img)
ndim <- length(imgdim) + 1
dim_[seq(2, ndim)] <- imgdim
if (ndim +1 <= length(dim_)) {
dim_[seq(ndim+1, length(dim_))] <- 1
}
pdim <- pixdim(img)
no.data <- dim_ <= 1
no.data <- no.data | pdim == 0
no.data[1] <- FALSE
if (onlylast) {
maxdim <- max(which(! no.data))
no.data[seq(maxdim)] <- FALSE
} else {
no.data[1] <- FALSE
}
ndim <- sum(! no.data) - 1
dim_[1] <- ndim
pdim <- pdim[! no.data]
pdim <- c(pdim, rep(1, 8 - length(pdim)))
dim_ <- dim_[! no.data]
dim_ <- c(dim_, rep(1, 8 - length(dim_)))
pixdim(img) <- pdim
dim_(img) <- dim_
if (length(imgdim) > ndim) {
if (onlylast) {
cs <- cumsum(rev(no.data[1 + seq(length(imgdim))]))
dropcols <- cs == seq(length(imgdim))
dropcols <- rev(dropcols)
dropcols <- which(dropcols)
D <- adrop([email protected], drop = dropcols)
} else {
D <- drop([email protected])
}
} else {
return(img)
}
checkdim = dim_(img)
checkdim[checkdim < 1] = 1
dim_(img) <- checkdim
if (ndim >= 3) {
[email protected] <- D
return(img)
} else {
if (warn) {
warning("Dropping under 3 dimensions - returning non-nifti object array.")
}
return(D)
}
}
drop_img_dim <- function(img, onlylast=TRUE, warn=TRUE) {
dropImageDimension(img=img, onlylast=onlylast, warn=warn)
}
|
`ll.jRCI.b1.A` =
function(par, yi, ind.lst, X, twosex, sex=NULL, ni, ni0, xs, iphi, theta)
{
if(twosex){
zeroes = c(0, 0)
seq = 1:4
logL = ll.aRC(par0=c(par[3], 0), ni[sex == 1], ni0[sex == 1], xs[sex == 1], theta)
logL = logL + ll.aRC(par0=c(par[4], 0), ni[sex == -1], ni0[sex == -1], xs[sex == -1], theta)
}else{
zeroes = 0
seq = 1:2
logL = ll.aRC(par0=c(par[2], 0), ni, ni0, xs, theta)
}
logL = logL + ll.tRCI.A(par0=c(par[seq], zeroes, par[-seq]), yi=yi, ind.lst=ind.lst, X=X, twosex=twosex, iphi=iphi)
return(logL)
}
|
pattLrep.fit<-function(obj, nitems, tpoints=1, formel=~1,elim=~1,resptype="ratingT",
obj.names=NULL, undec=TRUE, ia=FALSE, iaT=FALSE, NItest=FALSE, pr.it=FALSE)
{
if (tpoints<2)
stop("no of timepoints incorrectly specified! if tpoints==1 use pattL.fit")
call<-match.call()
ENV<-new.env()
ENV$pr.it<-pr.it
ENV$resptype<-"ratingT"
nobj<-nitems * tpoints
opt<-options()
options("warn"=-1)
if(is.character(obj)){
datafile <- obj
if(file.access(datafile, mode=0) == 0){
dat<-as.matrix(read.table(datafile,header=TRUE))
} else {
stop("\ninput data file does not exist!\n")
}
} else if(is.data.frame(obj)){
dat<-as.matrix(obj)
dat<-apply(dat,2,as.numeric)
} else {
stop("first argument must be either datafilename or dataframe")
}
varnames<-colnames(dat)
if (ncol(dat)>nobj) {
formel.names<-attr(terms(as.formula(formel)),"term.labels")
formel.names<-unique(unlist(strsplit(formel.names,":")))
elim.names<-attr(terms(as.formula(elim)),"term.labels")
elim.names<-unique(unlist(strsplit(elim.names,":")))
covnames<-unique(c(formel.names,elim.names))
covs<-as.data.frame(dat[,covnames])
} else {
covs<-NULL
}
idx<-apply(dat[,1:nobj],1,function(x) sum(!is.na(x))>1)
dat<-dat[idx,]
dat<-as.data.frame(dat[,1:nobj])
if(!is.null(covs)){
covs<-as.data.frame(covs[idx,])
colnames(covs)<-covnames
NAs<-which(!complete.cases(covs))
if (length(NAs)>0){
cat("\tsubject covariates: NAs in lines",NAs," - removed from data\n")
notNAs<-which(complete.cases(covs))
dat<-dat[notNAs,]
covs<-covs[notNAs,,drop=FALSE]
}
}
if (is.null(obj.names))
ENV$obj.names<-varnames[1:nobj]
else
ENV$obj.names<-obj.names[1:nobj]
if(NItest)
if(!any(is.na(dat)))
stop("Test for ignorable missing cannot be performed - no NA values!")
datrng<-range(dat,na.rm=TRUE)
Y <- Lpatternmat(datrng,nitems)
np<-nrow(Y)
npp<-np
YL<-Y
for (t in 1:(tpoints-1)){
YL<-do.call("rbind", lapply(1:np, function(i) YL) )
YR<-expand.mat(Y,rep(npp,np))
YL<-cbind(YL,YR)
npp<-npp*np
}
ENV$Y<-YL
rm(Y,YL)
dat.t<-as.data.frame(diffsred(dat[,1:nitems],nitems))
for (t in 2:tpoints){
from<-nitems*(t-1)+1
to<-from+nitems-1
dat.t<-cbind(dat.t,as.data.frame(diffsred(dat[,from:to],nitems)))
}
dat<-dat.t
rm(dat.t)
ncomp<-choose(nitems,2)
if(undec){
ENV$U <- apply(ENV$Y[,1:ncomp],1,function(x) sum(x==0))
for (t in 2:tpoints){
from<-ncomp*(t-1)+1
to<-from+ncomp-1
ENV$U <- cbind(ENV$U,apply(ENV$Y[,from:to],1,function(x) sum(x==0)))
}
}
ENV$undec<-undec
ENV$NItest<-NItest
if(ENV$NItest) {
if(formel!="~1" || elim != "~1"){
covs<-NULL
formel<-~1
elim<-~1
cat("\ncurrently no covariates fitted if NItest==TRUE !!\n")
}
}
ENV$ia<-ia
ilabels<-NULL
XI<-NULL
if (ia) {
XI<-NULL
ilabels<-NULL
for (t in 1:tpoints){
from<-ncomp*(t-1)+1
to<-from+ncomp-1
depL<-dependencies(nitems,ENV$Y[,from:to])
XI<-cbind(XI,depL$d)
ilabels<-c(ilabels,depL$label.intpars)
}
npars.ia<-length(ilabels)
ilabels<-paste(rep(paste("T",1:tpoints,":",sep=""),
rep(npars.ia/tpoints,tpoints)),ilabels,sep="")
} else {
ENV$ilabels<-NULL
npars.ia<-0
}
ENV$XI<-XI
rm(XI)
ENV$ilabels<-ilabels
ENV$iaT<-iaT
if (iaT) {
npars.iaT<-ncomp*(tpoints-1)
ENV$XIT<-do.call("cbind", lapply(1:npars.iaT,function(i) ENV$Y[,i]*ENV$Y[,i+ncomp]))
ENV$iTlabels<-paste(paste("Comp",1:ncomp,sep=""),
paste("IT",rep(1:(tpoints-1),rep(ncomp,tpoints-1)),rep(2:(tpoints),rep(ncomp,tpoints-1)),sep=""),
sep=":")
} else {
ENV$iTlabels<-NULL
npars.iaT<-0
}
ncomp<-choose(nitems,2)
X<- -(ENV$Y[,1:ncomp] %*% pcdesign(nitems))[,-nitems]
for (t in 2:tpoints){
from<-ncomp*(t-1)+1
to<-from+ncomp-1
X<-cbind(X,-(ENV$Y[,from:to] %*% pcdesign(nitems))[,-nitems] )
}
cList<-splitCovs(dat,covs,formel,elim,ENV)
partsList<-gen.partsList(nobj,cList,ENV)
rm(cList)
npar <- tpoints*(nitems-1) * ENV$ncovpar + ENV$undec*tpoints + npars.ia + npars.iaT
if (ENV$NItest) npar<-tpoints*(nitems-1)*2 + ENV$undec*tpoints + npars.ia + npars.iaT
lambda<-rep(0,npar)
ENV$iter<-0
nobj<-tpoints*(nitems-1)
result<-nlm(loglik,lambda,X,nobj,partsList,ENV,hessian=TRUE,
iterlim=1000)
if (pr.it) cat("\n")
options(opt)
ENV$nobj<-nobj
ENV$nitems<-nitems
ENV$tpoints<-tpoints
envList<-mget(ls(ENV),envir=ENV)
outputobj<-list(coefficients=result$estimate,
ll=ENV$ll,
fl=ENV$fl,
call=call,
result=result,
envList=envList,
partsList=partsList)
class(outputobj) <- c("pattMod")
outputobj
}
|
frm_em_calc_update_observed_likelihood <- function(like_obs, post_miss,
dmod, mm, ind_resp, ind_miss )
{
ind_resp_mm <- ind_resp[[mm]]
if ( length(ind_resp_mm) > 0 ){
like_obs[ind_resp_mm] <- like_obs[ind_resp_mm] * dmod$like[ind_resp_mm]
}
ind_miss_mm <- ind_miss[[mm]]
if ( length(ind_miss_mm) > 0 ){
post_miss[ind_miss_mm] <- post_miss[ind_miss_mm] * dmod$post[ind_miss_mm]
}
res <- list( like_obs=like_obs, post_miss=post_miss)
return(res)
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.