code
stringlengths
1
13.8M
neg2ELratio_nocrossings <- function(alpha, fit, fit1, fit2, fit_time_restrict_boot, nn, lowerbindx_boot, upperbindx_boot, sum_DWknGImuw_1_big, sum_DWknGImuw_2_big){ test_nocross = 0 HW_CBdistr = apply(abs(sum_DWknGImuw_2_big[,lowerbindx_boot:upperbindx_boot]-sum_DWknGImuw_1_big[,lowerbindx_boot:upperbindx_boot]),1,max) HW_CBcrit = as.vector(quantile(HW_CBdistr,1-alpha)) S1_hat = (((c(1,fit1$surv)[cumsum(c(0,fit$time) %in% c(0,fit1$time))])[-1])[fit_time_restrict_boot])[lowerbindx_boot:upperbindx_boot] S2_hat = (((c(1,fit2$surv)[cumsum(c(0,fit$time) %in% c(0,fit2$time))])[-1])[fit_time_restrict_boot])[lowerbindx_boot:upperbindx_boot] diff = log(S1_hat)-log(S2_hat) HW_CB_ubs = diff+HW_CBcrit/sqrt(sum(nn)) HW_CB_lbs = diff-HW_CBcrit/sqrt(sum(nn)) eq_S_all = sum(HW_CB_lbs <= 0) == (upperbindx_boot - lowerbindx_boot + 1) & sum(HW_CB_ubs >= 0) == (upperbindx_boot - lowerbindx_boot + 1) g_S_all = sum(HW_CB_ubs >= 0) == (upperbindx_boot - lowerbindx_boot + 1) & sum(HW_CB_lbs <= 0) != (upperbindx_boot - lowerbindx_boot + 1) if (g_S_all | eq_S_all) { test_nocross = 1 } return(list(test_nocross = test_nocross)) }
require(geophys) opar=par(no.readonly=TRUE) s1 = matrix(c(5,2,2,3) , byrow=TRUE, ncol=2, nrow=2) Stensor = s1 theta = 0*pi/180 rot1 = cbind( c( cos(theta), -sin(theta)), c(sin(theta), cos(theta))) DoMohrFig1(s1, rot1) s1 = matrix(c(15,-2,-2,3) , byrow=TRUE, ncol=2, nrow=2) Stensor = s1 DoMohr(Stensor) Stensor = matrix(c( 15, 0, 0, 0, 10, 0, 0, 0, 5), ncol=3) M = DoMohr(Stensor) par(ask=FALSE) Stensor = matrix(c( 15, 0, 0, 0, 10, 0, 0, 0, 5), ncol=3) stress(Stensor=Stensor) P1 = c(0.2, 1, 1, 0) P2 = c(1, 0.1, 1, 0) P3 = c(1, 1, 0.4, 0) S = stressSETUP(P1, P2, P3, xscale=30 ) stress(PPs = S$PPs, Rview =S$Rview, xscale = S$xscale, Stensor=Stensor ) S = stressSETUP( ) Nvec = NORMvec(S$PPs, S$xscale, S$Rview, S$aglyph , add = FALSE) Stensor = matrix(c( 15, 0, 0, 0, 8, 0, 0, 0, 5), ncol=3) Mstress = Maxstress(Nvec, Stensor) DoMohr(Stensor) axis(1) axis(2) points(Mstress$sigNORMmax , Mstress$tauSHEARmax, pch=21, col='blue' , bg='gold' ) u=par('usr') segments(0, Mstress$tauSHEARmax, Mstress$sigNORMmax , Mstress$tauSHEARmax, lty=2, col='green' , lwd=3 ) text(mean(c(0, Mstress$tauSHEARmax)), Mstress$tauSHEARmax, "MaxShear in Plane", pos=3) segments(Mstress$sigNORMmax , u[3] , Mstress$sigNORMmax , Mstress$tauSHEARmax, lty=2, col='purple' , lwd=3 ) text(Mstress$sigNORMmax , u[3], "MaxNormal stress", adj=c(0,-1) ) GG = randpoles(30, 40, 10, opt="norm", N=20) graphics.off() par(ask=TRUE) dev.new(width=10, height=6 ) par(mfrow=c(1,2)) RFOC::net() RFOC::qpoint(30, 40, col = "red", UP=FALSE ) RFOC::qpoint(GG$az, GG$dip, col = "blue", UP=FALSE ) rplane = RFOC::lowplane(30-90, 40, UP=TRUE, col='red') for(i in 1:length(GG$az)) { rplane = RFOC::lowplane(GG$az[i]-90, GG$dip[i], UP=TRUE, col='blue') } g = RSEIS::TOCART(GG$az, GG$dip) AA = DoMohr(Stensor) for(i in 1:length(g$az)) { KVEC = c(g$x[i], g$y[i],g$z[i]) Mstress = Maxstress(KVEC, Stensor) points(Mstress$sigNORMmax , Mstress$tauSHEARmax, pch=21, col='blue' , bg='gold' ) } par(opar)
gensvm.refit <- function(fit, x, y, p=NULL, lambda=NULL, kappa=NULL, epsilon=NULL, weights=NULL, kernel=NULL, gamma=NULL, coef=NULL, degree=NULL, kernel.eigen.cutoff=NULL, max.iter=NULL, verbose=NULL, random.seed=NULL) { p <- if(is.null(p)) fit$p else p lambda <- if(is.null(lambda)) fit$lambda else lambda kappa <- if(is.null(kappa)) fit$kappa else kappa epsilon <- if(is.null(epsilon)) fit$epsilon else epsilon weights <- if(is.null(weights)) fit$weights else weights kernel <- if(is.null(kernel)) fit$kernel else kernel gamma <- if(is.null(gamma)) fit$gamma else gamma coef <- if(is.null(coef)) fit$coef else coef degree <- if(is.null(degree)) fit$degree else degree kernel.eigen.cutoff <- (if(is.null(kernel.eigen.cutoff)) fit$kernel.eigen.cutoff else kernel.eigen.cutoff) max.iter <- if(is.null(max.iter)) fit$max.iter else max.iter verbose <- if(is.null(verbose)) fit$verbose else verbose random.seed <- if(is.null(random.seed)) fit$random.seed else random.seed errfunc <- getOption('error') options(error=function() {}) newfit <- gensvm(x, y, p=p, lambda=lambda, kappa=kappa, epsilon=epsilon, weights=weights, kernel=kernel, gamma=gamma, coef=coef, degree=degree, kernel.eigen.cutoff=kernel.eigen.cutoff, verbose=verbose, max.iter=max.iter, seed.V=coef(fit)) options(error=errfunc) return(newfit) }
write.csv <- function (...) { UseMethod("write.csv") } write.csv.default <- function (...) { utils::write.csv(...) } write.csv.AlphaPart <- function (x, file, traitsAsDir=FALSE, csv2=TRUE, row.names=FALSE, ...) { if(length(file) > 1) stop("'file' argument must be of length one") if(!("AlphaPart" %in% class(x))) stop("'x' must be of a 'AlphaPart' class") fileOrig <- sub(pattern=".csv$", replacement="", x=file) ret <- c() for(i in 1:(length(x)-1)) { if(traitsAsDir) { dir.create(path=file.path(dirname(fileOrig), x$info$lT[i]), recursive=TRUE, showWarnings=FALSE) file <- file.path(dirname(fileOrig), x$info$lT[i], basename(fileOrig)) } fileA <- paste(file, "_", x$info$lT[i], ".csv", sep="") ret <- c(ret, fileA) cat(fileA, "\n") if(csv2) { write.csv2(x=x[[i]], file=fileA, row.names=row.names, ...) } else { write.csv(x=x[[i]], file=fileA, row.names=row.names, ...) } } invisible(ret) } write.csv.summaryAlphaPart <- function (x, file, traitsAsDir=FALSE, csv2=TRUE, row.names=FALSE, ...) { if(length(file) > 1) stop("'file' argument must be of length one") if(!("summaryAlphaPart" %in% class(x))) stop("'x' must be of a 'summaryAlphaPart' class") fileOrig <- sub(pattern=".csv$", replacement="", x=file) ret <- c() for(i in 1:(length(x)-1)) { if(traitsAsDir) { dir.create(path=file.path(dirname(fileOrig), x$info$lT[i]), recursive=TRUE, showWarnings=FALSE) file <- file.path(dirname(fileOrig), x$info$lT[i], basename(fileOrig)) } fileA <- paste(file, x$info$lT[i], ".csv", sep="_") ret <- c(ret, fileA) cat(fileA, "\n") if(csv2) { write.csv2(x=x[[i]], file=fileA, row.names=row.names, ...) } else { write.csv(x=x[[i]], file=fileA, row.names=row.names, ...) } } invisible(ret) }
acontext("path key") path.list <- list() N <- 100 x <- 1:N point <- data.frame( showSelected.i=1:2) set.seed(1) for(group.i in 1:2){ for(showSelected.i in point$showSelected.i){ path.list[[paste(group.i, showSelected.i)]] <- data.frame(group.i, showSelected.i, x, y=rnorm(N, group.i)) } } path <- do.call(rbind, path.list) viz <- list( point=ggplot()+ geom_point(aes(showSelected.i, showSelected.i, id=paste0("point", showSelected.i), clickSelects=showSelected.i), size=10, data=point), transition=ggplot()+ ggtitle("should have animated transition")+ geom_path(aes(x, y, group=group.i, color=group.i, key=group.i, showSelected=showSelected.i), data=path), noTransition=ggplot()+ ggtitle("should NOT have animated transition")+ geom_path(aes(x, y, group=group.i, color=group.i, key=paste(group.i, showSelected.i), showSelected=showSelected.i), data=path), first=list(showSelected.i="1"), duration=list(showSelected.i=3000)) info <- animint2HTML(viz) getD <- function(html=getHTML()){ node.list <- getNodeSet(html, '//g[@class="PANEL1"]//path') node.mat <- sapply(node.list, xmlAttrs) node.mat["d",] } test_that("transitions only for equivalent keys", { d.before <- getD() clickID("point2") Sys.sleep(1) d.during <- getD() Sys.sleep(3) d.after <- getD() expect_identical(d.before == d.during, c(FALSE, FALSE, FALSE, FALSE)) expect_identical(d.during == d.after, c(FALSE, FALSE, TRUE, TRUE)) })
varNhat <- function(data, model){ grps <- attr(data, "groups") grps$.rows <- NULL grps <- apply(grps, 1, function(x) any(is.na(x))) vardat_str <- attr(data, "groups")[!grps, , drop=FALSE] ind <- vardat_str$.rows area <- rep(NA, length(ind)) covered_area <- rep(NA, length(ind)) for(i in 1:length(ind)){ idata <- data[ind[[i]], ] area[i] <- idata$Area[1] covered_area[i] <- sum(idata$Covered_area[!duplicated(idata$Sample.Label)]) } dhtd <- function(par, data, model, area, covered_area, ind){ res <- rep(NA, length(ind)) model$par <- par data$p <- predict(model, newdata=as.data.frame(data), integrate=TRUE, compute=TRUE)$fitted data$Nc <- (data$size/data$p)/data$rate for(i in 1:length(ind)){ res[i] <- (area[i]/covered_area[i]) * sum(data$Nc[ind[[i]]], na.rm=TRUE) } res } vcov <- solvecov(model$hessian)$inv data <- data[!is.na(data$object), ] dm <- DeltaMethod(model$par, dhtd, vcov, sqrt(.Machine$double.eps), model=model, data=data, area=area, covered_area=covered_area, ind=ind) attr(dm, "vardat_str") <- vardat_str ret <- list(Nhat=dm) attr(ret, "vardat_str") <- vardat_str return(ret) }
geom_polypath <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, rule = "winding", ...) { ggplot2::layer(data = data, mapping = mapping, stat = stat, geom = GeomPolypath, position = position, show.legend = show.legend, inherit.aes = inherit.aes, params = list(na.rm = na.rm , rule = rule, ...)) } GeomPolypath <- ggproto( "GeomPolypath", GeomPolygon, extra_params = c("na.rm", "rule"), draw_panel = function(data, scales, coordinates, rule) { n <- nrow(data) if (n == 1) return(zeroGrob()) munched <- coord_munch(coordinates, data, scales) munched <- munched[order(munched$group), ] object_munch <- function(xmunch) { first_idx <- !duplicated(xmunch$group) first_rows <- xmunch[first_idx, ] grid::pathGrob(xmunch$x, xmunch$y, default.units = "native", id = xmunch$group, rule = rule, gp = grid::gpar(col = first_rows$colour, fill = alpha(first_rows$fill, first_rows$alpha), lwd = first_rows$size * .pt, lty = first_rows$linetype)) } ggplot2:::ggname( "geom_holygon", do.call(grid::grobTree, lapply(split(munched, munched$fill), object_munch)) ) } )
test_that("get_translation", { testthat::expect_error(get_translation(local_path = ".", language = "german"), NA) pdfs <- list.files(path = ".", pattern = "*.pdf", full.names = TRUE) purrr::map(pdfs, fs::file_delete) })
logLik.loglm <- function(object, ..., zero=1E-10) { fr <- if(!is.null(object$frequencies)) unclass(object$frequencies) else { unclass(update(object, keep.frequencies = TRUE)$frequencies) } df <- prod(dim(fr)) - object$df if (any(fr==0)) { fr <- as.vector(fr) fr[fr==0] <- zero } structure(sum((log(fr) - 1) * fr - lgamma(fr + 1)) - object$deviance/2, df = df, class = "logLik") }
summary.msq.itemfit <- function( object, file=NULL, ... ) { tam_osink( file=file) sdisplay <- tam_summary_display() cat(sdisplay) tam_print_package_rsession(pack="TAM") tam_print_computation_time(object=object) cat("MSQ item fit statitics (Function 'msq.itemfit')\n") tam_print_call(object$CALL) sdisplay2 <- tam_summary_display("*", 52) cat(sdisplay2) cat("\nSummary outfit and infit statistic\n") obji <- object$summary_itemfit tam_round_data_frame_print(obji=obji, from=2, digits=3, rownames_null=TRUE) cat("\n") cat(sdisplay2) cat("\nOutfit and infit statistic\n") obji <- object$itemfit ind <- grep( "fitgroup", colnames(obji) ) tam_round_data_frame_print(obji=obji, from=ind+1, digits=3, rownames_null=FALSE) tam_csink(file=file) }
`NoOp` <- function(x) x
lwq_multi <- function(answering_department, peer_id, start_date, end_date, extra_args, verbose) { if (is.null(peer_id) == TRUE) { mp_id_list <- NA } else { mp_id_list <- as.list(peer_id) } if (is.null(answering_department) == TRUE) { dep_list <- NA } else { dep_list <- as.list(answering_department) } search_grid <- expand.grid(dep_list, mp_id_list, stringsAsFactors = FALSE) names(search_grid)[names(search_grid) == "Var1"] <- "department" names(search_grid)[names(search_grid) == "Var2"] <- "member" dat <- vector("list", nrow(search_grid)) seq_list <- seq(from = 1, to = nrow(search_grid), by = 1) for (i in seq_along(seq_list)) { dat[[i]] <- hansard::lords_written_questions( answering_department = search_grid$department[[i]], peer_id = search_grid$member[[i]], end_date = end_date, start_date = start_date, extra_args = extra_args, verbose = verbose, tidy = FALSE ) } dat <- dat[sapply(dat, function(d) is.null(d) == FALSE)] df <- dplyr::bind_rows(dat) names(df)[names(df) == "_about"] <- "about" df } lwq_tidy <- function(df, tidy_style) { if (nrow(df) > 0) { df$dateTabled._value <- as.POSIXct(df$dateTabled._value) df$AnswerDate._value <- as.POSIXct(df$AnswerDate._value) df$dateTabled._datatype <- "POSIXct" df$AnswerDate._value <- "POSIXct" df$AnsweringBody <- unlist(df$AnsweringBody) df$tablingMemberPrinted <- unlist(df$tablingMemberPrinted) df$tablingMember._about <- gsub( "http://data.parliament.uk/members/", "", df$tablingMember._about ) } df <- hansard_tidy(df, tidy_style) df } lords_division_tidy <- function(df, division_id, summary, tidy_style) { if (nrow(df) > 0) { if (is.null(division_id) == TRUE) { df$date._datatype <- "POSIXct" df$date._value <- as.POSIXct(df$date._value) } else { if (summary == FALSE) { df <- ldsum_tidy(df, tidy_style) } } } df <- hansard_tidy(df, tidy_style) df } ldsum_tidy <- function(df, tidy_style) { if (nrow(df) > 0) { df$date._value <- as.POSIXct(df$date._value) df$date._datatype <- "POSIXct" df$vote.type <- gsub( "http://data.parliament.uk/schema/parl df$vote.type ) df$vote.type <- gsub( "([[:lower:]])([[:upper:]])", "$1_$2", df$vote.type ) df$vote.member <- unlist(df$vote.member) df$vote.member <- gsub( "http://data.parliament.uk/resources/members/api/lords/id/", "", df$vote.member ) names(df) <- snakecase::to_any_case(names(df), case = tidy_style) } df } lord_vote_record_tidy <- function(df, tidy_style) { if (nrow(df) > 0) { df$vote <- as.factor(df$vote) df$date._datatype <- as.factor(df$date._datatype) df$date._value <- as.POSIXct(df$date._value) df$date._datatype <- "POSIXct" } df <- hansard_tidy(df, tidy_style) df } lords_amendments_tidy <- function(df, tidy_style) { if (nrow(df) > 0) { df$bill.date._value <- as.POSIXct(df$bill.date._value) df$bill.date._datatype <- "POSIXct" } df <- hansard_tidy(df, tidy_style) df } lords_attendance_tidy <- function(df, tidy_style) { if (nrow(df) > 0) { df$date._value <- as.POSIXct(df$date._value) df$date._datatype <- "POSIXct" } df <- hansard_tidy(df, tidy_style) df$about <- gsub("http://data.parliament.uk/resources/", "", df$about) df } lords_interests_tidy <- function(df, tidy_style) { if (nrow(df) > 0) { if ("amendedDate" %in% colnames(df)) { seq_list <- seq(from = 1, to = nrow(df), by = 1) for (i in seq_along(seq_list)) { if (is.null(df$amendedDate[[i]]) == FALSE) { df$amendedDate[[i]] <- df$amendedDate[[i]][["_value"]] } } df$amendedDate[df$amendedDate == "NULL"] <- NA df$amendedDate <- do.call("c", df$amendedDate) df$amendedDate <- as.POSIXct(df$amendedDate) } df$date._value <- as.POSIXct(df$date._value) df$date._datatype <- "POSIXct" df$registeredLate._value <- as.logical(df$registeredLate._value) df$registeredLate._datatype <- "Logical" names(df)[names(df) == "X_about"] <- "registeredInterestNumber" names(df)[names(df) == "_about"] <- "registeredInterestNumber" df$registeredInterestNumber <- gsub( ".*registeredinterest/", "", df$registeredInterestNumber ) } df <- hansard_tidy(df, tidy_style) df } lords_interests_tidy2 <- function(df, tidy_style) { if (nrow(df) > 0) { seq_list <- seq(from = 1, to = nrow(df), by = 1) for (i in seq_along(seq_list)) { df[i, ]$hasRegisteredInterest[[1]] <- as.data.frame( df[i, ]$hasRegisteredInterest ) } seq_list <- seq(from = 1, to = nrow(df), by = 1) for (i in seq_along(seq_list)) { if ("amendedDate" %in% colnames(df[i, ]$hasRegisteredInterest[[1]])) { seq_list2 <- seq( from = 1, to = nrow(df[i, ]$hasRegisteredInterest[[1]]), by = 1 ) for (x in seq_along(seq_list2)) { if (is.null( df[i, ]$hasRegisteredInterest[[1]]$amendedDate[[x]] ) == FALSE) { } } df[i, ]$hasRegisteredInterest[[1]]$amendedDate[ df[i, ]$hasRegisteredInterest[[1]]$amendedDate == "NULL" ] <- NA df[i, ]$hasRegisteredInterest[[1]]$amendedDate <- do.call( "c", df[i, ]$hasRegisteredInterest[[1]]$amendedDate ) df[i, ]$hasRegisteredInterest[[1]]$amendedDate <- as.POSIXct( df[i, ]$hasRegisteredInterest[[1]]$amendedDate, na.omit = TRUE ) } df[i, ]$hasRegisteredInterest[[1]]$date._value <- as.POSIXct( df[i, ]$hasRegisteredInterest[[1]]$date._value, na.omit = TRUE ) df[i, ]$hasRegisteredInterest[[1]]$date._datatype <- "POSIXct" df[i, ]$hasRegisteredInterest[[1]]$registeredLate._value <- as.logical( df[i, ]$hasRegisteredInterest[[1]]$registeredLate._value ) df[i, ]$hasRegisteredInterest[[1]]$registeredLate._datatype <- "Logical" names(df[i, ]$hasRegisteredInterest[[1]])[ names(df[i, ]$hasRegisteredInterest[[1]]) == "X_about" ] <- "registeredInterestNumber" names(df[i, ]$hasRegisteredInterest[[1]])[names( df[i, ]$hasRegisteredInterest[[1]] ) == "_about"] <- "registeredInterestNumber" df[i, ]$hasRegisteredInterest[[1]]$registeredInterestNumber <- gsub( ".*registeredinterest/", "", df[i, ]$hasRegisteredInterest[[1]]$registeredInterestNumber ) df[i, ]$hasRegisteredInterest[[1]] <- hansard_tidy( df[i, ]$hasRegisteredInterest[[1]], tidy_style ) } } df <- hansard_tidy(df, tidy_style) df }
gradtrmf <- function(model_switch,aX,groupsize,ni,xt,x,a,bpop,d,sigma,docc,poped.db,gradxt=FALSE){ m=size(ni,1) if (gradxt == FALSE) { gdmf=matrix(1,m,size(a,2)) } else { gdmf=matrix(1,m,size(xt,2)) } iParallelN = (poped.db$settings$parallel$bParallelSG==1) + 1 if((iParallelN == 2)){ designsin = cell(1,0) it=1 } for(p in 1:iParallelN){ if((p==2)){ stop("Parallel execution not yet implemented in PopED for R") designout = designsin } if((iParallelN==1)){ returnArgs <- mftot(model_switch,groupsize,ni,xt,x,a,bpop,d,sigma,docc,poped.db) mft <- returnArgs[[1]] poped.db <- returnArgs[[2]] } else { if((p==1)){ designsin = update_designinlist(designsin,groupsize,ni,xt,x,a,-1,0) } else { mft = designout[[it]]$FIM it = it+1 } } if((iParallelN==1 || p==2)){ if(all(size(poped.db$settings$prior_fim) == size(mft))){ mft = mft + poped.db$settings$prior_fim } imft=inv(mft) if((is.infinite(imft[1,1]))){ imft = zeros(size(mft)) } } for(i in 1:m){ if((groupsize[i]==0)){ gdmf[i,1:ni[i]]=zeros(1,ni(i)) } else { a0 = a xt0 = xt nCtl = ifelse(gradxt==FALSE, size(poped.db$design$a,2), ni[i]) for(ct1 in 1:nCtl){ if((aX[i,ct1]!=0)){ if (gradxt==FALSE) { a=a0 a[i,ct1]=a[i,ct1]+poped.db$settings$hgd } else { xt=xt0 xt[i,ct1]=xt[i,ct1]+poped.db$settings$hgd } if((!isempty(x))){ x_i = t(x[i,,drop=F]) } else { x_i = zeros(0,1) } if((!isempty(a))){ a_i = t(a[i,,drop=F]) } else { a_i = zeros(0,1) } if((iParallelN ==1)){ returnArgs <- mf_all(t(model_switch[i,1:ni[i,drop=F],drop=F]),t(xt[i,1:ni[i,drop=F],drop=F]),x_i,a_i,bpop,d,sigma,docc,poped.db) mf_tmp <- returnArgs[[1]] poped.db <- returnArgs[[2]] } else { if((p==1)){ designsin = update_designinlist(designsin,1,ni,xt,x,a,-1,i) } else { mf_tmp = designout[[it]]$FIM it = it+1 } } if((iParallelN ==1 || p==2)){ mf_plus = groupsize[i]*mf_tmp if((size(poped.db$settings$prior_fim)==size(mf_plus))){ mf_plus = mf_plus + poped.db$settings$prior_fim } imf_plus=inv(mf_plus) ir=(imf_plus-imft)/poped.db$settings$hgd if((trace_matrix(ir)!=0)){ gdmf[i,ct1]=-trace_matrix(ir) } else { gdmf[i,ct1]=1e-12 } } } } } } } return(list( gdmf= gdmf,poped.db=poped.db)) }
.parmaspec = function(scenario = NULL, probability = NULL, S = NULL, Q = NULL, qB = NULL, benchmark = NULL, benchmarkS = NULL, forecast = NULL, target = NULL, targetType = c("inequality", "equality"), risk = c("MAD", "MiniMax", "CVaR", "CDaR", "EV", "LPM", "LPMUPM"), riskType = c("minrisk", "optimal", "maxreward"), riskB = NULL, options = list(alpha = 0.05, threshold = 999, moment = 1, lmoment = 1, umoment = 1, lthreshold = -0.01, uthreshold = 0.01), LB = NULL, UB = NULL, budget = 1, leverage = NULL, ineqfun = NULL, ineqgrad = NULL, eqfun = NULL, eqgrad = NULL, uservars = list(), ineq.mat = NULL, ineq.LB = NULL, ineq.UB = NULL, eq.mat = NULL, eqB = NULL, max.pos = NULL, asset.names = NULL, ...){ hasminlp = 0 hasqcqp = 0 hasmiqp = 0 indx = rep(0, 8) names(indx) = c("datatype", "benchmark", "targettype", "risk", "risktype", "leverage", "aux1", "aux2") type = rep(0, 8) if(is.null(scenario) && is.null(S)) stop("\nparma: You cannot have both the scenario AND covariance matrix (S) NULL!") if(!is.null(scenario)){ if(tolower(riskType)=="maxreward") stop("\nparma: maxreward type only supported for covariance matrix (S) at present.") S = NULL scenario = as.matrix(scenario) indx[1] = 1 m = NCOL(scenario) n = NROW(scenario) indx[8] = m if(is.null(asset.names)) asset.names = colnames(scenario) if(is.null(forecast)){ if(!is.null(benchmark)){ warning("\nparma: no forecast provided but benchmark is included...using means from scenario - benchmark instead") forecast = as.numeric( colMeans(scenario) - mean(as.vector(benchmark)) ) } else{ forecast = as.numeric( colMeans(scenario) ) warning("\nparma: no forecast provided...using means from scenario instead.") } } else{ forecast = as.numeric(forecast)[1:m] } if(!is.null(benchmark)){ if(length(benchmark)<n){ benchmark = rep(benchmark[1], n) } else{ nb = length(as.numeric(benchmark)) if(nb!=n) stop("\nparma: benchmark length not equal to scenario length.") benchmark = as.numeric(benchmark[1:n]) } indx[2] = 1 } else{ benchmark = rep(0, n) } if(is.null(target)){ target = 0 if(tolower(riskType[1]) == "minrisk") warning("\nparma: no target provided...setting target reward to zero.") } else{ target = as.numeric(target)[1] } if(is.null(probability)){ probability = rep(1/n, n) } else{ probability = probability[1:n] if(sum(probability)!=1) warning("\nProbability does not sum to 1!") } xtmp = match(tolower(riskType[1]), c("minrisk", "optimal")) if(is.na(xtmp)) stop("\nparma: riskType not recognized") else riskType = c("minrisk", "optimal")[xtmp] indx[5] = xtmp tmp = match(tolower(targetType[1]), c("inequality", "equality")) if(is.na(tmp)) stop("\nparma: targetType not recognized") else targetType = c("inequality", "equality")[tmp] indx[3] = tmp tmp = match(tolower(risk[1]), tolower(c("MAD", "MiniMax", "CVaR", "CDaR", "EV", "LPM", "LPMUPM"))) if(is.na(tmp)) stop("\nparma: risk not recognized") else risk = c("MAD", "MiniMax", "CVaR", "CDaR", "EV", "LPM", "LPMUPM")[tmp] indx[4] = tmp if(!is.null(leverage)) indx[6] = as.numeric( leverage ) if(!is.null(ineqfun) && (!is.null(ineq.mat) | !is.null(eq.mat))){ stop("\nparma: you cannot mix ineqfun with linear custom constraints") } if(!is.null(eqfun) && (!is.null(ineq.mat) | !is.null(eq.mat))){ stop("\nparma: you cannot mix eqfun with linear custom constraints") } if(!is.null(leverage) && (!is.null(ineq.mat) | !is.null(eq.mat))){ stop("\nparma: you cannot mix leverage (NLP) with linear custom constraints") } if(!is.null(ineqfun)){ chk = .checkconsfun(ineqfun, name = "ineqfun") } if(!is.null(ineqgrad)){ chk = .checkconsfun(ineqgrad, name = "ineqgrad") } if(!is.null(eqfun)){ chk = .checkconsfun(eqfun, name = "eqfun") } if(!is.null(eqgrad)){ chk = .checkconsfun(eqgrad, name = "eqgrad") } midx = widx = vidx = NA if(tmp == 1){ widx = 1:m if(riskType == "optimal") midx=m+1 if(!is.null(max.pos)){ if(riskType == "minrisk"){ type[c(2, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[2] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[8] = 0 } if(hasminlp && type[2]>0) type[7] = 1 } else{ if(!is.null(ineq.mat) | !is.null(eq.mat)) stop("\nparma: you cannot have ineq.mat or eq.mat (LP constraints) with cardinality constraints in optimal risk case (MINLP/GNLP problem)!") if(hasminlp) type[c(7,8)] = 1 else type[8] = 1 } } else{ type[c(1, 6, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[1] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[c(6,8)] = 0 } } } if(tmp == 2){ if(riskType=="optimal"){ vidx = 1 widx = 2:(m+1) midx = m+2 } else{ vidx = 1 widx = 2:(m+1) midx = 0 } if(!is.null(max.pos)){ if(riskType == "minrisk"){ type[c(2, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[2] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[8] = 0 } if(hasminlp && type[2]>0) type[7] = 1 } else{ if(!is.null(ineq.mat) | !is.null(eq.mat)) stop("\nparma: you cannot have ineq.mat or eq.mat (LP constraints) with cardinality constraints in optimal risk case (MINLP/GNLP problem)!") if(hasminlp) type[c(7,8)] = 1 else type[8] = 1 } } else{ type[c(1, 6, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[1] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[c(6,8)] = 0 } } } if(tmp == 3){ widx = 2:(m+1) vidx = 1 if(riskType == "optimal") midx=m+2 if(!is.null(max.pos)){ if(riskType == "minrisk"){ type[c(2, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[2] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[8] = 0 } if(hasminlp && type[2]>0) type[7] = 1 } else{ if(!is.null(ineq.mat) | !is.null(eq.mat)) stop("\nparma: you cannot have ineq.mat or eq.mat (LP constraints) with cardinality constraints in optimal risk case (MINLP/GNLP problem)!") if(hasminlp) type[c(7,8)] = 1 else type[8] = 1 } } else{ type[c(1, 6, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[1] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[c(6,8)] = 0 } } } if(tmp == 4){ widx = 2:(m+1) vidx = 1 if(riskType == "optimal") midx=m+2 if(!is.null(max.pos)){ if(riskType == "minrisk") type[2] = 1 else stop("\nparma: CDaR with cardinality constraints and optimal risk type not supported.") } else{ type[1] = 1 } if(!is.null(leverage)) stop("\nparma: CDaR with leverage requires NLP formulation (not supported)") if(!is.null(ineqfun)) stop("\nparma: CDaR with custom NLP (ineqfun) constraints requires NLP formulation (not supported)") if(!is.null(eqfun)) stop("\nparma: CDaR with custom NLP (eqfun) constraints requires NLP formulation (not supported)") } if(tmp == 5){ widx = 1:m if(!is.null(max.pos)){ if(hasminlp) type[c(7,8)] = 1 else type[8] = 1 } else{ type[c(6, 8)] = 1 } if(riskType == "optimal") midx = m+1 if(!is.null(ineq.mat) | !is.null(eq.mat)){ stop("\nparma: EV scenario problem is NLP. Does not accept linear constraints (use QP with S matrix instead).") } } if(tmp == 6){ benchmark = 0 widx = 1:m if(riskType == "optimal") midx=m+1 if(options$moment == 1){ if(!is.null(max.pos)){ if(riskType == "minrisk"){ type[c(2, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[2] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[8] = 0 } if(hasminlp && type[2]>0) type[7] = 1 } else{ if(!is.null(ineq.mat) | !is.null(eq.mat)) stop("\nparma: you cannot have ineq.mat or eq.mat (LP constraints) with cardinality constraints in optimal risk case (MINLP/GNLP problem)!") if(hasminlp) type[c(7,8)] = 1 else type[8] = 1 } } else{ type[c(1, 6, 8)] = 1 if(!is.null(leverage) | !is.null(ineqfun) | !is.null(eqfun)){ type[1] = 0 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ type[c(6,8)] = 0 } } } else{ if(!is.null(max.pos)){ if(hasminlp) type[c(7,8)]<-1 else type[8]<-1 } else{ type[c(6, 8)] = 1 } if(!is.null(ineq.mat) | !is.null(eq.mat)){ stop("\nparma: LPM scenario problem with moment!=1 is NLP. Does not accept linear constraints.") } } } if(tmp == 7){ widx = 1:m midx = m+1 type[8]<-1 if(!is.null(ineq.mat) | !is.null(eq.mat)){ stop("\nparma: LPMUPM is GNLP. Does not accept linear constraints.") } riskType = "optimal" indx[5] = 2 } if(is.null(LB)){ LB = rep(0, m) warning("\nparma: no LB provided...setting Lower Bounds to zero.") } if(is.null(UB)){ UB = rep(1, m) warning("\nparma: no UB provided...setting Upper Bounds to 1.") } if(any(UB<LB)) stop("\nparma: UB must be greater than LB.") if(is.null(leverage)){ if(is.null(budget)){ budget = 1 warning("\nparma: no budget (or leverage) provided...setting budget constraint to 1.") } } else{ indx[6] = 1 } if(!is.null(ineq.mat)){ ineq.mat = as.matrix(ineq.mat) nb = dim(ineq.mat)[2] if(nb!=m) stop("\nparma: ineq.mat columns not equal to number of assets") nb = dim(ineq.mat)[1] if(nb!=length(ineq.LB)) stop("\nparma: ineq.mat rows not equal to length of ineq.LB") if(nb!=length(ineq.UB)) stop("\nparma: ineq.mat rows not equal to length of ineq.UB") } if(!is.null(eq.mat)){ ineq.mat = as.matrix(eq.mat) nb = dim(eq.mat)[2] if(nb!=m) stop("\nparma: eq.mat columns not equal to number of assets") nb = dim(eq.mat)[1] if(nb!=length(eqB)) stop("\nparma: eq.mat rows not equal to length of eqB") } if(!is.null(ineqfun)){ if(is.null(ineqgrad)){ type = rep(0,8) type[8] = 1 } } if(!is.null(eqfun)){ if(is.null(eqgrad)){ type = rep(0,8) type[8] = 1 } } } else{ m = NCOL(S) benchmark = ineqfun = eqfun = ineqgrad = eqgrad = NULL midx = 1 vidx = 0 widx = 2:(m+1) if( !is.null(max.pos) ){ if(hasmiqp){ type[4] = 1 } else{ stop("\nparma: max.pos NOT NULL but MIQP not available!") } } else{ if(!is.null(Q)){ type[5] = 1 if(riskType == "optimal") stop("\nparma: QCQP not yet implemented for optimal risk problem") } else{ type[3] = 1 type[5] = 1 } } if(!is.null(leverage)){ if(leverage<=0) stop("\nparma: leverage must be strictly positive!") type[3] = 0 type[5] = 1 indx[6] = as.numeric( leverage ) } if(tolower(riskType)=="maxreward"){ type[3] = 0 type[5] = 1 } if(riskType == "optimal") midx=1 if(tolower(risk[1])!="ev") stop("\nparma: only EV risk type allowed with covariance matrix (S)") indx[1] = 2 indx[8] = m if(is.null(asset.names)) asset.names = colnames(S) if(!is.null(benchmarkS)){ benchmarkS = matrix(benchmarkS, nrow = 1) indx[2] = 1 nb = NCOL(benchmarkS) if((nb-1)!=m) stop("\nparma: benchmarkS length must be equal to ncol S + 1.") } else{ benchmarkS = matrix(0, nrow = 1, ncol = m+1) } if(is.null(forecast)){ forecast = rep(0, m) warning("\nparma: no forecast provided...setting to zero.") } else{ forecast = as.numeric(forecast)[1:m] } if(is.null(target)){ target = 0 if(tolower(riskType[1]) == "minrisk"){ warning("\nparma: no target provided...setting target reward to zero.") indx[5] = 1 } else if(tolower(riskType[1])=="optimal"){ indx[5] = 2 } else{ indx[5] = 3 if(is.null(riskB)) stop("\nparma: maxreward option chosen but riskB not provided!") riskB = as.numeric(riskB[1]) } } else{ target = as.numeric(target)[1] if(tolower(riskType[1]) == "minrisk"){ indx[5] = 1 } else if(tolower(riskType[1])=="optimal"){ indx[5] = 2 } else{ indx[5] = 3 if(is.null(riskB)) stop("\nparma: maxreward option chosen but riskB not provided!") riskB = as.numeric(riskB[1]) target = NULL warning("\nparma: maxreward chosen AND target given...setting target to NULL.") } } tmp = match(tolower(targetType[1]), c("inequality", "equality")) if(is.na(tmp)) stop("\nparma: targetType not recognized") else targetType = c("inequality", "equality")[tmp] indx[3] = tmp if(is.null(LB)){ LB = rep(0, m) warning("\nparma: no LB provided...setting Lower Bounds to zero.") } if(is.null(UB)){ UB = rep(1, m) warning("\nparma: no UB provided...setting Upper Bounds to 1.") } if(any(UB<LB)) stop("\nparma: UB must be greater than LB.") if(is.null(leverage)){ if(is.null(budget)){ budget = 1 warning("\nparma: no budget (or leverage) provided...setting budget constraint to 1.") } } if(!is.null(ineq.mat)){ ineq.mat = as.matrix(ineq.mat) nb = dim(ineq.mat)[2] if(nb!=m) stop("\nparma: ineq.mat columns not equal to number of assets") nb = dim(ineq.mat)[1] if(nb!=length(ineq.LB)) stop("\nparma: ineq.mat rows not equal to length of ineq.LB") if(nb!=length(ineq.UB)) stop("\nparma: ineq.mat rows not equal to length of ineq.UB") } if(!is.null(eq.mat)){ eq.mat = as.matrix(eq.mat) nb = dim(eq.mat)[2] if(nb!=m) stop("\nparma: eq.mat columns not equal to number of assets") nb = dim(eq.mat)[1] if(nb!=length(eqB)) stop("\nparma: eq.mat rows not equal to length of eqB") } } model = list(indx = indx, risk = risk, riskType = riskType, targetType = targetType, options = options, type = type, widx = widx, midx = midx, vidx = vidx) modeldata = list(scenario = scenario, probability = probability, S = S, Q = Q, qB = qB, benchmark = benchmark, benchmarkS = benchmarkS, forecast = forecast, target = target, riskB = riskB, asset.names = asset.names, uservars = uservars) constraints = list(LB = LB, UB = UB, budget = budget, leverage = leverage, ineqfun = ineqfun, ineqgrad = ineqgrad, eqfun = eqfun, eqgrad = eqgrad, ineq.mat = ineq.mat, ineq.LB = ineq.LB, ineq.UB = ineq.UB, eq.mat = eq.mat, eqB = eqB, uservars = uservars, max.pos = max.pos) ans = new("parmaSpec", model = model, modeldata = modeldata, constraints = constraints) return(ans) } .spec2minNLP = function(spec){ optvars = list() optvars$widx = spec@model$widx optvars$midx = spec@model$midx optvars$vidx = spec@model$vidx optvars$index = spec@model$indx if(spec@model$indx[2]==0){ optvars$Data = switch(tolower(spec@model$risk), "mad" = scale(spec@modeldata$scenario, scale = FALSE), "ev" = scale(spec@modeldata$scenario, scale = FALSE), "minimax" = spec@modeldata$scenario, "cvar" = spec@modeldata$scenario, "cdar" = spec@modeldata$scenario, "lpm" = spec@modeldata$scenario, spec@modeldata$scenario) } else{ optvars$Data = spec@modeldata$scenario } optvars$benchmark = spec@modeldata$benchmark optvars$mu = spec@modeldata$forecast optvars$mutarget = spec@modeldata$target risk = spec@model$risk mn = dim(optvars$Data) N = mn[1] m = mn[2] optvars$wm = m optvars$N = N if(tolower(risk) == "lpm"){ if(spec@model$options$threshold == 999){ optvars$Data = scale(optvars$Data, scale = FALSE) optvars$threshold = 0 } else{ optvars$threshold = spec@model$options$threshold } } else{ optvars$threshold = 0 } optvars$moment = spec@model$options$moment if(tolower(risk) == "cvar"){ optvars$fm = m+1 x0 = as.numeric(c(quantile(optvars$Data %*% rep(1/m, m), spec@model$options$alpha), rep(1/m, m))) optvars$LB = c(-10, spec@constraints$LB) optvars$UB = c( 0, spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else if(tolower(risk) == "minimax"){ optvars$fm = m+1 x0 = as.numeric(c(-min(optvars$Data %*% rep(1/m, m)), rep(1/m, m))) optvars$LB = c( 0, spec@constraints$LB) optvars$UB = c( 1, spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else{ optvars$fm = m x0 = rep(1/m, m) optvars$LB = spec@constraints$LB optvars$UB = spec@constraints$UB optvars$alpha = 0.05 } optvars$budget = spec@constraints$budget optvars$leverage = spec@constraints$leverage optvars$ineqfun = spec@constraints$ineqfun optvars$ineqgrad = spec@constraints$ineqgrad optvars$eqfun = spec@constraints$eqfun optvars$eqgrad = spec@constraints$eqgrad optvars$x0 = x0 return(optvars) } .spec2optNLP = function(spec, pcontrol = list(ubounds = 1e4, mbounds = 1e5, penalty = 1e4, startp = 150)){ optvars = list() optvars$widx = spec@model$widx optvars$midx = spec@model$midx optvars$vidx = spec@model$vidx optvars$index = spec@model$indx if(spec@model$indx[2]==0){ optvars$Data = switch(tolower(spec@model$risk), "mad" = scale(spec@modeldata$scenario, scale = FALSE), "ev" = scale(spec@modeldata$scenario, scale = FALSE), "minimax" = spec@modeldata$scenario, "cvar" = spec@modeldata$scenario, "cdar" = spec@modeldata$scenario, "lpm" = spec@modeldata$scenario, spec@modeldata$scenario) } else{ optvars$Data = spec@modeldata$scenario } optvars$benchmark = spec@modeldata$benchmark optvars$mu = spec@modeldata$forecast optvars$mutarget = spec@modeldata$target risk = spec@model$risk mn = dim(optvars$Data) N = mn[1] m = mn[2] optvars$wm = m optvars$N = N if(tolower(risk) == "lpm"){ if(spec@model$options$threshold == 999){ optvars$Data = scale(optvars$Data, scale = FALSE) optvars$threshold = 0 } else{ optvars$threshold = spec@model$options$threshold } } else{ optvars$threshold = 0 } if(tolower(risk) == "lpmupm"){ if(spec@model$options$lthreshold == 999 || spec@model$options$uthreshold == 999){ optvars$Data = scale(optvars$Data, scale = FALSE) optvars$lthreshold = 0 optvars$uthreshold = 0 } else{ optvars$lthreshold = spec@model$options$lthreshold optvars$uthreshold = spec@model$options$uthreshold if(optvars$lthreshold>optvars$uthreshold) stop("\nparma: lower threshold higher than upper threshold in LPMUPM!") } optvars$lmoment = spec@model$options$lmoment optvars$umoment = spec@model$options$umoment } else{ optvars$lthreshold = 0 optvars$uthreshold = 0 optvars$umoment = 1 optvars$lmoment = 1 } optvars$moment = spec@model$options$moment if(tolower(risk) == "cvar"){ optvars$fm = m+2 x0 = as.numeric(c(5*quantile(optvars$Data %*% rep(1/m, m), spec@model$options$alpha), 5*rep(1/m, m), 5)) optvars$fLB = c( -pcontrol$ubounds, rep(-pcontrol$ubounds, m), 1e-8) optvars$fUB = c( pcontrol$ubounds, rep( pcontrol$ubounds, m), pcontrol$mbounds) optvars$LB = c(spec@constraints$LB) optvars$UB = c(spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else if(tolower(risk) == "minimax"){ optvars$fm = m+2 x0 = as.numeric(c(-min(optvars$Data %*% rep(1/m, m)), rep(1/m, m), 1)) optvars$fLB = c(-pcontrol$ubounds, rep(-pcontrol$ubounds, m), 1e-8) optvars$fUB = c( pcontrol$ubounds, rep( pcontrol$ubounds, m), pcontrol$mbounds) optvars$LB = c(spec@constraints$LB) optvars$UB = c(spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else{ optvars$fm = m+1 x0 = c(rep(1/m, m), 2) optvars$fLB = c(rep(-pcontrol$ubounds, m), 1e-8) optvars$fUB = c(rep( pcontrol$ubounds, m), pcontrol$mbounds) optvars$LB = spec@constraints$LB optvars$UB = spec@constraints$UB optvars$alpha = 0.05 } optvars$budget = spec@constraints$budget optvars$leverage = spec@constraints$leverage optvars$ineqfun = spec@constraints$ineqfun optvars$ineqgrad = spec@constraints$ineqgrad optvars$eqfun = spec@constraints$eqfun optvars$eqgrad = spec@constraints$eqgrad optvars$x0 = x0 return(optvars) } .spec2minGNLP = function(spec, pcontrol = list(ubounds = 1e4, mbounds = 1e5, penalty = 1e4, startp = 150)){ optvars = list() optvars$widx = spec@model$widx optvars$midx = spec@model$midx optvars$vidx = spec@model$vidx optvars$index = spec@model$indx if(spec@model$indx[2]==0){ optvars$Data = switch(tolower(spec@model$risk), "mad" = scale(spec@modeldata$scenario, scale = FALSE), "ev" = scale(spec@modeldata$scenario, scale = FALSE), "minimax" = spec@modeldata$scenario, "cvar" = spec@modeldata$scenario, "cdar" = spec@modeldata$scenario, "lpm" = spec@modeldata$scenario, spec@modeldata$scenario) } else{ optvars$Data = spec@modeldata$scenario } optvars$benchmark = spec@modeldata$benchmark optvars$mu = spec@modeldata$forecast optvars$mutarget = spec@modeldata$target optvars$penalty = pcontrol$penalty risk = spec@model$risk mn = dim(optvars$Data) N = mn[1] m = mn[2] optvars$wm = m optvars$N = N if(tolower(risk) == "lpm"){ if(spec@model$options$threshold == 999){ optvars$Data = scale(optvars$Data, scale = FALSE) optvars$threshold = 0 } else{ optvars$threshold = spec@model$options$threshold } } else{ optvars$threshold = 0 } optvars$moment = spec@model$options$moment if(tolower(risk) == "cvar"){ optvars$fm = m+1 x0 = as.numeric(c(quantile(optvars$Data %*% rep(1/m, m), spec@model$options$alpha), rep(1/m, m))) optvars$LB = c(-10, spec@constraints$LB) optvars$UB = c( 0, spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else if(tolower(risk) == "minimax"){ optvars$fm = m+1 x0 = as.numeric(c(-min(optvars$Data %*% rep(1/m, m)), rep(1/m, m))) optvars$LB = c(0, spec@constraints$LB) optvars$UB = c(1, spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else{ optvars$fm = m x0 = rep(1/m, m) optvars$LB = spec@constraints$LB optvars$UB = spec@constraints$UB optvars$alpha = 0.05 } optvars$budget = spec@constraints$budget optvars$leverage = spec@constraints$leverage optvars$ineqfun = spec@constraints$ineqfun optvars$ineqgrad = spec@constraints$ineqgrad optvars$eqfun = spec@constraints$eqfun optvars$eqgrad = spec@constraints$eqgrad optvars$x0 = x0 return(optvars) } .spec2optGNLP = function(spec, pcontrol = list(ubounds = 1e4, mbounds = 1e5, penalty = 1e4, startp = 150)){ optvars = list() optvars$widx = spec@model$widx optvars$midx = spec@model$midx optvars$vidx = spec@model$vidx optvars$index = spec@model$indx if(spec@model$indx[2]==0){ optvars$Data = switch(tolower(spec@model$risk), "mad" = scale(spec@modeldata$scenario, scale = FALSE), "ev" = scale(spec@modeldata$scenario, scale = FALSE), "minimax" = spec@modeldata$scenario, "cvar" = spec@modeldata$scenario, "cdar" = spec@modeldata$scenario, "lpm" = spec@modeldata$scenario, spec@modeldata$scenario) } else{ optvars$Data = spec@modeldata$scenario } optvars$benchmark = spec@modeldata$benchmark optvars$mu = spec@modeldata$forecast optvars$mutarget = spec@modeldata$target penalty = pcontrol$penalty risk = spec@model$risk mn = dim(optvars$Data) N = mn[1] m = mn[2] optvars$wm = m optvars$N = N if(tolower(risk) == "lpm"){ if(spec@model$options$threshold == 999){ optvars$Data = scale(optvars$Data, scale = FALSE) optvars$threshold = 0 } else{ optvars$threshold = spec@model$options$threshold } } else{ optvars$threshold = 0 } if(tolower(risk) == "lpmupm"){ if(spec@model$options$lthreshold == 999 || spec@model$options$uthreshold == 999){ optvars$Data = scale(optvars$Data, scale = FALSE) optvars$lthreshold = 0 optvars$uthreshold = 0 } else{ optvars$lthreshold = spec@model$options$lthreshold optvars$uthreshold = spec@model$options$uthreshold if(optvars$lthreshold>optvars$uthreshold) stop("\nparma: lower threshold higher than upper threshold in LPMUPM!") } optvars$lmoment = spec@model$options$lmoment optvars$umoment = spec@model$options$umoment } else{ optvars$lthreshold = 0 optvars$uthreshold = 0 optvars$umoment = 1 optvars$lmoment = 1 } optvars$moment = spec@model$options$moment if(tolower(risk) == "cvar"){ optvars$fm = m+2 x0 = as.numeric(c(5*quantile(optvars$Data %*% rep(1/m, m), spec@model$options$alpha), 5*rep(1/m, m), 5)) optvars$fLB = c( -pcontrol$ubounds, rep(-pcontrol$ubounds, m), 1e-8) optvars$fUB = c( pcontrol$ubounds, rep( pcontrol$ubounds, m), pcontrol$mbounds) optvars$LB = c(spec@constraints$LB) optvars$UB = c(spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else if(tolower(risk) == "minimax"){ optvars$fm = m+2 x0 = as.numeric(c(-min(optvars$Data %*% rep(1/m, m)), rep(1/m, m), 1)) optvars$fLB = c(-pcontrol$ubounds, rep(-pcontrol$ubounds, m), 1e-8) optvars$fUB = c( pcontrol$ubounds, rep( pcontrol$ubounds, m), pcontrol$mbounds) optvars$LB = c(spec@constraints$LB) optvars$UB = c(spec@constraints$UB) optvars$alpha = spec@model$options$alpha } else{ optvars$fm = m+1 x0 = c(rep(1/m, m), 2) optvars$fLB = c(rep(-pcontrol$ubounds, m), 1e-8) optvars$fUB = c(rep( pcontrol$ubounds, m), pcontrol$mbounds) optvars$LB = spec@constraints$LB optvars$UB = spec@constraints$UB optvars$alpha = 0.05 } optvars$budget = spec@constraints$budget optvars$leverage = spec@constraints$leverage optvars$ineqfun = spec@constraints$ineqfun optvars$ineqgrad = spec@constraints$ineqgrad optvars$eqfun = spec@constraints$eqfun optvars$eqgrad = spec@constraints$eqgrad optvars$x0 = x0 return(optvars) } .spec2QP = function(spec){ optvars = list() optvars$index = spec@model$indx optvars$S = spec@modeldata$S optvars$benchmarkS = spec@modeldata$benchmarkS optvars$mu = spec@modeldata$forecast optvars$mutarget = spec@modeldata$target optvars$budget = spec@constraints$budget optvars$ineq.mat = spec@constraints$ineq.mat optvars$eq.mat = spec@constraints$eq.mat optvars$LB = spec@constraints$LB optvars$UB = spec@constraints$UB optvars$ineq.LB = spec@constraints$ineq.LB optvars$ineq.UB = spec@constraints$ineq.UB optvars$eqB = spec@constraints$eqB return(optvars) } .spec2SOCP = function(spec){ optvars = list() optvars$index = spec@model$indx optvars$S = spec@modeldata$S optvars$Q = spec@modeldata$Q optvars$qB = spec@modeldata$qB optvars$riskB = spec@modeldata$riskB optvars$benchmarkS = spec@modeldata$benchmarkS optvars$mu = spec@modeldata$forecast optvars$mutarget = spec@modeldata$target optvars$budget = spec@constraints$budget optvars$leverage = spec@constraints$leverage optvars$ineq.mat = spec@constraints$ineq.mat optvars$eq.mat = spec@constraints$eq.mat optvars$LB = spec@constraints$LB optvars$UB = spec@constraints$UB optvars$ineq.LB = spec@constraints$ineq.LB optvars$ineq.UB = spec@constraints$ineq.UB optvars$eqB = spec@constraints$eqB return(optvars) } .spec2LP = function(spec){ optvars = list() optvars$index = spec@model$indx if(spec@model$indx[2]==0){ optvars$Data = switch(tolower(spec@model$risk), "mad" = scale(spec@modeldata$scenario, scale = FALSE), "ev" = scale(spec@modeldata$scenario, scale = FALSE), "minimax" = spec@modeldata$scenario, "cvar" = spec@modeldata$scenario, "cdar" = spec@modeldata$scenario, "lpm" = spec@modeldata$scenario, spec@modeldata$scenario) } else{ optvars$Data = spec@modeldata$scenario } optvars$probability = spec@modeldata$probability optvars$benchmark = spec@modeldata$benchmark optvars$mu = spec@modeldata$forecast optvars$mutarget = spec@modeldata$target risk = spec@model$risk mn = dim(optvars$Data) N = mn[1] m = mn[2] optvars$wm = m optvars$N = N if(tolower(risk) == "lpm"){ if(spec@model$options$threshold == 999){ optvars$Data = scale(optvars$Data, scale = FALSE) optvars$threshold = 0 } else{ optvars$threshold = spec@model$options$threshold } } else{ optvars$threshold = 0 } optvars$moment = 1 optvars$alpha = spec@model$options$alpha optvars$LB = spec@constraints$LB optvars$UB = spec@constraints$UB optvars$budget = spec@constraints$budget optvars$ineq.mat = spec@constraints$ineq.mat optvars$ineq.LB = spec@constraints$ineq.LB optvars$ineq.UB = spec@constraints$ineq.UB optvars$eq.mat = spec@constraints$eq.mat optvars$eqB = spec@constraints$eqB optvars$max.pos = spec@constraints$max.pos return(optvars) } .parmasolve = function(spec, type = NULL, solver = NULL, solver.control = list(), x0 = NULL, w0 = NULL, parma.control = list(ubounds = 1e4, mbounds = 1e5, penalty = 1e4, eqSlack = 1e-5), ...){ tic = Sys.time() if(is.null(parma.control)) parma.control = list() mm = match(names(parma.control), c("ubounds", "mbounds", "penalty","eqSlack")) if(any(is.na(mm))){ idx = which(is.na(mm)) enx = NULL for(i in 1:length(idx)) enx = c(enx, parma.control[idx[i]]) warning(paste(c("unidentified option(s) in parma.control:\n", enx), sep="", collapse=" "), call. = FALSE, domain = NULL) } if(is.null(parma.control$ubounds)) parma.control$ubounds = 1e4 else parma.control$ubounds = parma.control$ubounds[1] if(is.null(parma.control$mbounds)) parma.control$mbounds = 1e5 else parma.control$mbounds = parma.control$mbounds[1] if(is.null(parma.control$penalty)) parma.control$penalty = 1e4 else parma.control$penalty = parma.control$penalty[1] if(is.null(parma.control$eqSlack)) parma.control$eqSlack = 1e-5 else parma.control$eqSlack = parma.control$eqSlack[1] available.problems = toupper(c("LP", "MILP", "QP", "MIQP", "SOCP", "NLP", "MINLP", "GNLP")[which(spec@model$type==1)]) if(!is.null(type[1])){ type = toupper(type[1]) tmp = match.arg(type, available.problems) type = tmp } else{ type = available.problems[1] } if(spec@model$indx[5]==1){ optvars = switch(tolower(type), "lp" = .spec2LP(spec), "milp" = .spec2LP(spec), "nlp" = .spec2minNLP(spec), "qp" = .spec2QP(spec), "socp" = .spec2SOCP(spec), "gnlp" = .spec2minGNLP(spec, parma.control)) } else{ optvars = switch(tolower(type), "lp" = .spec2LP(spec), "milp" = .spec2LP(spec), "nlp" = .spec2optNLP(spec, parma.control), "qp" = .spec2QP(spec), "socp" = .spec2SOCP(spec), "gnlp" = .spec2optGNLP(spec, parma.control)) } uservars = spec@modeldata$uservars if(!is.null(x0)){ if(length(optvars$x0)!=length(x0)) stop("\nparma: wrong length for x0!") optvars$x0 = x0 } if(!is.null(w0)){ if(length(optvars$widx)!=length(w0)) stop("\nparma: wrong length for w0!") optvars$x0[optvars$widx] = w0 } if(type=="LP" && is.null(solver)) solver="GLPK" sol = switch(toupper(type), "LP" = lpport(optvars, solver, ...), "MILP" = milpport(optvars, solver, ...), "NLP" = nlpport(optvars, uservars, control = solver.control, ...), "QP" = qpport(optvars, ...), "SOCP" = socpport(optvars, control = solver.control, eqSlack = parma.control$eqSlack, ...), "GNLP" = gnlpport(optvars, uservars, solver = solver, control = solver.control, ...)) if(type!="QP" & type!="SOCP"){ arbitrage = .arbcheck(sol$weights, spec@modeldata$scenario, spec@model$options, spec@model$risk) } else{ arbitrage = c(0, 0) } spec@model$asset.names = spec@modeldata$asset.names spec@model$type = type sol$solver = solver sol$arbitrage = arbitrage toc = Sys.time() - tic spec@model$elapsed = toc ret = new("parmaPort", solution = sol, model = spec@model) return(ret) } .parmafrontier = function(spec, n.points = 100, miny = NULL, maxy = NULL, type = NULL, solver = NULL, solver.control = list(), parma.control = list(ubounds = 10000, mbounds = 1e+05, penalty = 10000), cluster = NULL) { if(!is.null(spec@modeldata$S)) { ans = m.parmafrontier(spec, n.points = n.points, type = type, miny = miny, maxy = maxy, cluster = cluster) } else { ans = s.parmafrontier(spec, n.points = n.points, miny = miny, maxy = maxy, type = type, solver = solver, solver.control = solver.control, parma.control = parma.control, cluster = cluster) } return(ans) } s.parmafrontier = function(spec, n.points = 100, miny = NULL, maxy = NULL, type = NULL, solver = NULL, solver.control = list(), parma.control = list(ubounds = 10000, mbounds = 1e+05, penalty = 10000), cluster = NULL) { targettype = parmaget(spec, "targetType") risktype = parmaget(spec, "riskType") if(risktype!="minrisk") stop("\nspec riskType must be minrisk...fix and resubmit.") if(targettype!="equality") stop("\nspec targetType must be equality...fix and resubmit.") m = NCOL(spec@modeldata$scenario) if(is.null(spec@modeldata$forecast)){ f = abs(apply(spec@modeldata$scenario, 2, "mean")) minb = min(f) maxb = max(f) } else{ minb = min(abs(spec@modeldata$forecast)) maxb = max(abs(spec@modeldata$forecast)) } if(is.null(miny)){ xspec = spec parmaset(xspec)<-list(target=0) parmaset(xspec)<-list(targetType="inequality") solx = try(parmasolve(xspec, type = type, solver = solver, solver.control = solver.control, parma.control = parma.control), silent = TRUE) if(!inherits(solx, "try-error")) minb = parmareward(solx) } else{ minb = miny } if(!is.null(maxy)){ maxb = maxy } fs = seq(minb, maxb, length.out = n.points) fmat = matrix(NA, ncol = m+3, nrow = n.points) if(!is.null(cluster)){ clusterEvalQ(cluster, require(parma)) clusterExport(cluster, c("fs", "spec", "type", "solver", "solver.control","parma.control"), envir = environment()) sol = parLapply(cluster, 1:n.points, fun = function(i){ xspec = spec parmaset(xspec)<-list(target=fs[i]) tmp = parmasolve(xspec, type = type, solver = solver, solver.control = solver.control, parma.control = parma.control) return(tmp) }) for(i in 1:n.points){ fmat[i,1:m] = weights(sol[[i]]) fmat[i,m+1] = parmarisk(sol[[i]]) fmat[i,m+2] = parmareward(sol[[i]]) fmat[i,m+3] = parmastatus(sol[[i]]) } } else{ for(i in 1:n.points){ xspec = spec parmaset(xspec)<-list(target=fs[i]) tmp = parmasolve(xspec, type = type, solver = solver, solver.control = solver.control, parma.control = parma.control) fmat[i,1:m] = weights(tmp) fmat[i,m+1] = parmarisk(tmp) fmat[i,m+2] = parmareward(tmp) fmat[i,m+3] = parmastatus(tmp) } } colnames(fmat) = c(spec@modeldata$asset.names, spec@model$risk, "reward", "status") return(fmat) } m.parmafrontier = function(spec, n.points = 100, type = "QP", solver.control = list(abs.tol = 1e-8, rel.tol = 1e-8, Nu=2, max.iter=5250, BigM.K = 4, BigM.iter = 15), miny = NULL, maxy = NULL, cluster = NULL) { targettype = parmaget(spec, "targetType") risktype = parmaget(spec, "riskType") if(risktype!="minrisk") stop("\nspec riskType must be minrisk...fix and resubmit.") if(targettype!="equality") stop("\nspec targetType must be equality...fix and resubmit.") m = NCOL(spec@modeldata$S) if(is.null(spec@modeldata$forecast)){ stop("\nparma: cannot have a NULL forecast vector in QP formulation.") } else{ minb = min(abs(spec@modeldata$forecast)) maxb = max(abs(spec@modeldata$forecast)) } if(is.null(miny)){ xspec = spec parmaset(xspec)<-list(target=0) parmaset(xspec)<-list(targetType="inequality") solx = try(parmasolve(xspec), silent = TRUE) if(!inherits(solx, "try-error")) minb = parmareward(solx) } else{ minb = miny } if(!is.null(maxy)){ maxb = maxy } fs = seq(minb, maxb, length.out = n.points) fmat = matrix(NA, ncol = m+2, nrow = n.points) if(!is.null(cluster)){ clusterEvalQ(cluster, require(parma)) clusterExport(cluster, c("fs", "spec","type","solver.control"), envir = environment()) sol = parLapply(cluster, 1:n.points, fun = function(i){ xspec = spec parmaset(xspec)<-list(target=fs[i]) tmp = parmasolve(xspec, type = type, solver.control = solver.control) return(tmp) }) for(i in 1:n.points){ fmat[i,1:m] = weights(sol[[i]]) fmat[i,m+1] = parmarisk(sol[[i]]) fmat[i,m+2] = parmareward(sol[[i]]) } } else{ for(i in 1:n.points){ xspec = spec parmaset(xspec)<-list(target=fs[i]) tmp = parmasolve(xspec, type = type, solver.control = solver.control) fmat[i,1:m] = weights(tmp) fmat[i,m+1] = parmarisk(tmp) fmat[i,m+2] = parmareward(tmp) } } colnames(fmat) = c(spec@modeldata$asset.names, spec@model$risk, "reward") return(fmat) } .checkconsfun = function(fun, name = "ineqfun"){ if(!is.list(fun)) stop(paste("\n",name," must be a list of functions",sep="")) n = length(fun) for(i in 1:n){ if(!is.function(fun[[i]])) stop(paste("\n",name," list constains non functions at position: ",i,sep="")) } return(0) }
context('extent calculations') test_that('extent calculations',{ data(leroy) expect_equal( extent(leroy), extent(move:::.extcalc(leroy,0)) ) expect_equal( extent(leroy)*2, extent(move:::.extcalc(leroy,0.5)) ) expect_equal( extent(leroy)*1:2, extent(move:::.extcalc(leroy,c(0,0.5))) ) }) test_that('extent calculations between bgb and dbbmm',{ data<-move(x=rep(2:3,9)/5, y=rep(2:3,9)/5, Sys.time()+1:18) expect_message(x<-brownian.bridge.dyn(data, location.error=.1, ext=7, dimSize=50, window.size=11, margin=5),'Computa') expect_warning(xd<-dynBGB(data, locErr=.1, ext=7, dimSize=50, windowSize=11, margin=5),'Brownian motion assumed, because no direction could be calculated') expect_equal( raster(xd), raster(x) ) expect_message(x<-brownian.bridge.dyn(data, location.error=.1, ext=7, raster=.020, window.size=11, margin=5),'Computa') expect_warning(xd<-dynBGB(data, locErr=.1, ext=7, raster=.020, windowSize=11, margin=5),'Brownian motion assumed, because no direction could be calculated') expect_equal( raster(xd) , raster(x) ) })
codeNames = c("Data","Technical.Constraints","Performance.Parameters","Client.and.Consultant.Requests","Design.Reasoning","Collaboration") accum = ena.accumulate.data( units = RS.data[,c("Condition","UserName")], conversation = RS.data[,c("Condition","GroupName")], metadata = RS.data[,c("CONFIDENCE.Change","CONFIDENCE.Pre","CONFIDENCE.Post","C.Change")], codes = RS.data[,codeNames], model = "EndPoint", window.size.back = 4 ); set = ena.make.set( enadata = accum, rotation.by = ena.rotate.by.mean, rotation.params = list(FirstGame=accum$meta.data$Condition=="FirstGame", SecondGame=accum$meta.data$Condition=="SecondGame") ); first.game = set$meta.data$Condition == "FirstGame" first.game.points = set$points.rotated[first.game,] second.game = set$meta.data$Condition == "SecondGame" second.game.points = set$points.rotated[second.game,] ena.conversations(set = set, units = c("FirstGame.steven z"), units.by=c("Condition","UserName"), conversation.by = c("Condition","GroupName"), codes=codeNames, window = 4 ) first.game.lineweights = set$line.weights[first.game,] first.game.mean = colMeans(first.game.lineweights) second.game.lineweights = set$line.weights[second.game,] second.game.mean = colMeans(second.game.lineweights) subtracted.network = first.game.mean - second.game.mean plot1 = rENA::ena.plot(set) plot1 = rENA::ena.plot.network(plot1, network = subtracted.network) plot2 = rENA::ena.plot(set) plot2 = rENA::ena.plot.group(plot2, second.game.points, labels = "SecondGame", colors = "blue", confidence.interval = "box") plot2 = rENA::ena.plot.group(plot2, first.game.points, labels = "FirstGame", colors = "red", confidence.interval = "box") plot3 = rENA::ena.plot(set) plot3 = rENA::ena.plot.network(plot3, network = subtracted.network) plot3 = rENA::ena.plot.group(plot3, first.game.points, labels = "FirstGame", colors = "red", confidence.interval = "box") plot3 = rENA::ena.plot.group(plot3, second.game.points, labels = "SecondGame", colors = "blue", confidence.interval = "box") dim.by.activity = cbind( set$points.rotated[,1], set$enadata$trajectories$step$ActivityNumber*.8/14-.4 ) accum = ena.accumulate.data( units = RS.data[,c("UserName","Condition")], conversation = RS.data[,c("GroupName","ActivityNumber")], metadata = RS.data[,c("CONFIDENCE.Change","CONFIDENCE.Pre","CONFIDENCE.Post","C.Change")], codes = RS.data[,codeNames], window.size.back = 4, model = "A" ); set = ena.make.set(accum); plot = ena.plot(set) plot = ena.plot.network(plot, network = subtracted.network, legend.name="Network", legend.include.edges = T) dim.by.activity = cbind( set$points.rotated[,1], set$enadata$trajectories$step$ActivityNumber*.8/14-.4 )
expected <- eval(parse(text="structure(list(price.index = c(4.70997, 4.70217, 4.68944, 4.68558, 4.64019, 4.62553, 4.61991, 4.61654, 4.61407, 4.60766, 4.60227, 4.5896, 4.57592, 4.58661, 4.57997, 4.57176, 4.56104, 4.54906, 4.53957, 4.51018, 4.50352, 4.4936, 4.46505, 4.44924, 4.43966, 4.42025, 4.4106, 4.41151, 4.3981, 4.38513, 4.3732, 4.3277, 4.32023, 4.30909, 4.30909, 4.30552, 4.29627, 4.27839, 4.27789)), .Names = \"price.index\")")); test(id=0, code={ argv <- eval(parse(text="list(structure(list(y = structure(c(8.79236, 8.79137, 8.81486, 8.81301, 8.90751, 8.93673, 8.96161, 8.96044, 9.00868, 9.03049, 9.06906, 9.05871, 9.10698, 9.12685, 9.17096, 9.18665, 9.23823, 9.26487, 9.28436, 9.31378, 9.35025, 9.35835, 9.39767, 9.4215, 9.44223, 9.48721, 9.52374, 9.5398, 9.58123, 9.60048, 9.64496, 9.6439, 9.69405, 9.69958, 9.68683, 9.71774, 9.74924, 9.77536, 9.79424), .Tsp = c(1962.25, 1971.75, 4), class = \"ts\"), lag.quarterly.revenue = c(8.79636, 8.79236, 8.79137, 8.81486, 8.81301, 8.90751, 8.93673, 8.96161, 8.96044, 9.00868, 9.03049, 9.06906, 9.05871, 9.10698, 9.12685, 9.17096, 9.18665, 9.23823, 9.26487, 9.28436, 9.31378, 9.35025, 9.35835, 9.39767, 9.4215, 9.44223, 9.48721, 9.52374, 9.5398, 9.58123, 9.60048, 9.64496, 9.6439, 9.69405, 9.69958, 9.68683, 9.71774, 9.74924, 9.77536), price.index = c(4.70997, 4.70217, 4.68944, 4.68558, 4.64019, 4.62553, 4.61991, 4.61654, 4.61407, 4.60766, 4.60227, 4.5896, 4.57592, 4.58661, 4.57997, 4.57176, 4.56104, 4.54906, 4.53957, 4.51018, 4.50352, 4.4936, 4.46505, 4.44924, 4.43966, 4.42025, 4.4106, 4.41151, 4.3981, 4.38513, 4.3732, 4.3277, 4.32023, 4.30909, 4.30909, 4.30552, 4.29627, 4.27839, 4.27789), income.level = c(5.8211, 5.82558, 5.83112, 5.84046, 5.85036, 5.86464, 5.87769, 5.89763, 5.92574, 5.94232, 5.95365, 5.9612, 5.97805, 6.00377, 6.02829, 6.03475, 6.03906, 6.05046, 6.05563, 6.06093, 6.07103, 6.08018, 6.08858, 6.10199, 6.11207, 6.11596, 6.12129, 6.122, 6.13119, 6.14705, 6.15336, 6.15627, 6.16274, 6.17369, 6.16135, 6.18231, 6.18768, 6.19377, 6.2003), market.potential = c(12.9699, 12.9733, 12.9774, 12.9806, 12.9831, 12.9854, 12.99, 12.9943, 12.9992, 13.0033, 13.0099, 13.0159, 13.0212, 13.0265, 13.0351, 13.0429, 13.0497, 13.0551, 13.0634, 13.0693, 13.0737, 13.077, 13.0849, 13.0918, 13.095, 13.0984, 13.1089, 13.1169, 13.1222, 13.1266, 13.1356, 13.1415, 13.1444, 13.1459, 13.152, 13.1593, 13.1579, 13.1625, 13.1664)), .Names = c(\"y\", \"lag.quarterly.revenue\", \"price.index\", \"income.level\", \"market.potential\"), row.names = c(\"1962.25\", \"1962.5\", \"1962.75\", \"1963\", \"1963.25\", \"1963.5\", \"1963.75\", \"1964\", \"1964.25\", \"1964.5\", \"1964.75\", \"1965\", \"1965.25\", \"1965.5\", \"1965.75\", \"1966\", \"1966.25\", \"1966.5\", \"1966.75\", \"1967\", \"1967.25\", \"1967.5\", \"1967.75\", \"1968\", \"1968.25\", \"1968.5\", \"1968.75\", \"1969\", \"1969.25\", \"1969.5\", \"1969.75\", \"1970\", \"1970.25\", \"1970.5\", \"1970.75\", \"1971\", \"1971.25\", \"1971.5\", \"1971.75\"), class = \"data.frame\"), 3L)")); do.call(`.subset`, argv); }, o=expected);
structure(list(url = "/browse-edgar?action=getcurrent&CIK=&type=&company=&datea=&dateb=&owner=include&start=0&count=40&output=atom", status_code = 200L, headers = structure(list(`content-encoding` = "gzip", `content-type` = "application/atom+xml", server = "Apache", `x-content-type-options` = "nosniff", `x-frame-options` = "SAMEORIGIN", `x-xss-protection` = "1; mode=block", `content-length` = "1705", `cache-control` = "no-cache", date = "Sun, 18 Apr 2021 16:54:19 GMT", vary = "Accept-Encoding", `strict-transport-security` = "max-age=31536000 ; includeSubDomains ; preload", location = character(0)), class = c("insensitive", "list" )), all_headers = list(list(status = 200L, version = "HTTP/2", headers = structure(list(`content-encoding` = "gzip", `content-type` = "application/atom+xml", server = "Apache", `x-content-type-options` = "nosniff", `x-frame-options` = "SAMEORIGIN", `x-xss-protection` = "1; mode=block", `content-length` = "1705", `cache-control` = "no-cache", date = "Sun, 18 Apr 2021 16:54:19 GMT", vary = "Accept-Encoding", `strict-transport-security` = "max-age=31536000 ; includeSubDomains ; preload"), class = c("insensitive", "list")))), cookies = structure(list(domain = logical(0), flag = logical(0), path = logical(0), secure = logical(0), expiration = structure(numeric(0), class = c("POSIXct", "POSIXt")), name = logical(0), value = logical(0)), row.names = integer(0), class = "data.frame"), content = as.raw(c(0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x20, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x49, 0x53, 0x4f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d, 0x31, 0x22, 0x20, 0x3f, 0x3e, 0x0a, 0x3c, 0x66, 0x65, 0x65, 0x64, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x32, 0x30, 0x30, 0x35, 0x2f, 0x41, 0x74, 0x6f, 0x6d, 0x22, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x20, 0x46, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x73, 0x20, 0x2d, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20, 0x31, 0x38, 0x20, 0x41, 0x70, 0x72, 0x20, 0x32, 0x30, 0x32, 0x31, 0x20, 0x31, 0x32, 0x3a, 0x35, 0x34, 0x3a, 0x31, 0x39, 0x20, 0x45, 0x44, 0x54, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2d, 0x62, 0x69, 0x6e, 0x2f, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x2d, 0x65, 0x64, 0x67, 0x61, 0x72, 0x3f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x67, 0x65, 0x74, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x73, 0x65, 0x6c, 0x66, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2d, 0x62, 0x69, 0x6e, 0x2f, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x2d, 0x65, 0x64, 0x67, 0x61, 0x72, 0x3f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x67, 0x65, 0x74, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x63, 0x67, 0x69, 0x2d, 0x62, 0x69, 0x6e, 0x2f, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x2d, 0x65, 0x64, 0x67, 0x61, 0x72, 0x3f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x67, 0x65, 0x74, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x3e, 0x3c, 0x6e, 0x61, 0x6d, 0x65, 0x3e, 0x57, 0x65, 0x62, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x3c, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x3e, 0x3c, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x3e, 0x77, 0x65, 0x62, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x40, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x3c, 0x2f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x3e, 0x3c, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x38, 0x54, 0x31, 0x32, 0x3a, 0x35, 0x34, 0x3a, 0x31, 0x39, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x2f, 0x41, 0x20, 0x2d, 0x20, 0x42, 0x72, 0x69, 0x61, 0x6e, 0x20, 0x41, 0x72, 0x6d, 0x73, 0x74, 0x72, 0x6f, 0x6e, 0x67, 0x20, 0x4c, 0x69, 0x76, 0x69, 0x6e, 0x67, 0x20, 0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x36, 0x37, 0x30, 0x35, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x36, 0x37, 0x30, 0x35, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x31, 0x38, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x35, 0x33, 0x3a, 0x32, 0x36, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x2f, 0x41, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x2f, 0x41, 0x20, 0x2d, 0x20, 0x41, 0x72, 0x6d, 0x73, 0x74, 0x72, 0x6f, 0x6e, 0x67, 0x20, 0x42, 0x72, 0x69, 0x61, 0x6e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x34, 0x39, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x34, 0x39, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x31, 0x38, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x35, 0x33, 0x3a, 0x32, 0x36, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x2f, 0x41, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x2f, 0x41, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x31, 0x38, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x35, 0x33, 0x3a, 0x32, 0x36, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x2f, 0x41, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x35, 0x30, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x20, 0x2d, 0x20, 0x42, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x20, 0x43, 0x61, 0x70, 0x69, 0x74, 0x61, 0x6c, 0x20, 0x49, 0x6e, 0x76, 0x65, 0x73, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x6f, 0x72, 0x70, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x31, 0x31, 0x39, 0x37, 0x32, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x31, 0x31, 0x39, 0x37, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x32, 0x31, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x35, 0x32, 0x3a, 0x32, 0x32, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x20, 0x2d, 0x20, 0x43, 0x6c, 0x69, 0x66, 0x66, 0x77, 0x61, 0x74, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x72, 0x70, 0x6f, 0x72, 0x61, 0x74, 0x65, 0x20, 0x4c, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x75, 0x6e, 0x64, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x37, 0x33, 0x35, 0x39, 0x36, 0x34, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x37, 0x33, 0x35, 0x39, 0x36, 0x34, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x32, 0x31, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x35, 0x32, 0x3a, 0x32, 0x32, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x33, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x20, 0x2d, 0x20, 0x49, 0x6e, 0x76, 0x65, 0x73, 0x61, 0x74, 0x20, 0x4c, 0x4c, 0x43, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x35, 0x37, 0x30, 0x37, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x35, 0x37, 0x30, 0x37, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x32, 0x31, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x31, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x39, 0x3a, 0x34, 0x30, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x20, 0x2d, 0x20, 0x41, 0x53, 0x54, 0x20, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x37, 0x38, 0x30, 0x33, 0x31, 0x32, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x37, 0x38, 0x30, 0x33, 0x31, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x32, 0x31, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x31, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x39, 0x3a, 0x34, 0x30, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x20, 0x2d, 0x20, 0x43, 0x49, 0x53, 0x4e, 0x45, 0x52, 0x4f, 0x53, 0x20, 0x47, 0x55, 0x53, 0x54, 0x41, 0x56, 0x4f, 0x20, 0x41, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x30, 0x33, 0x34, 0x31, 0x31, 0x34, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x30, 0x33, 0x34, 0x31, 0x31, 0x34, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x32, 0x31, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x31, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x39, 0x3a, 0x34, 0x30, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x31, 0x30, 0x34, 0x36, 0x35, 0x39, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x35, 0x31, 0x35, 0x35, 0x32, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x46, 0x65, 0x6c, 0x64, 0x73, 0x63, 0x68, 0x75, 0x68, 0x20, 0x4d, 0x69, 0x63, 0x68, 0x61, 0x65, 0x6c, 0x20, 0x52, 0x69, 0x63, 0x68, 0x61, 0x72, 0x64, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x35, 0x38, 0x39, 0x34, 0x39, 0x31, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x35, 0x38, 0x39, 0x34, 0x39, 0x31, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x32, 0x31, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x35, 0x30, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x44, 0x41, 0x58, 0x4f, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, 0x20, 0x28, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x37, 0x33, 0x36, 0x37, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x32, 0x37, 0x33, 0x36, 0x37, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x32, 0x31, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x35, 0x30, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x34, 0x39, 0x33, 0x31, 0x35, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x39, 0x30, 0x36, 0x31, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x33, 0x37, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x34, 0x38, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x57, 0x49, 0x4c, 0x53, 0x4f, 0x4e, 0x20, 0x46, 0x52, 0x45, 0x44, 0x45, 0x52, 0x49, 0x43, 0x4b, 0x20, 0x52, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x32, 0x32, 0x37, 0x36, 0x38, 0x38, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x32, 0x32, 0x37, 0x36, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x33, 0x37, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x34, 0x38, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x39, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x42, 0x75, 0x72, 0x6e, 0x68, 0x61, 0x6d, 0x20, 0x42, 0x72, 0x61, 0x64, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x38, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x57, 0x65, 0x6e, 0x67, 0x65, 0x72, 0x20, 0x41, 0x6c, 0x62, 0x65, 0x72, 0x74, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x34, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x34, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x57, 0x65, 0x69, 0x73, 0x73, 0x6d, 0x61, 0x6e, 0x20, 0x41, 0x6e, 0x64, 0x79, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x42, 0x75, 0x74, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x20, 0x4a, 0x6f, 0x68, 0x6e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x31, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x34, 0x30, 0x30, 0x31, 0x31, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x55, 0x53, 0x56, 0x20, 0x4f, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x20, 0x32, 0x30, 0x31, 0x34, 0x20, 0x47, 0x50, 0x2c, 0x20, 0x4c, 0x4c, 0x43, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x35, 0x39, 0x37, 0x38, 0x31, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x35, 0x39, 0x37, 0x38, 0x31, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x55, 0x53, 0x56, 0x20, 0x4f, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x20, 0x49, 0x6e, 0x76, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x20, 0x32, 0x30, 0x31, 0x34, 0x2c, 0x20, 0x4c, 0x50, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x35, 0x39, 0x37, 0x38, 0x30, 0x38, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x35, 0x39, 0x37, 0x38, 0x30, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x55, 0x53, 0x56, 0x20, 0x4f, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x20, 0x32, 0x30, 0x31, 0x34, 0x2c, 0x20, 0x4c, 0x50, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x35, 0x39, 0x37, 0x37, 0x39, 0x33, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x35, 0x39, 0x37, 0x37, 0x39, 0x33, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x55, 0x53, 0x56, 0x20, 0x49, 0x6e, 0x76, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x20, 0x32, 0x30, 0x31, 0x32, 0x20, 0x46, 0x75, 0x6e, 0x64, 0x2c, 0x20, 0x4c, 0x2e, 0x50, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x35, 0x33, 0x37, 0x34, 0x35, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x35, 0x33, 0x37, 0x34, 0x35, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x20, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x20, 0x32, 0x30, 0x31, 0x32, 0x20, 0x47, 0x50, 0x2c, 0x20, 0x4c, 0x2e, 0x4c, 0x2e, 0x43, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x35, 0x33, 0x32, 0x31, 0x38, 0x30, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x35, 0x33, 0x32, 0x31, 0x38, 0x30, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x20, 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x20, 0x56, 0x65, 0x6e, 0x74, 0x75, 0x72, 0x65, 0x73, 0x20, 0x32, 0x30, 0x31, 0x32, 0x20, 0x46, 0x75, 0x6e, 0x64, 0x2c, 0x20, 0x4c, 0x2e, 0x50, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x35, 0x33, 0x32, 0x31, 0x37, 0x39, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x35, 0x33, 0x32, 0x31, 0x37, 0x39, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x35, 0x3a, 0x32, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x38, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x4a, 0x6f, 0x6e, 0x65, 0x73, 0x20, 0x4a, 0x65, 0x6e, 0x6e, 0x69, 0x66, 0x65, 0x72, 0x20, 0x4e, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x34, 0x33, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x34, 0x33, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x31, 0x35, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x34, 0x3a, 0x34, 0x37, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x31, 0x35, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x34, 0x3a, 0x34, 0x37, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x37, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x48, 0x61, 0x75, 0x6e, 0x20, 0x4b, 0x61, 0x74, 0x68, 0x72, 0x79, 0x6e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x34, 0x32, 0x35, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x34, 0x32, 0x35, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x34, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x34, 0x3a, 0x30, 0x30, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x34, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x34, 0x3a, 0x30, 0x30, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x36, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x31, 0x39, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x33, 0x3a, 0x32, 0x36, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x48, 0x41, 0x41, 0x53, 0x20, 0x41, 0x4c, 0x45, 0x53, 0x49, 0x41, 0x20, 0x4a, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x36, 0x38, 0x37, 0x31, 0x31, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x36, 0x38, 0x37, 0x31, 0x31, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x31, 0x39, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x33, 0x3a, 0x32, 0x36, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x35, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x45, 0x68, 0x72, 0x73, 0x61, 0x6d, 0x20, 0x46, 0x72, 0x65, 0x64, 0x65, 0x72, 0x69, 0x63, 0x6b, 0x20, 0x45, 0x72, 0x6e, 0x65, 0x73, 0x74, 0x20, 0x49, 0x49, 0x49, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x34, 0x34, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x34, 0x34, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x36, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x32, 0x3a, 0x35, 0x36, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x34, 0x36, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x32, 0x3a, 0x35, 0x36, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x34, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x45, 0x68, 0x72, 0x73, 0x61, 0x6d, 0x20, 0x46, 0x72, 0x65, 0x64, 0x65, 0x72, 0x69, 0x63, 0x6b, 0x20, 0x45, 0x72, 0x6e, 0x65, 0x73, 0x74, 0x20, 0x49, 0x49, 0x49, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x34, 0x34, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x34, 0x34, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x33, 0x36, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x32, 0x3a, 0x31, 0x32, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x33, 0x36, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x32, 0x3a, 0x31, 0x32, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x33, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x45, 0x68, 0x72, 0x73, 0x61, 0x6d, 0x20, 0x46, 0x72, 0x65, 0x64, 0x65, 0x72, 0x69, 0x63, 0x6b, 0x20, 0x45, 0x72, 0x6e, 0x65, 0x73, 0x74, 0x20, 0x49, 0x49, 0x49, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x34, 0x34, 0x32, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x34, 0x34, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x36, 0x31, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x31, 0x3a, 0x33, 0x35, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x36, 0x31, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x31, 0x3a, 0x33, 0x35, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x32, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x68, 0x6f, 0x69, 0x20, 0x45, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x36, 0x35, 0x38, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x36, 0x35, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x31, 0x3a, 0x30, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x32, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x31, 0x3a, 0x30, 0x33, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x31, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x68, 0x6f, 0x69, 0x20, 0x45, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x31, 0x36, 0x35, 0x38, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x31, 0x36, 0x35, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x36, 0x30, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x30, 0x3a, 0x32, 0x37, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x34, 0x20, 0x2d, 0x20, 0x43, 0x6f, 0x69, 0x6e, 0x62, 0x61, 0x73, 0x65, 0x20, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x29, 0x20, 0x28, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x36, 0x37, 0x39, 0x37, 0x38, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x32, 0x31, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x36, 0x30, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x30, 0x3a, 0x32, 0x37, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x34, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x32, 0x30, 0x39, 0x31, 0x39, 0x31, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x37, 0x31, 0x34, 0x30, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x33, 0x20, 0x2d, 0x20, 0x56, 0x6f, 0x64, 0x61, 0x66, 0x6f, 0x6e, 0x65, 0x20, 0x56, 0x65, 0x6e, 0x74, 0x75, 0x72, 0x65, 0x73, 0x20, 0x4c, 0x74, 0x64, 0x20, 0x28, 0x30, 0x30, 0x30, 0x31, 0x38, 0x35, 0x35, 0x34, 0x32, 0x38, 0x29, 0x20, 0x28, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x29, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0a, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x65, 0x64, 0x67, 0x61, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x31, 0x38, 0x35, 0x35, 0x34, 0x32, 0x38, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x32, 0x39, 0x32, 0x32, 0x31, 0x30, 0x30, 0x30, 0x36, 0x32, 0x37, 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x32, 0x39, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x30, 0x36, 0x32, 0x37, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x0a, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x46, 0x69, 0x6c, 0x65, 0x64, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x41, 0x63, 0x63, 0x4e, 0x6f, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x30, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x32, 0x39, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x30, 0x36, 0x32, 0x37, 0x20, 0x26, 0x6c, 0x74, 0x3b, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x53, 0x69, 0x7a, 0x65, 0x3a, 0x26, 0x6c, 0x74, 0x3b, 0x2f, 0x62, 0x26, 0x67, 0x74, 0x3b, 0x20, 0x39, 0x20, 0x4b, 0x42, 0x0a, 0x3c, 0x2f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x32, 0x30, 0x32, 0x31, 0x2d, 0x30, 0x34, 0x2d, 0x31, 0x36, 0x54, 0x32, 0x31, 0x3a, 0x34, 0x30, 0x3a, 0x31, 0x39, 0x2d, 0x30, 0x34, 0x3a, 0x30, 0x30, 0x3c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x3e, 0x0a, 0x3c, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x20, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2f, 0x22, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3d, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x65, 0x72, 0x6d, 0x3d, 0x22, 0x33, 0x22, 0x2f, 0x3e, 0x0a, 0x3c, 0x69, 0x64, 0x3e, 0x75, 0x72, 0x6e, 0x3a, 0x74, 0x61, 0x67, 0x3a, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x6f, 0x76, 0x2c, 0x32, 0x30, 0x30, 0x38, 0x3a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3d, 0x30, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x32, 0x39, 0x32, 0x2d, 0x32, 0x31, 0x2d, 0x30, 0x30, 0x30, 0x36, 0x32, 0x37, 0x3c, 0x2f, 0x69, 0x64, 0x3e, 0x0a, 0x3c, 0x2f, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x3e, 0x0a, 0x3c, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x3e, 0x0a)), date = structure(1618764859, class = c("POSIXct", "POSIXt"), tzone = "GMT"), times = c(redirect = 0, namelookup = 2.4e-05, connect = 2.5e-05, pretransfer = 7.9e-05, starttransfer = 0.093213, total = 0.093385)), class = "response")
report.bayesfactor_models <- function(x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { out <- .report.bayesfactor_models( x, interpretation = interpretation, exact = exact, protect_ratio = protect_ratio, ... ) as.report( text = as.report_text(out$text_full, summary = out$text_short), table = as.report_table(out$table_full, summary = out$table_short), rules = out$rules, denominator = out$denominator, BF_method = out$BF_method ) } report_table.bayesfactor_models <- function(x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { out <- .report.bayesfactor_models( x, interpretation = interpretation, exact = exact, protect_ratio = protect_ratio, ... ) as.report_table(out$table_full, summary = out$table_short, rules = out$rules, denominator = out$denominator, BF_method = out$BF_method ) } report_text.bayesfactor_models <- function(x, table = NULL, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { out <- .report.bayesfactor_models( x, interpretation = interpretation, exact = exact, protect_ratio = protect_ratio, ... ) as.report_text(out$text_full, summary = out$text_short, rules = out$rules, denominator = out$denominator, BF_method = out$BF_method ) } .report.bayesfactor_models <- function(model, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { model$Model[model$Model == "1"] <- "(Intercept only)" denominator <- attr(model, "denominator") BF_method <- attr(model, "BF_method") max_den <- which.max(exp(model$log_BF)) min_den <- which.min(exp(model$log_BF)) model_ind <- rep("", nrow(model)) model_ind[max_den] <- " (the most supported model)" model_ind[min_den] <- " (the least supported model)" summ_inds <- c(max_den, min_den) summ_inds <- summ_inds[summ_inds != denominator] bf_text <- paste0( "Compared to the ", model$Model[denominator], " model", model_ind[denominator], ", ", "we found ", paste0( effectsize::interpret_bf(exp(model$log_BF)[summ_inds], rules = interpretation, include_value = TRUE, exact = exact, protect_ratio = protect_ratio ), " the ", model$Model[summ_inds], " model", model_ind[summ_inds], collapse = "; " ), "." ) if (grepl("BIC", BF_method)) { bf_explain <- paste0( "Bayes factors were computed using the BIC approximation, ", "by which BF10 = exp((BIC0 - BIC1)/2). " ) } else if (grepl("JZS", BF_method)) { bf_explain <- paste0( "Bayes factors were computed with the `BayesFactor` package, ", "using JZS priors. " ) } else if (grepl("bridgesampling", BF_method)) { bf_explain <- paste0( "Bayes factors were computed by comparing marginal likelihoods, ", "using the `bridgesampling` package. " ) } bf_text_full <- paste0(bf_explain, paste0( "Compared to the ", model$Model[denominator], " model", model_ind[denominator], ", ", "we found ", paste0( effectsize::interpret_bf(exp(model$log_BF)[-denominator], rules = interpretation, include_value = TRUE, exact = exact, protect_ratio = protect_ratio ), " the ", model$Model[-denominator], " model", model_ind[-denominator], collapse = "; " ), "." )) model$Model <- paste0(" [", seq_len(nrow(model)), "] ", model$Model) bf_table <- as.data.frame(model) bf_table$BF <- insight::format_bf(exp(model$log_BF), name = NULL, exact = exact, protect_ratio = protect_ratio ) colnames(bf_table) <- c("Model", "Bayes factor") footer <- list( paste0("\nBayes Factor Type: ", BF_method), paste0("\nAgainst denominator: Model ", denominator) ) attr(bf_table, "table_footer") <- footer bf_table_full <- bf_table bf_table_full$BF2 <- insight::format_bf(exp(model$log_BF) / exp(model$log_BF)[max_den], name = NULL, exact = exact, protect_ratio = protect_ratio ) colnames(bf_table_full) <- c( "Model", paste0("BF against model ", denominator, ""), paste0("BF against model ", max_den, " (best model)") ) out <- list( table_full = bf_table_full, table_short = bf_table, text_full = bf_text_full, text_short = bf_text, rules = interpretation, denominator = denominator, BF_method = BF_method ) } report.bayesfactor_inclusion <- function(x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { out <- .report.bayesfactor_inclusion( x, interpretation = interpretation, exact = exact, protect_ratio = protect_ratio, ... ) as.report( text = as.report_text(out$text_full, summary = out$text_short), table = as.report_table(out$table_full, summary = out$table_short), interpretation = out$interpretation, priorOdds = out$priorOdds, matched = out$matched ) } report_table.bayesfactor_inclusion <- function(x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { out <- .report.bayesfactor_inclusion( x, interpretation = interpretation, exact = exact, protect_ratio = protect_ratio, ... ) as.report_table(out$table_full, summary = out$table_short, interpretation = out$interpretation, priorOdds = out$priorOdds, matched = out$matched ) } report_text.bayesfactor_inclusion <- function(x, table = NULL, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { out <- .report.bayesfactor_inclusion( x, interpretation = interpretation, exact = exact, protect_ratio = protect_ratio, ... ) as.report_text(out$text_full, summary = out$text_short, interpretation = out$interpretation, priorOdds = out$priorOdds, matched = out$matched ) } .report.bayesfactor_inclusion <- function(model, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ...) { matched <- attr(model, "matched") priorOdds <- attr(model, "priorOdds") bf_results <- data.frame(Term = rownames(model), stringsAsFactors = FALSE) bf_results$evidence <- effectsize::interpret_bf(exp(model$log_BF), rules = interpretation, include_value = TRUE, exact = exact, protect_ratio = protect_ratio ) bf_results$postprob <- paste0(round(model$p_posterior * 100, ...), "%") bf_text <- paste0( "Bayesian model averaging (BMA) was used to obtain the average evidence ", "for each predictor. We found ", paste0( paste0(bf_results$evidence, " including ", bf_results$Term), collapse = "; " ), "." ) bf_explain <- paste0( "Bayesian model averaging (BMA) was used to obtain the average evidence ", "for each predictor. Since each model has a prior probability", if (is.null(priorOdds)) { NULL } else { paste0( " (here we used subjective prior odds of ", paste0(priorOdds, collapse = ", "), ")" ) }, ", it is possible to sum the prior probability of all models that include ", "a predictor of interest (the prior inclusion probability), and of all ", "models that do not include that predictor (the prior exclusion probability). ", "After the data are observed, we can similarly consider the sums of the ", "posterior models' probabilities to obtain the posterior inclusion ", "probability and the posterior exclusion probability. The change from ", "prior to posterior inclusion odds is the Inclusion Bayes factor. ", if (!matched) { NULL } else { paste0( "For each predictor, averaging was done only across models that ", "did not include any interactions with that predictor; ", "additionally, for each interaction predictor, averaging was done ", "only across models that contained the main effect from which the ", "interaction predictor was comprised. This was done to prevent ", "Inclusion Bayes factors from being contaminated with non-relevant ", "evidence (see Mathot, 2017). " ) } ) bf_text_full <- paste0( bf_explain, paste0( "We found ", paste0( paste0( bf_results$evidence, " including ", bf_results$Term, ", with models including ", bf_results$Term, " having an overall posterior probability of ", bf_results$postprob ), collapse = "; " ), "." ) ) bf_table <- as.data.frame(model) colnames(bf_table) <- c("Pr(prior)", "Pr(posterior)", "Inclusion BF") bf_table <- cbind(Terms = rownames(bf_table), bf_table) rownames(bf_table) <- NULL bf_table$`Inclusion BF` <- insight::format_bf( bf_table$`Inclusion BF`, name = NULL, exact = exact, protect_ratio = protect_ratio ) bf_table[, 2:3] <- insight::format_value(bf_table[, 2:3], ...) footer <- list( sprintf("\nAcross %s", ifelse(matched, "matched models only.", "all models.")), ifelse(is.null(priorOdds), "\nAssuming unifor prior odds.", paste0("\nWith custom prior odds of [", paste0(priorOdds, collapse = ", "), "].") ) ) attr(bf_table, "table_footer") <- footer bf_table_full <- bf_table out <- list( table_full = bf_table_full, table_short = bf_table, text_full = bf_text_full, text_short = bf_text, interpretation = interpretation, priorOdds = priorOdds, matched = matched, ... ) }
run_nm <- function(m, ignore.stdout = TRUE, ignore.stderr = TRUE, quiet = getOption("quiet_run"), intern = getOption("intern"), force = FALSE, cache_ignore_cmd = FALSE, cache_ignore_ctl = FALSE, cache_ignore_data = FALSE) { UseMethod("run_nm") } run_nm.nm_generic <- function(m, ignore.stdout = TRUE, ignore.stderr = TRUE, quiet = getOption("quiet_run"), intern = getOption("intern"), force = FALSE, cache_ignore_cmd = FALSE, cache_ignore_ctl = FALSE, cache_ignore_data = FALSE) { if (is.na(m)) { return(m) } ctl <- ctl_contents(m) if (length(ctl) == 1) { if (is.na(ctl)) { warning("no ctl_contents defined. Use ?based_on") return(m) } } m %>% write_ctl() if (!force) { if (length(run_cache_paths(m)) > 0) { run_cache_disk <- readRDS(run_cache_paths(m)) current_checksums <- run_checksums(m) if (cache_ignore_cmd) { keep <- !names(current_checksums) %in% "cmd" run_cache_disk$checksums <- run_cache_disk$checksums[keep] current_checksums <- current_checksums[keep] } if (cache_ignore_ctl) { keep <- !names(current_checksums) %in% "ctl" run_cache_disk$checksums <- run_cache_disk$checksums[keep] current_checksums <- current_checksums[keep] } if (cache_ignore_data) { keep <- !names(current_checksums) %in% "data" run_cache_disk$checksums <- run_cache_disk$checksums[keep] current_checksums <- current_checksums[keep] } names(current_checksums) <- NULL names(run_cache_disk$checksums) <- NULL matched <- identical(run_cache_disk$checksums, current_checksums) if (matched) { if (!is_finished(m)) { warning("run was previously executed but has is_finished() status = FALSE") } message("rebuilding run from cache... use run_nm(force = TRUE) to override") m <- m %>% executed(TRUE) m <- m %>% job_info(run_cache_disk$job_info) m <- m %>% save_run_cache() return(invisible(m)) } } } behaviour <- overwrite_behaviour() if ("skip" %in% behaviour) { message("skipping step as it would require overwriting \n change behaviour with overwrite_behaviour()") return(invisible(m)) } if (.sso_env$run_count == 0 & !force) { tryCatch(psn_check(fail_if_false = TRUE), error = function(e){ usethis::ui_stop("This message will only appear on first attempt to run NONMEM in the active R session. Failed: {usethis::ui_code('psn_check()')}. This is either due to a missing or incorrectly configured PsN installation or {usethis::ui_code('system_nm()')} not being configured for your system. Ensure PsN (and NONMEM) are installed and available from the command line with {usethis::ui_code('system_nm()')} and {usethis::ui_code('system_nm_intern()')}. The command {usethis::ui_code('system_nm_intern(\"psn --version\")')} should return the PsN version number. See {usethis::ui_path('https://uupharmacometrics.github.io/PsN/')} for instructions to install or re-install PsN. If PsN is installed, you may need to configure {usethis::ui_code('system_nm()')}. See {usethis::ui_code('?system_nm')} for config help. If you want to overide this message for future R session, use {usethis::ui_code('force = TRUE')}") }) } .sso_env$run_count <- .sso_env$run_count + 1 wipe_run(m) kill_job(m) message(paste0("Running: ", type(m), ":", ctl_path(m))) stdout0 <- system_nm( cmd = cmd(m), dir = run_in(m), wait = FALSE, ignore.stdout = FALSE, ignore.stderr = FALSE, intern = intern ) if (intern) { cat(stdout0, sep = "\n") job_info <- getOption("get_job_info")(stdout0) if (is.null(job_info)) job_info <- NA } else { job_info <- NA } m <- m %>% executed(TRUE) m <- m %>% job_info(job_info) m <- m %>% save_run_cache() invisible(m) } run_nm.nm_list <- Vectorize_nm_list(run_nm.nm_generic, SIMPLIFY = FALSE, invisible = TRUE) run_nm_batch <- function(m, threads = 10, ...) { runs_remaining <- seq_along(m) while (length(runs_remaining) > 0) { n_to_take <- min(threads, length(runs_remaining)) runs_to_run <- runs_remaining[seq_len(n_to_take)] m_sub <- m[runs_to_run] run_nm(m_sub, ...) runs_remaining <- setdiff(runs_remaining, runs_to_run) if (length(runs_remaining) > 0) wait_finish(m_sub) } m } wipe_run <- function(r) { UseMethod("wipe_run") } wipe_run.nm_generic <- function(r) { psn_exported_files <- psn_exported_files(r) lst_path <- file.path(run_in(r), lst_path(r)) run_dir_to_delete <- file.path(run_in(r), run_dir(r)) if (!file.exists(run_dir_to_delete)) { run_dir_to_delete <- c() } else { if (run_dir_to_delete %in% c(".", ".\\")) { run_dir_to_delete <- c() } else { if (normalizePath(run_dir_to_delete) == normalizePath(run_in(r))) run_dir_to_delete <- c() } } ctl_out_files <- c(lst_path, psn_exported_files, run_dir_to_delete) existing_ctl_out_files <- ctl_out_files[file.exists(ctl_out_files)] behaviour <- overwrite_behaviour() if ("stop" %in% behaviour & length(existing_ctl_out_files) > 0) { stop( "no overwriting allowed, stopping due to following files/directories:\n ", paste(paste(existing_ctl_out_files, collapse = "\n ")) ) } prompt_overwrite(rev(existing_ctl_out_files)) unlink(ctl_out_files, recursive = TRUE, force = TRUE) invisible() } wipe_run.nm_list <- Vectorize_nm_list(wipe_run.nm_generic, SIMPLIFY = FALSE, invisible = TRUE) psn_exported_files <- function(r, minimal = FALSE) { UseMethod("psn_exported_files") } psn_exported_files.nm_generic <- function(r, minimal = FALSE) { if (minimal) { output_files <- paste0( tools::file_path_sans_ext(ctl_path(r)), c(".ext") ) } else { output_files <- paste0( tools::file_path_sans_ext(ctl_path(r)), c(".phi", ".ext", ".cov", ".coi", ".cor", ".lst") ) } if (minimal) { ctl_out_files <- c(output_files) } else { exported_table_paths <- file.path(run_in(r), ctl_table_files(ctl_contents(r))) ctl_out_files <- c(output_files, exported_table_paths) } ctl_out_files } psn_exported_files.nm_list <- Vectorize_nm_list(psn_exported_files.nm_generic, SIMPLIFY = FALSE) ctl_table_files <- function(ctl) { UseMethod("ctl_table_files") } ctl_table_files.default <- function(ctl) { ctl <- ctl_character(ctl) s0 <- rem_comment(ctl) s <- grep("FILE\\s*=\\s*(\\S+)", s0, value = TRUE) table_files <- gsub(".*FILE\\s*=\\s*(\\S+)\\s*.*$", "\\1", s) table_files } ls_tempfiles <- function(object = ".", output_loc = c("run_dir", "base"), run_files = NA_character_, include_slurm_files = TRUE, ctl_extension = "mod", include_psn_exports = FALSE) { UseMethod("ls_tempfiles") } ls_tempfiles.default <- function(object = ".", output_loc = c("run_dir", "base"), run_files = NA_character_, include_slurm_files = TRUE, ctl_extension = "mod", include_psn_exports = FALSE) { output_loc <- match.arg(output_loc) if (length(run_files) == 0) return(character()) if (identical(run_files, NA_character_)) { all_run_dirs <- list_dirs( object, pattern = "NM_run[0-9]+", recursive = TRUE, full.names = TRUE, maxdepth = Inf ) if (length(all_run_dirs) == 0) { return(character()) } else { all_run_files <- dir(all_run_dirs, full.names = TRUE) } all_outside_run_dirs <- file.path(all_run_dirs, "..") all_outside_run_files <- dir(all_outside_run_dirs, full.names = TRUE) all_run_files <- c(all_run_files, all_outside_run_files) } else { all_run_files <- run_files } temp_files <- c() non_temp_files <- c() all_psn.mod <- all_run_files[basename(all_run_files) == "psn.mod"] non_temp_files <- c(non_temp_files, all_psn.mod) all_run_dir_table_files <- lapply(all_psn.mod, function(psn.mod) { file.path(dirname(psn.mod), ctl_table_files(psn.mod)) }) all_run_dir_table_files <- unlist(all_run_dir_table_files) non_temp_files <- c(non_temp_files, all_run_dir_table_files) all_base_tables <- all_run_dir_table_files all_base_table_dir <- dirname(all_base_tables) all_base_table_dir <- file.path(all_base_table_dir, "..", "..") all_base_table_dir <- normalizePath(all_base_table_dir) if (output_loc == "run_dir") { all_base_tables <- file.path(all_base_table_dir, basename(all_run_dir_table_files)) all_base_tables <- all_base_tables[file.exists(all_base_tables)] if (include_psn_exports) temp_files <- c(temp_files, all_base_tables) all_base_mod_files <- dir(unique(all_base_table_dir), pattern = paste0("\\.", ctl_extension, "$"), full.names = TRUE ) all_base_stubs <- tools::file_path_sans_ext(all_base_mod_files) all_base_psn_files <- lapply(all_base_stubs, function(base_mod_stub) { base_dir <- dirname(base_mod_stub) stub <- basename(base_mod_stub) dir(base_dir, pattern = paste0("^", stub, "\\..*"), full.names = TRUE) }) all_base_psn_files <- unlist(all_base_psn_files) all_base_psn_files <- all_base_psn_files[ !tools::file_ext(all_base_psn_files) %in% c("mod", "lst") ] if (include_psn_exports) temp_files <- c(temp_files, all_base_psn_files) } temp_files <- c(temp_files, all_run_files[grepl("temp_dir", all_run_files)]) temp_files <- c(temp_files, all_run_files[tools::file_ext(basename(all_run_files)) %in% c("o", "f90", "Rmd", "csv")]) temp_files <- c( temp_files, all_run_files[basename(all_run_files) %in% c( "INTER", "fort.2002", "model_NMrun_translation.txt", "modelfit.log", "raw_results_structure", "version_and_option_info.txt" )] ) temp_files <- setdiff(temp_files, non_temp_files) temp_dirs <- temp_files[file.info(temp_files)$isdir] temp_dir_files <- dir(temp_dirs, full.names = TRUE, recursive = TRUE) temp_files <- c( temp_files[!temp_files %in% temp_dirs], temp_dir_files ) if (length(temp_files) == 0) { return(character()) } relative_path(temp_files, getwd()) } ls_tempfiles.nm_list <- function(object = ".", output_loc = c("run_dir", "base"), run_files = NA_character_, include_slurm_files = TRUE, ctl_extension = "mod", include_psn_exports = FALSE) { output_loc <- match.arg(output_loc) if (output_loc %in% "run_dir") { all_run_dirs <- list_dirs( run_dir_path(object), pattern = "NM_run[0-9]+", full.names = TRUE ) } else { all_run_dirs <- list_dirs( run_in(object), full.names = TRUE ) } all_run_files <- dir(all_run_dirs, full.names = TRUE) ls_tempfiles( run_files = all_run_files, output_loc = output_loc, ctl_extension = tools::file_ext(ctl_name(object)), include_psn_exports = include_psn_exports ) } clean_run <- function(m, output_loc = c("run_dir", "base"), include_slurm_files = TRUE) { .Deprecated("clean_tempfiles") UseMethod("clean_run") } clean_run.nm_list <- function(m, output_loc = c("run_dir", "base"), include_slurm_files = TRUE) { ls_tempfiles(m, output_loc = output_loc) %>% unlink(force = TRUE) } clean_tempfiles <- function(object = ".", output_loc = c("run_dir", "base"), include_slurm_files = TRUE) { UseMethod("clean_run") } clean_tempfiles.nm_list <- function(object = ".", output_loc = c("run_dir", "base"), include_slurm_files = TRUE) { ls_tempfiles(object, output_loc = output_loc) %>% unlink(force = TRUE) } write_ctl <- function(m, force = FALSE) { UseMethod("write_ctl") } write_ctl.nm_generic <- function(m, force = FALSE) { ctl_name <- ctl_path(m) ctl_ob <- ctl_contents(m) %>% ctl_character() dir_name <- run_in(m) if (!file.exists(dir_name)) { dir.create(dir_name, showWarnings = FALSE, recursive = TRUE) } if (file.exists(ctl_name) & !force) { behaviour <- overwrite_behaviour() old_contents <- readLines(ctl_name) new_contents <- ctl_ob attributes(new_contents) <- NULL overwrite_required <- !identical(new_contents, old_contents) if (overwrite_required) { if ("stop" %in% behaviour) { stop("stopping because overwrite required: change behaviour in overwrite_behaviour()") } if ("ask" %in% behaviour) { prompt_overwrite(ctl_name, new_path_contents = ctl_ob) } if ("skip" %in% behaviour) { return(invisible(m)) } } } writeLines(ctl_ob, ctl_name) invisible(m) } write_ctl.nm_list <- Vectorize_nm_list(write_ctl.nm_generic, SIMPLIFY = FALSE, invisible = TRUE) data_name <- function(x) UseMethod("data_name") data_name.default <- function(x) { unlist(lapply(x, function(x) { if (!file.exists(x)) x <- file.path(nm_dir("models"), x) if (!file.exists(x)) stop("can't find control stream") x <- normalizePath(x) ctl <- readLines(x, warn = FALSE) data.row <- grep("^ *\\$DATA", ctl) if (length(data.row) < 1) stop("can't identify data row") if (length(data.row) > 1) { warning("multiple data rows found. Using first") data.row <- data.row[1] } ctl <- paste(ctl[data.row:length(ctl)], collapse = " ") data_name <- gsub("^ *\\$DATA\\s*([^ ]+).*$", "\\1", ctl) data_name })) }
if (!require("fritools", character.only = TRUE)) install.packages("fritools", repos = "https://cloud.r-project.org/") r <- fritools::is_running_on_gitlab_com(verbose = TRUE) warning(attr(r, "message")) print(r) if (!isTRUE(r)) { stop("fritools: Do not recognize gitlab.com") } else { message("Node is ", Sys.info()[["nodename"]], ", I guess this is gitlab.com.") }
"kfascv" <- function(xt,cov,k=np,mdx=nrow(xt),f=.dFvGet()$fff,sg,ip) { if (missing(xt)) messagena("xt") np <- ncol(xt) ncov <- length(cov) if (missing(cov)) cov <- single(ncov) se <- single(np) if (missing(sg)) sg <- single(np) if (missing(ip)) ip <- integer(np) f.res <- .Fortran("kfascvz", xt=to.single(xt), cov=to.single(cov), k=to.integer(k), np=to.integer(np), mdx=to.integer(mdx), ncov=to.integer(ncov), f=to.single(f), se=to.single(se), sg=to.single(sg), ip=to.integer(ip)) list(cov=f.res$cov) }
getIdCols <- function(x = NULL) { if (!is(x, "antaresDataTable") || is.null(x)) stop("x has to be an 'antaresDataTable' object") .idCols(x) }
library(RoughSets) data(RoughSetData) decision.table <- RoughSetData$hiring.dt res.1 <- FS.quickreduct.RST(decision.table) print(res.1) new.decTable <- SF.applyDecTable(decision.table, res.1) print(new.decTable)
{ library(vroom) data <- vroom(file, col_types = c(pickup_datetime = "c")) vroom:::vroom_materialize(data, replace = TRUE) } { con <- gzfile(tempfile(fileext = ".gz"), "wb") write.table(data, con, sep = "\t", quote = FALSE, row.names = FALSE) close(con) }
plot.smacofPerm <- function(x, alpha = 0.05, main, xlab, ylab, ...) { if (missing(main)) main <- "ECDF SMACOF Permutation Test" else main <- main if (missing(xlab)) xlab <- "Stress Values" else xlab <- xlab if (missing(ylab)) ylab <- "Probability" else ylab <- ylab Ecdf(x$stressvec, main = main, xlab = xlab, ylab = ylab, subtitles = FALSE, ...) abline(v = x$stress.obs, col = "gray", lty = 1) text(x$stress.obs, y = 1, labels = paste("Stress: ",round(x$stress.obs, 3), sep = ""), col = "gray", pos = 4, cex = 0.7) abline(h = x$pval, col = "gray", lty = 1) if (x$pval == 0) { pp <- "<0.001" text(max(x$stressvec)-0.01*max(x$stressvec), y = x$pval, labels = paste("p-value: ", pp, sep = ""), col = "gray", pos = 3, cex = 0.7) } else { pp <- x$pval text(max(x$stressvec)-0.01*max(x$stressvec), y = x$pval, labels = paste("p-value: ", round(pp, 3), sep = ""), col = "gray", pos = 3, cex = 0.7) } abline(h = alpha, col = "gray", lty = 2) }
plot.group_metric <- function(x, ...) { data <- x$group_metric_data performance_data <- x$performance_data fairness_metric <- x$fairness_metric performance_metric <- x$performance_metric n <- length(unique(data$model)) model <- group <- score <- label <- NULL plot1 <- ggplot(data, aes(x = group, y = score, fill = model)) + geom_bar( stat = "identity", position = "dodge" ) + DALEX::theme_drwhy() + theme( axis.text.x = element_text(angle = 90, hjust = 1), legend.position = "none" ) + ylab(fairness_metric) + xlab("subgroups") + scale_fill_manual(values = colors_fairmodels(n)) + ggtitle("Group metric plot") plot2 <- ggplot(performance_data, aes(x = model, y = score, fill = model)) + geom_bar( stat = "identity", width = 0.4 ) + geom_text(aes(label = round(score, 3)), vjust = -1, color = "black", size = 3, fontface = "bold" ) + DALEX::theme_drwhy() + theme( legend.title = element_blank(), axis.text.x = element_text(angle = 90, hjust = 0.3) ) + scale_fill_manual(values = colors_fairmodels(n)) + scale_y_continuous(limits = c(0, 1)) + xlab("Models") + ylab(performance_metric) plot1 + plot2 }
"latent<-" <- function(x,...,value) UseMethod("latent<-") "latent<-.lvm" <- function(x, clear=FALSE,..., value) { if (inherits(value,"formula")) { return(latent(x,all.vars(value),clear=clear,...)) } latent(x, var=value, clear=clear,...) } `latent` <- function(x,...) UseMethod("latent") `latent.lvm` <- function(x,var,clear=FALSE,messages=lava.options()$messages,...) { if (missing(var)) { latentidx <- unlist(x$latent) if (length(latentidx)>0) return(names(latentidx)) else return(NULL) } if (inherits(var,"formula")) var <- all.vars(var) if (clear) { x$noderender$shape[var] <- "rectangle" x$latent[var] <- NULL } else { if (!all(var%in%vars(x))) { addvar(x,messages=messages,reindex=FALSE,) <- setdiff(var,vars(x)) } x$noderender$shape[var] <- "ellipse" x$latent[var] <- TRUE ord <- intersect(var,ordinal(x)) if (length(ord)>0) ordinal(x,K=NULL) <- ord } xorg <- exogenous(x) exoset <- setdiff(xorg,var) if (length(exoset)<length(xorg)) { exogenous(x) <- exoset } index(x) <- reindex(x) return(x) } `latent.lvmfit` <- function(x,clear=FALSE,...) { latent(Model(x),...) } latent.list <- function(x,...) { latlist <- c() for (i in seq_along(x)) { latlist <- c(latlist, latent(x[[i]])) } latlist <- unique(latlist) return(latlist) } `latent.multigroup` <- function(x,...) { latent(Model(x)) }
kmunionclosure <- function(x) { if (!inherits(x, "matrix")) { stop(sprintf("%s must be of class %s.", dQuote("x"), dQuote("matrix"))) } if (any(x != 1*as.logical(x))) { stop(sprintf("%s must be a binary matrix.", dQuote("x"))) } noi <- dim(x)[2] nob <- dim(x)[1] f <- matrix(rep(0L, noi), nrow = 1, ncol = noi) lapply(as.list(1:nob), function(i) { f2 <- t(apply(f, 1, function(s) {1L*(s | x[i,])})) f <<- unique(rbind(f, f2)) }) storage.mode(f) <- "integer" f }
library(plyr) suppressPackageStartupMessages(library(dplyr)) library(ggplot2) library(readr) gap_dat <- read_tsv("05_gap-merged-with-china-1952.tsv") %>% mutate(country = factor(country), continent = factor(continent)) gap_dat %>% str gap_dat$continent %>% summary() tmp <- gap_dat %>% filter(continent == "FSU") %>% droplevels() tmp$country %>% levels() tmp <- gap_dat %>% filter(is.na(continent)) %>% droplevels() tmp$country %>% levels() cont_dat <- frame_data( ~country, ~continent, 'Armenia', 'FSU', 'Aruba', 'Americas', 'Australia', 'Oceania', 'Bahamas', 'Americas', 'Barbados', 'Americas', 'Belize', 'Americas', 'Canada', 'Americas', 'French Guiana', 'Americas', 'French Polynesia', 'Oceania', 'Georgia', 'FSU', 'Grenada', 'Americas', 'Guadeloupe', 'Americas', 'Haiti', 'Americas', 'Hong Kong, China', 'Asia', 'Maldives', 'Asia', 'Martinique', 'Americas', 'Micronesia, Fed. Sts.', 'Oceania', 'Netherlands Antilles', 'Americas', 'New Caledonia', 'Oceania', 'Papua New Guinea', 'Oceania', 'Reunion', 'Africa', 'Samoa', 'Oceania', 'Sao Tome and Principe', 'Africa', 'Tonga', 'Oceania', 'Uzbekistan', 'FSU', 'Vanuatu', 'Oceania') gap_dat <- gap_dat %>% merge(cont_dat, by = "country", all = TRUE) %>% tbl_df() %>% mutate(continent = factor(ifelse(is.na(continent.y), as.character(continent.x), as.character(continent.y))), continent.x = NULL, continent.y = NULL) %>% arrange(country, year) gap_dat %>% str() gap_dat$continent %>% summary() my_vars <- c('country', 'continent', 'year', 'lifeExp', 'pop', 'gdpPercap') gap_dat <- gap_dat[my_vars] write_tsv(gap_dat, "07_gap-merged-with-continent.tsv")
lam = 14^(1/4); rrat = 1825^(1/32); eps = rrat*lam/(2*(rrat*lam-1)); epsCml = 0.72; rStoc = rrat^(1:6); rDeterm = rrat^(7:30); stage1Cells = 1/((2*eps-1)*rrat/400); moran = function(regIni=399, cmlIni=1, period, timestep = 0.0025) { numSteps = floor(period/timestep); regCells = c(regIni,rep(0,times=numSteps)); cmlCells = c(cmlIni,rep(0,times=numSteps)); regFeed = rep(0,times=numSteps); cmlFeed = regFeed; prob = timestep; ran = rbinom(numSteps,400,prob); for (i in 2:(numSteps+1)) { regCells[i] = regCells[i-1]; cmlCells[i] = cmlCells[i-1]; regFeed[i-1] = 0; cmlFeed[i-1] = 0; if (ran[i-1] > 0) { for (j in 1:ran[i-1]) { r = runif(1); if (r < cmlCells[i]/(cmlCells[i] + regCells[i])) { cmlCells[i] = cmlCells[i] - 1; cmlFeed[i-1] = cmlFeed[i-1] + 1; } else { regCells[i] = regCells[i] - 1; regFeed[i-1] = regFeed[i-1] + 1; } r = runif(1); if (r < cmlCells[i]/(cmlCells[i] + regCells[i])) { cmlCells[i] = cmlCells[i] + 1; } else { regCells[i] = regCells[i] + 1; } } } } return(list(regCells,cmlCells,regFeed,cmlFeed,timestep)); } stocs = function(regIni = round(stage1Cells*lam^(0:5)), cmlIni = rep(0,times=6), regFeed, cmlFeed, timestep = 0.0025) { numSteps = length(regFeed); regFeedNext = rep(0,times=numSteps); cmlFeedNext = regFeedNext; regCells = c(regIni,rep(0,times=6*numSteps)); dim(regCells) = c(6,numSteps+1); cmlCells = c(cmlIni,rep(0,times=6*numSteps)); dim(cmlCells) = c(6,numSteps+1); prob = timestep*rStoc; for (i in 2:(numSteps+1)) { regCells[1:6,i] = regCells[1:6,(i-1)]; cmlCells[1:6,i] = cmlCells[1:6,(i-1)]; regCells[1,i] = regCells[1,i] + regFeed[i-1]; cmlCells[1,i] = cmlCells[1,i] + cmlFeed[i-1]; for (j in 1:5) { p = prob[j]; regTotalReps = rbinom(1,regCells[j,i-1],p); cmlTotalReps = rbinom(1,cmlCells[j,i-1],p); regDifferentiates = rbinom(1,regTotalReps,eps); cmldifferentiates = rbinom(1,cmlTotalReps,epsCml); regReplicates = regTotalReps - regDifferentiates; cmlReplicates = cmlTotalReps - cmldifferentiates; regCells[j,i] = regCells[j,i] + regReplicates - regDifferentiates; cmlCells[j,i] = cmlCells[j,i] + cmlReplicates - cmldifferentiates; regCells[j+1,i] = regCells[j+1,i] + 2*regDifferentiates; cmlCells[j+1,i] = cmlCells[j+1,i] + 2*cmldifferentiates; } regTotalReps = rbinom(1,regCells[6,i-1],prob[6]); cmlTotalReps = rbinom(1,cmlCells[6,i-1],prob[6]); regDifferentiates = rbinom(1,regTotalReps,eps); cmldifferentiates = rbinom(1,cmlTotalReps,epsCml); regReplicates = regTotalReps - regDifferentiates; cmlReplicates = cmlTotalReps - cmldifferentiates; regCells[6,i] = regCells[6,i] + regReplicates - regDifferentiates; cmlCells[6,i] = cmlCells[6,i] + cmlReplicates - cmldifferentiates; regFeedNext[i-1] = 2*regDifferentiates; cmlFeedNext[i-1] = 2*cmldifferentiates; } return(list(regCells,cmlCells,regFeedNext,cmlFeedNext,timestep)); } diffEq = function(y,params) { primes = rep(0,times=24); e = params[[1]]; r = params[[2]]; primes[1] = -(2*e-1)*r[1]*y[1]; primes[2:24] = 2*e*r[1:23]*y[1:23] - (2*e-1)*r[2:24]*y[2:24]; return(primes); } determs = function(regIni = c(round(stage1Cells*lam^(6:29)),0), cmlIni = rep(0,times=25), regFeed, cmlFeed, timestep = 0.0025) { numSteps = length(regFeed); regParams = list(eps,rDeterm); cmlParams = list(epsCml,rDeterm); regCells = c(regIni,rep(0,times=25*numSteps)); dim(regCells) = c(25,numSteps+1); cmlCells = c(cmlIni,rep(0,times=25*numSteps)); dim(cmlCells) = c(25,numSteps+1); for (i in 2:(numSteps+1)) { k1reg = timestep*diffEq(regCells[1:24,i-1],regParams); k2reg = timestep*diffEq(regCells[1:24,i-1]+k1reg/2,regParams); k3reg = timestep*diffEq(regCells[1:24,i-1]+k2reg/2,regParams); k4reg = timestep*diffEq(regCells[1:24,i-1]+k3reg,regParams); regCells[1:24,i] = regCells[1:24,i-1] + 1/6*(k1reg + 2*k2reg + 2*k3reg + k4reg); regCells[1,i] = regCells[1,i] + regFeed[i-1]; k1cml = timestep*diffEq(cmlCells[1:24,i-1],cmlParams); k2cml = timestep*diffEq(cmlCells[1:24,i-1]+k1cml/2,cmlParams); k3cml = timestep*diffEq(cmlCells[1:24,i-1]+k2cml/2,cmlParams); k4cml = timestep*diffEq(cmlCells[1:24,i-1]+k3cml,cmlParams); cmlCells[1:24,i] = cmlCells[1:24,i-1] + 1/6*(k1cml + 2*k2cml + 2*k3cml + k4cml); cmlCells[1,i] = cmlCells[1,i] + cmlFeed[i-1]; } regCells[25,] = timestep*(2*eps)*rDeterm[24]*regCells[24,]; cmlCells[25,] = timestep*(2*epsCml)*rDeterm[24]*cmlCells[24,]; return(list(regCells,cmlCells,timestep)); } simulate = function(regIni = c(399,round(stage1Cells*lam^(0:29)),0),cmlIni = c(1,rep(0,times=31)),period,timestep = 0.0025) { regStemCells = regIni[1]; regStocCells = regIni[2:7]; regDetermCells = regIni[8:32]; cmlStemCells = cmlIni[1]; cmlStocCells = cmlIni[2:7]; cmlDetermCells = cmlIni[8:32]; p = period; t = timestep; moranCells = moran(regIni = regStemCells,cmlIni = cmlStemCells,period = p,timestep = t); stocCells = stocs(regIni = regStocCells,cmlIni = cmlStocCells,regFeed = moranCells[[3]],cmlFeed = moranCells[[4]],timestep = t); determCells = determs(regIni = regDetermCells,cmlIni = cmlDetermCells,regFeed = stocCells[[3]],cmlFeed = stocCells[[4]],timestep = t); return(list(rbind(moranCells[[1]],stocCells[[1]],determCells[[1]]),rbind(moranCells[[2]],stocCells[[2]],determCells[[2]]))); } diagnosisSim = function(regIni = c(399,round(stage1Cells*lam^(0:30)),0),cmlIni = c(1,rep(0,times=32)),period=50,timestep = 0.0025,diagnoses = 1000,stop=0) { diagnosisCount = 0; numTotalSims = 0; leukStemCellCount = 0; diagnosisTimes = rep(0,times = diagnoses); regular = regIni; leukemic = cmlIni; while (diagnosisCount < diagnoses & (numTotalSims < stop | stop == 0)) { numTotalSims = numTotalSims + 1; reg1 = regular; leuk1 = leukemic; for(i in 1:floor(period/timestep)) { s = simulate(regIni = reg1,cmlIni = leuk1,period = timestep,timestep = timestep); regCells = s[[1]]; cmlCells = s[[2]]; r1 = regCells[,2]; l1 = cmlCells[,2]; if (leuk1[32] >= 10^12*365*timestep) { diagnosisCount = diagnosisCount + 1; diagnosisTimes[diagnosisCount] = i*timestep; if (leuk1[1] > 0) { leukStemCellCount = leukStemCellCount + 1; } break; } else if (sum(leuk1[1:7]) == 0 & l1[32] < leuk1[32]) { break; } reg1 = r1; leuk1 = l1; } } return(list(diagnosisTimes,numTotalSims,leukStemCellCount)); }
if (compareVersion(paste0(version$major, ".", version$minor), "3.6") < 0) { skip("Randomization algorithm has changed from R 3.6") } data(keyATM_data_bills) bills_dfm <- keyATM_data_bills$doc_dfm bills_keywords <- keyATM_data_bills$keywords bills_cov <- keyATM_data_bills$cov bills_time_index <- keyATM_data_bills$time_index labels_use <- keyATM_data_bills$labels keyATM_docs <- keyATM_read(bills_dfm) base <- keyATM(docs = keyATM_docs, no_keyword_topics = 3, keywords = bills_keywords, model = "base", options = list(seed = 250, store_theta = TRUE, iterations = 30, store_pi = 1, use_weights = 1)) test_that("keyATM base", { expect_s3_class(plot_alpha(base, start = 10), "keyATM_fig") expect_s3_class(plot_pi(base, method = "eti"), "keyATM_fig") skip_on_os("linux") ; skip_on_cran() expect_equal(base$model_fit$Perplexity[3], 1861.29, tolerance = 0.00001) expect_equal(top_words(base)[1, 1], "education [\U2713]") expect_equal(top_words(base)[3, 1], "educational") expect_equal(base$pi$Proportion[3], 6.403216, tolerance = 0.00001) }) out <- keyATM(docs = keyATM_docs, no_keyword_topics = 3, keywords = bills_keywords[1], model = "base", options = list(seed = 250, iterations = 5)) test_that("keyATM onle one keyword topic", { skip_on_os("linux") ; skip_on_cran() expect_equal(out$model_fit$Perplexity[2], 3064.172, tolerance = 0.0001) }) bills_keywords2 <- list( Education = c("education", "child", "student"), Law = c("court", "law", "attorney"), Health = c("public", "health", "student"), Drug = c("drug", "court") ) out <- keyATM(docs = keyATM_docs, no_keyword_topics = 3, keywords = bills_keywords2, model = "base", options = list(seed = 250, store_theta = TRUE, iterations = 12, thinning = 2, use_weights = 1)) test_that("keyATM overlapping keywords", { skip_on_os("linux") ; skip_on_cran() expect_equal(out$model_fit$Perplexity[2], 2283.335, tolerance = 0.0001) expect_equal(top_words(out)[1, 1], "education [\U2713]") expect_equal(top_words(out)[2, 5], "commission") expect_equal(out$pi$Proportion[2], 4.750078, tolerance = 0.00001) }) bills_keywords_multiple <- bills_keywords bills_keywords_multiple$New <- c("public", "drug", "health") bills_keywords_multiple$New2 <- c("law", "public", "health") bills_keywords_multiple$Education <- c("education", "child", "student", "law") out <- keyATM(docs = keyATM_docs, no_keyword_topics = 0, keywords = bills_keywords_multiple, model = "base", options = list(seed = 250, store_theta = TRUE, iterations = 10)) test_that("keyATM same keywords in multiple topics", { skip_on_os("linux") ; skip_on_cran() expect_equal(out$model_fit$Perplexity[2], 2246.162, tolerance = 0.0001) expect_equal(top_words(out)[1, 1], "education [\U2713]") expect_equal(top_words(out)[2, 5], "follow") expect_equal(top_words(out)[9, 6], "law [\U2713]") })
est_saeRB = function (formula, vardir, weight, samevar = FALSE, MAXITER = 100, PRECISION = 1E-04, data) { if (!is.list(formula)) formula = list(formula) r = length(formula) if (r > 1) stop("You should using est_msaeRB() for multivariate") R_function = function (vardir, n, r) { if (r == 1) { R = diag(vardir) } else { R = matrix(rep(0, times = n*r*n*r), nrow = n*r, ncol = n*r) k = 1 for (i in 1:r) { for (j in 1:r) { if (i <= j) { mat0 = matrix(rep(0, times = r*r), nrow = r, ncol = r) mat0[i, j] = 1 matVr = diag(vardir[, k], length(vardir[, k])) R_hasil = kronecker(mat0, matVr) R = R + R_hasil k = k + 1 } } } R = forceSymmetric(R) } return(as.matrix(R)) } namevar = deparse(substitute(vardir)) nameweight = deparse(substitute(weight)) if (!missing(data)) { formuladata = lapply(formula, function(x) model.frame(x, na.action = na.omit, data)) y = unlist(lapply(formula, function(x) model.frame(x, na.action = na.omit, data)[[1]])) X = Reduce(adiag, lapply(formula, function(x) model.matrix(x, data))) W = as.matrix(data[, nameweight]) n = length(y)/r if (any(is.na(data[, namevar]))) stop("Object vardir contains NA values.") if (any(is.na(data[, nameweight]))) stop("Object weight contains NA values.") R = R_function(data[, namevar], n, r) vardir = data[, namevar] } else { formuladata = lapply(formula, function(x) model.frame(x, na.action = na.omit)) y = unlist(lapply(formula, function(x) model.frame(x, na.action = na.omit)[[1]])) X = Reduce(adiag, lapply(formula, function(x) model.matrix(x))) W = as.matrix(weight) n = length(y)/r if (any(is.na(vardir))) stop("Object vardir contains NA values") if (any(is.na(weight))) stop("Object weight contains NA values.") R = R_function(vardir, n, r) } y_names = sapply(formula, "[[", 2) Ir = diag(r) In = diag(n) dV = list() dV1 = list() for (i in 1:r){ dV[[i]] = matrix(0, nrow = r, ncol = r) dV[[i]][i, i] = 1 dV1[[i]] = kronecker(dV[[i]], In) } convergence = TRUE if (samevar) { Vu = median(diag(R)) k = 0 diff = rep(PRECISION + 1, r) while (any(diff > PRECISION) & (k < MAXITER)) { k = k + 1 Vu1 = Vu Gr = kronecker(Vu1, Ir) Gn = kronecker(Gr, In) V = as.matrix(Gn + R) Vinv = solve(V) XtVinv = t(Vinv %*% X) Q = solve(XtVinv %*% X) P = Vinv - t(XtVinv) %*% Q %*% XtVinv Py = P %*% y s = (-0.5) %*% sum(diag(P)) + 0.5 %*% (t(Py) %*% Py) iF = 0.5 %*% sum(diag(P %*% P)) Vu = Vu1 + solve(iF) %*% s diff = abs((Vu - Vu1)/Vu1) } Vu = as.vector((rep(max(Vu, 0), r))) names(Vu) = y_names if (k >= MAXITER && diff >= PRECISION) { convergence = FALSE } Gn = kronecker(diag(Vu), In) V = as.matrix(Gn + R) Vinv = solve(V) XtVinv = t(Vinv %*% X) Q = solve(XtVinv %*% X) P = Vinv - t(XtVinv) %*% Q %*% XtVinv Py = P %*% y beta = Q %*% XtVinv %*% y res = y - X %*% beta eblup = data.frame(matrix(X %*% beta + Gn %*% Vinv %*% res, n, r)) names(eblup) = y_names se.b = sqrt(diag(Q)) t.value = beta/se.b p.value = 2 * pnorm(abs(as.numeric(t.value)), lower.tail = FALSE) coef = as.matrix(cbind(beta, se.b, t.value, p.value)) colnames(coef) = c("beta", "std. error", "t value", "p-value") rownames(coef) = colnames(X) coef = as.data.frame(coef) } else { Vu = apply(matrix(diag(R), nrow = n, ncol = r), 2, median) k = 0 diff = rep(PRECISION + 1, r) while (any(diff > rep(PRECISION, r)) & (k < MAXITER)) { k = k + 1 Vu1 = Vu if (r == 1) { Gr = Vu1 } else { Gr = diag(as.vector(Vu1)) } Gn = kronecker(Gr, In) V = as.matrix(Gn + R) Vinv = solve(V) XtVinv = t(Vinv %*% X) Q = solve(XtVinv %*% X) P = Vinv - t(XtVinv) %*% Q %*% XtVinv Py = P %*% y s = sapply(dV1, function(x) (-0.5) * sum(diag(P %*% x)) + 0.5 * (t(Py) %*% x %*% Py)) iF = matrix(unlist(lapply(dV1, function(x) lapply(dV1, function(y) 0.5 * sum(diag(P %*% x %*% P %*% y))))), r) Vu = Vu1 + solve(iF) %*% s diff = abs((Vu - Vu1)/Vu1) } Vu = as.vector(sapply(Vu, max, 0)) if (k >= MAXITER && diff >= PRECISION){ convergence = FALSE } if (r == 1) { Gr = Vu1 } else { Gr = diag(as.vector(Vu1)) } Gn = kronecker(Gr, In) V = as.matrix(Gn + R) Vinv = solve(V) XtVinv = t(Vinv %*% X) Q = solve(XtVinv %*% X) P = Vinv - t(XtVinv) %*% Q %*% XtVinv Py = P %*% y beta = Q %*% XtVinv %*% y res = y - X %*% beta eblup = data.frame(matrix(X %*% beta + Gn %*% Vinv %*% res, n, r)) names(eblup) = y_names se.b = sqrt(diag(Q)) t.value = beta/se.b p.value = 2 * pnorm(abs(as.numeric(t.value)), lower.tail = FALSE) coef = as.matrix(cbind(beta, se.b, t.value, p.value)) colnames(coef) = c("beta", "std. error", "t value", "p-value") rownames(coef) = colnames(X) coef = as.data.frame(coef) } random.effect = data.frame(matrix(Gn %*% Vinv %*% res, n, r)) names(random.effect) = y_names y.mat = matrix(y, nrow = n, ncol = r) eblup.mat = as.matrix(eblup) eblup.ratio = eblup.mat %*% (colSums(W * y.mat)/colSums(W * eblup.mat)) eblup.ratio = as.data.frame(eblup.ratio) names(eblup.ratio) = y_names agregation.direct = diag(t(W) %*% y.mat) agregation.eblup = diag(t(W) %*% eblup.mat) agregation.eblup.ratio = diag(t(W) %*% as.matrix(eblup.ratio)) agregation = as.matrix(rbind(agregation.direct, agregation.eblup, agregation.eblup.ratio)) colnames(agregation) = y_names agregation = as.data.frame(agregation) result = list(eblup = list(est.eblup = NA, est.eblupRB = NA), fit = list(method = NA, convergence = NA, iteration = NA, estcoef = NA, refvar = NA), random.effect = NA, agregation = NA) result$eblup$est.eblup = eblup result$eblup$est.eblupRB = eblup.ratio result$fit$method = "REML" result$fit$convergence = convergence result$fit$iteration = k result$fit$estcoef = coef result$fit$refvar = t(Vu) result$random.effect = random.effect result$agregation = agregation return(result) }
new_challenge <- function(path = ".", out_rmdfile = "challenge.rmd", recursive = FALSE, overwrite = recursive, quiet = FALSE, showWarnings = FALSE, template = c("en", "fr"), data_dir = "data", submissions_dir = "submissions", hist_dir = "history", install_data = TRUE, baseline = "baseline", add_baseline = install_data, clear_history = overwrite, title = "Challenge", author = "", date = "", email = "[email protected]", date_start = format(Sys.Date(), "%d %b %Y"), deadline = paste(Sys.Date()+90, "23:59:59"), data_list = data_split(get_data("german"))) { dir.create(path, recursive = recursive, showWarnings = showWarnings) if (!file.exists(path)) stop("could not create directory ", path) stopifnot(is.character(out_rmdfile), length(out_rmdfile)==1, nzchar(out_rmdfile)) stopifnot(is.character(template), nzchar(template)) template = match.arg(template, c("en", "fr")) dir.create(file.path(path, "data"), recursive = recursive, showWarnings = showWarnings) if (install_data) { data_train <- data_list$train data_test <- data_list$test y_test <- data_list$y_test ind_quiz <- data_list$ind_quiz tmpdir = tempdir() save('data_train', file = file.path(tmpdir, 'data_train.rda')) file.copy(file.path(tmpdir, 'data_train.rda'), file.path(path, data_dir), overwrite=overwrite, recursive=recursive) save('data_test', file = file.path(tmpdir, 'data_test.rda')) file.copy(file.path(tmpdir, 'data_test.rda'), file.path(path, data_dir), overwrite=overwrite, recursive=recursive) save('y_test', file = file.path(tmpdir, 'y_test.rda')) file.copy(file.path(tmpdir, 'y_test.rda'), file.path(path, data_dir), overwrite=overwrite, recursive=recursive) save('ind_quiz', file = file.path(tmpdir, 'ind_quiz.rda')) file.copy(file.path(tmpdir, 'ind_quiz.rda'), file.path(path, data_dir), overwrite=overwrite, recursive=recursive) unlink(tmpdir) } dir.create(file.path(path, submissions_dir), recursive = recursive, showWarnings = showWarnings) if (install_data && add_baseline) { team_dir = new_team(baseline, path=path, submissions_dir = submissions_dir, quiet = TRUE, showWarnings = showWarnings) y_pred <- rep("Good", nrow(data_test)) tmpfile = tempfile() write(y_pred, file = tmpfile) file.copy(tmpfile, file.path(team_dir, 'all_good.csv'), overwrite=overwrite) y_pred <- rep("Bad", nrow(data_test)) write(y_pred, file = tmpfile) file.copy(tmpfile, file.path(team_dir, 'all_bad.csv'), overwrite=overwrite) unlink(tmpfile) } if (clear_history) unlink(file.path(path, hist_dir), recursive = TRUE) dir.create(file.path(path, hist_dir), recursive = recursive, showWarnings = showWarnings) expr = list(title = title, author = author, date = date, email = email, date_start = date_start, deadline = deadline, baseline = baseline, data_dir = data_dir, submissions_dir = submissions_dir, hist_dir = hist_dir) tpl = system.file('template', paste0("challenge_", template, ".rmd"), package = 'rchallenge') if (!nzchar(tpl)) stop("could not find template ", template) text = readLines(tpl) for (n in names(expr)) text = gsub(paste0("@", toupper(n), "@"), expr[[n]], text) tmpfile = tempfile() writeLines(text, tmpfile) file.copy(tmpfile, file.path(path, out_rmdfile), overwrite=overwrite) unlink(tmpfile) if (!quiet) { cat('New challenge installed in: "', normalizePath(path), '"\n', sep='') cat('Next steps to complete the installation:\n') step <- 0 if (install_data) { step <- step + 1 cat(step, '. Replace the data files in the "data" subdirectory.\n', sep='') } if (add_baseline) { step <- step + 1 cat(step, '. Replace the baseline predictions in "', file.path(submissions_dir, baseline),'".\n', sep='') } step <- step + 1 cat(step, '. Customize the template R Markdown file "', out_rmdfile, '" as needed.\n', sep='') step <- step + 1 cat(step, '. Create and share subdirectories in "', submissions_dir, '" for each team:\n', sep='') cat(' rchallenge::new_team("team_foo", "team_bar", path="', path, '", submissions_dir="', submissions_dir, '")\n', sep='') step <- step + 1 cat(step, '. Render the HTML page:\n', sep='') cat(' rchallenge::publish("', file.path(path, out_rmdfile), '")\n', sep='') step <- step + 1 template_html <- paste0(sub("([^.]+)\\.[[:alnum:]]+$", "\\1", basename(out_rmdfile)), ".html") cat(step, '. Give the URL to "', template_html, '" to the participants.\n', sep='') step <- step + 1 cat(step, '. Automate the updates of the webpage.\n', sep='') if (.Platform$OS.type == "unix") { cat(' On Unix systems, you can setup the following line to your crontab using "crontab -e":\n', sep='') cat(' 0 * * * * Rscript -e \'rchallenge::publish("', normalizePath(file.path(path, out_rmdfile)), '")\'\n', sep='') } if (.Platform$OS.type == "windows") { cat(' On Windows systems, you can use the Task Scheduler to create a new task with a "Start a program" action with the settings:') cat(' - Program/script: Rscript.exe\n') cat(' - options: -e rchallenge::publish(\'', normalizePath(file.path(path, out_rmdfile)), '\')\n', sep='') } } invisible(normalizePath(path)) } new_team <- function(..., path = ".", submissions_dir = "submissions", quiet = FALSE, showWarnings = FALSE) { names <- c(...) stopifnot(is.character(names)) if (!file.exists(file.path(path, submissions_dir))) stop("could not find submissions directory:", normalizePath(file.path(path, submissions_dir))) for (i in seq_along(names)) { if (!quiet) cat("Creating team subdirectory:", file.path(submissions_dir, names[i]), "\n") dir.create(file.path(path, submissions_dir, names[i]), recursive = FALSE, showWarnings = showWarnings) } if (!quiet) cat("Next step: share the Dropbox folders with the corresponding teams.\n") invisible(normalizePath(file.path(path, submissions_dir, names))) } publish <- function(input="challenge.rmd", output_file = "index.html", output_dir = dirname(input), quiet = FALSE, ...) { wd <- getwd() setwd(dirname(input)) out <- rmarkdown::render(input = basename(input), output_file = output_file, output_dir = output_dir, quiet = quiet, ...) setwd(wd) if (!quiet) cat('Next step: give the URL to "', file.path(output_dir, basename(out)), '" to the participants.\n', sep='') invisible(out) }
`orglsegments` <- function (object, groups, order.by, display = "sites", choices = 1:3, col = "black", ...) { pts <- scores(object, display = display, choices = choices, ...) if (!missing(order.by)) { if (length(order.by) != nrow(pts)) stop(gettextf("the length of order.by (%d) does not match the number of points (%d)", length(order.by), nrow(pts))) ord <- order(order.by) pts <- pts[ord,] groups <- groups[ord] } inds <- names(table(groups)) if (is.factor(col)) col <- as.numeric(col) col <- rep(col, length = length(inds)) names(col) <- inds for (is in inds) { X <- pts[groups == is, , drop = FALSE] if (nrow(X) > 1) { for (i in 2:nrow(X)) { rgl.lines(c(X[i-1,1],X[i,1]), c(X[i-1,2],X[i,2]), c(X[i-1,3],X[i,3]), col = col[is], ...) } } } invisible() }
project_waypoints <- function( trajectory, space, waypoints = select_waypoints(trajectory), trajectory_projection_sd = sum(trajectory$milestone_network$length) * 0.05 ) { assert_that(!is.null(space)) if ("geodesic_distances" %in% names(waypoints)) { assert_that(all(rownames(space) %in% colnames(waypoints$geodesic_distances))) } else { waypoints$geodesic_distances <- calculate_geodesic_distances( trajectory, waypoint_milestone_percentages = waypoints$milestone_percentages )[unique(waypoints$milestone_percentages$waypoint_id), , drop = FALSE] } weights <- waypoints$geodesic_distances %>% stats::dnorm(sd = trajectory_projection_sd) assert_that(all(!is.na(weights))) weights <- weights / rowSums(weights) weights <- weights[, rownames(space)] assert_that(all(colnames(weights) == rownames(space))) projected_space <- weights %*% space projected_space } project_trajectory <- function( trajectory, dimred, waypoints = select_waypoints(trajectory), trajectory_projection_sd = sum(trajectory$milestone_network$length) * 0.05 ) { dimred_segment_points <- project_waypoints( trajectory, dimred, waypoints = waypoints, trajectory_projection_sd = trajectory_projection_sd ) dimred_milestones <- project_milestones( trajectory, dimred, trajectory_projection_sd = trajectory_projection_sd ) lst( dimred_segment_points = dimred_segment_points, dimred_segment_progressions = waypoints$progressions %>% select(from, to, percentage), dimred_milestones = dimred_milestones ) } project_milestones <- function(trajectory, dimred, trajectory_projection_sd = sum(trajectory$milestone_network$length) * 0.05) { waypoints <- lst( milestone_percentages = tibble( waypoint_id = trajectory$milestone_ids, milestone_id = waypoint_id, percentage = 1 ) ) project_waypoints( trajectory, dimred, waypoints = waypoints, trajectory_projection_sd = trajectory_projection_sd ) }
test_that("ibdsim() returns objects of correct class", { x = nuclearPed(1) sim = ibdsim(x, N=1, verbose=F, map=uniformMap(1), model="haldane") expect_is(sim, "genomeSimList") }) test_that("Full sib mating yields all 9 jaquard states", { x = fullSibMating(1) sim = ibdsim(x, N=1, ids = 5:6, map=uniformMap(M=10), verbose=F, seed=1)[[1]] expect_setequal(sim[, 'Sigma'], 1:9) })
prism_archive_clean <- function(type, temp_period, years = NULL, mon = NULL, minDate = NULL, maxDate = NULL, dates = NULL) { prism_check_dl_dir() pd <- prism_archive_subset(type, temp_period, years = years, mon = mon, minDate = minDate, maxDate = maxDate, dates = dates) early <- pd[stringr::str_detect(pd, "_early_")] delete <- c() if (length(early) > 0) { prov <- stringr::str_replace(early, "_early_", "_provisional_") stable <- stringr::str_replace(early, "_early_", "_stable_") delete <- early[file.exists(file.path(prism_get_dl_dir(), prov))] delete2 <- early[file.exists(file.path(prism_get_dl_dir(), stable))] delete <- unique(c(delete, delete2)) } prov <- pd[stringr::str_detect(pd, "_provisional_")] delete2 <- c() if (length(prov) > 0) { stable <- stringr::str_replace(prov, "_provisional_", "_stable_") delete2 <- prov[file.exists(file.path(prism_get_dl_dir(), stable))] } delete <- unique(c(delete, delete2)) if (length(delete) == 0) { return(invisible(NULL)) } delete <- folders_to_remove(delete) del_paths <- file.path(prism_get_dl_dir(), delete) unlink(del_paths, recursive = TRUE) del_i <- dir.exists(del_paths) no_delete <- delete[del_i] delete <- delete[!del_i] if (length(no_delete) > 0) { warning( paste0( "Unable to remove the following folders. Check permissions.", paste("\n -", no_delete, collapse = "\n - ") ) ) } invisible(delete) } folders_to_remove <- function(x) { if (interactive()) { msg <- "Please select the PRISM folders to remove:\n" choices <- paste("1: None", "2: All", sep = "\n") i <- 2 if (length(x) > 25) { msg <- paste0( msg, "There are ", length(x), " folders to be removed, but only the first 25 are options.\n" ) choices <- paste( "1: None", "2: Only the 25 shown below.", "3: All (even those not listed below).", sep = "\n" ) i <- 3 } msg <- paste0(msg, "\n", choices) n <- min(25, length(x)) choices <- paste(paste0(seq(n) + i, ": ", x[seq(n)]), collapse = "\n") msg <- paste0(msg, "\n", choices, "\n") cat(msg) ui <- readline("Enter choices seperated by commas: ") ui <- as.numeric(stringr::str_split( stringr::str_remove_all(ui, " "), ",", simplify = TRUE )) if (1 %in% ui) { x <- NULL message("No folders will be removed.\n") } else { del_i <- ui - i if (-1 %in% del_i) { x <- x[1:25] } else if (!(0 %in% del_i)) { x <- x[del_i] } } } x } del_early_prov <- function (type, minDate = NULL, maxDate = NULL, dates = NULL) { .Deprecated("`prism_archive_clean()`") prism_check_dl_dir() dates <- gen_dates(minDate = minDate, maxDate = maxDate, dates = dates) pd <- prism_archive_subset(type = type, temp_period = "daily", dates = dates) mddf <- pd_get_md(pd) mddf$dates_str <- stringr::str_extract(mddf$PRISM_DATASET_FILENAME, "[0-9]{8}") duplicates <- mddf$dates_str[duplicated(mddf$dates_str)] out <- NULL for (dup in duplicates) { dups <- mddf[mddf$dates_str == dup, ] dups$dates_num <- as.numeric(dups$dates_str) dups$priority <- sapply(dups$folder_path, function(x){ if(stringr::str_detect(x, "stable")){ return(1) } else if (stringr::str_detect(x, "provisional")){ return(2) } else if (stringr::str_detect(x, "early")){ return(3) } }) dups$to_delete <- dups$priority > min(dups$priority) if(sum(!dups$to_delete) > 1){ dups$new_to_delete <- dups$to_delete dups$new_to_delete[!dups$to_delete] <- TRUE ll <- length(dups$to_delete[!dups$to_delete]) dups$new_to_delete[!dups$to_delete][ll] <- FALSE dups$to_delete <- dups$new_to_delete } unlink(dups$folder_path[dups$to_delete], recursive = TRUE) tmp <- lapply(dups$folder_path[dups$to_delete], function(x){ if(file.exists(x)) { warning(paste0("Unable to remove folder ", x, ". Check permissions.")) } else { x } }) out <- c(out, unlist(tmp)) } invisible(out) }
context("test_prepare_number_args") test_that("prepare number throws appropriate errors on vectors", { expect_error(prepare_number(c("start", "end")), regexp = "Only a single number can be passed") expect_error(prepare_number(c(1234, 5678)), regexp = "Only a single number can be passed") }) iris <- data("iris") test_that("prepare number throws appropriate errors on bad coercion", { expect_error(prepare_number("start"), regexp = "NAs were introduced.") expect_error(prepare_number(iris), regexp = "NAs were introduced.") }) test_that("prepare number warns on logicals", { expect_warning(prepare_number(TRUE), regexp = "Coercing logical values to numeric.") expect_warning(prepare_number(FALSE), regexp = "Coercing logical values to numeric.") }) rm(iris)
interactivity <- function(linkingGroup = NULL, linkingKey = NULL, linkedStates = NULL, sync = NULL, active = NULL, activeGeomLayers = NULL, selected = NULL, selectBy = NULL, selectionLogic = NULL, layerId = NULL, scaleToFun = NULL, itemLabel = NULL, showItemLabels = NULL, ...) { ggplot2::ggproto("Interactivity", NULL, params = list( linkingGroup = linkingGroup, linkingKey = linkingKey, linkedStates = linkedStates, sync = sync, active = active, activeGeomLayers = activeGeomLayers, selected = selected, selectBy = selectBy, selectionLogic = selectionLogic, layerId = layerId, scaleToFun = scaleToFun, itemLabel = itemLabel, showItemLabels = showItemLabels, ... ), remove_null = function(..., as_list = TRUE) { if(as_list) Filter(Negate(is.null), list(...) ) else Filter(Negate(is.null), ...) }, warn_nDim_states = function(data, x) { n <- nrow(data) %||% 0 if(length(x) != n && length(x) != 1) { warning( "The length of ", deparse(substitute(x)), " is ", length(x), " that does not match the number of observations(" , n, ").", call. = FALSE ) } }, evalObj = function(data, params, x) { obj <- params[[x]] if(is.null(obj)) return(params) if(rlang::is_formula(obj)) { params[[x]] <- eval(obj[[2]], data) } else if (is.atomic(obj)) { NULL } else { params[[x]] <- tryCatch( expr = {eval(obj, data)}, error = function(e) { return(NULL) } ) } return(params) }, check_itemLabel = function(self, data, params) { if(!is.null(params$showItemLabels) && !is.logical(params$showItemLabels)) { stop("`showItemLabels` must be logical", call. = FALSE) } params <- self$evalObj(data, params, "itemLabel") itemLabel <- params$itemLabel if(is.null(itemLabel)) return(NULL) self$warn_nDim_states(data = data, x = itemLabel) self$params <- params }, check_selected = function(self, data, params) { params <- self$evalObj(data, params, "selected") selected <- params$selected if(is.null(selected)) return(NULL) if(!is.logical(selected)) { stop("`selected` must be logical", call. = FALSE) } self$warn_nDim_states(data = data, x = selected) self$params <- params }, check_active = function(self, data, params) { params <- self$evalObj(data, params, "active") active <- params$active if(is.null(active)) return(NULL) if(!is.logical(active)) { stop("`active` must be logical", call. = FALSE) } self$warn_nDim_states(data = data, x = active) self$params <- params }, check_linkingKey = function(self, data, params) { params <- self$evalObj(data, params, "linkingKey") linkingKey <- params$linkingKey if(is.null(linkingKey)) return(NULL) if(any(duplicated(linkingKey))) stop("The linkingKey is duplicated", call. = FALSE) self$warn_nDim_states(data = data, x = linkingKey) self$params <- params } ) } linking <- function(linkingGroup = NULL, linkingKey = NULL, linkedStates = NULL, sync = NULL) { interactivity(linkingGroup = linkingGroup, linkingKey = linkingKey, linkedStates = linkedStates, sync = sync) } active <- function(active = NULL, activeGeomLayers = NULL) { interactivity(active = active, activeGeomLayers = activeGeomLayers) } selection <- function(selected = NULL, selectBy = NULL, selectionLogic = NULL) { interactivity(selected = selected, selectBy = selectBy, selectionLogic = selectionLogic) } zoom <- function(layerId = NULL, scaleToFun= NULL) { interactivity(layerId = layerId, scaleToFun = scaleToFun) } hover <- function(itemLabel = NULL, showItemLabels = NULL) { interactivity(itemLabel = itemLabel, showItemLabels = showItemLabels) } ggplot_add.Interactivity <- function(object, plot, object_name) { if(!is.l_ggplot(plot)) { class(plot) <- c("l_ggplot", class(plot)) } update_interactivity(plot, object) } update_interactivity <- function(p, interactivity) { p$interactivity <- merge_interactivity(interactivity, p$interactivity) p } merge_interactivity <- function (new, old) { if(is.null(new)) return(old) pre <- find(old = old$params, new = new$params) if(any(pre)) { pre_name <- names(pre)[which(pre)] message_wrap("Interactive component for '", pre_name, "' is already present. Adding another interactive component for '", pre_name, "', which will replace the existing one.") } new$params <- replace(new = new$params, old = old$params) new } find <- function(new, old) { old <- remove_null(old, as_list = FALSE) new <- remove_null(new, as_list = FALSE) if(length(new) == 0) return(FALSE) vapply(names(new), function(param) any(names(old) %in% param), logical(1)) } replace <- function(new, old) { old <- remove_null(old, as_list = FALSE) new <- remove_null(new, as_list = FALSE) if(length(new) == 0 && length(old) == 0) return(list()) states <- unique(c(names(old), names(new))) stats::setNames( lapply(states, function(state) { if(state %in% names(new)) { new[[state]] } else { old[[state]] } }), states ) } params_check <- function(interactivity, data) { interactivity$check_selected(data, interactivity$params) interactivity$check_itemLabel(data, interactivity$params) interactivity$check_linkingKey(data, interactivity$params) interactivity$check_active(data, interactivity$params) }
.buiCalc <- function(dmc, dc) { bui1 <- ifelse(dmc == 0 & dc == 0, 0, 0.8 * dc * dmc/(dmc + 0.4 * dc)) p <- ifelse(dmc == 0, 0, (dmc - bui1)/dmc) cc <- 0.92 + ((0.0114 * dmc)^1.7) bui0 <- dmc - cc * p bui0 <- ifelse(bui0 < 0, 0, bui0) bui1 <- ifelse(bui1 < dmc, bui0, bui1) return(bui1) }
print.coef.gnm <- function(x, ...) { if (!is.null(attr(x, "ofInterest"))) { if (length(attr(x, "ofInterest"))){ cat("Coefficients of interest:\n", sep = "") print.default(format(x[attr(x, "ofInterest")]), quote = FALSE) } else cat("No coefficients of interest\n") } else { cat("Coefficients:\n") print.default(format(x), quote = FALSE) } }
sim2.bd.fast.age <- function(n,numbsim,lambda,mu,rho,age,mrca=FALSE){ phy <- list() for (j in 1:numbsim){ if (mrca==FALSE) { temp1 <- sim2.bd.fast.single.origin(n,lambda,mu,rho,age) temp<-collapse.singles(temp1) } else { temp <- sim2.bd.fast.single.mrca(n,lambda,mu,rho,age) } phy <- c(phy, list(temp)) } phy }
open_curly_linter <- function(allow_single_line = FALSE) { Linter(function(source_file) { lapply( ids_with_token(source_file, "'{'"), function(id) { parsed <- with_id(source_file, id) tokens_before <- source_file$parsed_content$token[ source_file$parsed_content$line1 == parsed$line1 & source_file$parsed_content$col1 < parsed$col1] tokens_after <- source_file$parsed_content$token[ source_file$parsed_content$line1 == parsed$line1 & source_file$parsed_content$col1 > parsed$col1 & source_file$parsed_content$token != "COMMENT"] if (isTRUE(allow_single_line) && "'}'" %in% tokens_after) { return() } line <- source_file$lines[as.character(parsed$line1)] some_before <- length(tokens_before) %!=% 0L some_after <- length(tokens_after) %!=% 0L content_after <- unname(substr(line, parsed$col1 + 1L, nchar(line))) content_before <- unname(substr(line, 1, parsed$col1 - 1L)) only_comment <- rex::re_matches(content_after, rex::rex(any_spaces, " double_curly <- rex::re_matches(content_after, rex::rex(start, "{")) || rex::re_matches(content_before, rex::rex("{", end)) if (double_curly) { return() } whitespace_after <- unname(substr(line, parsed$col1 + 1L, parsed$col1 + 1L)) %!=% "" if (!some_before || some_after || (whitespace_after && !only_comment)) { Lint( filename = source_file$filename, line_number = parsed$line1, column_number = parsed$col1, type = "style", message = paste( "Opening curly braces should never go on their own line and", "should always be followed by a new line." ), line = line ) } } ) }) }
read_xmile <- function(filepath, stock_list = NULL, const_list = NULL) { model_structure <- extract_structure_from_XMILE(filepath) if(!is.null(stock_list)) { stocks_override <- names(stock_list) lvl_names <- sapply(model_structure$levels, function(lvl_obj) lvl_obj$name) for(i in seq_len(length(stock_list))) { stk <- stocks_override[[i]] pos_stk <- which(stk == lvl_names) model_structure$levels[[pos_stk]]$initValue <- stock_list[[stk]] } } if(!is.null(const_list)) { model_structure <- override_consts(model_structure, const_list) } deSolve_components <- get_deSolve_elems(model_structure) igraph_inputs <- tryCatch( error = function(cnd) { warning("This model cannot be converted into a graph (network)", call. = FALSE) NULL }, get_igraph_inputs(model_structure) ) list( description = model_structure, deSolve_components = deSolve_components, graph_dfs = igraph_inputs ) } xmile_to_deSolve <- function(filepath) { model_structure <- extract_structure_from_XMILE(filepath) deSolve_components <- get_deSolve_elems(model_structure) } override_consts <- function(mdl_structure, const_list) { consts_override <- names(const_list) const_names <- sapply(mdl_structure$constants, function(const_obj) const_obj$name) for(i in seq_len(length(const_list))) { cst <- consts_override[[i]] pos_cst <- which(cst == const_names) if(length(pos_cst) == 0) { msg <- paste0("Can't find constant: ", cst) stop(msg, call. = FALSE) } mdl_structure$constants[[pos_cst]]$value <- const_list[[cst]] } mdl_structure }
format_splits <- function(distance, time) { df <- data.frame(distance = distance, time = time) create_lag <- function(x) { x_lag <- x for (i in seq(1, length(x) - 1)) { x_lag[i + 1] <- x[i] } x_lag[1] <- 0 return(x_lag) } df <- df[order(df$distance), ] df$split_distance_start <- create_lag(df$distance) df$split_distance_stop <- df$distance df$split_distance <- df$split_distance_stop - df$split_distance_start df$split_time_start <- create_lag(df$time) df$split_time_stop <- df$time df$split_time <- df$split_time_stop - df$split_time_start df$split_mean_velocity <- df$split_distance / df$split_time df$split <- seq(1, nrow(df)) df <- df[c( "split", "split_distance_start", "split_distance_stop", "split_distance", "split_time_start", "split_time_stop", "split_time", "split_mean_velocity" )] return(df) }
testthat::context("as_rdf")
if(require("suppdata") & require("testthat")){ context("PLOS") test_that("PLOS works with minimal input", { skip_on_cran() expect_true(file.exists(suppdata("10.1371/journal.pone.0127900", 1))) }) test_that("PLOS works specifying 'from'", { skip_on_cran() expect_true(file.exists(suppdata("10.1371/journal.pone.0127900", 1, "plos"))) }) test_that("PLOS fails with character SI info", { skip_on_cran() expect_error(suppdata("10.1371/journal.pone.0127900", "999"), "numeric SI info") }) test_that("PLOS fails with unknown journal SI info", { skip_on_cran() expect_error(suppdata:::.suppdata.plos("10.1111/ele.12437", 1), "Unrecognised PLoS journal") }) }
DT_GA_C <- function(train, test, confidence=0.25, instancesPerLeaf=2, geneticAlgorithmApproach="GA-LARGE-SN", threshold=10, numGenerations=50, popSize=200, crossoverProb=0.8, mutProb=0.01, seed=-1){ alg <- RKEEL::R6_DT_GA_C$new() alg$setParameters(train, test, confidence, instancesPerLeaf, geneticAlgorithmApproach, threshold, numGenerations, popSize, crossoverProb, mutProb, seed) return (alg) } R6_DT_GA_C <- R6::R6Class("R6_DT_GA_C", inherit = ClassificationAlgorithm, public = list( confidence = 0.25, instancesPerLeaf = 2, geneticAlgorithmApproach = "GA-LARGE-SN", threshold = 10, numGenerations = 50, popSize = 200, crossoverProb = 0.8, mutProb = 0.01, seed = -1, setParameters = function(train, test, confidence=0.25, instancesPerLeaf=2, geneticAlgorithmApproach="GA-LARGE-SN", threshold=10, numGenerations=50, popSize=200, crossoverProb=0.8, mutProb=0.01, seed=-1){ super$setParameters(train, test) stopText <- "" if((hasMissingValues(train)) || (hasMissingValues(test))){ stopText <- paste0(stopText, "Dataset has missing values and the algorithm does not accept it.\n") } if(stopText != ""){ stop(stopText) } self$confidence <- confidence self$instancesPerLeaf <- 2 if((tolower(geneticAlgorithmApproach) == "ga-small") || (tolower(geneticAlgorithmApproach) == "ga-large-sn")){ self$geneticAlgorithmApproach <- toupper(geneticAlgorithmApproach) } else{ self$geneticAlgorithmApproach <- "GA-LARGE-SN" } self$threshold <- threshold self$numGenerations <- numGenerations self$popSize <- popSize self$crossoverProb <- crossoverProb self$mutProb <- mutProb if(seed == -1) { self$seed <- sample(1:1000000, 1) } else { self$seed <- seed } } ), private = list( jarName = "DT_GA.jar", algorithmName = "DT_GA-C", algorithmString = "Hybrid Decision Tree/Genetic Algorithm", getParametersText = function(){ text <- "" text <- paste0(text, "seed = ", self$seed, "\n") text <- paste0(text, "confidence = ", self$confidence, "\n") text <- paste0(text, "isntancesPerLeaf = ", self$instancesPerLeaf, "\n") text <- paste0(text, "Genetic Algorithm Approach = ", self$geneticAlgorithmApproach, "\n") text <- paste0(text, "Threshold S to consider a Small Disjunt = ", self$threshold, "\n") text <- paste0(text, "Number of Total Generations for the GA = ", self$numGenerations, "\n") text <- paste0(text, "Number of chromosomes in the population = ", self$popSize, "\n") text <- paste0(text, "Crossover Probability = ", self$crossoverProb, "\n") text <- paste0(text, "Mutation Probability = ", self$mutProb, "\n") return(text) } ) )
n_eff <- function (kinship, max = TRUE, weights = NULL, nonneg = TRUE, algo = c('gradient', 'newton', 'heuristic'), tol = 1e-10) { algo <- match.arg(algo) if (missing(kinship)) stop('`kinship` matrix is required!') validate_kinship(kinship) n_ind <- ncol( kinship ) if (max) { inverse_kinship <- solve(kinship) weights <- rowSums( inverse_kinship ) if (min(weights) < 0 && nonneg) { if (algo == 'gradient') { obj <- n_eff_max_gradient(kinship, tol = tol) } else if (algo == 'newton') { obj <- n_eff_max_newton(kinship, tol = tol) } else if (algo == 'heuristic') { obj <- n_eff_max_heuristic(kinship, weights) } else stop('algorithm not implemented: ', algo) } else { n_eff <- sum( inverse_kinship ) weights <- weights / sum(weights) obj <- list(n_eff = n_eff, weights = weights) } } else { mean_kin <- mean_kinship(kinship, weights) n_eff <- 1 / mean_kin weights <- weights / sum(weights) obj <- list(n_eff = n_eff, weights = weights) } if ( obj$n_eff < 1 ) { obj$n_eff <- 1 } else if ( obj$n_eff > 2 * n_ind ) { obj$n_eff <- 2 * n_ind } return(obj) }
Gupper<-function(theta,y,n,j) { if(j==length(y)) return (pbinom(q=y[j],size=n[j],prob=theta)) pbinom(q=y[j]-1,size=n[j],prob=theta)+dbinom(x=y[j],size=n[j],prob=theta)*Gupper(theta=theta,y=y,n=n,j=j+1) } Glower<-function(theta,y,n,j) { if(j==1) return (pbinom(q=y[j]-1,size=n[j],prob=theta,lower.tail=FALSE)) pbinom(q=y[j],size=n[j],prob=theta,lower.tail=FALSE)+dbinom(x=y[j],size=n[j],prob=theta)*Glower(theta=theta,y=y,n=n,j=j-1) } morrisUCL<-function(y,n,halfa=0.05) { m=length(y) if(length(n)!=m) stop("Mismatched lengths in Morris.\n") uout=rep(1,m) a=m while((y[a]==n[a] || n[a]==0) && a>=1) a=a-1 if(a<1) return(uout) for(b in a:1) { uout[b]=uniroot(function(theta,h,d,alpha,...) h(theta=theta,...)-alpha,interval=c(0,1), alpha=halfa,j=b,h=Gupper,n=n,y=y)$root } if(any(n==0)) { uout = approx((1:m)[n>0],uout[n>0],xout=1:m,rule=2)$y } return(uout) } morrisLCL<-function(y,n,halfa=0.05) { m=length(y) if(length(n)!=m) stop("Mismatched lengths in Morris.\n") uout=rep(0,m) a=1 while((y[a]==0 || n[a]==0) && a<=m) a=a+1 if(a>m) return(uout) for(b in a:m) { uout[b]=uniroot(function(theta,h,d,alpha,...) h(theta=theta,...)-alpha,interval=c(0,1), alpha=halfa,j=b,h=Glower,n=n,y=y)$root } if(any(n==0)) { uout = approx((1:m)[n>0],uout[n>0],xout=1:m,rule=2)$y } return(uout) } morrisCI<-function(y,n,phat=y/n,conf=0.9,narrower=TRUE,alternate=wilsonCI,...) { if(conf<=0 || conf>=1) stop("Confidence must be between 0 and 1.\n") tailp=(1-conf)/2 lcl=morrisLCL(y=y,n=n,halfa=tailp) ucl=morrisUCL(y=y,n=n,halfa=tailp) if(narrower) { relevants=which(n>0) altout=alternate(phat=phat[relevants],n=n[relevants],conf=conf,...) lcl[relevants]=cummax(pmax(lcl[relevants],altout[,1])) ucl[relevants]=rev(cummin(rev(pmin(ucl[relevants],altout[,2])))) } return(cbind(lcl,ucl)) }
BayesSUR <- function(data = NULL, Y, X, X_0 = NULL, covariancePrior = "HIW", gammaPrior = "hotspot", betaPrior = "independent", nIter = 10000, burnin = 5000, nChains = 2, outFilePath = "", gammaSampler = "bandit", gammaInit = "R", mrfG = NULL, standardize = TRUE, standardize.response = TRUE, maxThreads = 1, output_gamma = TRUE, output_beta = TRUE, output_Gy = TRUE, output_sigmaRho = TRUE, output_pi = TRUE, output_tail = TRUE, output_model_size = TRUE, output_model_visit = FALSE, output_CPO = FALSE, output_Y = TRUE, output_X = TRUE, hyperpar = list(), tmpFolder = "tmp/") { if(outFilePath == "") stop("Please specify a directory to save all output files!") outFilePathLength = nchar(outFilePath) if( substr(outFilePath,outFilePathLength,outFilePathLength) != "/" ) outFilePath = paste( outFilePath , "/" , sep="" ) if(!file.exists(outFilePath)) dir.create(outFilePath) tmpFolderLength = nchar(tmpFolder) if( substr(tmpFolder,tmpFolderLength,tmpFolderLength) != "/" ) tmpFolder = paste( tmpFolder , "/" , sep="" ) tmpFolder = paste(outFilePath, tmpFolder, sep="") if(!file.exists(tmpFolder)) dir.create(tmpFolder) cl <- match.call() if ( is.null( data ) ){ npY = dim(Y) if ( (!is.numeric(Y)) | is.null(npY) ) my_stop("If 'data' is NULL, Y should be a numeric matrix",tmpFolder) npX = dim(X) if ( (!is.numeric(X)) | is.null(npX) | (npX[1]!=npY[1]) ) my_stop("If 'data' is NULL, X should be a numeric matrix and the same number of rows of Y",tmpFolder) if ( is.null ( X_0 ) ){ X_0 = matrix(NA,nrow=npY[1],ncol=0) }else{ npX0 = dim(X_0) if ( (!is.numeric(X_0)) | is.null(npX0) | (npX0[1]!=npY[1]) ) my_stop("If 'data' is NULL and X_0 is provided, X_0 should be a numeric matrix and the same number of rows of Y",tmpFolder) } if( standardize ){ X = scale(X) X_0 = scale(X_0) } if( standardize.response ) Y = scale(Y) write.table(cbind(Y,X,X_0),paste(sep="",tmpFolder,"data.txt"), row.names = FALSE, col.names = FALSE) data = paste(sep="",tmpFolder,"data.txt") blockLabels = c( rep(0,ncol(Y)) , rep(1,ncol(X)) , rep(2,ncol(X_0)) ) write.table(Y,paste(sep="",outFilePath,"data_Y.txt"), row.names = FALSE, col.names = TRUE) write.table(X,paste(sep="",outFilePath,"data_X.txt"), row.names = FALSE, col.names = TRUE) write.table(X_0,paste(sep="",outFilePath,"data_X0.txt"), row.names = FALSE, col.names = TRUE) }else{ npData = dim(data) if( is.numeric(data) | (!is.null(npData)) | (npData[2]>=2) ) { if( standardize ){ data[,X]= scale(data[,X]) data[,X_0] = scale(data[,X_0]) } if( standardize.response ) data[,Y] = scale(data[,Y]) write.table(data[,Y],paste(sep="",outFilePath,"data_Y.txt"), row.names = FALSE, col.names = TRUE) write.table(data[,X],paste(sep="",outFilePath,"data_X.txt"), row.names = FALSE, col.names = TRUE) write.table(data[,X_0],paste(sep="",outFilePath,"data_X0.txt"), row.names = FALSE, col.names = TRUE) write.table(data,paste(sep="",tmpFolder,"data.txt"), row.names = FALSE, col.names = FALSE) data = paste(sep="",tmpFolder,"data.txt") }else{ my_stop("Y should be NULL or a numeric matrix with 2 or more columns!") } if( is.character(data) & length(data) == 1 ){ if( substr(data,1,1) == "~" ) data = path.expand(data) } dataHeader = read.table(data,header = FALSE,nrows = 1) nVariables = ncol(dataHeader) if ( is.null(X_0) ) X_0 = as.numeric(c()) if ( !( is.vector(Y,"numeric") & is.vector(X,"numeric") & is.vector(X_0,"numeric") ) ) my_stop("When the 'data' argument is set, Y,X and X_0 need to be corresponding index vectors!",tmpFolder) if ( length( c( intersect(Y,X) , intersect(Y,X_0) , intersect(X_0,X) ) ) != 0 ) my_stop("Y, X and X_0 need to be distinct index vectors!",tmpFolder) if( length( c(Y,X,X_0) ) > nVariables ) my_stop("When the 'data' argument is set, Y,X and X_0 need to be corresponding index vectors!",tmpFolder) blockLabels = rep(NA,nVariables) blockLabels[Y] = 0 blockLabels[X] = 1 if ( length ( X_0 ) > 0 ) blockLabels[X_0] = 2 blockLabels[ is.na ( blockLabels ) ] = -1 } dataLength = nchar(data) if( dataLength == 0 ) my_stop("Please provide a correct path to a plain-text (.txt) file", tmpFolder) dataString = head( strsplit( tail( strsplit(data,split = c("/"))[[1]] , 1 ) , ".txt" )[[1]] , 1 ) if ( length ( X_0 ) > 0 ){ structureGraph = structureGraph = matrix(c(0,0,0,1,0,0,2,0,0),3,3,byrow=TRUE) }else structureGraph = structureGraph = matrix(c(0,0,1,0),2,2,byrow=TRUE) write.table(blockLabels,paste(sep="",tmpFolder,"blockLabels.txt"), row.names = FALSE, col.names = FALSE) blockList = paste(sep="",tmpFolder,"blockLabels.txt") write.table(structureGraph, paste(sep="",tmpFolder,"structureGraph.txt"), row.names = FALSE, col.names = FALSE) structureGraph = paste(sep="",tmpFolder,"structureGraph.txt") if ( burnin < 0 ){ my_stop("Burnin must be positive or 0",tmpFolder) }else{ if ( burnin > nIter ){ my_stop("Burnin might not be greater than nIter",tmpFolder) }else{ if ( burnin < 1 ){ burnin = ceiling(nIter * burnin) }}} hyperpar.all <- list(a_w=2, b_w=5, a_o=2, b_o=sum(blockLabels==1)-2, a_pi=NA, b_pi=NA, nu=sum(blockLabels==0)+2, a_tau=0.1, b_tau=10, a_eta=0.1, b_eta=1, a_sigma=1, b_sigma=1, mrf_d=-3, mrf_e=0.03) if(toupper(gammaPrior) %in% c("HOTSPOT", "HOTSPOTS", "HS")){ hyperpar.all$a_pi <- 2 hyperpar.all$b_pi <- 1 if(toupper(covariancePrior) %in% c("INDEPENDENT", "INDEP", "IG")) hyperpar.all <- hyperpar.all[-c(7:11,14:15)] if(toupper(covariancePrior) %in% c("DENSE", "IW")) hyperpar.all <- hyperpar.all[-c(10:11,12:15)] if(toupper(covariancePrior) %in% c("SPARSE", "HIW")) hyperpar.all <- hyperpar.all[-c(12:15)] } if( toupper(gammaPrior) %in% c("HIERARCHICAL", "H")){ hyperpar.all$a_pi <- 1 hyperpar.all$b_pi <- sum(blockLabels==0) - 1 if(toupper(covariancePrior) %in% c("INDEPENDENT", "INDEP", "IG")) hyperpar.all <- hyperpar.all[-c(3:6,7:11,14:15)] if(toupper(covariancePrior) %in% c("DENSE", "IW")) hyperpar.all <- hyperpar.all[-c(3:6,10:11,12:15)] if(toupper(covariancePrior) %in% c("SPARSE", "HIW")) hyperpar.all <- hyperpar.all[-c(3:6,12:15)] } if( toupper(gammaPrior) %in% c("MRF", "MARKOV RANDOM FIELD")){ if ( is.null(mrfG) ) my_stop("Argument 'mrfG' was specified!",tmpFolder) if(toupper(covariancePrior) %in% c("INDEPENDENT", "INDEP", "IG")) hyperpar.all <- hyperpar.all[-c(3:6,7:13)] if(toupper(covariancePrior) %in% c("DENSE", "IW")) hyperpar.all <- hyperpar.all[-c(3:6,10:13)] if(toupper(covariancePrior) %in% c("SPARSE", "HIW")) hyperpar.all <- hyperpar.all[-c(3:6,12:13)] } if(toupper(betaPrior) == "REGROUP"){ hyperpar.all$a_w0 <- hyperpar.all$a_w hyperpar.all$b_w0 <- hyperpar.all$b_w } if(length(hyperpar)>0) for( i in 1:length(hyperpar)){ if(names(hyperpar)[[i]] %in% names(hyperpar.all)) hyperpar.all[[which(names(hyperpar.all)==names(hyperpar)[[i]])]] <- hyperpar[[i]] if(!is.null(hyperpar$a_omega)) hyperpar.all$a_pi <- hyperpar$a_omega if(!is.null(hyperpar$b_omega)) hyperpar.all$b_pi <- hyperpar$b_omega } if ( toupper(covariancePrior) %in% c("SPARSE", "HIW") ){ covariancePrior <- "HIW" }else if ( toupper(covariancePrior) %in% c("DENSE", "IW") ){ covariancePrior <- "IW" }else if ( toupper(covariancePrior) %in% c("INDEPENDENT", "INDEP", "IG") ){ covariancePrior <- "IG" }else my_stop("Unknown covariancePrior argument: only sparse (HIW), dense(IW) or independent (IG) are available",tmpFolder) if( gammaPrior == "" ) { if ( is.null(mrfG) ) { message( "Using default prior for Gamma - hotspot prior\n") gammaPrior = "hotspot" }else{ message( "No value for gammaPrior was specified, but mrfG was given - choosing MRF prior\n") gammaPrior = "MRF" } }else{ if ( toupper(gammaPrior) %in% c("HOTSPOT", "HOTSPOTS", "HS") ) gammaPrior = "hotspot" else if ( toupper(gammaPrior) %in% c("MRF", "MARKOV RANDOM FIELD") ) gammaPrior = "MRF" else if ( toupper(gammaPrior) %in% c("HIERARCHICAL", "H") ) gammaPrior = "hierarchical" else my_stop("Unknown gammaPrior argument: only hotspot, MRF or hierarchical are available",tmpFolder) } if( !(is.character(mrfG) & length(mrfG) == 1) ) { if( (is.numeric(mrfG) | is.data.frame(mrfG)) & !is.null(dim(mrfG)) ) { if(ncol(mrfG) == 2) mrfG = cbind( mrfG, rep(1,nrow(mrfG)) ) write.table(mrfG,paste(sep="",outFilePath,"mrfG.txt"), row.names = FALSE, col.names = FALSE) mrfG = paste(sep="",outFilePath,"mrfG.txt") }else if( is.null( mrfG )){ mrfG = matrix(c(0,0,0),ncol=3) write.table(mrfG, paste(sep="",outFilePath,"mrfG.txt"), row.names = FALSE, col.names = FALSE) mrfG = paste(sep="",outFilePath,"mrfG.txt") }else my_stop("Unknown mrfG argument: check the help function for possibile values",tmpFolder) } xml = as_xml_document( list( hyperparameters = list( lapply(hyperpar,function(x) list(x)) ))) hyperParFile = paste(sep="",tmpFolder,"hyperpar.xml") write_xml(xml,file = hyperParFile) ret = list( status=1, input=list(), output = list() ) class(ret) = "BayesSUR" ret$input["nIter"] = nIter ret$input["burnin"] = burnin ret$input["nChains"] = nChains ret$input["covariancePrior"] = covariancePrior ret$input["gammaPrior"] = gammaPrior ret$input["gammaSampler"] = gammaSampler ret$input["gammaInit"] = gammaInit ret$input["mrfG"] = mrfG if( toupper(gammaPrior) %in% c("HIERARCHICAL", "H")){ names(hyperpar.all)[names(hyperpar.all)=="a_pi"] <- "a_omega" names(hyperpar.all)[names(hyperpar.all)=="b_pi"] <- "b_omega" } ret$input$hyperParameters = hyperpar.all methodString = switch( covariancePrior, "HIW" = "SSUR" , "IW" = "dSUR" , "IG" = "HRR" ) ret$call = cl ret$output["outFilePath"] = outFilePath ret$output["logP"] = paste(sep="", dataString , "_", methodString , "_logP_out.txt") if ( output_gamma ) ret$output["gamma"] = paste(sep="", dataString , "_", methodString , "_gamma_out.txt") if( gammaPrior %in% c("hierarchical","hotspot") & output_pi ) ret$output["pi"] = paste(sep="", dataString , "_", methodString , "_pi_out.txt") if( gammaPrior == "hotspot" & output_tail ) ret$output["tail"] = paste(sep="", dataString , "_", methodString , "_hotspot_tail_p_out.txt") if ( output_beta ) ret$output["beta"] = paste(sep="", dataString , "_", methodString , "_beta_out.txt") if ( covariancePrior == "HIW" & output_Gy ){ ret$output["Gy"] = paste(sep="", dataString , "_", methodString , "_Gy_out.txt") ret$output["Gvisit"] = paste(sep="", dataString , "_", methodString , "_Gy_visit.txt") } if ( covariancePrior %in% c("HIW","IW") & output_sigmaRho ) ret$output["sigmaRho"] = paste(sep="", dataString , "_", methodString , "_sigmaRho_out.txt") if ( output_model_size ) ret$output["model_size"] = paste(sep="", dataString , "_", methodString , "_model_size_out.txt") if ( output_CPO ){ ret$output["CPO"] = paste(sep="", dataString , "_", methodString , "_CPO_out.txt") ret$output["CPOsumy"] = paste(sep="", dataString , "_", methodString , "_CPOsumy_out.txt") ret$output["WAIC"] = paste(sep="", dataString , "_", methodString , "_WAIC_out.txt") } if ( output_Y ) ret$output["Y"] = paste(sep="", "data_Y.txt") if ( output_X ){ ret$output["X"] = paste(sep="", "data_X.txt") if( length(X_0)>0 ) ret$output["X0"] = paste(sep="", "data_X0.txt") } ret$status = BayesSUR_internal(data, mrfG, blockList, structureGraph, hyperParFile, outFilePath, nIter, burnin, nChains, covariancePrior, gammaPrior, gammaSampler, gammaInit, betaPrior, maxThreads, output_gamma, output_beta, output_Gy, output_sigmaRho, output_pi, output_tail, output_model_size, output_CPO, output_model_visit) obj_BayesSUR = list(status=ret$status, input=ret$input, output=ret$output, call=ret$call) save(obj_BayesSUR, file=paste(sep="",outFilePath,"obj_BayesSUR.RData")) if(outFilePath != tmpFolder) unlink(tmpFolder,recursive = TRUE) return(ret) } my_stop = function( msg , tmpFolder ) { unlink(tmpFolder,recursive = TRUE) stop(msg) }
SNPtm2<- function(trange=100,tsl=1.0,x6=NULL,r6=NULL) { testrange<- is.null(trange) if(testrange == TRUE) trange<- 400 testtsl<- is.null(tsl) if(testtsl == TRUE) tsl<- 1.0 x<- rep(0,trange*6/tsl) x<- matrix(x,ncol=6) testr<- is.null(r6) if(testr == TRUE) r<- c(0.025,0.040,0.045,0.045,0.045,0.045) if(testr == FALSE) r<- r6 testx<- is.null(x6) if(testx == TRUE) x[1,]<- c(0.50,0.70,1.70,6.0,13.0,78.0) if(testx == FALSE) x[1,]<- x6 nt<- (trange/tsl) tv<- seq(0,trange-tsl,tsl) vegtypes<- c("Aconitum","Trisetum","Deschampsia","Festuca","Carex","Pinus") K<- 100 dx<- rep(0,6) for(t in 2:nt) { dx[1]<- r[1]*x[t-1,1]*((K- x[t-1,1])/K) dx[2]<- r[2]*x[t-1,2]*((K- x[t-1,1]-x[t-1,2])/K) dx[3]<- r[3]*x[t-1,3]*((K- x[t-1,1]-x[t-1,2]-x[t-1,3])/K) dx[4]<- r[4]*x[t-1,4]*((K- x[t-1,1]-x[t-1,2]-x[t-1,3]-x[t-1,4])/K) dx[5]<- r[5]*x[t-1,5]*((K- x[t-1,1]-x[t-1,2]-x[t-1,3]-x[t-1,4]-x[t-1,5])/K) dx[6]<- r[6]*x[t-1,6]*((K- x[t-1,1]-x[t-1,2]-x[t-1,3]-x[t-1,4]-x[t-1,5]-x[t-1,6])/K) dx[2]<- dx[2] - (dx[1])*(x[t-1,2]/sum(x[t-1,2:6])) dx[3]<- dx[3] - (dx[1]+dx[2])*(x[t-1,3]/sum(x[t-1,3:6])) dx[4]<- dx[4] - (dx[1]+dx[2]+dx[3])*(x[t-1,4]/sum(x[t-1,4:6])) dx[5]<- dx[5] - (dx[1]+dx[2]+dx[3]+dx[4])*(x[t-1,5]/sum(x[t-1,5:6])) dx[6]<- dx[6] - (dx[1]+dx[2]+dx[3]+dx[4]+dx[5])*(x[t-1,6]/sum(x[t-1,6])) for(v in 1:6){ x[t,v]<- x[t-1,v]+(dx[v]*tsl) } } o.SNP<- list(n.time.steps=trange,time.step.length=tsl,time.vector=tv,veg.types=vegtypes,growth.rates=r,initial.cond=x[1,],sim.data=x) }
calcATHBpts <- function(trm, psych, ta, tr, vel, rh, met, wme, pb, ltime, ht, wt){ set <- calcATHBset(trm, psych, ta, tr, vel, rh, met, wme, pb, ltime, ht, wt) ATHBpts <- .25 * set - 6.03 data.frame(ATHBpts) }
logLikVec.fExtremes_gev <- function(object, pars = NULL, ...) { if (!missing(...)) { warning("extra arguments discarded") } if (is.null(pars)) { pars <- coef(object) } n_pars <- length(pars) response_data <- object@fit$data mu <- pars["mu"] sigma <- pars["beta"] xi <- pars["xi"] if (sigma <= 0) { val <- -Inf } else { val <- revdbayes::dgev(response_data, loc = mu, scale = sigma, shape = xi, log = TRUE) } attr(val, "nobs") <- nobs(object) attr(val, "df") <- length(pars) class(val) <- "logLikVec" return(val) } nobs.fExtremes_gev <- function(object, ...) { return(object@fit$n) } coef.fExtremes_gev <- function(object, ...) { return(object@fit$par.ests) } vcov.fExtremes_gev <- function(object, ...) { return(object@fit$varcov) } logLik.fExtremes_gev <- function(object, ...) { return(logLik(logLikVec(object))) }
plot.rlme <- function(x, ...) { if (x$method == "GR") { getgrstplot(x) } else if (x$method == "REML") { getlmestplot(x) } else { cat("rlme only supports plotting fits from GR and REML methods\n") } invisible() } rlme <- function(f, data, method = "gr", print = FALSE, na.omit = TRUE, weight = "wil", rprpair = "hl-disp", verbose=FALSE) { location = 2 method = tolower(method) fit = list(formula = f, location = location, scale = scale) if (na.omit == TRUE) { data = na.omit(data) } response_name = as.character(as.formula(f)[[2]]) random_terms = str_extract_all(as.character(f)[[3]], "\\(([0-9 a-zA-Z.:|]+)\\)") random_terms = lapply(random_terms[[1]], function(str) substr(str, 2, nchar(str) - 1)) covariate_names = setdiff(attributes(terms(f))$term.labels, random_terms) school_name = section_name = "" levels = 0 if (length(random_terms) == 2) { levels = 3 school_name = tail(strsplit(random_terms[[1]], "\\W")[[1]], 1) section_name = tail(strsplit(random_terms[[2]], "\\W")[[1]], 1) I = length(unique(factor(data[[school_name]]))) sec = as.vector(sec_vec(data[[school_name]], data[[section_name]])) fit$num.clusters = I fit$num.subclusters = sum(sec) mat = mat_vec(data[[school_name]], data[[section_name]]) ss = rowSums(mat) J = sum(sec) n = sum(mat) one = rep(1, length(data[[response_name]])) schsize = aggregate(one, by = list(data[[response_name]]), FUN = sum)[, 2] school1 = factor(rep(1:length(schsize), schsize)) sss = aggregate(one, by = list(data[[school_name]], data[[section_name]]), FUN = sum)[, 3] section = factor(rep(1:length(ss), ss)) } if (length(random_terms) == 1) { levels = 2 school_name = tail(strsplit(random_terms[[1]], "\\W")[[1]], 1) I = length(unique(factor(data[[school_name]]))) mat = mat_vec(data[[school_name]], rep(1, length(data[[school_name]]))) n = sum(mat) } x = as.matrix(data[covariate_names]) x = apply(x, 2, function(x) { x - mean(x) }) y = data[[response_name]] fit$num.obs = length(y) fit$y = y if (length(random_terms) == 0) { cat("You have entered an independent linear model.\n") cat("The function 'lmr' can be used to fit these models.\n") cat("Continuing using lmr.\n") fitw = lmr(f, data=data) return(fitw) } if (method == "reml" || method == "ml") { if (levels == 3) { REML = LM_est(x, y, dat = data.frame(y = y, x, school = data[[school_name]], section = data[[section_name]]), method = toupper(method)) } else if (levels == 2) { REML = LM_est2(x, y, dat = data.frame(y = y, x, school = data[[school_name]]), method = toupper(method)) } REMLb = REML$theta REMLs = REML$sigma REMLe = REML$ses REML$ehat tvalue = REMLb/REMLe pvalue = 2 * pnorm(-abs(tvalue)) intracoeffs = c(REMLs[1]/sum(REMLs), (REMLs[1] + REMLs[2])/sum(REMLs)) fit$method = "REML" fit$ehat = REML$ehat fit$effect.err = REML$effect_err fit$effect.cluster = REML$effect_sch if (levels == 3) { fit$effect.subcluster = REML$effect_sec } fit$fixed.effects = data.frame(RowNames = c("(Intercept)", covariate_names), Estimate = REMLb, StdError = REMLe, tvalue = tvalue, pvalue = pvalue) fit$var.b = REML$varb fit$intra.class.correlations = intracoeffs fit$t.value = tvalue fit$p.value = pvalue fit$standr.lme = REML$standr.lme } else if (method == "jr") { if (levels == 3) { JR = JR_est(x, y, I, sec, mat, data[[school_name]], data[[section_name]], rprpair = rprpair, verbose=verbose) } else if (levels == 2) { JR = JR_est2(x, y, I, 1, mat, data[[school_name]], rep(1, length(data[[school_name]])), rprpair = rprpair, verbose=verbose) } JRb = JR$theta JRe = JR$ses JRs = JR$sigma tvalue = JRb/JRe pvalue = 2 * pnorm(-abs(tvalue)) intracoeffs = c(JRs[1]/sum(JRs), (JRs[1] + JRs[2])/sum(JRs)) fit$method = "JR" fit$ehat = JR$ehat fit$fixed.effects = data.frame(RowNames = c("(Intercept)", covariate_names), Estimate = JRb, StdError = JRe, tvalue = tvalue, pvalue = pvalue) fit$effect.err = JR$effect_err fit$effect.cluster = JR$effect_sch if (levels == 3) { fit$random.effects = data.frame(Groups = c(paste(school_name, ":", section_name, sep = ""), school_name, "Residual"), Name = c("(Intercept)", "(Intercept)", ""), Variance = JRs) fit$effect.subcluster = JR$effect_sec } else if (levels == 2) { fit$random.effects = data.frame(Groups = c(school_name, "Residual"), Name = c("(Intercept)", ""), Variance = JRs) } fit$intra.class.correlations = intracoeffs fit$var.b = JR$varb fit$t.value = tvalue fit$p.value = pvalue } else if (method == "gr") { if (levels == 3) { GR = GR_est(x, y, I, sec, mat, data[[school_name]], data[[section_name]], rprpair = rprpair, verbose=verbose) } else if (levels == 2) { GR = GR_est2(x, y, I, rep(1, length(data[[school_name]])), mat, data[[school_name]], rep(1, length(data[[school_name]])), rprpair = rprpair, verbose=verbose) } GRb = GR$theta GRe = GR$ses tvalue = GRb/GRe pvalue = 2 * pnorm(-abs(tvalue)) varb = GR$varb GRs = GR$sigma intracoeffs = c(GRs[1]/sum(GRs), (GRs[1] + GRs[2])/sum(GRs)) coll.stres <- stanresidgr(GR$xstar, GR$ystar, resid = GR$ehats, delta = 0.8, param = 2, conf = 0.95) stresgr <- coll.stres$stanr fit$method = "GR" fit$ehat = GR$ehat fit$ehats = GR$ehats fit$xstar = GR$xstar fit$ystar = GR$ystar fit$fixed.effects = data.frame(RowNames = c("(Intercept)", covariate_names), Estimate = GRb, StdError = GRe, tvalue = tvalue, pvalue = pvalue) fit$effect.err = GR$effect_err fit$effect.cluster = GR$effect_sch if (levels == 3) { fit$random.effects = data.frame(Groups = c(school_name, paste(school_name, ":", section_name, sep = ""), "Residual"), Name = c("(Intercept)", "(Intercept)", ""), Variance = GRs) fit$effect.subcluster = GR$effect_sec } else if (levels == 2) { fit$random.effects = data.frame(Groups = c(school_name, "Residual"), Name = c("(Intercept)", ""), Variance = GRs) } fit$standard.residual = stresgr fit$intra.class.correlations = intracoeffs fit$var.b = varb fit$t.value = tvalue fit$p.value = pvalue } else if (method == "geer") { tol = 1.1e-25 if (levels == 3) { GEER = GEER_est(x, y, I, sec, mat, data[[school_name]], data[[section_name]], weight = weight, rprpair = rprpair, verbose=verbose) } else if (levels == 2) { GEER = GEER_est2(x, y, I, rep(1, length(data[[school_name]])), mat, data[[school_name]], rep(1, length(data[[school_name]])), weight = weight, rprpair = rprpair, verbose=verbose) } GEERb = GEER$theta GEERs = GEER$sigma GEER_e2 = GEER$ses_AP intracoeffs = c(GEERs[1]/sum(GEERs), (GEERs[1] + GEERs[2])/sum(GEERs)) GEERe = GEER$ses_AP tvalue = GEERb/GEERe pvalue = 2 * pnorm(-abs(tvalue)) fit$method = "GEER" fit$ehat = GEER$ehat fit$fixed.effects = data.frame(RowNames = c("(Intercept)", covariate_names), Estimate = GEERb, StdError = GEERe, tvalue = tvalue, pvalue = pvalue) fit$effect.err = GEER$effect_err fit$effect.cluster = GEER$effect_sch if (levels == 3) { fit$random.effects = data.frame(Groups = c(school_name, paste(school_name, ":", section_name, sep = ""), "Residual"), Name = c("(Intercept)", "(Intercept)", ""), Variance = GEERs) fit$effect.subcluster = GEER$effect_sec } else if (levels == 2) { fit$random.effects = data.frame(Groups = c(school_name, "Residual"), Name = c("(Intercept)", ""), Variance = GEERs) } fit$intra.class.correlations = intracoeffs fit$var.b = GEER$varb fit$t.value = tvalue fit$p.value = pvalue } class(fit) = "rlme" if (print == TRUE) { summary(fit) } return(fit) } summary.rlme <- function(object, ...) { fit = object cat("Linear mixed model fit by ", fit$method, "\n") cat("Formula: ", deparse(fit$formula), "\n") if ("random.effects" %in% attributes(fit)$names) { cat("Random effects:\n") random.effects = fit$random.effects names(random.effects) = c("Groups", "Name", "Variance") print(random.effects, row.names = FALSE, right = FALSE) } cat("\nNumber of obs:\n") cat(fit$num.obs) if ("num.clusters" %in% attributes(fit)$names && "num.subclusters" %in% attributes(fit)$names) { cat(" observations,", fit$num.clusters, "clusters,", fit$num.subclusters, "subclusters") } cat("\n") cat("\nFixed effects:\n") fixed.effects = fit$fixed.effects if(length(fixed.effects) == 5) { names(fixed.effects) = c("", "Estimate", "Std. Error", "t value", "p value") } else if(length(fixed.effects) == 3) { names(fixed.effects) = c("", "Estimate", "Std. Error") } else if(length(fixed.effects) == 2) { names(fixed.effects) = c("", "Estimate") } print(fixed.effects, row.names = FALSE, right = FALSE) if ("intra.class.correlations" %in% attributes(fit)$names) { cat("\nIntra-class correlation coefficients\n") intra.coeffs = data.frame(names = c("intra-cluster", "intra-subcluster"), Estimates = fit$intra.class.correlations) names(intra.coeffs) = c("", "Esimates") print(intra.coeffs, row.names = FALSE, right = FALSE) } if(!is.null(fit$var.b)) { cat("\ncov-var (fixed effects)\n") print(fit$var.b) } }
library(ISLR) data('Default') str(Default) LR1 = glm(default ~ ., family='binomial', data=Default) summary(LR1) LR2 = glm(default ~ student + balance, family='binomial', data=Default) summary(LR2) range(Default$balance) ndata3 = Default[c(1,60,700),] predict(LR2,newdata=ndata3, type='response' ) str(mtcars) x = 1:5 x1 = c('a','b') m1 = matrix(1:24, nrow=6) m1 list1 = list(x, x1, m1) list1 class(women) women str(women) ?women women head(women) tail(women,n=3) head(women, n=3) names(women) summary(women) dim(women) data() library(MASS) x = women$height x plot(x) mean(x) sd(x) ; var(x) max(x) median(x) x sort(x, decreasing = T) table(x) quantile(x) x seq(0,1,.1) quantile(x, c(.1, .5, .8)) quantile(x,seq(0,1,.1) ) summary(x) min(x); max(x) boxplot(x) abline(h= c(min(x), max(x),mean(x)+1, median(x)), col=1:5, lwd=4) head(women) names(women) model1 = lm(weight ~ height, data=women) plot(women) ?lm summary(model1) model1 y = 3.45 * x + - 87 women$height fitted(model1) cbind(women, fitted(model1)) residuals(model1) cbind(women, fitted(model1), residuals(model1), diff= fitted(model1) - women$weight) sqrt(sum(residuals(model1)^2)/nrow(women)) cbind(women, fitted(model1)) range(women$height) new1= data.frame(height=c(57, 60.5,70)) p1=predict(model1, newdata = new1) cbind(new1, p1) names(mtcars) ?mtcars mtmodel_1 = lm(mpg ~ wt, data=mtcars ) mtmodel_2 = lm(mpg ~ wt + disp, data=mtcars ) mtmodel_3 = lm(mpg ~ wt + disp + cyl, data=mtcars ) mtmodel_4 = lm(mpg ~ ., data=mtcars ) summary(mtmodel_1) summary(mtmodel_2) summary(mtmodel_3) summary(mtmodel_4) AIC(mtmodel_1, mtmodel_2,mtmodel_3,mtmodel_4) summary(mtmodel_4) step(lm(mpg ~ ., data=mtcars )) mtmodel_5= lm(mpg ~ wt + qsec + am, data=mtcars) summary(mtmodel_5) attendance = 1:20 marks = 1:20 summary(lm(marks ~ attendance)) cbind(attendance, marks) cor(attendance, marks) x y = 3.45 * x + - 87 x head(women) (y = 4.45 * 58 - 87) plot(women) abline(model1, col='red', lwd=4) abline(v=64) ; abline(h=150) x2 = floor(runif(1000, 50, 100)) x2 x2a= sort(x2) x2a[1000/2] median(x2) sort(x) t1= table(x2) sort(t1, decreasing = T) x1 = rep(10,10) x1 sd(x1) dim(mtcars) mtlogmodel = glm(am ~ hp + wt, family='binomial', data=mtcars) summary(mtlogmodel) p1=predict(mtlogmodel, newdata=mtcars, type='response') p2= round(p1, 3) p3 = ifelse(p2<0.5,0,1) cbind(mtcars$am, mtcars$hp, mtcars$wt, p2,p3, truefalse= mtcars$am == p3)
gap.in.segments.f <- function(seg = NULL, geometry = "euc") { num.seg <- dim(seg)[1] gap <- rep(0, num.seg) for (i in 1:(num.seg - 1)) { if (seg$Transect.Label[i] == seg$Transect.Label[i + 1]) { if (geometry == "euc") dist <- euc.distance.f(seg$x[i], seg$y[i], seg$x[i + 1], seg$y[i + 1]) if (geometry == "geo") dist <- geo.distance.f(seg$longitude[i], seg$latitude[i], seg$longitude[i + 1], seg$latitude[i + 1]) effort.dist <- (seg$Effort[i] / 2) + (seg$Effort[i + 1] / 2) if (dist > effort.dist) gap[i + 1] <- 1 } } gap } define.blocks.f <- function(seg = NULL, covar.col = NULL, geometry = "euc") { num.covar <- length(covar.col) if (is.na(covar.col)) print("No covariates used to combined segments - using transects") num.seg <- dim(seg)[1] seg$Block.Label <- rep(NA, num.seg) j <- 1 seg$Block.Label[1] <- j gap <- gap.in.segments.f(seg = seg, geometry = geometry) for (i in 2:num.seg) { if (seg$Transect.Label[i] != seg$Transect.Label[i - 1]) j <- j + 1 if (gap[i] == 1) j <- j + 1 if (seg$Transect.Label[i] == seg$Transect.Label[i - 1]) { chg <- 0 if (!is.na(covar.col)) { for (k in 1:num.covar) { if (seg[i, covar.col[k]] != seg[i - 1, covar.col[k]]) chg <- 1 } } j <- j + chg } seg$Block.Label[i] <- j } seg } get.blocks.f <- function(seg = NULL, geometry = "euc") { name.blocks <- unique(seg$Block.Label) num.blocks <- length(name.blocks) blocks <- NULL for (i in 1:num.blocks) { temp <- seg[seg$Block.Label == name.blocks[i], ] num.seg <- dim(temp)[1] first <- temp[1, ] if (geometry == "euc") { first$end.x <- temp$end.x[num.seg] first$end.y <- temp$end.y[num.seg] } if (geometry == "geo") { first$end.lon <- temp$end.lon[num.seg] first$end.lat <- temp$end.lat[num.seg] } first$Effort <- sum(temp$Effort) if (i == 1) blocks <- first if (i > 1) blocks <- rbind(blocks, first) } exc.labels <- c("quadrant", "angle", "what.angle", "x", "y", "latitude", "longitude") col.names <- names(blocks) col.names <- !is.element(col.names, exc.labels) blocks <- blocks[, col.names] blocks } add.labels.to.obs.f <- function(dists = NULL, obs = NULL, seg = NULL) { num.dists <- dim(dists)[1] if (num.dists != dim(obs)[1]) print("Perp distance data and observation data different number of records") dists$Sample.Label <- obs$Sample.Label dists$Block.Label <- rep(NA, num.dists) for (i in 1:num.dists) { temp <- seg[seg$Sample.Label == dists$Sample.Label[i], ] if (dim(temp)[1] > 1) print(paste("More than one segment chosen for observation, object=", dists$object[i])) dists$Block.Label[i] <- temp$Block.Label[1] } dists } combine.dsmdata.f <- function(blocks = NULL, dists = NULL) { num.blocks <- dim(blocks)[1] cols.dists <- names(dists) exc.labels <- c("Sample.Label", "Block.Label", "Transect.Label", "Effort") cols.dist <- !is.element(cols.dists, exc.labels) one.dists.small <- dists[1, cols.dist] one.dists.small[1, ] <- NA k <- 0 for (i in 1:num.blocks) { one.block <- blocks[i, ] temp <- dists[dists$Block.Label == blocks$Block.Label[i], ] num.temp <- dim(temp)[1] if (num.temp > 0) { dists.small <- temp[, cols.dist] for (j in 1:num.temp) { block.dist <- cbind(one.block, dists.small[j, ]) if (j == 1) comb <- rbind(cbind(one.block, one.dists.small), block.dist) if (j > 1) comb <- rbind(comb, block.dist) } } if (num.temp == 0) comb <- cbind(one.block, one.dists.small) if (i == 1) all <- comb if (i > 1) all <- rbind(all, comb) } exc.labels <- c("quadrant", "angle", "what.angle", "Sample.Label") col.names <- names(all) col.names <- !is.element(col.names, exc.labels) all <- all[, col.names] col1 <- match("Transect.Label", names(all)) col2 <- match("Block.Label", names(all)) col3 <- match("object", names(all)) names(all)[c(col1, col2, col3)] <- c("trans", "seg", "det") all } get.direction.unit.f <- function(data = NULL, is.blocks = TRUE, geometry = "euc") { if (is.blocks) { data$Unit <- data$Block.Label name.label <- "Block.Label" } else { data$Unit <- data$Transect.Label name.label <- "Transect.Label" } if (geometry == "euc") { data$new.x <- data$x data$new.y <- data$y } if (geometry == "geo") { data$new.x <- data$longitude data$new.y <- data$latitude } name.unit <- unique(data$Unit) num.unit <- length(name.unit) unit <- NULL for (i in 1:num.unit) { temp <- data[data$Unit == name.unit[i], ] num.temp <- dim(temp)[1] unit$Unit[i] <- as.character(name.unit[i]) quad <- get.quadrant.f(temp$new.x[1], temp$new.y[1], temp$new.x[num.temp], temp$new.y[num.temp]) unit$quadrant[i] <- quad diff.x <- temp$new.x[num.temp] - temp$new.x[1] diff.y <- temp$new.y[num.temp] - temp$new.y[1] what.angle <- atan(diff.y / diff.x) * (180 / pi) if (quad == 1) unit$angle[i] <- 0 if (quad == 2) unit$angle[i] <- 90 if (quad == 3) unit$angle[i] <- 180 if (quad == 4) unit$angle[i] <- 270 if (quad == 5) unit$angle[i] <- 90 - abs(what.angle) if (quad == 6) unit$angle[i] <- 90 + abs(what.angle) if (quad == 7) unit$angle[i] <- 180 + abs(what.angle) if (quad == 8) unit$angle[i] <- 270 + abs(what.angle) unit$what.angle[i] <- what.angle } unit <- data.frame(unit) names(unit)[1] <- name.label unit } get.direction.segment.f <- function(data = NULL, geometry = "euc") { if (geometry == "euc") { data$new.x <- data$x data$new.y <- data$y } if (geometry == "geo") { data$new.x <- data$longitude data$new.y <- data$latitude } num.unit <- dim(data)[1] data$quadrant <- rep(NA, num.unit) data$angle <- rep(NA, num.unit) data$quadrant.r <- rep(NA, num.unit) data$angle.r <- rep(NA, num.unit) for (i in 1:(num.unit - 1)) { j <- i + 1 temp <- data[i:j, ] quad <- get.quadrant.f(temp$new.x[1], temp$new.y[1], temp$new.x[2], temp$new.y[2]) data$quadrant[i] <- quad diff.x <- temp$new.x[2] - temp$new.x[1] diff.y <- temp$new.y[2] - temp$new.y[1] data$angle[i] <- what.angle.f(dy = diff.y, dx = diff.x, quad = quad) if (temp$Transect.Label[1] != temp$Transect.Label[2]) { if (data$Transect.Label[i] == data$Transect.Label[i - 1]) { data$quadrant[i] <- data$quadrant[i - 1] data$angle[i] <- data$angle[i - 1] } if (data$Transect.Label[i] != data$Transect.Label[i - 1]) { print(paste("Only one segment in transect", data$Transect.Label[i])) } } } if (data$Transect.Label[num.unit] == data$Transect.Label[num.unit - 1]) { data$quadrant[num.unit] <- data$quadrant[num.unit - 1] data$angle[num.unit] <- data$angle[num.unit - 1] } if (data$Transect.Label[num.unit] != data$Transect.Label[num.unit - 1]) print("Last segment on its own") for (i in num.unit:2) { j <- i - 1 temp <- rbind(data[i, ], data[j, ]) quad <- get.quadrant.f(temp$new.x[1], temp$new.y[1], temp$new.x[2], temp$new.y[2]) data$quadrant.r[i] <- quad diff.x <- temp$new.x[2] - temp$new.x[1] diff.y <- temp$new.y[2] - temp$new.y[1] data$angle.r[i] <- what.angle.f(dy = diff.y, dx = diff.x, quad = quad) if (temp$Transect.Label[1] != temp$Transect.Label[2]) { if (data$Transect.Label[i] == data$Transect.Label[i - 1]) { data$quadrant.r[i] <- data$quadrant.r[i - 1] data$angle.r[i] <- data$angle.r[i - 1] } if (data$Transect.Label[i] != data$Transect.Label[i + 1]) { print(paste("Only one segment in transect", data$Transect.Label[i])) } } } if (data$Transect.Label[1] == data$Transect.Label[2]) { data$quadrant.r[1] <- data$quadrant.r[2] data$angle.r[1] <- data$angle.r[2] } exc.labels <- c("new.x", "new.y") col.names <- names(data) col.names <- !is.element(col.names, exc.labels) data <- data[, col.names] data } start.end.points.segments.f <- function(seg = NULL, use.tran = FALSE, tran = NULL, geometry = "euc") { num.seg <- dim(seg)[1] for (i in 1:num.seg) { if (use.tran) { temp <- tran[tran$Transect.Label == seg$Transect.Label[i], ] seg$quadrant[i] <- temp$quadrant[1] seg$angle[i] <- temp$angle[1] } seg.half.len <- seg$Effort[i] / 2 if (geometry == "euc") { if (seg$quadrant[i] == 1) { seg$start.x[i] <- seg$x[i] seg$start.y[i] <- seg$y[i] - seg.half.len seg$end.x[i] <- seg$x[i] seg$end.y[i] <- seg$y[i] + seg.half.len } if (seg$quadrant[i] == 2) { seg$start.x[i] <- seg$x[i] - seg.half.len seg$start.y[i] <- seg$y[i] seg$end.x[i] <- seg$x[i] + seg.half.len seg$end.y[i] <- seg$y[i] } if (seg$quadrant[i] == 3) { seg$start.x[i] <- seg$x[i] seg$start.y[i] <- seg$y[i] + seg.half.len seg$end.x[i] <- seg$x[i] seg$end.y[i] <- seg$y[i] - seg.half.len } if (seg$quadrant[i] == 4) { seg$start.x[i] <- seg$x[i] + seg.half.len seg$start.y[i] <- seg$y[i] seg$end.x[i] <- seg$x[i] - seg.half.len seg$end.y[i] <- seg$y[i] } if (seg$quadrant[i] == 5) { angle <- 90 - seg$angle[i] tri.sides <- get.triangle.sides.f(seg.len = seg.half.len, angle = angle) seg$start.x[i] <- seg$x[i] - tri.sides[2] seg$start.y[i] <- seg$y[i] - tri.sides[1] seg$end.x[i] <- seg$x[i] + tri.sides[2] seg$end.y[i] <- seg$y[i] + tri.sides[1] } if (seg$quadrant[i] == 6) { angle <- 180.0 - seg$angle[i] tri.sides <- get.triangle.sides.f(seg.len = seg.half.len, angle = angle) seg$start.x[i] <- seg$x[i] - tri.sides[1] seg$start.y[i] <- seg$y[i] + tri.sides[2] seg$end.x[i] <- seg$x[i] + tri.sides[1] seg$end.y[i] <- seg$y[i] - tri.sides[2] } if (seg$quadrant[i] == 7) { angle <- seg$angle[i] - 180.0 tri.sides <- get.triangle.sides.f(seg.len = seg.half.len, angle = angle) seg$start.x[i] <- seg$x[i] + tri.sides[1] seg$start.y[i] <- seg$y[i] + tri.sides[2] seg$end.x[i] <- seg$x[i] - tri.sides[1] seg$end.y[i] <- seg$y[i] - tri.sides[2] } if (seg$quadrant[i] == 8) { angle <- 360 - seg$angle[i] tri.sides <- get.triangle.sides.f(seg.len = seg.half.len, angle = angle) seg$start.x[i] <- seg$x[i] + tri.sides[1] seg$start.y[i] <- seg$y[i] - tri.sides[2] seg$end.x[i] <- seg$x[i] - tri.sides[1] seg$end.y[i] <- seg$y[i] + tri.sides[2] } } if (geometry == "geo") { print("This option is not implemented yet - use geometry=euc!") } } if (geometry == "euc") { x.col <- match("x", names(seg)) y.col <- match("y", names(seg)) names(seg)[c(x.col, y.col)] <- c("mid.x", "mid.y") } seg } get.quadrant.f <- function(start.x, start.y, end.x, end.y, tol = 0.0000001) { x.diff <- (start.x - end.x) y.diff <- (start.y - end.y) if (abs(x.diff) < tol & abs(y.diff) < tol) print("Segments on top of each other!") quad <- NA if (abs(x.diff) < tol) { if (end.y > start.y) quad <- 1 if (end.y < start.y) quad <- 3 } if (abs(y.diff) < tol) { if (end.x > start.x) quad <- 2 if (end.x < start.x) quad <- 4 } if (end.x > start.x & end.y > start.y) quad <- 5 if (end.x > start.x & end.y < start.y) quad <- 6 if (end.x < start.x & end.y < start.y) quad <- 7 if (end.x < start.x & end.y > start.y) quad <- 8 if (is.na(quad)) print("Quadrant not assigned") quad } euc.distance.f <- function(x1, y1, x2, y2) { x.diff <- abs(x1 - x2) y.diff <- abs(y1 - y2) hypot <- sqrt(x.diff^2 + y.diff^2) hypot } geo.distance.f <- function(lon1, lat1, lon2, lat2) { rad <- pi / 180 nm2km <- 1.852 if ((lat1 == lat2) & (lon1 == lon2)) { posdist <- 0 } else { rlat1 <- lat1 * rad rlat2 <- lat2 * rad rlon <- (lon2 - lon1) * rad posdist <- 60 * (1 / rad) * acos(sin(rlat1) * sin(rlat2) + cos(rlat1) * cos(rlat2) * cos(rlon)) } posdist <- posdist * nm2km posdist } get.triangle.sides.f <- function(seg.len = NULL, angle = NULL) { deg2rad <- pi / 180 x <- seg.len * sin(angle * deg2rad) y <- seg.len * cos(angle * deg2rad) triangle <- c(x, y) triangle } generate.obs.location.f <- function(seg = NULL, dists = NULL, geometry = "euc", do.plot = FALSE) { deg2rad <- pi / 180 num.sgt <- dim(dists)[1] new.sgt <- NULL new.sgt$x <- rep(NA, num.sgt) new.sgt$y <- rep(NA, num.sgt) new.sgt <- data.frame(new.sgt) if (do.plot) stop("do.plot code has been removed") for (i in 1:num.sgt) { temp <- seg[seg$Sample.Label == dists$Sample.Label[i], ] new.coords <- get.point.along.segment.f(temp$start.x[1], temp$start.y[1], temp$end.x[1], temp$end.y[1], quad = temp$quadrant[1], seg.angle = temp$angle[1]) new.x <- new.coords[1] new.y <- new.coords[2] what.side <- sample(c(-1, 1), 1) pd <- dists$distance[i] sgt.coords <- get.coords.f(quad = temp$quadrant[1], alpha = temp$angle[1], new.x = new.x, new.y = new.y, pd = pd, side = what.side) new.sgt$x[i] <- sgt.coords[1] new.sgt$y[i] <- sgt.coords[2] if (do.plot) { stop("do.plot=TRUE. This code has been removed.") } } new.sgt } get.point.along.segment.f <- function(x1, y1, x2, y2, quad = NULL, seg.angle) { deg2rad <- pi / 180 if (quad == 1) { new.x <- x1 new.y <- runif(1, min = y1, max = y2) } if (quad == 2) { new.x <- runif(1, min = x1, max = x2) new.y <- y1 } if (quad == 3) { new.x <- x1 new.y <- runif(1, min = y2, max = y1) } if (quad == 2) { new.x <- runif(1, min = x2, max = x1) new.y <- y1 } if (quad == 5) { theta <- 90 - seg.angle diffx <- x2 - x1 diffy <- y2 - y1 hyp <- get.hypot.f(diffx, diffy) smallhyp <- runif(1, 0, hyp) smallx <- cos(theta * deg2rad) * smallhyp smally <- sin(theta * deg2rad) * smallhyp new.x <- x1 + smallx new.y <- y1 + smally } if (quad == 6) { theta <- 180 - seg.angle diffx <- x2 - x1 diffy <- y1 - y2 hyp <- get.hypot.f(diffx, diffy) smallhyp <- runif(1, 0, hyp) smallx <- sin(theta * deg2rad) * smallhyp smally <- cos(theta * deg2rad) * smallhyp new.x <- x1 + smallx new.y <- y1 - smally } if (quad == 7) { theta <- seg.angle - 180 diffx <- x2 - x1 diffy <- y1 - y2 hyp <- get.hypot.f(diffx, diffy) smallhyp <- runif(1, 0, hyp) smallx <- sin(theta * deg2rad) * smallhyp smally <- cos(theta * deg2rad) * smallhyp new.x <- x1 - smallx new.y <- y1 - smally } if (quad == 8) { theta <- seg.angle - 270 diffx <- x1 - x2 diffy <- y1 - y2 hyp <- get.hypot.f(diffx, diffy) smallhyp <- runif(1, 0, hyp) smallx <- cos(theta * deg2rad) * smallhyp smally <- sin(theta * deg2rad) * smallhyp new.x <- x1 - smallx new.y <- y1 + smally } new.coords <- c(new.x, new.y) new.coords } get.coords.f <- function(quad = NULL, alpha = NULL, new.x = NULL, new.y = NULL, pd = NULL, side = NULL) { deg2rad <- pi / 180 if (quad == 1 | quad == 3) { sgt.x <- new.x + (side * pd) sgt.y <- new.y } if (quad == 2 | quad == 4) { sgt.x <- new.x sgt.y <- new.y + (side * pd) } if (quad == 5) { theta <- 90 - alpha x1 <- sin(theta * deg2rad) * pd y1 <- sqrt(pd^2 - x1^2) if (side == 1) { sgt.x <- new.x - x1 sgt.y <- new.y + y1 } if (side == (-1)) { sgt.x <- new.x + x1 sgt.y <- new.y - y1 } } if (quad == 6) { theta <- alpha - 90 x1 <- pd / tan(deg2rad * theta) y1 <- sin(theta * deg2rad) * x1 x2 <- sqrt(pd^2 - y1^2) if (side == 1) { sgt.x <- new.x + x2 sgt.y <- new.y + y1 } if (side == (-1)) { sgt.x <- new.x - x2 sgt.y <- new.y - y1 } } if (quad == 7) { theta <- 270 - alpha x1 <- sin(theta * deg2rad) * pd y1 <- sqrt(pd^2 - x1^2) if (side == 1) { sgt.x <- new.x - x1 sgt.y <- new.y + y1 } if (side == (-1)) { sgt.x <- new.x + x1 sgt.y <- new.y - y1 } } if (quad == 8) { theta <- 360 - alpha x1 <- pd / tan(deg2rad * theta) x2 <- sin(theta * deg2rad) * x1 y1 <- sqrt(pd^2 - x2^2) if (side == 1) { sgt.x <- new.x + x2 sgt.y <- new.y + y1 } if (side == (-1)) { sgt.x <- new.x - x2 sgt.y <- new.y - y1 } } sgt.coord <- c(sgt.x, sgt.y) sgt.coord } get.hypot.f <- function(side1, side2) { hyp <- sqrt(side1^2 + side2^2) hyp } what.angle.f <- function(dy = NULL, dx = NULL, quad = NULL) { what.angle <- atan(dy / dx) * (180 / pi) if (quad == 1) angle <- 0 if (quad == 2) angle <- 90 if (quad == 3) angle <- 180 if (quad == 4) angle <- 270 if (quad == 5) angle <- 90 - abs(what.angle) if (quad == 6) angle <- 90 + abs(what.angle) if (quad == 7) angle <- 180 + (90 - abs(what.angle)) if (quad == 8) angle <- 270 + abs(what.angle) angle }
check.mat <- function(H) { if (isSymmetric(H) == FALSE) {stop("H must be a symmetric matrix")} if (all(diag(H)>0) == FALSE) {stop("The diagonal elements of H must be positive")} if (all(diag(H) == floor(diag(H))) == FALSE) {stop("The diagonal elements of H must be integers")} if (mean(diag(H) == -apply(H-diag(diag(H)),1,sum)) != 1 | mean(diag(H) == -apply(H-diag(diag(H)),2,sum)) != 1) {stop("The diagonal elements of H should equal the number of neighbors for each region")} if (sum(eigen(H)$values < 1e-5) > 1) {stop("The specified region must be contiguous for this analysis")} }
data_dir <- file.path("..", "testdata") tempfile_nc <- function() { tempfile_helper("cmsaf.add_") } file_out <- tempfile_nc() cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- c(seq(480, 524, by = 2), seq(480, 524, by = 2), seq(480, 484, by = 2)) expected <- array(expected_data, dim = c(7, 7)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") actual <- ncatt_get(file, "SIS", "standard_name")$value expect_equal(actual, "SIS_standard") actual <- ncatt_get(file, "SIS", "long_name")$value expect_equal(actual, "Surface Incoming Shortwave Radiation") actual <- ncatt_get(file, "SIS", "units")$value expect_equal(actual, "W m-2") actual <- ncatt_get(file, "SIS", "_FillValue")$value expect_equal(actual, -999) actual <- ncatt_get(file, "SIS", "cmsaf_info")$value expect_equal(actual, "cmsafops::cmsaf.add for variable SIS") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(149016)) }) nc_close(file) file_out <- tempfile_nc() cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out, nc34 = 4) file <- nc_open(file_out) test_that("data is correct in version 4", { actual <- ncvar_get(file) expected_data <- c(seq(480, 524, by = 2), seq(480, 524, by = 2), seq(480, 484, by = 2)) expected <- array(expected_data, dim = c(7, 7)) expect_equivalent(actual, expected) }) test_that("attributes are correct in version 4", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct in version 4", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(149016)) }) nc_close(file) file_out <- tempfile_nc() test_that("error is thrown if ncdf version is wrong", { expect_error( cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out, nc34 = 7), "nc version must be in c(3, 4), but was 7", fixed = TRUE ) }) file_out <- tempfile_nc() test_that("ncdf version NULL throws an error", { expect_error( cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out, nc34 = NULL), "nc_version must not be NULL" ) }) file_out <- tempfile_nc() test_that("warning is shown if var does not exist", { expect_warning( cmsaf.add("lat", "lon", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out), "Variable 'lat' not found. Variable 'SIS' will be used instead." ) }) file <- nc_open(file_out) test_that("data is correct if non-existing variable is given", { actual <- ncvar_get(file) expected_data <- c(seq(480, 524, by = 2), seq(480, 524, by = 2), seq(480, 484, by = 2)) expected <- array(expected_data, dim = c(7, 7)) expect_equivalent(actual, expected) }) test_that("attributes are correct if non-existing variable is given", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct if non-existing variable is given", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(149016)) }) nc_close(file) file_out <- tempfile_nc() test_that("error is thrown if variable is NULL", { expect_error( cmsaf.add(NULL, "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out), "variable must not be NULL" ) }) file_out <- tempfile_nc() test_that("warning is shown if var is empty", { expect_warning( cmsaf.add("SIS", "", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out), "Variable '' not found. Variable 'SIS' will be used instead.") }) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- c(seq(480, 524, by = 2), seq(480, 524, by = 2), seq(480, 484, by = 2)) expected <- array(expected_data, dim = c(7, 7)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(149016)) }) nc_close(file) file_out <- tempfile_nc() test_that("error is thrown if input file does not exist", { expect_error( cmsaf.add("SIS", "SIS", file.path(data_dir, "xemaple1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out), "Input file does not exist") }) file_out <- tempfile_nc() test_that("error is thrown if input filename is empty", { expect_error( cmsaf.add("SIS", "SIS", "", file.path(data_dir, "ex_normal2.nc"), file_out), "Input file does not exist") }) file_out <- tempfile_nc() test_that("error is thrown if input filename is NULL", { expect_error( cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), NULL, file_out), "Input filepath must be of length one and not NULL") }) file_out <- tempfile_nc() cat("test\n", file = file_out) test_that("error is thrown if output file already exists", { expect_error( cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out), paste0("File '", file_out, "' already exists. Specify 'overwrite = TRUE' if you want to overwrite it."), fixed = TRUE ) expect_equal(readLines(con = file_out), "test") }) file_out <- tempfile_nc() cat("test\n", file = file_out) test_that("no error is thrown if overwrite = TRUE", { expect_error( cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out, overwrite = TRUE), NA ) }) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- c(seq(480, 524, by = 2), seq(480, 524, by = 2), seq(480, 484, by = 2)) expected <- array(expected_data, dim = c(7, 7)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(149016)) }) nc_close(file) file_out <- tempfile_nc() cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_time_dim1.nc"), file.path(data_dir, "ex_time_dim2.nc"), file_out) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- rep(seq(480, 524, by = 2), 4) expected <- array(expected_data, dim = c(7, 7, 2)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(c(149016, 158544))) }) nc_close(file) file_out <- tempfile_nc() cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_time_dim2.nc"), file_out) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- c(rep(seq(480, 524, by = 2), 2), seq(480, 484, by = 2), seq(483, 521, by = 2), seq(500, 504, by = 2), seq(483, 521, by = 2), seq(500, 504, by = 2), seq(483, 487, by = 2)) expected <- array(expected_data, dim = c(7, 7, 2)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(c(167976, 177480))) }) nc_close(file) file_out <- tempfile_nc() cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_time_dim1.nc"), file.path(data_dir, "ex_normal2.nc"), file_out) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- c(rep(seq(480, 524, by = 2), 2), seq(480, 484, by = 2), seq(483, 521, by = 2), seq(500, 504, by = 2), seq(483, 521, by = 2), seq(500, 504, by = 2), seq(483, 487, by = 2)) expected <- array(expected_data, dim = c(7, 7, 2)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(c(149016, 158544))) }) nc_close(file) file_out <- tempfile_nc() test_that("error is thrown if dimensions do not match", { expect_error(cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_time_dim3.nc"), file.path(data_dir, "ex_time_dim2.nc"), file_out), "Uncompatible time lengths!") }) file_out <- tempfile_nc() test_that("error is thrown if dimensions don't match", { expect_error(cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_normal1.nc"), file.path(data_dir, "ex_different_lon_length.nc"), file_out), "Dimensions of infiles do not match!") }) file_out <- tempfile_nc() cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_additional_attr.nc"), file.path(data_dir, "ex_normal2.nc"), file_out) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- c(seq(480, 524, by = 2), seq(480, 524, by = 2), seq(480, 484, by = 2)) expected <- array(expected_data, dim = c(7, 7)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 2) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") actual <- names(global_attr[2]) expect_equal(actual, "institution") actual <- global_attr[[2]] expect_equal(actual, "This is a test attribute.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(149016)) }) nc_close(file) file_out <- tempfile_nc() cmsaf.add("SIS", "SIS", file.path(data_dir, "ex_v4_1.nc"), file.path(data_dir, "ex_v4_2.nc"), file_out) file <- nc_open(file_out) test_that("data is correct", { actual <- ncvar_get(file) expected_data <- c(seq(480, 524, by = 2), seq(480, 524, by = 2), seq(480, 484, by = 2)) expected <- array(expected_data, dim = c(7, 7)) expect_equivalent(actual, expected) }) test_that("attributes are correct", { actual <- ncatt_get(file, "lon", "units")$value expect_equal(actual, "degrees_east") actual <- ncatt_get(file, "lon", "long_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "standard_name")$value expect_equal(actual, "longitude") actual <- ncatt_get(file, "lon", "axis")$value expect_equal(actual, "X") actual <- ncatt_get(file, "lat", "units")$value expect_equal(actual, "degrees_north") actual <- ncatt_get(file, "lat", "long_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "standard_name")$value expect_equal(actual, "latitude") actual <- ncatt_get(file, "lat", "axis")$value expect_equal(actual, "Y") actual <- ncatt_get(file, "time", "units")$value expect_equal(actual, "hours since 1983-01-01 00:00:00") actual <- ncatt_get(file, "time", "long_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "standard_name")$value expect_equal(actual, "time") actual <- ncatt_get(file, "time", "calendar")$value expect_equal(actual, "standard") global_attr <- ncatt_get(file, 0) expect_equal(length(global_attr), 1) actual <- names(global_attr[1]) expect_equal(actual, "Info") actual <- global_attr[[1]] expect_equal(actual, "Created with the CM SAF R Toolbox.") }) test_that("coordinates are correct", { actual <- ncvar_get(file, "lon") expect_identical(actual, array(seq(5, 8, 0.5))) actual <- ncvar_get(file, "lat") expect_identical(actual, array(seq(45, 48, 0.5))) actual <- ncvar_get(file, "time") expect_equal(actual, array(149016)) }) nc_close(file)
context("Function scenarioBuilder") sapply(studies, function(study) { setup_study(study, sourcedir) opts <- antaresRead::setSimulationPath(studyPath, "input") test_that("scenarioBuilder works", { sbuilder <- scenarioBuilder( n_scenario = 2, n_mc = 2, areas = c("fr", "it", "be"), areas_rand = c("it", "be") ) sb <- structure( c("1", "rand", "rand", "2", "rand", "rand"), .Dim = 3:2, .Dimnames = list(c("fr", "it", "be"), NULL) ) expect_identical(sbuilder, sb) }) test_that("scenarioBuilder works when areas_rand has length 1", { sbuilder <- scenarioBuilder( n_scenario = 2, n_mc = 2, areas = c("fr", "it", "be"), areas_rand = "it" ) sb <- structure( c("1", "rand", "1", "2", "rand", "2"), .Dim = 3:2, .Dimnames = list(c("fr", "it", "be"), NULL) ) expect_identical(sbuilder, sb) }) test_that("Warning is thrown when n_mc differs from nbyears", { expect_warning(scenarioBuilder( n_scenario = 2, n_mc = 3, areas = c("fr", "it", "be"), areas_rand = "it" )) }) test_that("readScenarioBuilder works", { expect_identical( readScenarioBuilder(), list( l = structure( c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Dim = c(9L, 2L), .Dimnames = list( c("a", "a_offshore", "b", "c", "hub", "psp in", "psp in-2", "psp out", "psp out-2"), NULL) ), t = structure( c(1L, 1L, 1L, 1L, 1L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2L, 2L, 2L, 2L, 2L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), .Dim = c(15L, 2L), .Dimnames = list( c("a_base", "a_base_must_run", "a_peak", "a_peak_must_run_partial", "a_semi base", "b_base", "b_peak", "b_semi base", "c_base", "c_peak", "c_semi base", "psp in-2_psp_in_2", "psp in_psp_in", "psp out-2_psp_out_2", "psp out_psp_out"), NULL ) ) ) ) expect_warning(readScenarioBuilder(ruleset = "fake ruleset name")) }) test_that("updateScenarioBuilder works", { m <- scenarioBuilder( n_scenario = 2, n_mc = 2, areas = c("a", "b", "c"), areas_rand = c("b", "c") ) m2 <- scenarioBuilder( n_scenario = 2, n_mc = 2, areas = c("a", "b", "c"), areas_rand = "c" ) expect_error(updateScenarioBuilder(ldata = m)) expect_error(updateScenarioBuilder(ldata = m, series = "h"), NA) updateScenarioBuilder(ldata = list(w = m, s = m2)) newSB <- readScenarioBuilder(as_matrix = TRUE) m <- m[m[, 1] != "rand", , drop = FALSE] m_out <- apply(m, 2, as.integer) attributes(m_out) <- attributes(m) expect_identical(newSB[["w"]]["a", , drop = FALSE], m_out) m2 <- m2[m2[, 1] != "rand", , drop = FALSE] m2_out <- apply(m2, 2, as.integer) attributes(m2_out) <- attributes(m2) expect_identical(newSB[["s"]][c("a", "b"), , drop = FALSE], m2_out) }) test_that("clearScenarioBuilder works", { expect_true(clearScenarioBuilder()) expect_length(readScenarioBuilder(), 0L) }) unlink(x = file.path(pathstd, "test_case"), recursive = TRUE) })
context("CHECK_X") mat <- matrix(0, 10, 10) X <- as.big.matrix(mat) test_that("is a big.matrix?", { expect_error(check_X(mat), ERROR_BIGMATRIX, fixed = TRUE) expect_null(check_X(X)) })
setMethod("split_by_doc_id", signature=signature(obj="kRp.corpus"), function(obj, keepFeatures=TRUE){ return( split_by_doc_id( kRp_text( lang=language(obj), desc=describe(obj), tokens=taggedText(obj), features=slot(obj, "features"), feat_list=slot(obj, "feat_list") ), keepFeatures=keepFeatures ) ) } )
"getStartTri" <- function(xx, nexp, ncomp){ y <- as.matrix(rowSums(xx)) dim(y) <- c(ncomp, nexp) ampList <- vector("list", length=nexp) for(i in 1:nexp) ampList[[i]] <- rep(0,ncomp) fixedamps <- vector("list", length=ncomp) for(i in 1:ncomp) { ycol <- y[i,] mind <- which(ycol==max(ycol)) ycol <- ycol / max(ycol) fixedamps[[i]] <- c(mind,i) for(j in 1:nexp) ampList[[j]][i] <- ycol[j] } list(fixedamps=fixedamps, ampList=ampList) }
.euclideanDist.forNCP = function(x, y, use = 'p') { x = as.matrix(x); y = as.matrix(y); ny = ncol(y) diff = matrix(NA, ncol(x), ny); for (cy in 1:ny) diff[, cy] = apply( (x - y[, cy])^2, 2, sum, na.rm = TRUE); -diff; } nearestCentroidPredictor = function( x, y, xtest = NULL, featureSignificance = NULL, assocFnc = "cor", assocOptions = "use = 'p'", assocCut.hi = NULL, assocCut.lo = NULL, nFeatures.hi = 10, nFeatures.lo = 10, weighFeaturesByAssociation = 0, scaleFeatureMean = TRUE, scaleFeatureVar = TRUE, centroidMethod = c("mean", "eigensample"), simFnc = "cor", simOptions = "use = 'p'", useQuantile = NULL, sampleWeights = NULL, weighSimByPrediction = 0, CVfold = 0, returnFactor = FALSE, randomSeed = 12345, verbose = 2, indent = 0) { centroidMethod = match.arg(centroidMethod); if (simFnc=="dist") { if (verbose > 0) printFlush(paste("NearestCentroidPredictor: 'dist' is changed to a suitable", "Euclidean distance function.\n", " Note: simOptions will be disregarded.")); simFnc = ".euclideanDist.forNCP"; simOptions = "use = 'p'" } ySaved = y; originalYLevels = sort(unique(y)) ; y = as.numeric(as.factor(y)); x = as.matrix(x); doTest = !is.null(xtest) if (doTest) { xtest = as.matrix(xtest); nTestSamples = nrow(xtest); if (ncol(x)!=ncol(xtest)) stop("Number of learning and testing predictors (columns of x, xtest) must equal."); } else { if (weighSimByPrediction > 0) stop("weighting similarity by prediction is not possible when xtest = NULL."); nTestSamples = 0; } numYLevels = sort(unique(y)); minY = min(y); maxY = max(y); nSamples = length(y); nVars = ncol(x); if (!is.null(assocCut.hi)) { if (is.null(assocCut.lo)) assocCut.lo = -assocCut.hi; } spaces = indentSpaces(indent); if (!is.null(useQuantile)) { if ( (useQuantile < 0) | (useQuantile > 1) ) stop("If 'useQuantile' is given, it must be between 0 and 1."); } if (is.null(sampleWeights)) sampleWeights = rep(1, nSamples); if (CVfold > 0) { if (CVfold > nSamples ) { printFlush("'CVfold' is larger than number of samples. Will perform leave-one-out cross-validation."); CVfold = nSamples; } ratio = nSamples/CVfold; if (floor(ratio)!=ratio) { smaller = floor(ratio); nLarger = nSamples - CVfold * smaller binSizes = c(rep(smaller, CVfold-nLarger), rep(smaller +1, nLarger)); } else binSizes = rep(ratio, CVfold); if (!is.null(randomSeed)) { if (exists(".Random.seed")) { saved.seed = .Random.seed; seedSaved = TRUE; } else seedSaved = FALSE; set.seed(randomSeed); } sampleOrder = sample(1:nSamples); CVpredicted = rep(NA, nSamples); CVbin = rep(0, nSamples); if (verbose > 0) { cat(paste(spaces, "Running cross-validation: ")); if (verbose==1) pind = initProgInd() else printFlush(""); } if (!is.null(featureSignificance)) printFlush(paste("Warning in nearestCentroidPredictor: \n", " cross-validation will be biased if featureSignificance was derived", "from training data.")); ind = 1; for (cv in 1:CVfold) { if (verbose > 1) printFlush(paste("..cross validation bin", cv, "of", CVfold)); end = ind + binSizes[cv] - 1; samples = sampleOrder[ind:end]; CVbin[samples] = cv; xCVtrain = x[-samples, , drop = FALSE]; xCVtest = x[samples, , drop = FALSE]; yCVtrain = y[-samples]; yCVtest = y[samples]; CVsampleWeights = sampleWeights[-samples]; pr = nearestCentroidPredictor(xCVtrain, yCVtrain, xCVtest, featureSignificance = featureSignificance, assocCut.hi = assocCut.hi, assocCut.lo = assocCut.lo, nFeatures.hi = nFeatures.hi, nFeatures.lo = nFeatures.lo, useQuantile = useQuantile, sampleWeights = CVsampleWeights, CVfold = 0, returnFactor = FALSE, randomSeed = randomSeed, centroidMethod = centroidMethod, assocFnc = assocFnc, assocOptions = assocOptions, scaleFeatureMean = scaleFeatureMean, scaleFeatureVar = scaleFeatureVar, simFnc = simFnc, simOptions = simOptions, weighFeaturesByAssociation = weighFeaturesByAssociation, weighSimByPrediction = weighSimByPrediction, verbose = verbose - 2, indent = indent + 1) CVpredicted[samples] = pr$predictedTest; ind = end + 1; if (verbose==1) pind = updateProgInd(cv/CVfold, pind); } if (verbose==1) printFlush(""); } if (nrow(x)!=length(y)) stop("Number of observations in x and y must equal."); xWeighted = x * sampleWeights; yWeighted = y * sampleWeights; if (is.null(featureSignificance)) { corEval = parse(text = paste(assocFnc, "(xWeighted, yWeighted, ", assocOptions, ")")); featureSignificance = as.vector(eval(corEval)); } else { if (length(featureSignificance)!=nVars) stop("Given 'featureSignificance' has incorrect length (must be nFeatures)."); } nGood = nVars; nNA = sum(is.na(featureSignificance)); testCentroidSimilarities = list(); xSD = apply(x, 2, sd, na.rm = TRUE); keep = is.finite(featureSignificance) & (xSD>0); nKeep = sum(keep); keepInd = c(1:nVars)[keep]; order = order(featureSignificance[keep]); levels = sort(unique(y)); nLevels = length(levels); if (is.null(assocCut.hi)) { nf = c(nFeatures.hi, nFeatures.lo); if (nf[2] > 0) ind1 = c(1:nf[2]) else ind1 = c(); if (nf[1] > 0) ind2 = c((nKeep-nf[1] + 1):nKeep) else ind2 = c(); indexSelect = unique(c(ind1, ind2)); if (length(indexSelect) < 1) stop("No features were selected. At least one of 'nFeatures.hi', 'nFeatures.lo' must be nonzero."); indexSelect = indexSelect[indexSelect > 0]; select = keepInd[order[indexSelect]]; } else { indexSelect = (1:nKeep)[ featureSignificance[keep] >= assocCut.hi | featureSignificance[keep] <= assocCut.lo ] if (length(indexSelect)<2) stop(paste("'assocCut.hi'", assocCut.hi, "and assocCut.lo", assocCut.lo, "are too stringent, less than 3 features were selected.\n", "Please relax the cutoffs.")); select = keepInd[indexSelect]; } if ((length(select) < 3) && (simFnc!='dist')) { stop(paste("Less than 3 features were selected. Please either relax", "the selection criteria of use simFnc = 'dist'.")); } selectedFeatures = select; nSelect = length(select); xSel = x[, select]; selectSignif = featureSignificance[select]; if (scaleFeatureMean) { if (scaleFeatureVar) { xSD = apply(xSel, 2, sd, na.rm = TRUE); } else xSD = rep(1, nSelect); xMean = apply(xSel, 2, mean, na.rm = TRUE); } else { if (scaleFeatureVar) { xSD = sqrt(apply(xSel^2, 2, sum, na.rm = TRUE)) / pmax(apply(!is.na(xSel), 2, sum) - 1, rep(1, nSelect)); } else xSD = rep(1, nSelect); xMean = rep(0, nSelect); } xSel = scale(xSel, center = scaleFeatureMean, scale = scaleFeatureVar); if (doTest) { xtestSel = xtest[, select]; xtestSel = (xtestSel - matrix(xMean, nTestSamples, nSelect, byrow = TRUE) ) / matrix(xSD, nTestSamples, nSelect, byrow = TRUE); } else xtestSel = NULL; xWeighted = xSel * sampleWeights; if (weighSimByPrediction > 0) { pr = .quickGeneVotingPredictor.CV(xSel, xtestSel, c(1:nSelect)) dCV = sqrt(colMeans( (pr$CVpredicted - xSel)^2, na.rm = TRUE)); dTS = sqrt(colMeans( (pr$predictedTest - xtestSel)^2, na.rm = TRUE)); dTS[dTS==0] = min(dTS[dTS>0]); validationWeight = (dCV/dTS)^weighSimByPrediction; validationWeight[validationWeight > 1] = 1; } else validationWeight = rep(1, nSelect); nTestSamples = if (doTest) nrow(xtest) else 0; predicted = rep(0, nSamples); predictedTest = rep(0, nTestSamples); clusterLabels = list(); clusterNumbers = list(); if ( (centroidMethod=="eigensample") ) { if (sum(is.na(xSel)) > 0) { xImp = t(impute.knn(t(xSel), k = min(10, nSelect - 1))$data); } else xImp = xSel; if (doTest && sum(is.na(xtestSel))>0) { xtestImp = t(impute.knn(t(xtestSel), k = min(10, nSelect - 1))$data); } else xtestImp = xtestSel; } clusterNumbers = rep(1, nLevels); sampleModules = list(); for (l in 1:nLevels) clusterLabels[[l]] = rep(l, sum(y==levels[l])) nClusters = sum(clusterNumbers); centroidSimilarities = array(NA, dim = c(nSamples, nClusters)); testCentroidSimilarities = array(NA, dim = c(nTestSamples, nClusters)); cluster2level = rep(c(1:nLevels), clusterNumbers); featureWeight = validationWeight; if (is.null(useQuantile)) { centroidProfiles = array(0, dim = c(nSelect, nClusters)); for (cl in 1:nClusters) { l = cluster2level[cl]; clusterSamples = c(1:nSamples)[ y==l ] [ clusterLabels[[l]]==cl ]; if (centroidMethod=="mean") { centroidProfiles[, cl] = apply(xSel[clusterSamples, , drop = FALSE], 2, mean, na.rm = TRUE); } else if (centroidMethod=="eigensample") { cp = svd(xSel[clusterSamples,], nu = 0, nv = 1)$v[, 1]; cor = cor(t(xSel[clusterSamples,]), cp); if (sum(cor, na.rm = TRUE) < 0) cp = -cp; centroidProfiles[, cl] = cp; } } if (weighFeaturesByAssociation > 0) featureWeight = featureWeight * sqrt(abs(selectSignif)^weighFeaturesByAssociation); wcps = centroidProfiles * featureWeight; wxSel = t(xSel) * featureWeight; distExpr = spaste( simFnc, "( wcps, wxSel, ", simOptions, ")"); sample.centroidSim = eval(parse(text = distExpr)); if (doTest) { wxtestSel = t(xtestSel) * featureWeight distExpr = spaste( simFnc, "( wcps, wxtestSel, ", simOptions, ")"); testSample.centroidSim = eval(parse(text = distExpr)); } } else { labelVector = y; for (l in 1:nLevels) labelVector[y==l] = clusterLabels[[l]]; keepSamples = labelVector!=0; nKeepSamples = sum(keepSamples); keepLabels = labelVector[keepSamples]; if (weighFeaturesByAssociation > 0) featureWeight = featureWeight * sqrt(abs(selectSignif)^weighFeaturesByAssociation); wxSel = t(xSel) * featureWeight; wxSel.keepSamples = t(xSel[keepSamples, ]) * featureWeight; distExpr = spaste( simFnc, "( wxSel.keepSamples, wxSel, ", simOptions, ")"); dst = eval(parse(text = distExpr)); if (doTest) { wxtestSel = t(xtestSel) * featureWeight distExpr = spaste( simFnc, "( wxSel.keepSamples, wxtestSel, ", simOptions, ")"); dst.test = eval(parse(text = distExpr)); sample.centroidSim = matrix(0, nClusters, nSamples); testSample.centroidSim = matrix(0, nClusters, nTestSamples); } for (l in 1:nClusters) { lSamples = c(1:nKeepSamples)[keepLabels==l]; sample.centroidSim[l, ] = colQuantileC(dst[lSamples, ], 1-useQuantile); testSample.centroidSim[l, ] = colQuantileC(dst.test[lSamples, ], 1-useQuantile); } } centroidSimilarities = t(sample.centroidSim); prediction = cluster2level[apply(sample.centroidSim, 2, which.max)]; predicted = prediction; if (doTest) { testCentroidSimilarities = t(testSample.centroidSim); testprediction = cluster2level[apply(testSample.centroidSim, 2, which.max)]; predictedTest = testprediction; } if (returnFactor) { predicted.out = factor(originalYLevels[[t]][predicted]) if (doTest) predictedTest.out = factor(originalYLevels[[t]][predictedTest]); if (CVfold > 0) CVpredicted.out = factor(originalYLevels[[t]][CVpredicted]); } else { predicted.out = originalYLevels[predicted]; if (doTest) predictedTest.out = originalYLevels[predictedTest]; if (CVfold > 0) CVpredicted.out = originalYLevels[CVpredicted]; } out = list(predicted = predicted.out, predictedTest = if (doTest) predictedTest.out else NULL, featureSignificance = featureSignificance, selectedFeatures = selectedFeatures, centroidProfiles = if (is.null(useQuantile)) centroidProfiles else NULL, testSample2centroidSimilarities = if (doTest) testCentroidSimilarities else NULL, featureValidationWeights = validationWeight ) if (CVfold > 0) out$CVpredicted = CVpredicted.out; out; }
get_par_filenames = function(ids = get_ids(), modalities = c("FLAIR", "MPRAGE", "T2w", "fMRI", "DTI"), visits = c(1,2)){ modalities = unique(modalities) visits = as.numeric(visits) visits = sprintf("%02.0f", visits) v_ids = c(outer(ids, visits, paste, sep="-")) fnames = c(outer(v_ids, modalities, paste, sep="-")) fnames = paste0(fnames, ".par.gz") df = data.frame(fname = fnames, stringsAsFactors = FALSE) ss = strsplit(df$fname, "-") df$id = sapply(ss, `[`, 1) df$visit = as.numeric(sapply(ss, `[`, 2)) df$fname = file.path(paste0("visit_", df$visit), df$id, df$fname) df$id = NULL filenames = system.file( df$fname, package="kirby21") return(filenames) }
context("config_file_location") skip_on_cran() loc <- config_file_location() test_that("config_file_location returns a character", { expect_is(loc, "character") }) test_that("should be able to set and get a default qsub config", { if (file.exists(loc)) { prev <- get_default_qsub_config() } else { prev <- NULL } on.exit({ set_default_qsub_config(prev) }) config <- create_qsub_config(remote = "foo", local_tmp_path = "/help", remote_tmp_path = "/bar") set_default_qsub_config(config) expect_equal(get_default_qsub_config(), config) config2 <- create_qsub_config(remote = "foo2", local_tmp_path = "/help2", remote_tmp_path = "/bar2") set_default_qsub_config(config2, permanent = FALSE) expect_equal(get_default_qsub_config(), config2) set_default_qsub_config(NULL, permanent = FALSE) expect_equal(get_default_qsub_config(), config) })
plot.lab.qcs <- function(x, title = NULL, xlab = NULL, ylab = NULL, col = NULL, ylim = NULL, ...) { if(!is.null(x) & !inherits(x, "lab.qcs") & !is.list(x)) stop("x must be an objects of class (or extending) 'lab.qcs'") data.name <- attributes(x)$object.name type.data <- attributes(x)$type.data oldpar <- par(mar = c(4, 3, 1, 1) + 0.1) if (is.null(title)) title <- data.name if (is.null(xlab)) xlab <- "Laboratory" if (is.null(ylab)) ylab <- "Statistical" if (type.data == "lab.qcs") { print(dotplot(rownames(x$statistics.material) ~ S+S_r+S_B+S_R, data = x$statistics.material,horizontal = T, key = simpleKey(c("S","S_r","S_B","S_R"), space = "right"), xlab = xlab, aspect=0.5, ylab = ylab)) } else { st<-t(x[[6]]) p <-x$p m <- x$m crit <- x[[7]] if (is.null(col)){ if (m==1){ col <- terrain.colors(p) }else{ col <- terrain.colors(m) } } legend.text = rownames(t(x[[6]])) if (type.data=="h.qcs") { if (is.null(ylim)) ylim <- c(-3,3) if (m>1){ barplot(height = st,width = 0.05,main=title,names.arg = colnames(t(x[[6]])), beside = T, col=col,xlab=xlab, ylim=ylim,axisnames=T) legend ("topleft",legend = legend.text,bty = "n",pch = 22,pt.bg = col,cex = 0.8) }else{ barplot(height = st,width = 0.05,main=title,names.arg = colnames(t(x[[6]])), beside = T, col=col,xlab=xlab, ylim=ylim,axisnames=T) } abline(h=c(crit,-crit),lty="dashed") } else{ if (is.null(ylim)) ylim <- c(0,3) if (m>1){ barplot(height = st,width = 0.05,main=title,names.arg = colnames(t(x[[6]])), beside = T, horiz=F,col=col,xlab=xlab, ylim=ylim,axisnames=T) legend ("topleft",legend = legend.text,bty = "n",pch = 22,pt.bg = col,cex = 0.8,pt.cex = 1.5) }else{ barplot(height = st,width = 0.05,main=title,names.arg = colnames(t(x[[6]])), beside = T, horiz=F,col=col,xlab=xlab, ylim=ylim,axisnames=T) } abline(h=crit,lty="dashed") } } par(oldpar) }
estimateNoise <- function(x, y, intercept = TRUE) { n <- NROW(x) p <- NCOL(x) stopifnot(n > p) fit <- stats::lm.fit(x, y) sqrt(sum(fit$residuals^2) / (n-p+intercept)) }
DFS_is_available <- function( henv = hive() ) { if( DFS_is_registered(henv) ){ stat <- .DFS_stat( "/", henv ) if( !(is.null(stat) || is.na(stat)) ) return( TRUE ) } FALSE } DFS_is_registered <- function(henv = hive()){ if( is.null(HDFS(henv)) || is.null(IOUTILS(henv)) ){ return(FALSE) } TRUE } DFS_file_exists <- function( file, henv = hive() ) { stopifnot(DFS_is_registered(henv)) hdfs <- HDFS(henv) hdfs$exists(HDFS_path(file)) } DFS_dir_exists <- function( path, henv = hive() ) { path <- file.path(path) status <- tryCatch(.DFS_getFileStatus(path, henv ), error = identity) if(inherits(status, "error")) return(FALSE) status$isDir() } DFS_dir_create <- function( path, henv = hive() ) { if( DFS_dir_exists(path, henv) ) { warning( sprintf("directory '%s' already exists.", path) ) return( invisible(FALSE) ) } if( DFS_file_exists(path, henv) ) { warning( sprintf("'%s' already exists but is not a directory", path) ) return( invisible(FALSE) ) } status <- .DFS_mkdir( path, henv ) if( is.null(status) ) { warning( sprintf("cannot create dir '%s'.", path) ) return( invisible(FALSE) ) } invisible( TRUE ) } DFS_delete <- function( file, recursive = FALSE, henv = hive() ) { if( DFS_dir_exists(file, henv) && !recursive){ warning(sprintf("cannot remove directory '%s'. Use 'recursive = TRUE' instead.", file)) return(FALSE) } status <- .DFS_delete( file, henv ) if(!status){ warning(sprintf("cannot remove file '%s'.", file)) return(FALSE) } TRUE } DFS_dir_remove <- function(path, recursive = TRUE, henv = hive()){ if( DFS_dir_exists(path, henv) ){ DFS_delete(path, recursive, henv) TRUE } else { warning(sprintf("'%s' is not a directory.", path)) FALSE } } DFS_list <- function( path = ".", henv = hive() ) { globstat <- .DFS_stat(path, henv) if( is.null(globstat) ){ warning(sprintf("'%s' is not a readable directory", path)) return(character(0)) } splitted <- strsplit(grep(path, .DFS_intern("-ls", path, henv), value = TRUE), path) sapply(splitted, function(x) basename(x[2])) } DFS_cat <- function( file, con = stdout(), henv = hive() ){ stopifnot( DFS_file_exists(file, henv) ) .DFS("-cat", file, henv) } DFS_rename <- function( from, to, henv = hive() ){ stopifnot( DFS_file_exists(from, henv) ) .DFS_rename( from, to, henv ) } DFS_tail <- function(file, n = 6L, size = 1024, henv = hive() ){ stopifnot( as.integer(n) > 0L ) stopifnot( DFS_file_exists(file, henv) ) out <- .DFS_tail(file, size, henv = henv) len <- length(out) if( len < n ) n <- len out[(len - (n - 1)) : len] } .DFS_tail <- function(file, size = 1024, henv = hive()){ stopifnot(DFS_is_registered(henv)) hdfs <- HDFS(henv) ioutils <- IOUTILS(henv) hdfs_file <- HDFS_path(file) len <- hdfs$getFileStatus(hdfs_file)$getLen() offset <- ifelse(len > size, len - size, 0) inputstream <- hdfs$open(hdfs_file) inputstream$seek(.jlong(offset)) routput <- .jnew("org/rosuda/JRI/RConsoleOutputStream", .jengine(TRUE), as.integer(0)) out <- character(0) con <- textConnection("out", open = "w", local = TRUE) sink(file = con) ioutils$copyBytes(inputstream, routput, as.integer(1024), TRUE) sink() close(con) out } DFS_put <- function( files, path = ".", henv = hive() ) { if(length(files) == 1) status <- .DFS("-put", paste(files, path), henv ) else { if( !DFS_dir_exists(path, henv) ) DFS_dir_create( path, henv ) status <- .DFS("-put", paste(paste(files, collapse = " "), path), henv ) } if( status ){ warning( sprintf("Cannot put file(s) to '%s'.", path) ) return( invisible(FALSE) ) } invisible( TRUE ) } DFS_put_object <- function( obj, file, henv = hive() ) { con <- .DFS_pipe( "-put", file, open = "w", henv = henv ) status <- tryCatch(serialize( obj, con ), error = identity) close.connection(con) if(inherits(status, "error")) stop("Serialization failed.") invisible(file) } DFS_write_lines <- function( text, file, henv = hive() ) { stopifnot(DFS_is_registered(henv = henv)) if(DFS_file_exists(file)){ warning(sprintf("file '%s' already exists.", file)) return(NA) } if(!length(text)) stop("text length of zero not supported.") hdfs <- HDFS(henv) outputstream <- hdfs$create(HDFS_path(file)) for( i in seq_along(text) ){ outputstream$writeBytes(text[i]) outputstream$writeBytes("\n") } outputstream$close() invisible(file) } DFS_read_lines <- function( file, n = -1L, henv = hive() ) { if(!DFS_file_exists(file)){ warning(sprintf("file '%s' does not exists.", file)) return(NA) } hdfs <- HDFS(henv) ioutils <- IOUTILS(henv) offset <- 0 inputstream <- hdfs$open(HDFS_path(file)) if( n <= 0 ){ inputstream$seek(.jlong(offset)) routput <- .jnew("org/rosuda/JRI/RConsoleOutputStream", .jengine(TRUE), as.integer(0)) con <- textConnection("out", open = "w", local = TRUE) sink(file = con) ioutils$copyBytes(inputstream, routput, as.integer(1024), TRUE) sink() close(con) } else { out <- character(n) for(i in 1:n) out[i] <- inputstream$readLine() inputstream$close() } out } DFS_get_object <- function( file, henv = hive() ) { con <- .DFS_pipe( "-cat", file, open = "r", henv = henv ) obj <- tryCatch( unserialize(con), error = identity) close.connection(con) if(inherits(obj, "error")) return(NA) obj } .DFS_delete <- function(x, henv){ stopifnot( DFS_is_registered(henv) ) hdfs <- HDFS(henv) hdfs$delete(HDFS_path(x)) } .DFS_mkdir <- function(x, henv){ stopifnot( DFS_is_registered(henv) ) hdfs <- HDFS(henv) hdfs$mkdirs(HDFS_path(x)) } .DFS_stat <- function(x, henv){ stat <- DFS_file_exists(x, henv) if(!stat){ warning(sprintf("cannot stat '%s': No such file or directory", x)) return(NULL) } TRUE } .DFS_rename <- function( from, to, henv ){ stopifnot( DFS_is_registered(henv) ) hdfs <- HDFS(henv) hdfs$rename(HDFS_path(from), HDFS_path(to)) } .DFS_getFileStatus <- function(x, henv){ stopifnot( DFS_is_registered(henv) ) hdfs <- HDFS(henv) hdfs$getFileStatus(HDFS_path(x)) } .DFS <- function( cmd, args, henv ) system( .DFS_create_command(cmd, args, henv), ignore.stderr = TRUE ) .DFS_pipe <- function( cmd, args, open = "w", henv ){ if(open == "w") pipe(.DFS_create_command(cmd, sprintf("- %s", args), henv), open = open) else pipe(.DFS_create_command(cmd, args, henv), open = open) } .DFS_intern <- function( cmd, args, henv ) system( .DFS_create_command(cmd, args, henv), intern = TRUE, ignore.stderr = TRUE ) .DFS_create_command <- function( cmd, args, henv ) sprintf("%s fs %s %s", hadoop(henv), cmd, args) .DFS_format <- function(henv){ stopifnot(hive_stop(henv)) machines <- unique(c(hive_get_workers(henv), hive_get_masters(henv))) DFS_root <- gsub("\\$\\{user.name\\}", system("whoami", intern = TRUE), hive_get_parameter("hadoop.tmp.dir", henv)) for(machine in machines){ command <- sprintf("ssh %s 'rm -rf %s/* rm -rf %s-*' ", machine, DFS_root, DFS_root) system(command) } system(sprintf("%s namenode -format", hadoop(henv))) }
crono <- read.csv(text="Name,Group,start_year,end_year First long period,long,1800-01-01,1899-12-31 Second period,short,1870-01-01,1910-12-31 Another long period,long,1900-01-01,1990-12-31 More events on period time,short,1965-01-01,1985-12-31") events <- read.csv(text="Name,start_year Person 1 was born,1870-01-01 Person 1 first novel,1895-01-01 Build the new building,1905-01-01 Death person 1,1930-01-01 renovation building,1950-01-01 collection,1970-01-01") crono <- sapply(crono, as.character) events$end_year <- NA events$Group<-c(1,2,1,2,1,2) events <- sapply(events, as.character) data <- as.data.frame(rbind(crono, events[, c(1,4,2,3)])) vistime(data, col.event="Name", col.start="start_year", col.end ="end_year", linewidth=70) vistime(data, col.event="Name", col.start="start_year", col.end ="end_year", col.group ="Group", linewidth=70) hc_vistime(data, col.event="Name", col.start="start_year", col.end ="end_year", col.group ="Group", )
x <- seq(0, 30, by=0.25) density <- 0.3 * dnorm(x,8,2) + 0.7 * dnorm(x,16,3) xyplot(density~x, type="l", main="pdf of a mixture of normals")
tar_test("backoff actually slows down and then resets", { test_backoff <- function(backoff) { expect_equal(backoff$index, 0L) begin <- unname(proc.time()["elapsed"]) for (index in seq_len(30L)) { bound <- round(backoff$bound(), 4L) backoff$wait() end <- unname(proc.time()["elapsed"]) elapsed <- end - begin begin <- end msg <- paste0( "bound: ", bound, " | elapsed: ", round(elapsed, 4), "\n" ) cat(msg) } } backoff <- backoff_init(min = 0.001, max = 2, rate = 1.5) test_backoff(backoff) backoff$reset() cat("\n") test_backoff(backoff) }) tar_test("backoff interval is uniformly distributed", { set.seed(1) backoff <- backoff_init(min = 1, max = 10, rate = 2) map(seq_len(1e3), ~backoff$increment()) out <- map_dbl(seq_len(1e5), ~backoff$interval()) expect_equal(min(out), 1, tolerance = 1e-3) expect_equal(max(out), 10, tolerance = 1e-3) hist(out) })
mcmc_mra <- function( y, X, locs, params, priors = NULL, M = 4, n_neighbors = 68, n_coarse_grid = 10, n_padding = 5L, n_cores = 1L, inits = NULL, config = NULL, verbose = FALSE, use_spam = TRUE, n_chain = 1 ) { if (!is_numeric_vector(y, length(y))) stop("y must be a numeric vector of length N.") if (length(y) != nrow(X)) stop("X must have the same number of rows as the length of y.") if (!is_numeric_matrix(X, length(y), ncol(X))) stop("X must be a numeric matrix with N rows.") if (!is_numeric_matrix(locs, length(y), 2)) stop("locs must be a numeric matrix with N rows and 2 columns.") if (!is_positive_integer(params$n_adapt, 1)) stop("params must contain a positive integer n_adapt.") if (!is_positive_integer(params$n_mcmc, 1)) stop("params must contain a positive integer n_mcmc.") if (!is_positive_integer(params$n_thin, 1)) stop("params must contain a positive integer n_thin.") if (!is_positive_integer(params$n_message, 1)) stop("params must contain a positive integer n_message.") params$n_adapt <- as.integer(params$n_adapt) params$n_mcmc <- as.integer(params$n_mcmc) params$n_thin <- as.integer(params$n_thin) params$n_message <- as.integer(params$n_message) if (!is.logical(verbose) || length(verbose) != 1 || is.na(verbose)) { stop("verbose must be either TRUE or FALSE.") } if (!is.logical(use_spam) || length(use_spam) != 1 || is.na(use_spam)) { stop("use_spam must be either TRUE or FALSE.") } if (!is_positive_integer(n_cores, 1)) { stop("n_cores must be a positive integer") } n_cores <- as.integer(n_cores) if (!is_positive_integer(n_chain, 1)) { stop("n_chain must be a positive integer") } n_chain <- as.integer(n_chain) sample_beta <- TRUE if (!is.null(config)) { if (!is.null(config[['sample_beta']])) { sample_beta <- config[['sample_beta']] if (!is.logical(sample_beta) | is.na(sample_beta)) stop('If specified, sample_beta must be TRUE or FALSE') } } sample_tau2 <- TRUE if (!is.null(config)) { if (!is.null(config[['sample_tau2']])) { sample_tau2 <- config[['sample_tau2']] if (!is.logical(sample_tau2) | is.na(sample_tau2)) stop('If specified, sample_tau2 must be TRUE or FALSE') } } sample_lambda <- TRUE if (!is.null(config)) { if (!is.null(config[['sample_lambda']])) { sample_lambda <- config[['sample_lambda']] if (!is.logical(sample_lambda) | is.na(sample_lambda)) stop('If specified, sample_lambda must be TRUE or FALSE') } } sample_sigma2 <- TRUE if (!is.null(config)) { if (!is.null(config[['sample_sigma2']])) { sample_sigma2 <- config[['sample_sigma2']] if (!is.logical(sample_sigma2) | is.na(sample_sigma2)) stop('If specified, sample_sigma2 must be TRUE or FALSE') } } sample_alpha <- TRUE if (!is.null(config)) { if (!is.null(config[['sample_alpha']])) { sample_alpha <- config[['sample_alpha']] if (!is.logical(sample_alpha) | is.na(sample_alpha)) stop('If specified, sample_alpha must be TRUE or FALSE') } } num_chol_failures <- 0 N <- length(y) p <- ncol(X) MRA <- mra_wendland_2d( locs = locs, M = M, n_coarse_grid = n_coarse_grid, n_padding = n_padding, n_neighbors = n_neighbors, use_spam = use_spam ) W_list <- MRA$W tW_list <- vector(mode = 'list', length = M) tWW_list <- vector(mode = 'list', length = M) for (m in 1:M) { if (use_spam) { tW_list[[m]] <- t(W_list[[m]]) } else { stop("Only support use_spam = TRUE") } tWW_list[[m]] <- tW_list[[m]] %*% W_list[[m]] } n_dims <- rep(NA, length(W_list)) dims_idx <- c() for (i in 1:M) { n_dims[i] <- ncol(W_list[[i]]) dims_idx <- c(dims_idx, rep(i, n_dims[i])) } W <- do.call(cbind, W_list) tW <- NULL if (use_spam) { tW <- t(W) } else { stop ('Only support use_spam = TRUE') } tWW <- tW %*% W tX <- t(X) tXX <- tX %*% X mu_beta <- rep(0, p) Sigma_beta <- 10 * diag(p) if (!is.null(priors[['mu_beta']])) { if(!is_numeric_vector(priors[['mu_beta']], p)) stop("If specified, the parameter mu_beta in priors must be a numeric vector of length equal to the number of columns of X.") if (all(!is.na(priors[['mu_beta']]))) { mu_beta <- priors[['mu_beta']] } } if (!is.null(priors[['Sigma_beta']])) { if(!is_sympd_matrix(priors[['Sigma_beta']], p)) stop("If specified, the parameter Sigma_beta in priors must be a symmetric positive definite matrix with rows and columns equal to the number of columns of X.") if (all(!is.na(priors[['Sigma_beta']]))) { Sigma_beta <- priors[['Sigma_beta']] } } Sigma_beta_chol <- tryCatch( chol(Sigma_beta), error = function(e) { if (verbose) message("The Cholesky decomposition of the prior covariance Sigma_beta was ill-conditioned and mildy regularized.") chol(Sigma_beta + 1e-8 * diag(p)) } ) Sigma_beta_inv <- chol2inv(Sigma_beta_chol) beta <- as.vector(lm (y ~ X - 1)$coeff) X_beta <- X %*% beta Q_alpha <- make_Q_alpha_2d(sqrt(n_dims), rep(0.999, length(n_dims)), use_spam = use_spam) scale_lambda <- 0.5 lambda <- rgamma(M, 0.5, scale_lambda) tau2 <- rep(1, M) alpha_tau2 <- 1 beta_tau2 <- 1 if (!is.null(priors[['alpha_tau2']])) { if (!is_positive_numeric(priors[['alpha_tau2']], 1)) stop("If specified, the parameter alpha_tau2 in priors must be a positive numeric value.") if (all(!is.na(priors[['alpha_tau2']]))) { alpha_tau2 <- priors[['alpha_tau2']] } } if (!is.null(priors[['beta_tau2']])) { if (!is_positive_numeric(priors[['beta_tau2']], 1)) stop("If specified, the parameter beta_tau2 in priors must be a positive numeric value.") if (all(!is.na(priors[['beta_tau2']]))) { beta_tau2 <- priors[['beta_tau2']] } } Q_alpha_tau2 <- make_Q_alpha_tau2(Q_alpha, tau2, use_spam = use_spam) alpha_sigma2 <- 1 beta_sigma2 <- 1 if (!is.null(priors[['alpha_sigma2']])) { if (!is_positive_numeric(priors[['alpha_sigma2']], 1)) stop("If specified, the parameter alpha_sigma2 in priors must be a positive numeric value.") if (all(!is.na(priors[['alpha_sigma2']]))) { alpha_sigma2 <- priors[['alpha_sigma2']] } } if (!is.null(priors[['beta_sigma2']])) { if (!is_positive_numeric(priors[['beta_sigma2']], 1)) stop("If specified, the parameter beta_sigma2 in priors must be a positive numeric value.") if (all(!is.na(priors[['beta_sigma2']]))) { beta_sigma2 <- priors[['beta_sigma2']] } } sigma2 <- pmax(pmin(1 / rgamma(1, alpha_sigma2, beta_sigma2), 5), 0.1) sigma <- sqrt(sigma2) alpha <- NULL if (use_spam) { A_alpha <- 1 / sigma2 * tWW + Q_alpha_tau2 Rstruct <- chol(A_alpha) b_alpha <- 1 / sigma2 * tW %*% (y - X_beta) alpha <- rep(0, sum(n_dims)) } else { stop("The only sparse matrix pacakage available is spam") } A_constraint <- t( sapply(1:M, function(i){ tmp = rep(0, sum(n_dims)) tmp[dims_idx == i] <- 1 return(tmp) }) ) a_constraint <- rep(0, M) Q_alpha <- make_Q_alpha_2d(sqrt(n_dims), rep(1, length(n_dims)), use_spam = use_spam) Q_alpha_tau2 <- make_Q_alpha_tau2(Q_alpha, tau2, use_spam = use_spam) W_alpha <- W %*% alpha if (!is.null(inits[['beta']])) { if(!is_numeric_vector(inits[['beta']], p)) stop("initial value for beta must be a numeric vector of length p") if (all(!is.na(inits[['beta']]))) { beta <- inits[['beta']] } } if (!is.null(inits[['sigma2']])) { if(!is_positive_numeric(inits[['sigma2']], 1)) stop("initial value for sigma2 must be a positive numeric value") if (all(!is.na(inits[['sigma2']]))) { sigma2 <- inits[['sigma2']] } } if (!is.null(inits[['alpha']])) { if(!is_numeric_vector(inits[['alpha']], length(alpha))) stop("initial value for alpha must be positive numeric vector of length equal to the number of all grid points") if (all(!is.na(inits[['alpha']]))) { alpha <- inits[['alpha']] } } if (!is.null(inits[['tau2']])) { if(!is_positive_numeric(inits[['tau2']], M) | !is.vector(inits[['tau2']])) stop("initial value for tau2 must be a positive numeric vector of length M") if (all(!is.na(inits[['tau2']]))) { tau2 <- inits[['tau2']] } } n_save <- params$n_mcmc / params$n_thin beta_save <- matrix(0, n_save, p) tau2_save <- matrix(0, n_save, M) sigma2_save <- rep(0, n_save) alpha_save <- matrix(0, n_save, sum(n_dims)) lambda_save <- matrix(0, n_save, M) message("Starting MCMC for chain ", n_chain, ", running for ", params$n_adapt, " adaptive iterations and ", params$n_mcmc, " fitting iterations \n") for (k in 1:(params$n_adapt + params$n_mcmc)) { if (k == params$n_adapt + 1) { message("Starting MCMC fitting for chain ", n_chain, ", running for ", params$n_mcmc, " iterations \n") } if (k %% params$n_message == 0) { if (k <= params$n_adapt) { message("MCMC adaptation iteration ", k, " for chain ", n_chain) } else { message("MCMC fitting iteration ", k - params$n_adapt, " for chain ", n_chain) } } if (sample_sigma2) { if (verbose) message("sample sigma2") devs <- y - X_beta - W_alpha SS <- sum(devs^2) sigma2 <- 1 / rgamma(1, N / 2 + alpha_sigma2, SS / 2 + beta_sigma2) sigma <- sqrt(sigma2) } if (sample_beta) { if (verbose) message("sample beta") A <- 1 / sigma2 * tXX + Sigma_beta_inv b <- 1 / sigma2 * tX %*% (y - W_alpha) + Sigma_beta_inv %*% mu_beta A <- (A + t(A)) / 2 beta <- rmvn_arma(A, b) X_beta <- X %*% beta } if (sample_alpha) { if (verbose) message("sample alpha") A_alpha <- 1 / sigma2 * tWW + Q_alpha_tau2 b_alpha <- 1 / sigma2 * tW %*% (y - X_beta) alpha <- as.vector(rmvnorm.canonical.const(1, b_alpha, A_alpha, Rstruct = Rstruct, A = A_constraint, a = a_constraint)) } W_alpha <- W %*% alpha if (sample_tau2) { if (verbose) message("sample tau2") for (m in 1:M) { devs <- alpha[dims_idx == m] SS <- as.numeric(devs %*% (Q_alpha[[m]] %*% devs)) tau2[m] <- rgamma(1, alpha_tau2 + n_dims[m] / 2, beta_tau2 + SS / 2) } } Q_alpha_tau2 <- make_Q_alpha_tau2(Q_alpha, tau2, use_spam = use_spam) if (sample_lambda) { if (verbose) message("sample lambda") for (m in 1:M) { lambda[m] <- rgamma(1, 1, scale_lambda + 1 / tau2[m]) } } if (k >= params$n_adapt) { if (k %% params$n_thin == 0) { save_idx <- (k - params$n_adapt) / params$n_thin beta_save[save_idx, ] <- beta tau2_save[save_idx, ] <- tau2 sigma2_save[save_idx] <- sigma2 alpha_save[save_idx, ] <- alpha lambda_save[save_idx, ] <- lambda } } } if (num_chol_failures > 0) warning("The Cholesky decomposition for the update of alpha was ill-conditioned and mildy regularized ", num_chol_failures, " times. If this warning is rare, this should be safe to ignore.") out <- list( beta = beta_save, tau2 = tau2_save, sigma2 = sigma2_save, alpha = alpha_save, lambda = lambda_save, MRA = MRA ) class(out) <- "mcmc_mra" return(out) }
dirm <- function(formula, state.specification, data, prior = NULL, contrasts = NULL, na.action = na.pass, niter, ping = niter / 10, model.options = DirmModelOptions(), timestamps = NULL, seed = NULL, ...) { check.nonnegative.scalar(niter) check.scalar.integer(ping) stopifnot(is.null(seed) || length(seed) == 1) stopifnot(inherits(model.options, "DirmModelOptions")) if (!is.null(seed)) { seed <- as.integer(seed) } function.call <- match.call() my.model.frame <- match.call(expand.dots = FALSE) frame.match <- match(c("formula", "data", "na.action"), names(my.model.frame), 0L) my.model.frame <- my.model.frame[c(1L, frame.match)] my.model.frame$drop.unused.levels <- TRUE if (! "na.action" %in% names(my.model.frame)) { my.model.frame$na.action <- na.pass } my.model.frame[[1L]] <- as.name("model.frame") my.model.frame <- eval(my.model.frame, parent.frame()) model.terms <- attr(my.model.frame, "terms") predictors <- model.matrix(model.terms, my.model.frame, contrasts) if (any(is.na(predictors))) { stop("dirm does not allow NA's in the predictors.") } response <- model.response(my.model.frame, "any") sample.size <- if (is.matrix(response)) nrow(response) else length(response) stopifnot(nrow(predictors) == sample.size) if (missing(data)) { data <- NULL } timestamp.info <- TimestampInfo(response, data, timestamps) data.list <- list(response = as.numeric(response), predictors = predictors, response.is.observed = !is.na(response), timestamp.info = timestamp.info) if (is.null(prior)) { prior <- SpikeSlabPrior( x = predictors, y = response, optional.coefficient.estimate = rep(0, ncol(predictors)), sigma.upper.limit = 1.2 * sd(response, na.rm = TRUE), ...) } stopifnot(inherits(prior, "SpikeSlabPriorBase")) predictor.sd <- apply(predictors, 2, sd) prior$prior.inclusion.probabilities[predictor.sd <= 0] <- 0 if (is.null(prior$max.flips)) { prior$max.flips <- -1 } ans <- .Call("analysis_common_r_fit_dirm_", data.list, state.specification, prior, model.options, niter, ping, seed, PACKAGE = "bsts") ans$has.regression <- TRUE ans$state.specification <- state.specification ans$prior <- prior ans$timestamp.info <- timestamp.info ans$niter <- niter if (!is.null(ans$ngood)) { ans <- .Truncate(ans) } ans$original.series <- response number.of.state.components <- length(state.specification) state.names <- character(number.of.state.components) for (i in seq_len(number.of.state.components)) { state.names[i] <- state.specification[[i]]$name } dimnames(ans$state.contributions) <- list( mcmc.iteration = NULL, component = state.names, time = NULL) ans$contrasts <- attr(predictors, "contrasts") ans$xlevels <- .getXlevels(model.terms, my.model.frame) ans$terms <- model.terms ans$predictors <- predictors variable.names <- colnames(predictors) if (!is.null(variable.names)) { colnames(ans$coefficients) <- variable.names } class(ans) <- c("DynamicIntercept", "bsts") return(ans) } DirmModelOptions <- function(timeout.seconds = Inf, high.dimensional.threshold.factor = 1.0) { stopifnot(is.numeric(timeout.seconds), length(timeout.seconds) == 1, timeout.seconds >= 0) stopifnot(is.numeric(high.dimensional.threshold.factor), length(high.dimensional.threshold.factor) == 1, high.dimensional.threshold.factor >= 0) ans <- list(timeout.seconds = timeout.seconds, high.dimensional.threshold.factor = high.dimensional.threshold.factor) class(ans) <- "DirmModelOptions" return(ans) } .RemoveIntercept <- function(predictors) { stopifnot(is.matrix(predictors)) is.intercept <- rep(FALSE, ncol(predictors)) for (i in 1:ncol(predictors)) { if (all(predictors[, i]) == 1) { is.intercept[i] <- TRUE } } return(predictors[, !is.intercept]) }
dhalfcauchy <- function(x, location = 0, scale = 1) { ifelse(x < 0, 0, 1) * dcauchy(x, location, scale) / (1 - pcauchy( 0, location, scale )) }
knitr::opts_chunk$set( collapse = TRUE, comment = " ) library(tidyverse) library(pharmaRTF) ht <- huxtable::as_hux(iris[, c("Species", "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")], add_colnames=TRUE) ht[1:10, c('Species', 'Petal.Width')] huxtable::print_screen(ht[1:10,]) huxtable::width(ht) <- 1.5 ht <- ht %>% huxtable::set_width(1.5) ht[1:10,] huxtable::col_width(ht) <- c(.4, .15, .15, .15, .15) ht <- ht %>% huxtable::set_col_width(c(.4, .15, .15, .15, .15)) ht[1:10,] ht[1,] column_headers <- data.frame( Species = "Species of Flower", Sepal.Length = "Sepal Length", Sepal.Width = "Sepal Width", Petal.Length = "Petal Length", Petal.Width = "Petal Width", stringsAsFactors = FALSE ) ht <- huxtable::as_hux(rbind(column_headers, iris)) ht[1:10,] huxtable::bold(ht[1, ]) <- TRUE huxtable::italic(ht[2, ]) <- TRUE ht <- ht %>% huxtable::set_bottom_border(1, 1:ncol(ht), 1) %>% huxtable::set_bottom_border(2, 1:ncol(ht), 4) %>% huxtable::set_align(3, 2, 'right') ht[1:10,] column_headers <- data.frame( Species = c("", "Species of Flower"), Sepal.Length = c("Sepal", "Length"), Sepal.Width = c("", "Width"), Petal.Length = c("Petal", "Length"), Petal.Width = c("", "Width"), stringsAsFactors = FALSE ) ht <- huxtable::as_hux(rbind(column_headers, iris)) %>% huxtable::merge_cells(1, 2:3) %>% huxtable::merge_cells(1, 4:5) %>% huxtable::set_align(1,2, 'center') %>% huxtable::set_align(1,4, 'center') %>% huxtable::set_bold(1:2, 1:ncol(iris), TRUE) %>% huxtable::set_bottom_border(1, 2:4, 1) %>% huxtable::set_bottom_border(2, 1:ncol(iris), 2) ht[1:10,] ht[2, 1] <- "Species of\\line flower" huxtable::escape_contents(ht) <- FALSE huxtable::width(ht) <- 1.5 ht[1:10,] doc <- rtf_doc(ht, header_rows = 2) write_rtf(doc, file='table4.rtf') knitr::include_graphics("table4_img1.png")
library(lamme) data("schoene") attach(schoene) summary(schoene) c('sd_pre'=sd(pre_HRT),'sd_post'=sd(post_HRT)) abc(post_HRT,group,pre_HRT) lancova(post_HRT,group,pre_HRT) boot.es(post_HRT,group,pre_HRT) par(mfrow=c(2,2)) lanova(post_HRT,group) pwr.lanova(3,40,.01,.05) pwr.lancova(3,40,.01,.5,.05) ss.lanova(3,.01,.8,.05) ss.lancova(3,.01,.5,.8,.05)
AdditionFI_W3 <- function() { self <- environment() class(self) <- append('AdditionFI_W3', class(self)) addNumeric <- function(x_n, y_n) x_n + y_n addDouble <- function(x_d, y_d) x_d + y_d addInteger <- function(x_i, y_i) x_i + y_i divideByZero <- function(x_n) x_n / 0 generateWarning <- function(x_) 1:3 + 1:7 generateError <- function() stop('generated error') function_return_types <- data.table( function_name = c('addNumeric', 'addDouble', 'addInteger', 'generateWarning', 'generateError'), return_value = c('x_n', 'x_d', 'x_i', 'x_i', 'x') ) label <- 'erroneous function return type definition - unknown return type x' self }
"theta" <- c(0, 0) "X" <- c(0, 0, 0)
setClassUnion("data.frameOrNULL",members=c("data.frame", "NULL")) setClassUnion("numericOrNULL",members=c("numeric", "NULL")) pednames <- c("famid", "id", "father", "mother", "sex", "pheno") snpnames <- c("chr", "id", "dist", "pos", "A1", "A2") snpstatnames0 <- c("N0", "N1", "N2", "NAs", "callrate", "maf", "hz", "N0.f", "N1.f", "N2.f", "NAs.f" ) snpstatnames <- c(snpstatnames0, "hwe") pedstatnames <- c("N0", "N1", "N2", "NAs", "N0.x", "N1.x", "N2.x", "NAs.x", "N0.y", "N1.y", "N2.y", "NAs.y", "N0.mt", "N1.mt", "N2.mt", "NAs.mt", "callrate", "hz", "callrate.x", "hz.x", "callrate.y", "hz.y", "callrate.mt", "hz.mt") is.null.df <- function(x) is.data.frame(x) & nrow(x) == 0 & ncol(x) == 0 setClass("bed.matrix", representation( ped = 'data.frame', snps = 'data.frame', bed = 'externalptr', p = 'numericOrNULL', mu = 'numericOrNULL', sigma = 'numericOrNULL', standardize_p = 'logical', standardize_mu_sigma = 'logical' )) setValidity('bed.matrix', function(object) { errors <- character() if ( object@standardize_p & object@standardize_mu_sigma ) errors <- c(errors, "Only one center scale parameter can be TRUE.") if ( object@standardize_p & is.null(object@p) ) errors <- c(errors, "If 'standardize_p' is TRUE, 'p' must be defined.") if ( object@standardize_mu_sigma & ( is.null(object@mu) | is.null(object@sigma) ) ) errors <- c(errors, "If 'standardize_mu_sigma' is TRUE, 'mu' and 'sigma' must be defined.") if ( !is.null(object@p) & length(object@p) != ncol(object) ) errors <- c(errors, "The length of 'p' must be equal to the number of markers.") if ( !is.null(object@mu) & length(object@mu) != ncol(object) ) errors <- c(errors, "The length of 'mu' must be equal to the number of markers.") if ( !is.null(object@sigma) & length(object@sigma) != ncol(object) ) errors <- c(errors, "The length of 'sigma' must be equal to the number of markers.") if(.Call("isnullptr", PACKAGE = 'gaston', object@bed)) errors <- c(errors, 'The externalptr is broken') if ( length(errors)==0 ) return(TRUE) else return(errors) } ); setAs("bed.matrix", "matrix", function(from) { validObject(from) to <- if(from@standardize_p) .Call('gg_m4_as_scaled_matrix_p', PACKAGE = 'gaston', from@bed, from@p) else if(from@standardize_mu_sigma) .Call('gg_m4_as_scaled_matrix_mu_sigma', PACKAGE = 'gaston', from@bed, from@mu, from@sigma) else .Call('gg_m4_as012', PACKAGE = 'gaston', from@bed) colnames(to) <- from@snps$id rownames(to) <- if(any(duplicated(from@ped$id))) paste(from@ped$fam, from@ped$id, sep=":") else from@ped$id to } ); setGeneric('as.matrix') setMethod("as.matrix", signature="bed.matrix", definition = function(x) as(x,"matrix") ) setAs("matrix", "bed.matrix", function(from) { bed <- .Call('gg_as_matrix4', PACKAGE = 'gaston', from) ped <- if(is.null(rownames(from))) structure(list(), row.names = c(NA, -nrow(from)), class = "data.frame") else data.frame(famid = rownames(from), id = rownames(from), father = 0, mother = 0, sex = 0, pheno = 0, stringsAsFactors = FALSE) snp <- if(is.null(colnames(from))) structure(list(), row.names = c(NA, -ncol(from)), class = "data.frame") else data.frame(chr = NA, id = colnames(from), dist = NA, pos = NA, A1 = NA, A2 = NA, stringsAsFactors = FALSE) x <- new("bed.matrix", bed = bed, snps = snp, ped = ped, p = NULL, mu = NULL, sigma = NULL, standardize_p = FALSE, standardize_mu_sigma = FALSE ) if(getOption("gaston.auto.set.stats", TRUE)) x <- set.stats(x, verbose = FALSE) x } ); setGeneric('dim') setMethod("dim", signature = "bed.matrix", function(x) c(.Call('gg_ninds', PACKAGE = 'gaston', x@bed), .Call('gg_nsnps', PACKAGE = 'gaston', x@bed))) setGeneric('head') setMethod( 'head', signature(x='bed.matrix'), function(x, nrow=10, ncol=10) print( as.matrix( x[1:min( nrow, nrow(x) ),1:min( ncol, ncol(x) )] ) ) ) setMethod(show, signature("bed.matrix"), function(object) { if(.Call("isnullptr", PACKAGE = 'gaston', object@bed)) cat("A bed.matrix with a broken externalptr!\nHint: don't save/load bed.matrices with other functions than write.bed.matrix and read.bed.matrix\n") else { cat('A bed.matrix with ', nrow(object), ' individuals and ', ncol(object), ' markers.\n', sep='') if(anyDuplicated(object@snps$id)) cat("There are some duplicated SNP id's\n") if(all(snpstatnames0 %in% names(object@snps))) { cat("snps stats are set\n"); a <- sum(object@snps$NAs == nrow(object)) if(a > 1) cat(" There are ", a, " SNPs with a callrate equal to zero\n"); if(a == 1) cat(" There is one SNP with a callrate equal to zero\n"); a <- sum(object@snps$maf == 0, na.rm = TRUE) if(a > 1) cat(" There are ", a, " monomorphic SNPs\n"); if(a == 1) cat(" There is one monomorphic SNP\n"); } else cat("snps stats are not set (or incomplete)\n") if(anyDuplicated(object@ped[, c("famid", "id")])) cat("There are some duplicated individual id's\n") if(all(pedstatnames %in% names(object@ped))) { cat("ped stats are set\n"); a <- sum(object@ped$NAs == ncol(object)) if(a > 1) cat(" There are ", a, " individuals with a callrate equal to zero\n"); if(a == 1) cat(" There is one individual with a callrate equal to zero\n"); } else cat("ped stats are not set (or incomplete)\n") } } )
varlog.lam <- function(sight1,sight2){ if(sight1$call$form != sight2$call$form){ stop("Need same sightability model to calculate the covariance") } if(is.null(sight1$sight$note)){ varbeta <- vcov(sight1$sight) beta <- coef(sight1$sight) }else{ varbeta <- sight1$sight$varbet beta <- sight1$sight$bet } y1 <- sight1$odat$total y2 <- sight2$odat$total n1 <- nrow(sight1$odat) n2 <- nrow(sight2$odat) inv.srate1 <- 1/sight1$odat$samp.rates inv.srate2 <- 1/sight2$odat$samp.rates fo <- sight1$call$form class(fo) <- "formula" tempnm1 <- terms(fo, data = sight1$odat) tempnm2 <- attr(tempnm1, "term.labels") covars1 <- sight1$odat[, tempnm2] covars2 <- sight2$odat[, tempnm2] xdat1 <- as.matrix(cbind(rep(1, n1), covars1)) xdat2 <- as.matrix(cbind(rep(1, n2), covars2)) xb1 <- xdat1%*%beta xb2 <- xdat2%*%beta xbb <- kronecker(xb1, t(xb2), FUN = "+") xvarbeta <- xdat1%*%varbeta%*%t(xdat2) smat <- matrix(0, n1, n2) for(i in 1:n1){ for(j in 1:n2){ xtemp1 <- as.vector(xdat1[i, ], mode = "numeric") xtemp2 <- as.vector(xdat2[j, ], mode = "numeric") xtot <- t(xtemp1+xtemp2) smat[i,j] <- (xtot%*%varbeta%*%t(xtot))/2 } } smat.cov <- exp(-xbb-smat)*(exp(xvarbeta)-1) y.p1 <- as.matrix(y1*inv.srate1, n1, 1) y.p2 <- as.matrix(y2*inv.srate2, n2, 1) cov.total <- t(y.p1)%*%smat.cov%*%y.p2 var.tau1.tau2 <- matrix(c(sight2$est[2], cov.total, cov.total, sight1$est[2]), ncol = 2, byrow = TRUE) dfs <- matrix(c(1/sight2$est[1], -1/sight1$est[1]), 1, 2) varloglam <- list(loglamda = log(sight2$est[1]/sight1$est[1]), varloglamda = dfs%*%var.tau1.tau2%*%t(dfs)) return(varloglam = varloglam) }
NNS.FSD.uni <- function(x, y, type = "discrete"){ if(any(class(x)==c("tbl", "data.table"))) x <- as.vector(unlist(x)) if(any(class(y)==c("tbl", "data.table"))) y <- as.vector(unlist(y)) if(sum(is.na(cbind(x,y))) > 0) stop("You have some missing values, please address.") type <- tolower(type) if(!any(type%in%c("discrete", "continuous"))){ warning("type needs to be either discrete or continuous") } if(min(y) > min(x)){ return(0) } else { Combined_sort <- sort(c(x, y), decreasing = FALSE) if(type == "discrete"){ degree <- 0 } else { degree <- 1 } L.x <- LPM(degree, Combined_sort, x) LPM_x_sort <- L.x / (UPM(degree, Combined_sort, x) + L.x) L.y <- LPM(degree, Combined_sort, y) LPM_y_sort <- L.y / (UPM(degree, Combined_sort, y) + L.y) x.fsd.y <- any(LPM_x_sort > LPM_y_sort) ifelse(!x.fsd.y && min(x) >= min(y) && !identical(LPM_x_sort, LPM_y_sort), return(1), return(0)) } } NNS.SSD.uni <- function(x, y){ if(any(class(x)==c("tbl", "data.table"))) x <- as.vector(unlist(x)) if(any(class(y)==c("tbl", "data.table"))) y <- as.vector(unlist(y)) if(sum(is.na(cbind(x,y))) > 0) stop("You have some missing values, please address.") if(min(y) > min(x) | mean(y) > mean(x)) { return(0) } else { Combined_sort <- sort(c(x, y), decreasing = FALSE) LPM_x_sort <- LPM(1, Combined_sort, x) LPM_y_sort <- LPM(1, Combined_sort, y) x.ssd.y <- any(LPM_x_sort > LPM_y_sort) ifelse(!x.ssd.y && min(x) >= min(y) && !identical(LPM_x_sort, LPM_y_sort), return(1), return(0)) } } NNS.TSD.uni <- function(x, y){ if(any(class(x)==c("tbl", "data.table"))) x <- as.vector(unlist(x)) if(any(class(y)==c("tbl", "data.table"))) y <- as.vector(unlist(y)) if(sum(is.na(cbind(x,y))) > 0) stop("You have some missing values, please address.") if(min(y) > min(x) | mean(y) > mean(x)) { return(0) } else { Combined_sort <- sort(c(x, y), decreasing = FALSE) LPM_x_sort <- LPM(2, Combined_sort, x) LPM_y_sort <- LPM(2, Combined_sort, y) x.tsd.y <- any(LPM_x_sort > LPM_y_sort) ifelse(!x.tsd.y && min(x) >= min(y) && !identical(LPM_x_sort, LPM_y_sort), return(1), return(0)) } }
test_that("invalid seeds are forbidden", { expect_error(flametree_grow(seed = NULL), "must not be null") expect_error(flametree_grow(seed = NA), "must not contain missing values") expect_error(flametree_grow(seed = .1234), "must be integer valued") expect_error(flametree_grow(seed = 1:3), "must have length") expect_error(flametree_grow(seed = numeric(0L)), "must have length") expect_error(flametree_grow(seed = "abc"), "must be numeric") expect_error(flametree_grow(seed = TRUE), "must be numeric") expect_error(flametree_grow(seed = list(1)), "must be numeric") expect_error(flametree_grow(seed = c(1, NA))) expect_error(flametree_grow(seed = list(1, NA))) expect_silent(flametree_grow(seed = 0)) expect_silent(flametree_grow(seed = -1)) }) test_that("invalid times are forbidden", { expect_error(flametree_grow(time = 0)) expect_error(flametree_grow(time = -1)) expect_error(flametree_grow(time = .3)) expect_error(flametree_grow(time = 1:4)) expect_error(flametree_grow(time = NA_integer_)) expect_error(flametree_grow(time = NaN)) expect_error(flametree_grow(time = Inf)) expect_error(flametree_grow(time = "abc")) expect_error(flametree_grow(time = NULL)) expect_error(flametree_grow(time = TRUE)) expect_error(flametree_grow(time = list(2))) expect_silent(flametree_grow(time = 3)) }) test_that("invalid scales are forbidden",{ expect_error(flametree_grow(scale = "abc")) expect_error(flametree_grow(scale = TRUE)) expect_error(flametree_grow(scale = list())) expect_error(flametree_grow(scale = NULL)) expect_error(flametree_grow(scale = NA)) expect_error(flametree_grow(scale = -.123)) expect_error(flametree_grow(scale = numeric(0))) expect_error(flametree_grow(scale = character(0))) expect_error(flametree_grow(scale = c(.8, -.123, .1))) expect_error(flametree_grow(scale = c(.8, NA, .1))) expect_error(flametree_grow(scale = 0)) expect_silent(flametree_grow(scale = c(.8, .9))) expect_silent(flametree_grow(scale = c(.8, .9, 1.1))) }) test_that("invalid angles are forbidden",{ expect_error(flametree_grow(angle = "abc")) expect_error(flametree_grow(angle = TRUE)) expect_error(flametree_grow(angle = list())) expect_error(flametree_grow(angle = NULL)) expect_error(flametree_grow(angle = NA)) expect_error(flametree_grow(angle = numeric(0))) expect_error(flametree_grow(angle = character(0))) expect_error(flametree_grow(angle = c(.8, NA, 10))) expect_error(flametree_grow(angle = -12.3)) expect_silent(flametree_grow(angle = c(0, -12.3))) expect_silent(flametree_grow(angle = c(-700, 1000))) }) test_that("invalid splits are forbidden", { expect_error(flametree_grow(split = 0)) expect_error(flametree_grow(split = -1)) expect_error(flametree_grow(split = .3)) expect_error(flametree_grow(split = 1:4)) expect_error(flametree_grow(split = NA_integer_)) expect_error(flametree_grow(split = NaN)) expect_error(flametree_grow(split = Inf)) expect_error(flametree_grow(split = "abc")) expect_error(flametree_grow(split = NULL)) expect_error(flametree_grow(split = TRUE)) expect_error(flametree_grow(split = list(2))) expect_silent(flametree_grow(split = 3)) }) test_that("flametree data has correct columns", { dat <- flametree_grow() expect_s3_class(dat, "tbl") expect_named( object = dat, expected = c( "coord_x", "coord_y", "id_tree", "id_time", "id_path", "id_leaf", "id_pathtree", "id_step", "seg_deg", "seg_len", "seg_col", "seg_wid" ) ) expect_type(dat$coord_x, "double") expect_type(dat$coord_y, "double") expect_type(dat$seg_deg, "double") expect_type(dat$seg_len, "double") expect_type(dat$seg_col, "double") expect_type(dat$seg_wid, "double") expect_type(dat$id_time, "integer") expect_type(dat$id_path, "integer") expect_type(dat$id_step, "integer") expect_type(dat$id_leaf, "logical") expect_type(dat$id_tree, "integer") expect_type(dat$id_pathtree, "character") }) test_that("flametree edges are well defined", { dat <- flametree_grow() expect_equal(nrow(dat) %% 3, 0) expect_equal(nrow(dat), length(unique(dat$id_path)) * 3) expect_equal(sum(dat$id_step == 0), sum(dat$id_step == 1)) expect_equal(sum(dat$id_step == 0), sum(dat$id_step == 2)) expect_true(all(table(paste(dat$id_path, dat$id_step)) == 1)) })
get_genes_in_region <- function(chr=chr, xmin=xmin,xmax=xmax,protein_coding_only=F, show_exons=F,show_genes=T){ if(show_genes){ genes <- get_genes(chr,xmin,xmax,protein_coding_only = protein_coding_only ) }else if(show_exons){ genes <- get_exons(chr,xmin,xmax,protein_coding_only = protein_coding_only) }else{ if(xmax-xmin < 1000001){ genes <- get_exons(chr,xmin,xmax,protein_coding_only = protein_coding_only ) } else{ genes <- get_genes(chr,xmin,xmax,protein_coding_only = protein_coding_only ) } } return(genes) } get_main_LD_snp <- function(dat){ label_cols <- c("CHROM","POS","P","ID","log10p") top_snps <- data.frame(matrix(nrow = 0, ncol = length(label_cols))) colnames(top_snps) <- label_cols for(i in seq_along(dat)){ top_snps <- rbind(top_snps, dat[[i]] %>% dplyr::filter("R2" >= 1) %>% dplyr::distinct(ID, .keep_all=T) %>% dplyr::arrange(-R2) %>% utils::head(n=1) %>% dplyr::select("CHROM","POS","P","ID","log10p") ) } return(top_snps) } get_annotation <- function(dat, annotate=1e-09, region_size=1000000,distinct_gene_labels=FALSE,protein_coding_only=FALSE, verbose=FALSE){ if(is.data.frame(dat)){dat <- list(dat)} if("log10p" %in% colnames(dat[[1]])){ label_cols <- c("CHROM","POS","P","ID","Gene_Symbol","biotype", "log10p", "color","alpha","size","shape") } else{ label_cols <- c("CHROM","POS","P","ID","Gene_Symbol","biotype") } plot_labels <- data.frame(matrix(nrow = 0, ncol = length(label_cols))) colnames(plot_labels) <- label_cols for(i in seq_along(dat)){ df <- as.data.frame(dat[[i]]) if(is.vector(annotate)){ annot_thresh <- ifelse(i <= length(annotate), annotate[i], annotate[length(annotate)]) } else{ annot_thresh <- annotate} tmp_labels <- get_best_snp_per_MB(df, thresh = annot_thresh, region_size=region_size, .checked=TRUE, protein_coding_only = protein_coding_only, verbose=FALSE) if(nrow(tmp_labels) > 0){ if(!"biotype" %in% tmp_labels){tmp_labels$biotype <- "unknown"} if(! "Gene_Symbol" %in% colnames(tmp_labels)){ tmp_labels <- annotate_with_nearest_gene(tmp_labels, protein_coding_only=protein_coding_only) } if("log10p" %in% colnames(dat[[1]])){ tmp_labels <- tmp_labels %>% dplyr::select("CHROM","POS","P","ID","Gene_Symbol","biotype", "log10p", "color","alpha","size","shape") } else{ tmp_labels <- tmp_labels %>% dplyr::select("CHROM","POS","P","ID","Gene_Symbol","biotype") } } plot_labels <- rbind(plot_labels,tmp_labels) } if(distinct_gene_labels){ plot_labels <- plot_labels %>% dplyr::arrange(CHROM,POS,P) %>% dplyr::distinct(CHROM,POS,Gene_Symbol, .keep_all = TRUE) } return(plot_labels) } annotate_with_nearest_gene <- function(variants, protein_coding_only=FALSE){ if("POS" %in% colnames(variants) & "CHROM" %in% colnames(variants)){ if(length(variants$POS) > 1000){ warning(paste("The dataset includes [",length(variants$POS),"] variants. This may take a while...", sep="")) } for(i in seq_along(variants$POS)){ if(length(variants$POS) > 1000){ if(i %% 1000==0) { print(paste(i," variants annotated", sep="")) } } nearest_gene <- NULL variant <- variants[i,] chr <- gsub("chr", "", variant$CHROM) chr <- paste("chr",chr,sep="") genes_on_chr <- toprdata::ENSGENES %>% dplyr::filter(chrom == chr) %>% dplyr::arrange(gene_start) if(protein_coding_only){ genes_on_chr <- genes_on_chr %>% dplyr::filter(biotype == "protein_coding") } within_gene <- genes_on_chr %>% dplyr::filter(gene_end >= variant$POS & gene_start <= variant$POS) if(length(within_gene$gene_symbol) > 0 ){ if(length(within_gene) == 1){ nearest_gene <- within_gene$gene_symbol } else{ prot_coding <- within_gene %>% dplyr::filter(biotype=="protein_coding") if(length(prot_coding$gene_symbol) > 0){ nearest_gene <- prot_coding %>% utils::head(n=1)} else{ nearest_gene <- within_gene %>% utils::head(n=1) } } }else{ genes_left <- genes_on_chr %>% dplyr::filter(gene_end <= variant$POS) %>% dplyr::arrange(gene_end) genes_right <- genes_on_chr %>% dplyr::filter(gene_start >= variant$POS) %>% dplyr::arrange(gene_start) if(length(genes_left$gene_symbol)>0 & length(genes_right$gene_symbol)> 0){ gene_left <- genes_left[as.numeric(length(genes_left$gene_symbol)),] gene_right <- genes_right[1,] dist_left <- variant$POS-gene_left$gene_end dist_right <- gene_right$gene_start-variant$POS if(abs(dist_left) < abs(dist_right)){ nearest_gene <- gene_left } else{ nearest_gene <- gene_right } } else if(length(genes_left$gene_symbol)== 0 & length(genes_right$gene_symbol)> 0){ nearest_gene <- genes_right[1,] } else if(length(genes_left$gene_symbol)> 0 & length(genes_right$gene_symbol)==0){ nearest_gene <- genes_left[as.numeric(length(genes_left$gene_symbol)),] } } if(! is.null(nearest_gene)){ variants[i,"Gene_Symbol"] <- nearest_gene$gene_symbol variants[i, "biotype"] <- nearest_gene$biotype }else{ variants[i,"Gene_Symbol"] <- "not_found" variants[i, "biotype"] <- "." } } } else{ stop("Cannot find the columns CHROM and POS in the input data. Add the required columns and try again, or rename existing columns, e.g. df=df %>% dplyr::rename(CHROM=yourColname)") } return(variants) }
.qbbinom <- function(p, N, shape1, shape2, lower.tail = TRUE, log.p = FALSE) { if (shape1 == 0 || shape2 == 0) { return(Inf) } if (log.p) p <- exp(p) if (!lower.tail) p <- 1 - p x <- extraDistr::dbbinom(x = 0:N, size = N, alpha = shape1, beta = shape2) q <- which(cumsum(x) > p)[1] - 1 return(q) } .modebbinom <- function(N, shape1, shape2) { if ((shape1 == 1 && shape2 == 1) || shape1 == 0 || shape2 == 0) { return(NA) } if (shape1 == 1 && shape2 > 1) { return(0) } index <- which.max(extraDistr::dbbinom(x = 0:N, size = N, alpha = shape1, beta = shape2)) - 1 return(index) } .qhyper <- function(p, N, n, k) { K <- k:N cdf <- stats::phyper(q = k, m = K, n = N - K, k = n) return(max(K[cdf > (1 - p)])) } .getfun <- function(x) { if (length(grep("::", x)) > 0) { parts <- strsplit(x, "::")[[1]] return(getExportedValue(parts[1], parts[2])) } else { return(x) } }
knitr::opts_chunk$set( collapse = TRUE, comment = " ) xropi = c(11:9,10:8,9,10,9,10:7,8:11,10:12,11:7,8,7:10,9,8,9,8:10,9,10,9,10) xlevo = c(11,10,11,10,11:9,10:7,8,7,8:5,6:8,7,8:6,7,6,7,6,7:5,6,7,6:12) library(cir) bhamou03ropi = DRtrace(x=xropi[-40]/100, y=(1-diff(xropi))/2) bhamou03levo = DRtrace(x=xlevo[-40]/100, y=(1-diff(xlevo))/2) par(mfrow=c(1,2), las=1, mar=c(4,4,4,1)) doserange = c(5,12)/100 plot(bhamou03ropi, ylim=doserange, ylab="Concentration (%)", main='Ropivacaine Arm') legend('bottomright',legend=c('Effective','Ineffective'),pch=c(19,1),bty='n') plot(bhamou03levo, ylim=doserange, ylab="Concentration (%)", main='Levobupivacaine Arm') bhamou03ropiRates = doseResponse(bhamou03ropi) bhamou03levoRates = doseResponse(bhamou03levo) knitr::kable(bhamou03ropiRates, row.names=FALSE,align='ccr',digits=c(2,4,0)) knitr::kable(bhamou03levoRates, row.names=FALSE,align='ccr',digits=c(2,4,0)) ropiTargetCIR=quickInverse(bhamou03ropiRates, target=0.5, adaptiveShrink=TRUE) ropiTargetCIR levoTargetCIR=quickInverse(bhamou03levoRates, target=0.5, adaptiveShrink=TRUE) levoTargetCIR quickInverse(bhamou03ropiRates, target=0.5, adaptiveShrink=TRUE, conf=0.83) quickInverse(bhamou03levoRates, target=0.5, adaptiveShrink=TRUE, conf=0.83) quickInverse(bhamou03ropiRates, target=0.5, estfun=oldPAVA, conf=0.83) quickInverse(bhamou03levoRates, target=0.5, estfun=oldPAVA, conf=0.83) ropiCurveIR = oldPAVA(bhamou03ropiRates, full=TRUE) ropiCurveCIR = cirPAVA(bhamou03ropiRates, target=0.5, adaptiveShrink=TRUE, full=TRUE) levoCurveIR = oldPAVA(bhamou03levoRates, full=TRUE) levoCurveCIR = cirPAVA(bhamou03levoRates, target=0.5, adaptiveShrink=TRUE, full=TRUE) ropiCurveCIR par(mfrow=c(1,2), las=1, mar=c(4,4,4,1)) plot(bhamou03ropiRates, xlab="Concentration (%)", ylab="Proportion Effective", main='Ropivacaine Arm') lines(y~x, data=ropiCurveIR$output, lty=2) lines(y~x, data=ropiCurveCIR$shrinkage, col='blue',lwd=2) points(target~point, data=ropiTargetCIR, col='purple', pch=19, cex=2) lines(c(ropiTargetCIR$lower90conf,ropiTargetCIR$upper90conf), rep(0.5,2), col='purple', lwd=2) legend('bottomright', legend=c("Observed Proportions",'Isotonic Regression', 'Centered Isotonic Regression','Estimate +/- 90% CI'), bty='n',pch=c(4,rep(NA,2),16),col=c('black','black','blue','purple'),lty=c(0,2,1,1)) plot(bhamou03levoRates, xlab="Concentration (%)", ylab="Proportion Effective", main='Levobupivacaine Arm', ylim=0:1) lines(y~x, data=levoCurveIR$output, lty=2) lines(y~x, data=levoCurveCIR$shrinkage, col='blue',lwd=2) points(target~point, data=levoTargetCIR, col='purple', pch=19, cex=2) lines(c(levoTargetCIR$lower90conf,levoTargetCIR$upper90conf), rep(0.5,2), col='purple', lwd=2)
context("anova_apa") library(dplyr, warn.conflicts = FALSE) library(magrittr, warn.conflicts = FALSE) test_that("Formal structure for anova_apa output", { library(ez) data(ANT) data <- ANT %>% filter(error == 0) %>% group_by(subnum, group, cue, flank) %>% summarise(rt = mean(rt)) %>% filter(!is.nan(rt)) %>% as.data.frame anova <- anova_apa( ezANOVA(data, dv = rt, wid = subnum, within = c(cue, flank), between = group, detailed = TRUE), print = FALSE ) expect_equal(nrow(anova), 1 + 3 + 3 + 1) expect_match(`[.data.frame`(anova, anova$effect == "group", "text"), paste0("F\\([[:digit:]]+, [[:digit:]]+\\) = [[:digit:]]+\\.", "[[:digit:]]{2}, p [=<] \\.[[:digit:]]{3}, petasq ", "[=<] \\.[[:digit:]]{2}")) }) test_that("Output for anova_apa: oneway between ANOVA", { data <- data.frame(id = factor(1:15), dose = rep(c("placebo", "low dose", "high dose"), each = 5), libido = c(3, 2, 1, 1, 4, 5, 2, 4, 2, 3, 7, 4, 5, 3, 6)) anova_afex <- anova_apa( afex::aov_ez(id = "id", dv = "libido", data = data, between = "dose"), print = FALSE ) expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "dose", "text"), "F(2, 12) = 5.12, p = .025, petasq = .46") anova_ez <- anova_apa( ez::ezANOVA(data, dv = libido, wid = id, between = dose, detailed = TRUE), print = FALSE ) expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "dose", "text"), "F(2, 12) = 5.12, p = .025, petasq = .46") }) test_that("Output for anova_apa: factorial between ANOVA", { data <- data.frame( id = factor(1:48), gender = rep(c("female", "male"), each = 24), alcohol = rep(c("none", "2 pints", "4 pints"), each = 8, times = 2), attractiveness = c(65, 70, 60, 60, 60, 55, 60, 55, 70, 65, 60, 70, 65, 60, 60, 50, 55, 65, 70, 55, 55, 60, 50, 50, 50, 55, 80, 65, 70, 75, 75, 65, 45, 60, 85, 65, 70, 70, 80, 60, 30, 30, 30, 55, 35, 20, 45, 40) ) anova_afex <- anova_apa( afex::aov_ez(id = "id", dv = "attractiveness", data = data, between = c("gender", "alcohol")), print = FALSE ) expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "gender", "text"), "F(1, 42) = 2.03, p = .161, petasq = .05") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "alcohol", "text"), "F(2, 42) = 20.07, p < .001, petasq = .49") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "gender:alcohol", "text"), "F(2, 42) = 11.91, p < .001, petasq = .36") anova_ez <- anova_apa( ez::ezANOVA(data, dv = attractiveness, wid = id, between = c(gender, alcohol), detailed = TRUE, type = 3), print = FALSE ) expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "gender", "text"), "F(1, 42) = 2.03, p = .161, petasq = .05") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "alcohol", "text"), "F(2, 42) = 20.07, p < .001, petasq = .49") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "gender:alcohol", "text"), "F(2, 42) = 11.91, p < .001, petasq = .36") }) test_that("Output for anova_apa: repeated-measures ANOVA", { data <- data.frame( id = factor(rep(1:8, each = 4)), animal = rep(c("stick insect", "kangaroo testicle", "fish eye", "witchetty grub"), times = 8), retch = c(8, 7, 1, 6, 9, 5, 2, 5, 6, 2, 3, 8, 5, 3, 1, 9, 8, 4, 5, 8, 7, 5, 6, 7, 10, 2, 7, 2, 12, 6, 8, 1) ) anova_afex <- anova_apa( afex::aov_ez(id = "id", dv = "retch", data = data, within = "animal"), print = FALSE ) expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "animal", "text"), "F(1.60, 11.19) = 3.79, p = .063, petasq = .35") anova_ez <- anova_apa( ez::ezANOVA(data, dv = retch, wid = id, within = animal, detailed = TRUE), print = FALSE ) expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "animal", "text"), "F(1.60, 11.19) = 3.79, p = .063, petasq = .35") }) test_that("Output for anova_apa: factorial repeated-measures ANOVA", { data <- data.frame( id = factor(rep(1:20, each = 9)), gender = rep(c("male", "female"), each = 10 * 9), imagery = rep(c("positive", "negative", "neutral"), times = 60), drink = rep(c("beer", "wine", "water"), each = 3, times = 20), attitude = c(1, 6, 5, 38, -5, 4, 10, -14, -2, 43, 30, 8, 20, -12, 4, 9, -10, -13, 15, 15, 12, 20, -15, 6, 6, -16, 1, 40, 30, 19, 28, -4, 0, 20, -10, 2, 8, 12, 8, 11, -2, 6, 27, 5, -5, 17, 17, 15, 17, -6, 6, 9, -6, -13, 30, 21, 21, 15, -2, 16, 19, -20, 3, 34, 23, 28, 27, -7, 7, 12, -12, 2, 34, 20, 26, 24, -10, 12, 12, -9, 4, 26, 27, 27, 23, -15, 14, 21, -6, 0, 1, -19, -10, 28, -13, 13, 33, -2, 9, 7, -18, 6, 26, -16, 19, 23, -17, 5, 22, -8, 4, 34, -23, 14, 21, -19, 0, 30, -6, 3, 32, -22, 21, 17, -11, 4, 40, -6, 0, 24, -9, 19, 15, -10, 2, 15, -9, 4, 29, -18, 7, 13, -17, 8, 20, -17, 9, 30, -17, 12, 16, -4, 10, 9, -12, -5, 24, -15, 18, 17, -4, 8, 14, -11, 7, 34, -14, 20, 19, -1, 12, 15, -6, 13, 23, -15, 15, 29, -1, 10) ) anova_afex <- anova_apa( afex::aov_ez(id = "id", dv = "attitude", data = data, within = c("drink", "imagery")), print = FALSE ) expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "drink", "text"), "F(1.15, 21.93) = 5.11, p = .030, petasq = .21") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "imagery", "text"), "F(1.49, 28.40) = 122.56, p < .001, petasq = .87") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "drink:imagery", "text"), "F(4, 76) = 17.15, p < .001, petasq = .47") anova_ez <- anova_apa( ez::ezANOVA(data, dv = attitude, wid = id, within = c(drink, imagery), type = 3, detailed = TRUE), print = FALSE ) expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "drink", "text"), "F(1.15, 21.93) = 5.11, p = .030, petasq = .21") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "imagery", "text"), "F(1.49, 28.40) = 122.56, p < .001, petasq = .87") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "drink:imagery", "text"), "F(4, 76) = 17.15, p < .001, petasq = .47") }) test_that("Output for anova_apa: mixed ANOVA", { data <- data.frame( id = factor(rep(1:20, each = 9)), gender = rep(c("male", "female"), each = 10 * 9), looks = rep(c("attractive", "average", "ugly"), times = 60), personality = rep(c("high carisma", "some charisma", "dullard"), each = 3, times = 20), rating = c(86, 84, 67, 88, 69, 50, 97, 48, 47, 91, 83, 53, 83, 74, 48, 86, 50, 46, 89, 88, 48, 99, 70, 48, 90, 45, 48, 89, 69, 58, 86, 77, 40, 87, 47, 53, 80, 81, 57, 88, 71, 50, 82, 50, 45, 80, 84, 51, 96, 63, 42, 92, 48, 43, 89, 85, 61, 87, 79, 44, 86, 50, 45, 100, 94, 56, 86, 71, 54, 84, 54, 47, 90, 74, 54, 92, 71, 58, 78, 38, 45, 89, 86, 63, 80, 73, 49, 91, 48, 39, 89, 91, 93, 88, 65, 54, 55, 48, 52, 84, 90, 85, 95, 70, 60, 50, 44, 45, 99, 100, 89, 80, 79, 53, 51, 48, 44, 86, 89, 83, 86, 74, 58, 52, 48, 47, 89, 87, 80, 83, 74, 43, 58, 50, 48, 80, 81, 79, 86, 59, 47, 51, 47, 40, 82, 92, 85, 81, 66, 47, 50, 45, 47, 97, 69, 87, 95, 72, 51, 45, 48, 46, 95, 92, 90, 98, 64, 53, 54, 53, 45, 95, 93, 96, 79, 66, 46, 52, 39, 47) ) anova_afex <- anova_apa( afex::aov_ez(id = "id", dv = "rating", data = data, between = "gender", within = c("looks", "personality")), print = FALSE ) expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "gender", "text"), "F(1, 18) = 0.00, p = .946, petasq < .01") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "looks", "text"), "F(2, 36) = 423.73, p < .001, petasq = .96") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "personality", "text"), "F(2, 36) = 328.25, p < .001, petasq = .95") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "gender:looks", "text"), "F(2, 36) = 80.43, p < .001, petasq = .82") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "gender:personality", "text"), "F(2, 36) = 62.45, p < .001, petasq = .78") expect_identical(`[.data.frame`(anova_afex, anova_afex$effect == "looks:personality", "text"), "F(4, 72) = 36.63, p < .001, petasq = .67") anova_ez <- anova_apa( ez::ezANOVA(data, dv = rating, wid = id, between = gender, within = c(looks, personality), type = 3, detailed = TRUE), print = FALSE ) expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "gender", "text"), "F(1, 18) = 0.00, p = .946, petasq < .01") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "looks", "text"), "F(2, 36) = 423.73, p < .001, petasq = .96") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "personality", "text"), "F(2, 36) = 328.25, p < .001, petasq = .95") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "gender:looks", "text"), "F(2, 36) = 80.43, p < .001, petasq = .82") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "gender:personality", "text"), "F(2, 36) = 62.45, p < .001, petasq = .78") expect_identical(`[.data.frame`(anova_ez, anova_ez$effect == "looks:personality", "text"), "F(4, 72) = 36.63, p < .001, petasq = .67") }) data <- data.frame(id = factor(1:15), dose = rep(c("placebo", "low dose", "high dose"), each = 5), libido = c(3, 2, 1, 1, 4, 5, 2, 4, 2, 3, 7, 4, 5, 3, 6)) anova_afex <- suppressMessages( afex::aov_ez(id = "id", dv = "libido", data = data, between = "dose") ) anova_ez <- ez::ezANOVA(data, dv = libido, wid = id, between = dose, detailed = TRUE) test_that("anova_apa: markdown", { expect_identical(anova_apa(anova_afex, effect = "dose", print = FALSE, format = "markdown"), "*F*(2, 12) = 5.12, *p* = .025, *petasq* = .46") expect_identical(anova_apa(anova_afex, effect = "dose", print = FALSE, format = "markdown"), "*F*(2, 12) = 5.12, *p* = .025, *petasq* = .46") }) test_that("anova_apa: rmarkdown", { expect_identical(anova_apa(anova_afex, effect = "dose", print = FALSE, format = "rmarkdown"), "*F*(2, 12) = 5.12, *p* = .025, $\\eta^2_p$ = .46") expect_identical(anova_apa(anova_ez, effect = "dose", print = FALSE, format = "rmarkdown"), "*F*(2, 12) = 5.12, *p* = .025, $\\eta^2_p$ = .46") }) test_that("anova_apa: html", { expect_identical(anova_apa(anova_afex, effect = "dose", print = FALSE, format = "html"), paste0("<i>F</i>(2, 12) = 5.12, <i>p</i> = .025, ", "<i>&eta;<sup>2</sup><sub>p</sub></i> = .46")) expect_identical(anova_apa(anova_afex, effect = "dose", print = FALSE, format = "html"), paste0("<i>F</i>(2, 12) = 5.12, <i>p</i> = .025, ", "<i>&eta;<sup>2</sup><sub>p</sub></i> = .46")) }) test_that("anova_apa: latex", { expect_identical(anova_apa(anova_afex, effect = "dose", print = FALSE, format = "latex"), paste0("\\textit{F}(2,~12)~=~5.12, \\textit{p}~=~.025, ", "$\\eta^2_p$~=~.46")) expect_identical(anova_apa(anova_ez, effect = "dose", print = FALSE, format = "latex"), paste0("\\textit{F}(2,~12)~=~5.12, \\textit{p}~=~.025, ", "$\\eta^2_p$~=~.46")) }) test_that("anova_apa: plotmath", { expect_identical(as.character(anova_apa(anova_afex, effect = "dose", print = FALSE, format = "plotmath")), paste0("paste(italic(\"F\"), \"(2, 12) = 5.12, \", ", "italic(\"p\"), \" = .025, \", ", "eta[p]^2, \" = .46\")")) expect_identical(as.character(anova_apa(anova_ez, effect = "dose", print = FALSE, format = "plotmath")), paste0("paste(italic(\"F\"), \"(2, 12) = 5.12, \", ", "italic(\"p\"), \" = .025, \", ", "eta[p]^2, \" = .46\")")) })
shrinkTVP <- function(formula, data, mod_type = "double", niter = 10000, nburn = round(niter / 2), nthin = 1, learn_a_xi = TRUE, learn_a_tau = TRUE, a_xi = 0.1, a_tau = 0.1, learn_c_xi = TRUE, learn_c_tau = TRUE, c_xi = 0.1, c_tau = 0.1, a_eq_c_xi = FALSE, a_eq_c_tau = FALSE, learn_kappa2_B = TRUE, learn_lambda2_B = TRUE, kappa2_B = 20, lambda2_B = 20, hyperprior_param, display_progress = TRUE, sv = FALSE, sv_param, MH_tuning, starting_vals){ if (!mod_type %in% c("triple", "double", "ridge")) { stop("mod_type has to be a string equal to 'triple', 'double' or 'ridge'") } default_hyper <- list(c0 = 2.5, g0 = 5, G0 = 5 / (2.5 - 1), e1 = 0.001, e2 = 0.001, d1 = 0.001, d2 = 0.001, beta_a_xi = 10, beta_a_tau = 10, alpha_a_xi = 5, alpha_a_tau = 5, beta_c_xi = 2, beta_c_tau = 2, alpha_c_xi = 5, alpha_c_tau = 5) default_hyper_sv <- list(Bsigma_sv = 1, a0_sv = 5, b0_sv = 1.5, bmu = 0, Bmu = 1) default_tuning_par <- list(a_xi_adaptive = TRUE, a_xi_tuning_par = 1, a_xi_target_rate = 0.44, a_xi_max_adapt = 0.01, a_xi_batch_size = 50, a_tau_adaptive = TRUE, a_tau_tuning_par = 1, a_tau_target_rate = 0.44, a_tau_max_adapt = 0.01, a_tau_batch_size = 50, c_xi_adaptive = TRUE, c_xi_tuning_par = 1, c_xi_target_rate = 0.44, c_xi_max_adapt = 0.01, c_xi_batch_size = 50, c_tau_adaptive = TRUE, c_tau_tuning_par = 1, c_tau_target_rate = 0.44, c_tau_max_adapt = 0.01, c_tau_batch_size = 50) if (missing(MH_tuning)){ MH_tuning <- default_tuning_par } else { MH_tuning <- list_merger(default_tuning_par, MH_tuning) } if (missing(hyperprior_param)){ hyperprior_param <- default_hyper } else { hyperprior_param <- list_merger(default_hyper, hyperprior_param) } if (missing(sv_param) | sv == FALSE){ sv_param <- default_hyper_sv } else { sv_param <- list_merger(default_hyper_sv, sv_param) } to_test_num <- list(lambda2_B = lambda2_B, kappa2_B = kappa2_B, a_xi = a_xi, a_tau = a_tau, c_xi = c_xi, c_tau = c_tau) if (missing(hyperprior_param) == FALSE){ to_test_num <- c(to_test_num, hyperprior_param) } if (missing(sv_param) == FALSE){ to_test_num <- c(to_test_num, sv_param[names(sv_param) != "bmu"]) } if (missing(MH_tuning) == FALSE){ to_test_num <- c(to_test_num, MH_tuning[!grepl("(batch|adaptive)", names(MH_tuning))]) } bad_inp <- sapply(to_test_num, numeric_input_bad) if (any(bad_inp)){ stand_names <- c(names(default_hyper), names(default_hyper_sv), "lambda2_B", "kappa2_B", "a_xi", "a_tau", "c_xi", "c_tau") bad_inp_names <- names(to_test_num)[bad_inp] bad_inp_names <- bad_inp_names[bad_inp_names %in% stand_names] stop(paste0(paste(bad_inp_names, collapse = ", "), ifelse(length(bad_inp_names) == 1, " has", " have"), " to be a real, positive number")) } if (!is.numeric(sv_param$bmu) | !is.scalar(sv_param$bmu)){ stop("bmu has to be a real number") } if (any(0 > MH_tuning[grepl("rate", names(MH_tuning))] | MH_tuning[grepl("rate", names(MH_tuning))] > 1)) { stop("all target_rate parameters in MH_tuning have to be > 0 and < 1") } to_test_int <- c(niter = niter, nburn = nburn, nthin = nthin, MH_tuning[grepl("batch", names(MH_tuning))]) bad_int_inp <- sapply(to_test_int, int_input_bad) if (any(bad_int_inp)){ bad_inp_names <- names(to_test_int)[bad_int_inp] stop(paste0(paste(bad_inp_names, collapse = ", "), ifelse(length(bad_inp_names) == 1, " has", " have"), " to be a single, positive integer")) } if ((niter - nburn) < 2){ stop("niter has to be larger than or equal to nburn + 2") } if (nthin == 0){ stop("nthin can not be 0") } if ((niter - nburn)/2 < nthin){ stop("nthin can not be larger than (niter - nburn)/2") } to_test_bool <- c(learn_lambda2_B = learn_lambda2_B, learn_kappa2_B = learn_kappa2_B, learn_a_xi = learn_a_xi, learn_a_tau = learn_a_tau, display_progress = display_progress, sv = sv, MH_tuning[grepl("adaptive", names(MH_tuning))]) bad_bool_inp <- sapply(to_test_bool, bool_input_bad) if (any(bad_bool_inp)){ bad_inp_names <- names(to_test_bool)[bad_bool_inp] stop(paste0(paste(bad_inp_names, collapse = ", "), ifelse(length(bad_inp_names) == 1, " has", " have"), " to be a single logical value")) } if (inherits(formula, "formula") == FALSE){ stop("formula is not of class formula") } mf <- match.call(expand.dots = FALSE) m <- match(x = c("formula", "data"), table = names(mf), nomatch = 0L) mf <- mf[c(1L, m)] mf$drop.unused.levels <- TRUE mf$na.action <- na.pass mf[[1L]] <- quote(stats::model.frame) mf <- eval(expr = mf, envir = parent.frame()) y <- model.response(mf, "numeric") mt <- attr(x = mf, which = "terms") x <- model.matrix(object = mt, data = mf) if (any(is.na(y))) { stop("No NA values are allowed in response variable") } if (any(is.na(x))){ stop("No NA values are allowed in covariates") } if (missing(data)){ index <- zoo::index(y) } else { index <- zoo::index(data) } p <- 0 if (p != 0){ x <- cbind(x, mlag(y, p))[(p + 1):nrow(x), ] colnames(x)[(ncol(x) - p + 1):ncol(x)] <- paste0("ar", 1:p) y <- y[(p + 1):length(y)] index <- index[(p + 1):length(index)] } colnames(x)[colnames(x) == "(Intercept)"] <- "Intercept" d <- dim(x)[2] default_starting_vals <- list(beta_mean_st = rep(0, d), theta_sr_st = rep(1, d), tau2_st = rep(1, d), xi2_st = rep(1, d), kappa2_st = rep(1, d), lambda2_st = rep(1, d), kappa2_B_st = 20, lambda2_B_st = 20, a_xi_st = 0.1, a_tau_st = 0.1, c_xi_st = 0.1, c_tau_st = 0.1, sv_mu_st = -10, sv_phi_st = 0.5, sv_sigma2_st = 1, C0_st = 1, sigma2_st = 1, h0_st = 0) if (sv == TRUE){ default_starting_vals$sigma2_st <- rep(1, length(y)) } if (missing(starting_vals)){ starting_vals <- default_starting_vals } else { starting_vals <- list_merger(default_starting_vals, starting_vals) } vec_valued <- c("beta_mean_st", "theta_sr_st", "tau2_st", "xi2_st", "kappa2_st", "lambda2_st") bad_length <- sapply(starting_vals[vec_valued], function(x) length(x) != d) if (any(bad_length)){ bad_length_names <- vec_valued[bad_length] stop(paste0(paste(bad_length_names, collapse = ", "), ifelse(length(bad_length_names) == 1, " has", " have"), " to be of length ", d)) } if (sv == TRUE) { if (length(starting_vals$sigma2_st) != length(y)) { stop("sigma2_st has to be the same length as y if sv is TRUE") } num_input_bad <- sapply(starting_vals$sigma2_st, numeric_input_bad) if (any(num_input_bad)) { stop("sigma2_st may only contain real, positive numbers") } } else if (numeric_input_bad(starting_vals$sigma2_st)) { stop("sigma2_st has to be a real, positive number") } vec_valued_pos <- vec_valued[vec_valued != "beta_mean_st"] bad_content <- sapply(starting_vals[vec_valued_pos], function(x) any(sapply(x, numeric_input_bad))) if (any(bad_content)) { bad_content_names <- vec_valued_pos[bad_content] stop(paste0(paste(bad_content_names, collapse = ", "), " may only contain real, positive numbers")) } if (any(sapply(starting_vals$beta_mean_st, numeric_input_bad_))) { stop("beta_mean_st may only contain real numbers") } to_check_num_st <- names(starting_vals)[!names(starting_vals) %in% c(vec_valued, "h0_st", "sv_mu_st", "sigma2_st")] bad_num_st <- sapply(starting_vals[to_check_num_st], numeric_input_bad) if (any(bad_num_st)) { bad_num_names <- to_check_num_st[bad_num_st] stop(paste0(paste(bad_num_names, collapse = ", "), ifelse(length(bad_num_names) == 1, " has", " have"), " to be a real, positive number")) } if (numeric_input_bad_(starting_vals$h0_st)) { stop("h0_st has to be a real number") } if (numeric_input_bad_(starting_vals$sv_mu_st)) { stop("sv_mu_st has to be a real number") } if (abs(starting_vals$sv_phi_st) >= 1) { stop("sv_phi_st has to be between -1 and 1") } if (starting_vals$c_xi_st >= 0.5) { warning("c_xi_st is >= 0.5, which means the algorithm will not move away from the starting value", immediate. = TRUE) } if (starting_vals$c_tau_st >= 0.5) { warning("c_tau_st is >= 0.5, which means the algorithm will not move away from the starting value", immediate. = TRUE) } runtime <- system.time({ suppressWarnings({ res <- shrinkTVP_cpp(y, x, mod_type, niter, nburn, nthin, hyperprior_param$c0, hyperprior_param$g0, hyperprior_param$G0, hyperprior_param$d1, hyperprior_param$d2, hyperprior_param$e1, hyperprior_param$e2, learn_lambda2_B, learn_kappa2_B, lambda2_B, kappa2_B, learn_a_xi, learn_a_tau, a_xi, a_tau, learn_c_xi, learn_c_tau, c_xi, c_tau, a_eq_c_xi, a_eq_c_tau, MH_tuning$a_xi_tuning_par, MH_tuning$a_tau_tuning_par, MH_tuning$c_xi_tuning_par, MH_tuning$c_tau_tuning_par, hyperprior_param$beta_a_xi, hyperprior_param$beta_a_tau, hyperprior_param$alpha_a_xi, hyperprior_param$alpha_a_tau, hyperprior_param$beta_c_xi, hyperprior_param$beta_c_tau, hyperprior_param$alpha_c_xi, hyperprior_param$alpha_c_tau, display_progress, sv, sv_param$Bsigma_sv, sv_param$a0_sv, sv_param$b0_sv, sv_param$bmu, sv_param$Bmu, unlist(MH_tuning[grep("adaptive", names(MH_tuning))]), unlist(MH_tuning[grep("target", names(MH_tuning))]), unlist(MH_tuning[grep("max", names(MH_tuning))]), unlist(MH_tuning[grep("size", names(MH_tuning))]), starting_vals) }) }) if (res$internals$success_vals$success == FALSE){ stop(paste0("The sampler failed at iteration ", res$internals$success_vals$fail_iter, " while trying to ", res$internals$success_vals$fail, ". ", "Try rerunning the model. ", "If the sampler fails again, try changing the prior to be more informative. ", "If the problem still persists, please contact the maintainer: ", maintainer("shrinkTVP"))) } else { res$internals$success_vals <- NULL } if (display_progress == TRUE){ cat("Timing (elapsed): ", file = stderr()) cat(runtime["elapsed"], file = stderr()) cat(" seconds.\n", file = stderr()) cat(round( (niter + nburn) / runtime[3]), "iterations per second.\n\n", file = stderr()) cat("Converting results to coda objects and summarizing draws... ", file = stderr()) } if (sv == FALSE){ res$sigma2 <- matrix(res$sigma2[1, 1, ], ncol = 1) } res[sapply(res, function(x) 0 %in% dim(x))] <- NULL res$MH_diag[sapply(res$MH_diag, function(x) 0 %in% dim(x))] <- NULL if (a_eq_c_tau == TRUE) { res$c_tau <- NULL } if (a_eq_c_xi == TRUE) { res$c_xi <- NULL } res$priorvals <- c(hyperprior_param, sv_param, a_xi = a_xi, a_tau = a_tau, c_xi = c_xi, c_tau = c_tau, lambda2_B = lambda2_B, kappa2_B = kappa2_B) res[["model"]] <- list() res$model$x <- x res$model$y <- y res$model$formula <- formula res$model$xlevels <- .getXlevels(mt, mf) res$model$terms <- mt res$summaries <- list() nsave <- floor((niter - nburn)/nthin) for (i in names(res)){ attr(res[[i]], "type") <- ifelse(nsave %in% dim(res[[i]]), "sample", "stat") if (attr(res[[i]], "type") == "sample"){ if (dim(res[[i]])[2] == d){ colnames(res[[i]]) <- paste0(i, "_", colnames(x)) } else if (dim(res[[i]])[2] == 2 * d){ colnames(res[[i]]) <- paste0(i, "_", rep( colnames(x), 2)) } else { colnames(res[[i]]) <- i } } if (attr(res[[i]], "type") == "sample"){ if (is.na(dim(res[[i]])[3]) == FALSE){ dat <- res[[i]] res[[i]] <- list() for (j in 1:dim(dat)[2]){ res[[i]][[j]] <- as.mcmc(t(dat[, j, ]), start = niter - nburn, end = niter, thin = nthin) colnames(res[[i]][[j]]) <- paste0(i, "_", j, "_", 1:ncol(res[[i]][[j]])) class(res[[i]][[j]]) <- c("mcmc.tvp", "mcmc") attr(res[[i]][[j]], "type") <- "sample" attr(res[[i]][[j]], "index") <- index } if (length(res[[i]]) == 1){ res[[i]] <- res[[i]][[j]] attr(res[[i]][[j]], "index") <- index } attr(res[[i]], "type") <- "sample" if (dim(dat)[2] > 1){ names(res[[i]]) <- colnames(dat) } } else { res[[i]] <- as.mcmc(res[[i]], start = niter - nburn, end = niter, thin = nthin) } } if (is.list(res[[i]]) == FALSE & attr(res[[i]], "type") == "sample") { if (i != "theta_sr" & !(i == "sigma2" & sv == TRUE) & i != "beta") { res$summaries[[i]] <- t(apply(res[[i]], 2, function(x){ obj <- as.mcmc(x, start = niter - nburn, end = niter, thin = nthin) ESS <- tryCatch(coda::effectiveSize(obj), error = function(err) { warning("Calculation of effective sample size failed for one or more variable(s). This can happen if the prior placed on the model induces extreme shrinkage.") return(NA) }, silent = TRUE) return(c("mean" = mean(obj), "sd" = sd(obj), "median" = median(obj), "HPD" = HPDinterval(obj)[c(1, 2)], "ESS" = round(ESS))) })) } else if (i == "theta_sr") { res$summaries[[i]] <- t(apply(res[[i]], 2, function(x){ obj <- as.mcmc(abs(x), start = niter - nburn, end = niter, thin = nthin) ESS <- tryCatch(coda::effectiveSize(obj), error = function(err) { warning("Calculation of effective sample size failed for one or more variable(s). This can happen if the prior placed on the model induces extreme shrinkage.") return(NA) }, silent = TRUE) return(c("mean" = mean(obj), "sd" = sd(obj), "median" = median(obj), "HPD" = HPDinterval(obj)[c(1, 2)], "ESS" = round(ESS))) })) } } } if (display_progress == TRUE) { cat("Done!\n", file = stderr()) } attr(res, "class") <- "shrinkTVP" attr(res, "learn_a_xi") <- learn_a_xi attr(res, "learn_a_tau") <- learn_a_tau attr(res, "learn_c_xi") <- learn_c_xi attr(res, "learn_c_tau") <- learn_c_tau attr(res, "learn_kappa2_B") <- learn_kappa2_B attr(res, "learn_lambda2_B") <- learn_lambda2_B attr(res, "a_eq_c_xi") <- a_eq_c_xi attr(res, "a_eq_c_tau") <- a_eq_c_tau attr(res, "niter") <- niter attr(res, "nburn") <- nburn attr(res, "nthin") <- nthin attr(res, "sv") <- sv attr(res, "colnames") <- colnames(x) attr(res, "index") <- index attr(res, "p") <- p attr(res, "mod_type") <- mod_type return(res) } updateTVP <- function(y, x, curr_draws, mod_type = "double", learn_a_xi = TRUE, learn_a_tau = TRUE, a_xi = 0.1, a_tau = 0.1, learn_c_xi = TRUE, learn_c_tau = TRUE, c_xi = 0.1, c_tau = 0.1, a_eq_c_xi = FALSE, a_eq_c_tau = FALSE, learn_kappa2_B = TRUE, learn_lambda2_B = TRUE, kappa2_B = 20, lambda2_B = 20, hyperprior_param, sv = FALSE, sv_param, MH_tuning){ default_hyper <- list(c0 = 2.5, g0 = 5, G0 = 5 / (2.5 - 1), e1 = 0.001, e2 = 0.001, d1 = 0.001, d2 = 0.001, beta_a_xi = 10, beta_a_tau = 10, alpha_a_xi = 5, alpha_a_tau = 5, beta_c_xi = 2, beta_c_tau = 2, alpha_c_xi = 5, alpha_c_tau = 5) default_hyper_sv <- list(Bsigma_sv = 1, a0_sv = 5, b0_sv = 1.5, bmu = 0, Bmu = 1) default_tuning_par <- list(a_xi_adaptive = TRUE, a_xi_tuning_par = 1, a_xi_target_rate = 0.44, a_xi_max_adapt = 0.01, a_xi_batch_size = 50, a_tau_adaptive = TRUE, a_tau_tuning_par = 1, a_tau_target_rate = 0.44, a_tau_max_adapt = 0.01, a_tau_batch_size = 50, c_xi_adaptive = TRUE, c_xi_tuning_par = 1, c_xi_target_rate = 0.44, c_xi_max_adapt = 0.01, c_xi_batch_size = 50, c_tau_adaptive = TRUE, c_tau_tuning_par = 1, c_tau_target_rate = 0.44, c_tau_max_adapt = 0.01, c_tau_batch_size = 50) if (missing(MH_tuning)){ MH_tuning <- default_tuning_par } else { MH_tuning <- list_merger(default_tuning_par, MH_tuning) } if (missing(hyperprior_param)){ hyperprior_param <- default_hyper } else { hyperprior_param <- list_merger(default_hyper, hyperprior_param) } if (missing(sv_param) | sv == FALSE){ sv_param <- default_hyper_sv } else { sv_param <- list_merger(default_hyper_sv, sv_param) } suppressWarnings({ res <- shrinkTVP_cpp(y, x, mod_type, 1, 0, 1, hyperprior_param$c0, hyperprior_param$g0, hyperprior_param$G0, hyperprior_param$d1, hyperprior_param$d2, hyperprior_param$e1, hyperprior_param$e2, learn_lambda2_B, learn_kappa2_B, lambda2_B, kappa2_B, learn_a_xi, learn_a_tau, a_xi, a_tau, learn_c_xi, learn_c_tau, c_xi, c_tau, a_eq_c_xi, a_eq_c_tau, MH_tuning$a_xi_tuning_par, MH_tuning$a_tau_tuning_par, MH_tuning$c_xi_tuning_par, MH_tuning$c_tau_tuning_par, hyperprior_param$beta_a_xi, hyperprior_param$beta_a_tau, hyperprior_param$alpha_a_xi, hyperprior_param$alpha_a_tau, hyperprior_param$beta_c_xi, hyperprior_param$beta_c_tau, hyperprior_param$alpha_c_xi, hyperprior_param$alpha_c_tau, FALSE, sv, sv_param$Bsigma_sv, sv_param$a0_sv, sv_param$b0_sv, sv_param$bmu, sv_param$Bmu, unlist(MH_tuning[grep("adaptive", names(MH_tuning))]), unlist(MH_tuning[grep("target", names(MH_tuning))]), unlist(MH_tuning[grep("max", names(MH_tuning))]), unlist(MH_tuning[grep("size", names(MH_tuning))]), curr_draws) }) if(sv == FALSE){ res$sigma2_st <- res$sigma2_st[1] } return(res) }
context("Ensuring that the `tab_footnote()` function works as expected") data <- mtcars %>% gt(rownames_to_stub = TRUE) %>% cols_move_to_start(columns = c("gear", "carb")) %>% tab_stubhead(label = "cars") %>% cols_hide(columns = "mpg") %>% cols_hide(columns = "vs") %>% tab_row_group( label = "Mercs", rows = contains("Merc"), ) %>% tab_row_group( label = "Mazdas", rows = contains("Mazda"), ) %>% tab_options(row_group.default_label = "Others") %>% tab_spanner( label = "gear_carb_cyl", id = "gcc", columns = c(gear, carb, cyl) ) %>% row_group_order(groups = c("Mazdas", "Mercs")) %>% cols_merge_range( col_begin = "disp", col_end = "drat" ) %>% tab_header( title = "Title", subtitle = "Subtitle" ) %>% tab_source_note(source_note = "this is a source note") %>% summary_rows( groups = c("Mazdas", "Mercs"), columns = c(hp, wt, qsec), fns = list( ~mean(., na.rm = TRUE), ~sum(., na.rm = TRUE)) ) %>% summary_rows( columns = c(hp, wt), fns = list( ~mean(., na.rm = TRUE), ~sum(., na.rm = TRUE)) ) data_2 <- gtcars %>% dplyr::filter(ctry_origin == "Germany") %>% dplyr::group_by(mfr) %>% dplyr::top_n(2, msrp) %>% dplyr::ungroup() %>% dplyr::select(mfr, model, drivetrain, msrp) %>% gt() %>% tab_spanner( label = "make and model", id = "mm", columns = c(mfr, model) ) %>% tab_spanner( label = "specs and pricing", id = "sp", columns = c(drivetrain, msrp) ) %>% tab_footnote( footnote = "Prices in USD.", locations = cells_column_labels(columns = msrp) ) %>% tab_footnote( footnote = "AWD = All Wheel Drive, RWD = Rear Wheel Drive.", locations = cells_column_labels(columns = drivetrain) ) %>% tab_footnote( footnote = "The most important details.", locations = cells_column_spanners(spanners = "sp") ) %>% tab_footnote( footnote = "German cars only.", locations = cells_column_spanners(spanners = "mm") ) data_3 <- gtcars %>% dplyr::filter(ctry_origin == "Germany") %>% dplyr::group_by(mfr) %>% dplyr::top_n(3, msrp) %>% dplyr::ungroup() %>% dplyr::select(mfr, model, drivetrain, msrp) %>% gt(rowname_col = "model", groupname_col = "mfr") %>% summary_rows( groups = c("BMW", "Audi"), columns = "msrp", fns = list( ~mean(., na.rm = TRUE), ~min(., na.rm = TRUE)) ) %>% summary_rows( columns = "msrp", fns = list( ~min(., na.rm = TRUE), ~max(., na.rm = TRUE)) ) %>% tab_footnote( footnote = "Average price for BMW and Audi.", locations = cells_summary( groups = c("BMW", "Audi"), columns = "msrp", rows = starts_with("me")) ) %>% tab_footnote( footnote = "Maximum price across all cars.", locations = cells_grand_summary( columns = "msrp", rows = starts_with("ma")) ) %>% tab_footnote( footnote = "Minimum price across all cars.", locations = cells_grand_summary( columns = "msrp", rows = starts_with("mi")) ) data_4 <- sp500 %>% dplyr::filter( date >= "2015-01-05" & date <="2015-01-10" ) %>% dplyr::select( -c(adj_close, volume, high, low) ) %>% gt() %>% tab_header( title = "S&P 500", subtitle = "Open and Close Values" ) %>% tab_footnote( footnote = "All values in USD.", locations = list( cells_title(groups = "subtitle") ) ) %>% tab_footnote( footnote = "Standard and Poor 500.", locations = list( cells_title(groups = "title") ) ) check_suggests <- function() { skip_if_not_installed("rvest") skip_if_not_installed("xml2") } selection_value <- function(html, key) { selection <- paste0("[", key, "]") html %>% rvest::html_nodes(selection) %>% rvest::html_attr(key) } selection_text <- function(html, selection) { html %>% rvest::html_nodes(selection) %>% rvest::html_text() } test_that("the `tab_footnote()` function works correctly", { check_suggests() tab <- data %>% tab_footnote( footnote = "Column labels and stub footnote.", locations = list( cells_column_labels(), cells_stub(rows = TRUE) ) ) dt_footnotes_get(data = tab) %>% dplyr::pull(locname) %>% unique() %>% expect_equal(c("columns_columns", "stub")) dt_footnotes_get(data = tab) %>% dplyr::pull(footnotes) %>% unlist() %>% unique() %>% expect_equal("Column labels and stub footnote.") tab <- data %>% tab_footnote( footnote = "Stub cell footnote.", locations = cells_stub(rows = "Merc 240D") ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("stub", NA_character_, NA_character_, "5", "8", NA_character_, "Stub cell footnote.") ) tab <- data %>% tab_footnote( footnote = "Title footnote.", locations = cells_title(groups = "title") ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("title", NA_character_, NA_character_, "1", NA_character_, NA_character_, "Title footnote.") ) tab <- data %>% tab_footnote( footnote = "Subtitle footnote.", locations = cells_title(groups = "subtitle") ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("subtitle", NA_character_, NA_character_, "2", NA_character_, NA_character_, "Subtitle footnote.") ) tab <- data %>% tab_footnote( footnote = "Stubhead label footnote.", locations = cells_stubhead() ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("stubhead", NA_character_, NA_character_, "2.5", NA_character_, NA_character_, "Stubhead label footnote.") ) tab <- data %>% tab_footnote( footnote = "Summary cell footnote.", locations = cells_summary( groups = "Mercs", columns = "hp", rows = 2) ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("summary_cells", "Mercs", "hp", "5", "2", NA_character_, "Summary cell footnote.") ) expect_error( data %>% tab_footnote( footnote = "Summary cell footnote.", locations = cells_summary( groups = "Mercs", columns = starts_with("x"), rows = 2) ) ) expect_error( data %>% tab_footnote( footnote = "Summary cell footnote.", locations = cells_summary( groups = "Mercs", columns = starts_with("m"), rows = starts_with("x")) ) ) tab <- data %>% tab_footnote( footnote = "Grand summary cell footnote.", locations = cells_grand_summary( columns = wt, rows = starts_with("s") ) ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("grand_summary_cells", "::GRAND_SUMMARY", "wt", "6", "2", NA_character_, "Grand summary cell footnote.") ) expect_error( data %>% tab_footnote( footnote = "Grand summary cell footnote.", locations = cells_grand_summary( columns = starts_with("x"), rows = 2) ) ) expect_error( data %>% tab_footnote( footnote = "Grand summary cell footnote.", locations = cells_grand_summary( columns = starts_with("m"), rows = starts_with("x")) ) ) tab <- data %>% tab_footnote( footnote = "Summary cell footnote.", locations = cells_summary( groups = "Mercs", columns = "hp", rows = 2) ) %>% tab_footnote( footnote = "Grand summary cell footnote.", locations = cells_grand_summary( columns = wt, rows = starts_with("s") ) ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(2) expect_attr_equal( tab, "_footnotes", c("summary_cells", "grand_summary_cells", "Mercs", "::GRAND_SUMMARY", "hp", "wt", "5", "6", "2", "2", NA_character_, NA_character_, "Summary cell footnote.", "Grand summary cell footnote.") ) tab <- data %>% tab_footnote( footnote = "Group cell footnote.", locations = cells_row_groups(groups = "Mazdas")) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("row_groups", "Mazdas", NA_character_, "5", NA_character_, NA_character_, "Group cell footnote.") ) tab <- data %>% tab_footnote( footnote = "Column group footnote.", locations = cells_column_spanners(spanners = "gcc") ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("columns_groups", "gcc", NA_character_, "3", NA_character_, NA_character_, "Column group footnote.") ) tab <- data %>% tab_footnote( footnote = "Single column label footnote.", locations = cells_column_labels(columns = "gear") ) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("columns_columns", NA_character_, "gear", "4", NA_character_, NA_character_, "Single column label footnote.") ) tab <- data %>% tab_footnote( footnote = "Five rows footnote.", locations = cells_body(columns = "hp", rows = 1:5)) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(5) dt_footnotes_get(data = tab) %>% dplyr::pull(rownum) %>% expect_equal(1:5) dt_footnotes_get(data = tab) %>% dplyr::pull(footnotes) %>% unlist() %>% unique() %>% expect_equal("Five rows footnote.") dt_footnotes_get(data = tab) %>% dplyr::pull(locname) %>% unique() %>% expect_equal("data") dt_footnotes_get(data = tab) %>% dplyr::pull(colname) %>% unique() %>% expect_equal("hp") expect_error( data %>% tab_footnote( footnote = "Footnote error.", locations = cells_body(columns = "disp", rows = "Mazda RX7"))) tab <- data %>% tab_footnote( footnote = "A footnote.", locations = cells_body(columns = "disp", rows = c("Mazda RX4"))) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(1) dt_footnotes_get(data = tab) %>% unlist() %>% unname() %>% expect_equal( c("data", NA_character_, "disp", "5", "1", NA_character_, "A footnote.")) tab <- data %>% tab_footnote( footnote = "A footnote.", locations = cells_body(columns = c(disp, hp), rows = "Mazda RX4")) dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(2) dt_footnotes_get(data = tab)[1, ] %>% unlist() %>% unname() %>% expect_equal(c( "data", NA_character_, "disp", "5", "1", NA_character_, "A footnote.")) dt_footnotes_get(data = tab)[2, ] %>% unlist() %>% unname() %>% expect_equal(c( "data", NA_character_, "hp", "5", "1", NA_character_, "A footnote.")) tab <- data_2 dt_footnotes_get(data = tab) %>% nrow() %>% expect_equal(4) dt_footnotes_get(data = tab) %>% dplyr::pull(locname) %>% unique() %>% expect_equal(c("columns_columns", "columns_groups")) tbl_html <- tab %>% render_as_html() %>% xml2::read_html() tbl_html %>% selection_text(selection = "[class='gt_footnote']") %>% tidy_gsub("\n ", "") %>% expect_equal( c( "1 German cars only.", "2 The most important details.", "3 AWD = All Wheel Drive, RWD = Rear Wheel Drive.", "4 Prices in USD.") ) tbl_html %>% selection_text(selection = "[class='gt_footnote_marks']") %>% tidy_gsub("\\s+", "") %>% expect_equal(rep(as.character(1:4), 2)) }) test_that("the footnotes table is structured correctly", { footnotes_tbl <- dt_footnotes_get(data = data_3) expect_is(footnotes_tbl, "tbl_df") expect_equal( colnames(footnotes_tbl), c("locname", "grpname", "colname", "locnum", "rownum", "colnum", "footnotes") ) expect_equal(nrow(footnotes_tbl), 4) expect_equal( footnotes_tbl$locname, c("summary_cells", "summary_cells", "grand_summary_cells", "grand_summary_cells") ) expect_equal(footnotes_tbl$locnum, c(5, 5, 6, 6)) expect_equal(footnotes_tbl$grpname, c("BMW", "Audi", "::GRAND_SUMMARY", "::GRAND_SUMMARY")) expect_equal(footnotes_tbl$colname, rep("msrp", 4)) expect_equal(footnotes_tbl$colnum, rep(NA_integer_, 4)) expect_equal( unlist(footnotes_tbl$footnotes), c("Average price for BMW and Audi.", "Average price for BMW and Audi.", "Maximum price across all cars.", "Minimum price across all cars.") ) footnotes_tbl <- dt_footnotes_get(data = data_4) expect_is(footnotes_tbl, "tbl_df") expect_equal( colnames(footnotes_tbl), c("locname", "grpname", "colname", "locnum", "rownum", "colnum", "footnotes") ) expect_equal(nrow(footnotes_tbl), 2) expect_equal(footnotes_tbl$locname, c("subtitle", "title")) expect_equal(footnotes_tbl$grpname, c(NA_character_, NA_character_)) expect_equal(footnotes_tbl$colname, c(NA_character_, NA_character_)) expect_equal(footnotes_tbl$locnum, c(2, 1)) expect_equal(footnotes_tbl$rownum, c(NA_integer_, NA_integer_)) expect_equal(footnotes_tbl$colnum, c(NA_integer_, NA_integer_)) expect_equal( unlist(footnotes_tbl$footnotes), c("All values in USD.", "Standard and Poor 500.") ) tbl_html <- data_4 %>% render_as_html() %>% xml2::read_html() tbl_html %>% selection_text(selection = "[class='gt_heading gt_title gt_font_normal']") %>% expect_equal("S&P 5001") tbl_html %>% selection_text(selection = "[class='gt_heading gt_subtitle gt_font_normal gt_bottom_border']") %>% expect_equal("Open and Close Values2") }) test_that("the `list_of_summaries` table is structured correctly", { gtcars_built <- gtcars %>% dplyr::filter(ctry_origin == "Germany") %>% dplyr::group_by(mfr) %>% dplyr::top_n(3, msrp) %>% dplyr::ungroup() %>% dplyr::select(mfr, model, drivetrain, msrp) %>% gt(rowname_col = "model", groupname_col = "mfr") %>% summary_rows( groups = c("BMW", "Audi"), columns = msrp, fns = list( ~mean(., na.rm = TRUE), ~min(., na.rm = TRUE)) ) %>% summary_rows( columns = msrp, fns = list( ~min(., na.rm = TRUE), ~max(., na.rm = TRUE)) ) %>% build_data(context = "html") gtcars_built_summary_df <- dt_summary_df_get(data = gtcars_built) gtcars_built_summary_df_data <- dt_summary_df_data_get(data = gtcars_built) gtcars_built_summary_df_display <- dt_summary_df_display_get(data = gtcars_built) expect_equal(length(gtcars_built_summary_df), 2) expect_equal( names(gtcars_built_summary_df), c("summary_df_data_list", "summary_df_display_list") ) expect_equal(length(gtcars_built_summary_df_data$summary_df_data_list), 3) expect_equal(length(gtcars_built_summary_df_display$summary_df_display_list), 3) expect_equal( names(gtcars_built_summary_df_data$summary_df_data_list), c("BMW", "Audi", "::GRAND_SUMMARY") ) expect_equal( names(gtcars_built_summary_df_display$summary_df_display_list), c("::GRAND_SUMMARY", "Audi", "BMW") ) expect_equal( gtcars_built_summary_df_display$summary_df_display_list$`::GRAND_SUMMARY`$msrp, c("56,000.00", "140,700.00") ) expect_equal( gtcars_built_summary_df_display$summary_df_display_list$Audi$msrp, c("113,233.33", "108,900.00") ) expect_equal( gtcars_built_summary_df_display$summary_df_display_list$BMW$msrp, c("116,066.67", "94,100.00") ) })
describeRNA = function(counts, biotypes, groups, report = FALSE, verbose = FALSE, filter = 1) { table = table(biotypes$gene_biotype, exclude = NA) target = c("miRNA", "protein_coding", "lincRNA", "pseudogene", "snoRNA", "snRNA", "ribozyme") table = data.frame(table) index <- table$Var1 %in% target barplot = table[index, ] if (report) { File <- tempfile(fileext = ".pdf") warning("\n Temporary report at ", File, call. = FALSE, immediate. = TRUE) dir.create(dirname(File), showWarnings=FALSE) pdf(File, width = 15, height = 15) oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(2, 2)) plotMDS(counts, main = "Multidimensional Scaling") sortbar = barplot[order(barplot$Freq, decreasing = TRUE), ] barplot(sortbar$Freq, names.arg = sortbar$Var1, col = 1:6, main = "Absolute Quantity") x = t(counts) x = hclust(dist(x)) plot(x, main = "Cluster Dendrogram") wordcloud(table$Var1, table$Freq, colors = brewer.pal(5,"Dark2"), min.freq = 10) dev.off() } if (filter == 1) { data_filtered = filterByExpr(counts, group = groups) data_filtered = counts[data_filtered, ] } if (filter == 2) { data_filtered = filterByExpr(counts, group = groups, min.count = 15, min.total.count = 25) data_filtered = counts[data_filtered, ] } if (filter == 3) { data_filtered = filterByExpr(counts, group = groups, min.count = 25, min.total.count = 40) data_filtered = counts[data_filtered, ] } if (verbose) { print(knitr::kable(table)) cat("\nGENES", sep = "\n") cat("Total number of genes:", nrow(counts)) cat("\nGenes remaining:", dim(data_filtered)[1]) } pos <- 1 envir = as.environment(pos) BioInsight <- assign("BioInsight", data_filtered, envir = envir) }
context("Plot annual stats") test_that("a list of plots is created", { skip_on_cran() skip_on_ci() plots <- plot_annual_stats(station_number = "08NM116", start_year = 1981, end_year = 2010, water_year_start = 10) expect_true("list" %in% class(plots) & "gg" %in% sapply(plots, class)) }) test_that("multiple plots are created with multiple groups", { skip_on_cran() skip_on_ci() plots <- plot_annual_stats(station_number = c("08NM116","08NM242"), ignore_missing = TRUE) expect_true(length(plots) == 2) })
.edgeDataMatrix <- function(g, att) { if (class(g)[1] != "graphNEL") stop("'g' has to be a 'graphNEL' object") stopifnot(.validateGraph(g)) if (is.null(edgeDataDefaults(g)[[att]])) stop(paste("edge attribute", att, "not set")) raw <- edgeData(g) n <- nodes(g) m <- matrix(0, nrow=length(n), ncol=length(n), dimnames=list(n, n)) for (e in names(raw)) { vert <- strsplit(e, "\\|")[[1]] m[[vert[[1]], vert[[2]]]] <- raw[[e]][[att]] } m }
context("sum of llcont") test_that("lavaan object", { if (isTRUE(require("lavaan"))) { HS.model <- 'visual =~ x1 + x2 + x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9 ' fit1 <- cfa(HS.model, data=HolzingerSwineford1939) fit2 <- cfa(HS.model, data=HolzingerSwineford1939, group="school") fit3 <- cfa(HS.model, data = HolzingerSwineford1939, group = "school", group.equal = c("loadings")) fit4 <- cfa(HS.model, data = HolzingerSwineford1939, group = "school", group.equal = c("loadings"), group.partial = c("visual=~x2", "x7~1")) expect_equal(sum(llcont(fit1)), as.numeric(logLik(fit1))) expect_equal(sum(llcont(fit2)), as.numeric(logLik(fit2))) expect_equal(round(sum(llcont(fit3)) - as.numeric(logLik(fit3)), 8), 0L) expect_equal(sum(llcont(fit4)), as.numeric(logLik(fit4))) HS.model2 <- 'visual =~ x1 + 0.5*x2 + c(0.6, 0.8)*x3 textual =~ x4 + start(c(1.2, 0.6))*x5 + a*x6 speed =~ x7 + x8 + x9' fit5 <- cfa(HS.model2, data=HolzingerSwineford1939, group="school") expect_equal(round(sum(llcont(fit5)) - as.numeric(logLik(fit5)), 8), 0L) HS.model3 <- 'visual =~ x1 + x2 + c(v3,v3)*x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9' fit6 <- cfa(HS.model3, data=HolzingerSwineford1939, group="school") expect_equal(sum(llcont(fit6)), as.numeric(logLik(fit6))) set.seed(1234) pop.model <- ' f =~ 0.7*y1 + 0.7*y2 + 0.7*y3 + 0.7*y4 + 0.7*y5 f ~ (-2.3)*x1 + 0.8*x2 y1 ~ 0.2*x2 y3 ~ 0.7*x1 ' Data <- simulateData(pop.model, sample.nobs=100) model <- ' f =~ y1 + y2 + y3 + y4 + y5 f ~ x1 + x2 y1 ~ x2 y3 ~ x1 ' obs <- rbinom(prod(dim(Data)), 1, .9) Data <- Data*obs Data[Data==0] <- NA Data[95,] <- NA fit7 <- sem(model, data=Data, fixed.x=TRUE, meanstructure=TRUE, missing='ml') expect_equal(sum(llcont(fit7)), as.numeric(logLik(fit7))) } }) test_that("glm object", { if (isTRUE(require("faraway")) && isTRUE(require("MASS"))) { bin1 <- glm(formula=am ~ hp + wt, data=mtcars, family=binomial) bin2 <- glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial(logit), data=menarche) expect_equal(sum(llcont(bin1)), as.numeric(logLik(bin1))) expect_equal(sum(llcont(bin2)), as.numeric(logLik(bin2))) qbin1 <- glm(formula=am ~ hp + wt, data=mtcars, family=quasibinomial) qbin2 <- glm(cbind(Menarche, Total-Menarche) ~ Age, family=quasibinomial, data=menarche) expect_equal(sum(llcont(qbin1)), as.numeric(logLik(qbin1))) expect_equal(sum(llcont(qbin2)), as.numeric(logLik(qbin2))) gau1 <- glm(Species ~ Area + Elevation + Nearest + Scruz + Adjacent, data=gala, family=gaussian) gau2 <- glm(Species ~ Area + Elevation + Nearest, data=gala, family=gaussian) expect_equal(sum(llcont(gau1)), as.numeric(logLik(gau1))) expect_equal(sum(llcont(gau2)), as.numeric(logLik(gau2))) invGau1 <- glm(actual ~ projected-1, family=inverse.gaussian(link="identity"), cpd) expect_equal(sum(llcont(invGau1)), as.numeric(logLik(invGau1))) clotting <- data.frame(u = c(5,10,15,20,30,40,60,80,100), lot1 = c(118,58,42,35,27,25,21,19,18), lot2 = c(69,35,26,21,18,16,13,12,12)) gam1 <- glm(lot1 ~ log(u), data = clotting, family = Gamma) expect_equal(sum(llcont(gam1)), as.numeric(logLik(gam1))) counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) d.AD <- data.frame(treatment, outcome, counts) pois1 <- glm(counts ~ outcome + treatment, family = poisson) pois2 <- glm(counts ~ outcome, family = poisson) expect_equal(sum(llcont(pois1)), as.numeric(logLik(pois1))) expect_equal(sum(llcont(pois2)), as.numeric(logLik(pois2))) qpois1 <- glm(counts ~ outcome + treatment, family = quasipoisson) qpois2 <- glm(counts ~ outcome, family = quasipoisson) expect_equal(sum(llcont(qpois1)), as.numeric(logLik(qpois1))) expect_equal(sum(llcont(qpois2)), as.numeric(logLik(qpois2))) nb1 <- glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine) expect_equal(sum(llcont(nb1)), as.numeric(logLik(nb1))) } }) test_that("clm object", { if (isTRUE(require("ordinal")) && isTRUE(require("MASS"))) { clm1 <- clm(rating ~ temp * contact, data = wine) clm2 <- update(clm1, ~.-temp:contact) clm3 <- update(clm1, link = "logit") clm4 <- update(clm1, link = "probit") clm5 <- update(clm1, link = "loglog") clm6 <- update(clm1, link = "cloglog") clm7 <- update(clm1, link = "cauchit") clm8 <- update(clm1, threshold = "symmetric") clm9 <- update(clm1, threshold = "equidistant") clm10 <- clm(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) expect_equal(sum(llcont(clm1)), as.numeric(logLik(clm1))) expect_equal(sum(llcont(clm2)), as.numeric(logLik(clm2))) expect_equal(sum(llcont(clm3)), as.numeric(logLik(clm3))) expect_equal(sum(llcont(clm4)), as.numeric(logLik(clm4))) expect_equal(sum(llcont(clm5)), as.numeric(logLik(clm5))) expect_equal(sum(llcont(clm6)), as.numeric(logLik(clm6))) expect_equal(sum(llcont(clm7)), as.numeric(logLik(clm7))) expect_equal(sum(llcont(clm8)), as.numeric(logLik(clm8))) expect_equal(sum(llcont(clm9)), as.numeric(logLik(clm9))) expect_equal(sum(llcont(clm10)), as.numeric(logLik(clm10))) } }) test_that("hurdle object", { if (isTRUE(require("pscl"))) { hurdle1 <- hurdle(formula = art ~ ., data = bioChemists) hurdle2 <- hurdle(formula = art ~ ., data = bioChemists, separate=FALSE) hurdle3 <- hurdle(art ~ ., data = bioChemists, zero = "geometric") hurdle4 <- hurdle(art ~ fem + ment, data = bioChemists, dist = "negbin", zero = "negbin") hurdle5 <- hurdle(art ~ ., data = bioChemists, dist = "negbin") expect_equal(sum(llcont(hurdle1)), as.numeric(logLik(hurdle1))) expect_equal(sum(llcont(hurdle2)), as.numeric(logLik(hurdle2))) expect_equal(sum(llcont(hurdle3)), as.numeric(logLik(hurdle3))) expect_equal(sum(llcont(hurdle4)), as.numeric(logLik(hurdle4))) expect_equal(sum(llcont(hurdle5)), as.numeric(logLik(hurdle5))) } }) test_that("zeroinfl object", { if (isTRUE(require("pscl"))) { zi1 <- zeroinfl(art ~ . | 1, data = bioChemists) zi2 <- zeroinfl(art ~ . | 1, data = bioChemists, dist = "negbin") zi3 <- zeroinfl(art ~ . | ., data = bioChemists) zi4 <- zeroinfl(art ~ . | ., data = bioChemists, dist = "negbin") expect_equal(sum(llcont(zi1)), as.numeric(logLik(zi1))) expect_equal(sum(llcont(zi2)), as.numeric(logLik(zi2))) expect_equal(sum(llcont(zi3)), as.numeric(logLik(zi3))) expect_equal(sum(llcont(zi4)), as.numeric(logLik(zi4))) } }) test_that("lm object", { ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm1 <- lm(weight ~ group) expect_equal(sum(llcont(lm1)), as.numeric(logLik(lm1))) }) test_that("mlogit object", { if (isTRUE(require("mlogit")) & isTRUE(require("AER"))) { data("Fishing", package = "mlogit") Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode") mlog1 <- mlogit(mode ~ price + catch, data = Fish) mlog2 <- mlogit(mode ~ 0 | income, data = Fish) mlog3 <- mlogit(mode ~ price+ catch | income, data = Fish) mlog4 <- mlogit(mode ~ price+ catch | income, data = Fish, reflevel = "charter") mlog5 <- mlogit(mode ~ price+ catch | income, data = Fish, alt.subset = c("charter", "pier", "beach")) Fishing2 <- Fishing Fishing2[1, "price.pier"] <- Fishing2[3, "price.beach"] <- NA mlog6 <- mlogit(mode~price+catch|income, Fishing2, shape="wide", choice="mode", varying = 2:9) data("TravelMode", package = "AER") Tr2 <- TravelMode[-c(2, 7, 9),] mlog7 <- mlogit(choice~wait+gcost|income+size, Tr2, shape = "long", chid.var = "individual", alt.var="mode", choice = "choice") data("TravelMode", package = "AER") mlog8 <- mlogit(choice ~ wait + travel + vcost, TravelMode, shape = "long", chid.var = "individual", alt.var = "mode", method = "bfgs", heterosc = TRUE, tol = 10) data("Game", package = "mlogit") mlog10 <- mlogit(ch~own|hours, Game, choice='ch', varying = 1:12, ranked=TRUE, shape="wide", reflevel="PC") expect_equal(sum(llcont(mlog1)), as.numeric(logLik(mlog1))) expect_equal(sum(llcont(mlog2)), as.numeric(logLik(mlog2))) expect_equal(sum(llcont(mlog3)), as.numeric(logLik(mlog3))) expect_equal(sum(llcont(mlog4)), as.numeric(logLik(mlog4))) expect_equal(sum(llcont(mlog5)), as.numeric(logLik(mlog5))) expect_equal(sum(llcont(mlog6)), as.numeric(logLik(mlog6))) expect_equal(sum(llcont(mlog7)), as.numeric(logLik(mlog7))) expect_equal(sum(llcont(mlog8)), as.numeric(logLik(mlog8))) expect_equal(sum(llcont(mlog10)), as.numeric(logLik(mlog10))) } }) test_that("nls object", { DNase1 <- subset(DNase, Run == 1) nls1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), DNase1) nls2 <- nls(density ~ 1/(1 + exp((xmid - log(conc))/scal)), data = DNase1, start = list(xmid = 0, scal = 1), algorithm = "plinear") nls3 <- nls(density ~ Asym/(1 + exp((xmid - log(conc))/scal)), data = DNase1, start = list(Asym = 3, xmid = 0, scal = 1)) nls4 <- nls(density ~ Asym/(1 + exp((xmid - log(conc))/scal)), data = DNase1, start = list(Asym = 3, xmid = 0, scal = 1), algorithm = "port") Treated <- Puromycin[Puromycin$state == "treated", ] weighted.MM <- function(resp, conc, Vm, K) { pred <- (Vm * conc)/(K + conc) (resp - pred) / sqrt(pred) } nls5 <- nls( ~ weighted.MM(rate, conc, Vm, K), data = Treated, start = list(Vm = 200, K = 0.1)) lisTreat <- with(Treated, list(conc1 = conc[1], conc.1 = conc[-1], rate = rate)) weighted.MM1 <- function(resp, conc1, conc.1, Vm, K) { conc <- c(conc1, conc.1) pred <- (Vm * conc)/(K + conc) (resp - pred) / sqrt(pred) } nls6 <- nls( ~ weighted.MM1(rate, conc1, conc.1, Vm, K), data = lisTreat, start = list(Vm = 200, K = 0.1)) weighted.MM.grad <- function(resp, conc1, conc.1, Vm, K) { conc <- c(conc1, conc.1) K.conc <- K+conc dy.dV <- conc/K.conc dy.dK <- -Vm*dy.dV/K.conc pred <- Vm*dy.dV pred.5 <- sqrt(pred) dev <- (resp - pred) / pred.5 Ddev <- -0.5*(resp+pred)/(pred.5*pred) attr(dev, "gradient") <- Ddev * cbind(Vm = dy.dV, K = dy.dK) dev } nls7 <- nls( ~ weighted.MM.grad(rate, conc1, conc.1, Vm, K), data = lisTreat, start = list(Vm = 200, K = 0.1)) if(isTRUE(require("MASS"))){ utils::data(muscle, package = "MASS") nls9 <- nls(Length ~ cbind(1, exp(-Conc/th)), muscle, start = list(th = 1), algorithm = "plinear") b <- coef(nls9) nls10 <- nls(Length ~ a[Strip] + b[Strip]*exp(-Conc/th), muscle, start = list(a = rep(b[2], 21), b = rep(b[3], 21), th = b[1])) expect_equal(sum(llcont(nls9)), as.numeric(logLik(nls9))) expect_equal(sum(llcont(nls10)), as.numeric(logLik(nls10))) } expect_equal(sum(llcont(nls1)), as.numeric(logLik(nls1))) expect_equal(sum(llcont(nls2)), as.numeric(logLik(nls2))) expect_equal(sum(llcont(nls3)), as.numeric(logLik(nls3))) expect_equal(sum(llcont(nls4)), as.numeric(logLik(nls4))) expect_equal(sum(llcont(nls5)), as.numeric(logLik(nls5))) expect_equal(sum(llcont(nls6)), as.numeric(logLik(nls6))) expect_equal(sum(llcont(nls7)), as.numeric(logLik(nls7))) }) test_that("polr object", { if (isTRUE(require("MASS"))) { options(contrasts = c("contr.treatment", "contr.poly")) polr1 <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) polr2 <- update(polr1, method = "probit", Hess = TRUE) polr3 <- update(polr1, method = "loglog", Hess = TRUE) polr4 <- update(polr1, method = "cloglog", Hess = TRUE) expect_equal(sum(llcont(polr1)), as.numeric(logLik(polr1))) expect_equal(sum(llcont(polr2)), as.numeric(logLik(polr2))) expect_equal(sum(llcont(polr3)), as.numeric(logLik(polr3))) expect_equal(sum(llcont(polr4)), as.numeric(logLik(polr4))) } }) test_that("rlm object", { if (isTRUE(require("MASS"))) { rlm1 <- rlm(stack.loss ~ ., stackloss) rlm2 <- rlm(stack.loss ~ ., stackloss, psi = psi.hampel, init = "lts") rlm3 <- rlm(stack.loss ~ ., stackloss, psi = psi.bisquare) expect_equal(sum(llcont(rlm1)), as.numeric(logLik(rlm1))) expect_equal(sum(llcont(rlm2)), as.numeric(logLik(rlm2))) expect_equal(sum(llcont(rlm3)), as.numeric(logLik(rlm3))) } })
library(hamcrest) expected <- structure(list(breaks = c(0x1.8p+0, 0x1p+1, 0x1.4p+1, 0x1.8p+1, 0x1.cp+1, 0x1p+2, 0x1.2p+2, 0x1.4p+2, 0x1.6p+2), counts = c(51L, 41L, 5L, 7L, 30L, 73L, 61L, 4L), density = c(0x1.8p-2, 0x1.34b4b4b4b4b4bp-2, 0x1.2d2d2d2d2d2d3p-5, 0x1.a5a5a5a5a5a5ap-5, 0x1.c3c3c3c3c3c3cp-3, 0x1.12d2d2d2d2d2dp-1, 0x1.cb4b4b4b4b4b5p-2, 0x1.e1e1e1e1e1e1ep-6 ), mids = c(0x1.cp+0, 0x1.2p+1, 0x1.6p+1, 0x1.ap+1, 0x1.ep+1, 0x1.1p+2, 0x1.3p+2, 0x1.5p+2), xname = "c(3.6, 1.8, 3.333, 2.283, 4.533, 2.883, 4.7, 3.6, 1.95, 4.35, 1.833, 3.917, 4.2, 1.75, 4.7, 2.167, 1.75, 4.8, 1.6, 4.25, 1.8, 1.75, 3.45, 3.067, 4.533, 3.6, 1.967, 4.083, 3.85, 4.433, 4.3, 4.467, 3.367, 4.033, 3.833, 2.017, 1.867, 4.833, 1.833, 4.783, 4.35, 1.883, 4.567, 1.75, 4.533, 3.317, 3.833, 2.1, 4.633, 2, 4.8, 4.716, 1.833, 4.833, 1.733, 4.883, 3.717, 1.667, 4.567, 4.317, 2.233, 4.5, 1.75, 4.8, 1.817, 4.4, 4.167, 4.7, 2.067, 4.7, 4.033, 1.967, 4.5, 4, 1.983, 5.067, 2.017, 4.567, 3.883, 3.6, \n 4.133, 4.333, 4.1, 2.633, 4.067, 4.933, 3.95, 4.517, 2.167, 4, 2.2, 4.333, 1.867, 4.817, 1.833, 4.3, 4.667, 3.75, 1.867, 4.9, 2.483, 4.367, 2.1, 4.5, 4.05, 1.867, 4.7, 1.783, 4.85, 3.683, 4.733, 2.3, 4.9, 4.417, 1.7, 4.633, 2.317, 4.6, 1.817, 4.417, 2.617, 4.067, 4.25, 1.967, 4.6, 3.767, 1.917, 4.5, 2.267, 4.65, 1.867, 4.167, 2.8, 4.333, 1.833, 4.383, 1.883, 4.933, 2.033, 3.733, 4.233, 2.233, 4.533, 4.817, 4.333, 1.983, 4.633, 2.017, 5.1, 1.8, 5.033, 4, 2.4, 4.6, 3.567, 4, 4.5, 4.083, 1.8, 3.967, \n 2.2, 4.15, 2, 3.833, 3.5, 4.583, 2.367, 5, 1.933, 4.617, 1.917, 2.083, 4.583, 3.333, 4.167, 4.333, 4.5, 2.417, 4, 4.167, 1.883, 4.583, 4.25, 3.767, 2.033, 4.433, 4.083, 1.833, 4.417, 2.183, 4.8, 1.833, 4.8, 4.1, 3.966, 4.233, 3.5, 4.366, 2.25, 4.667, 2.1, 4.35, 4.133, 1.867, 4.6, 1.783, 4.367, 3.85, 1.933, 4.5, 2.383, 4.7, 1.867, 3.833, 3.417, 4.233, 2.4, 4.8, 2, 4.15, 1.867, 4.267, 1.75, 4.483, 4, 4.117, 4.083, 4.267, 3.917, 4.55, 4.083, 2.417, 4.183, 2.217, 4.45, 1.883, 1.85, 4.283, 3.95, 2.333, \n 4.15, 2.35, 4.933, 2.9, 4.583, 3.833, 2.083, 4.367, 2.133, 4.35, 2.2, 4.45, 3.567, 4.5, 4.15, 3.817, 3.917, 4.45, 2, 4.283, 4.767, 4.533, 1.85, 4.25, 1.983, 2.25, 4.75, 4.117, 2.15, 4.417, 1.817, 4.467)", equidist = TRUE), .Names = c("breaks", "counts", "density", "mids", "xname", "equidist"), class = "histogram") assertThat(graphics:::hist.default(plot=FALSE,right=FALSE,x=c(3.6, 1.8, 3.333, 2.283, 4.533, 2.883, 4.7, 3.6, 1.95, 4.35, 1.833, 3.917, 4.2, 1.75, 4.7, 2.167, 1.75, 4.8, 1.6, 4.25, 1.8, 1.75, 3.45, 3.067, 4.533, 3.6, 1.967, 4.083, 3.85, 4.433, 4.3, 4.467, 3.367, 4.033, 3.833, 2.017, 1.867, 4.833, 1.833, 4.783, 4.35, 1.883, 4.567, 1.75, 4.533, 3.317, 3.833, 2.1, 4.633, 2, 4.8, 4.716, 1.833, 4.833, 1.733, 4.883, 3.717, 1.667, 4.567, 4.317, 2.233, 4.5, 1.75, 4.8, 1.817, 4.4, 4.167, 4.7, 2.067, 4.7, 4.033, 1.967, 4.5, 4, 1.983, 5.067, 2.017, 4.567, 3.883, 3.6, 4.133, 4.333, 4.1, 2.633, 4.067, 4.933, 3.95, 4.517, 2.167, 4, 2.2, 4.333, 1.867, 4.817, 1.833, 4.3, 4.667, 3.75, 1.867, 4.9, 2.483, 4.367, 2.1, 4.5, 4.05, 1.867, 4.7, 1.783, 4.85, 3.683, 4.733, 2.3, 4.9, 4.417, 1.7, 4.633, 2.317, 4.6, 1.817, 4.417, 2.617, 4.067, 4.25, 1.967, 4.6, 3.767, 1.917, 4.5, 2.267, 4.65, 1.867, 4.167, 2.8, 4.333, 1.833, 4.383, 1.883, 4.933, 2.033, 3.733, 4.233, 2.233, 4.533, 4.817, 4.333, 1.983, 4.633, 2.017, 5.1, 1.8, 5.033, 4, 2.4, 4.6, 3.567, 4, 4.5, 4.083, 1.8, 3.967, 2.2, 4.15, 2, 3.833, 3.5, 4.583, 2.367, 5, 1.933, 4.617, 1.917, 2.083, 4.583, 3.333, 4.167, 4.333, 4.5, 2.417, 4, 4.167, 1.883, 4.583, 4.25, 3.767, 2.033, 4.433, 4.083, 1.833, 4.417, 2.183, 4.8, 1.833, 4.8, 4.1, 3.966, 4.233, 3.5, 4.366, 2.25, 4.667, 2.1, 4.35, 4.133, 1.867, 4.6, 1.783, 4.367, 3.85, 1.933, 4.5, 2.383, 4.7, 1.867, 3.833, 3.417, 4.233, 2.4, 4.8, 2, 4.15, 1.867, 4.267, 1.75, 4.483, 4, 4.117, 4.083, 4.267, 3.917, 4.55, 4.083, 2.417, 4.183, 2.217, 4.45, 1.883, 1.85, 4.283, 3.95, 2.333, 4.15, 2.35, 4.933, 2.9, 4.583, 3.833, 2.083, 4.367, 2.133, 4.35, 2.2, 4.45, 3.567, 4.5, 4.15, 3.817, 3.917, 4.45, 2, 4.283, 4.767, 4.533, 1.85, 4.25, 1.983, 2.25, 4.75, 4.117, 2.15, 4.417, 1.817, 4.467))[-5] , identicalTo( expected[-5] ) )
WACSdata=function(data, mapping=NULL, bounds=NULL, from = NULL, to = NULL, skip=NULL, Trange=FALSE, seasons = c("03-01", "06-01", "09-01","12-01")) { for (toskip in skip){ data[[toskip]] <- NULL } mapping = wacs.buildMapping(mapping_user=mapping, names(data),Trange); data = wacs.renameData(data, mapping) if (! all(data$tmin <= data$tmax)) { stop ("[WACSdata] found tmin > tmax"); } if (! all(data$rain >= 0)) { stop ("[WACSdata] found rain < 0"); } l = length(seasons); seasonsRes = data.frame(month=rep(0,l), day=rep(0,l)) for (s in 1:l) { tmp = strsplit(seasons[s],"-")[[1]] seasonsRes$month[s] = as.numeric(tmp[1]); seasonsRes$day[s] = as.numeric(tmp[2]); } seasons=seasonsRes; data$season = unlist(lapply(1:nrow(data), function(x){ return(wacs.season(data$month[x], data$day[x], seasons)); })) data = wacs.reorderData(data,mapping,Trange); sel = wacs.selectDates(data, from, to) data = data[sel,] bounds = wacs.getBounds(data, bounds, mapping); data = data[-(which(data$month == 2 & data$day == 29)), ] data$rain[data$rain <0.05] = 0 res = list(data=data, mapping=mapping, bounds = bounds, seasons=seasons, Trange=Trange) class(res) = "WACSdata" return(res) }
ITPimage <- function(ITP.result,alpha=0.05,abscissa.range=c(0,1),nlevel=20){ if(ITP.result$basis=='paFourier' & ITP.result$test=='2pop'){ par(ask=T) p <- dim(ITP.result$heatmap.matrix_phase)[1] min.ascissa <- 1-(p-1)/2 max.ascissa <- p+(p-1)/2 ascissa.grafico <- seq(min.ascissa,max.ascissa,length.out=p*4) ordinata.grafico <- 1:p colori=rainbow(nlevel,start=0.15,end=0.67) colori <- colori[length(colori):1] layout(rbind(1:2,c(3,0),c(4,0)),widths=c(8,1),heights=c(2,1,1)) par(mar=c(4.1, 4.1, 3, .2),cex.main=1.5,cex.lab=1.1,las=0) matrice.quad <- ITP.result$heatmap.matrix_phase[,(p+1):(3*p)] ascissa.quad <- ascissa.grafico[(p+1):(3*p)] image(ascissa.quad,ordinata.grafico,t(matrice.quad[p:1,]),col=colori,ylab='Interval length',main='p-value heatmap (phase)',xlab='Abscissa',zlim=c(0,1),asp=1) min.plot <- par("usr")[1] max.plot <- par("usr")[2] par(mar=c(4.1, 1, 3, 3),las=1) image(1,seq(0,1,length.out=nlevel)-0.025*seq(0,1,length.out=nlevel)+0.025*seq(1,0,length.out=nlevel),t(as.matrix(seq(0,1,length.out=nlevel))),col=colori,xaxt='n',yaxt='n',xlab='',ylab='') axis(4,at=seq(0,1,0.2),padj=0.4) rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') par(mar=c(4.1, 4.1, 3, .2),las=0) plot(1:p,ITP.result$corrected.pval_phase,pch=16,ylim=c(0,1),xlim=c(min.plot,max.plot),main='Corrected p-values (phase)',ylab='p-value',xlab='Component',xaxs='i') difference <- which(ITP.result$corrected.pval_phase<alpha) abscissa.pval <- 1:p if(length(difference)>0){ for(j in 1:length(difference)){ min.rect <- abscissa.pval[difference[j]] - 0.5 max.rect <- min.rect + 1 rect(min.rect, par("usr")[3], max.rect, par("usr")[4], col = 'gray90',density=-2,border = NA) } rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') } for(j in 0:10){ abline(h=j/10,col='lightgray',lty="dotted") } points(abscissa.pval,ITP.result$corrected.pval_phase,pch=16) abscissa.new <- seq(abscissa.range[1],abscissa.range[2],length.out=dim(ITP.result$data.eval)[2]) matplot(abscissa.new,t(ITP.result$data.eval),col=ITP.result$labels,type='l',main='Functional data',xlab='Abscissa',ylab='Value',xaxs='i') layout(rbind(1:2,c(3,0),c(4,0)),widths=c(8,1),heights=c(2,1,1)) par(mar=c(4.1, 4.1, 3, .2),cex.main=1.5,cex.lab=1.1,las=0) matrice.quad <- ITP.result$heatmap.matrix_amplitude[,(p+1):(3*p)] ascissa.quad <- ascissa.grafico[(p+1):(3*p)] image(ascissa.quad,ordinata.grafico,t(matrice.quad[p:1,]),col=colori,ylab='Interval length',main='p-value heatmap (amplitude)',xlab='Abscissa',zlim=c(0,1),asp=1) min.plot <- par("usr")[1] max.plot <- par("usr")[2] par(mar=c(4.1, 1, 3, 3),las=1) image(1,seq(0,1,length.out=nlevel)-0.025*seq(0,1,length.out=nlevel)+0.025*seq(1,0,length.out=nlevel),t(as.matrix(seq(0,1,length.out=nlevel))),col=colori,xaxt='n',yaxt='n',xlab='',ylab='') axis(4,at=seq(0,1,0.2),padj=0.4) rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') par(mar=c(4.1, 4.1, 3, .2),las=0) plot(1:p,ITP.result$corrected.pval_amplitude,pch=16,ylim=c(0,1),xlim=c(min.plot,max.plot),main='Corrected p-values (amplitude)',ylab='p-value',xlab='Component',xaxs='i') difference <- which(ITP.result$corrected.pval_amplitude<alpha) abscissa.pval <- 1:p if(length(difference)>0){ for(j in 1:length(difference)){ min.rect <- abscissa.pval[difference[j]] - 0.5 max.rect <- min.rect + 1 rect(min.rect, par("usr")[3], max.rect, par("usr")[4], col = 'gray90',density=-2,border = NA) } rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') } for(j in 0:10){ abline(h=j/10,col='lightgray',lty="dotted") } points(1:p,ITP.result$corrected.pval_amplitude,pch=16) abscissa.new <- seq(abscissa.range[1],abscissa.range[2],length.out=dim(ITP.result$data.eval)[2]) matplot(abscissa.new,t(ITP.result$data.eval),col=ITP.result$labels,type='l',main='Functional data',xlab='Abscissa',ylab='Value',xaxs='i') par(ask=FALSE) }else if(ITP.result$basis=='Fourier'){ p <- dim(ITP.result$heatmap.matrix)[1] min.ascissa <- 1-(p-1)/2 max.ascissa <- p+(p-1)/2 ascissa.grafico <- seq(min.ascissa,max.ascissa,length.out=p*4) ordinata.grafico <- 1:p colori=rainbow(nlevel,start=0.15,end=0.67) colori <- colori[length(colori):1] layout(rbind(1:2,c(3,0),c(4,0)),widths=c(8,1),heights=c(2,1,1)) par(mar=c(4.1, 4.1, 3, .2),cex.main=1.5,cex.lab=1.1,las=0) matrice.quad <- ITP.result$heatmap.matrix[,(p+1):(3*p)] ascissa.quad <- ascissa.grafico[(p+1):(3*p)] image(ascissa.quad,ordinata.grafico,t(matrice.quad[p:1,]),col=colori,ylab='Interval length',main='p-value heatmap',xlab='Abscissa',zlim=c(0,1),asp=1) min.plot <- par("usr")[1] max.plot <- par("usr")[2] par(mar=c(4.1, 1, 3, 3),las=1) image(1,seq(0,1,length.out=nlevel)-0.025*seq(0,1,length.out=nlevel)+0.025*seq(1,0,length.out=nlevel),t(as.matrix(seq(0,1,length.out=nlevel))),col=colori,xaxt='n',yaxt='n',xlab='',ylab='') axis(4,at=seq(0,1,0.2),padj=0.4) rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') par(mar=c(4.1, 4.1, 3, .2),las=0) plot(1:p,ITP.result$corrected.pval,pch=16,ylim=c(0,1),xlim=c(min.plot,max.plot),main='Corrected p-values',ylab='p-value',xlab='Component',xaxs='i') difference <- which(ITP.result$corrected.pval<alpha) abscissa.pval <- 1:p if(length(difference)>0){ for(j in 1:length(difference)){ min.rect <- abscissa.pval[difference[j]] - 0.5 max.rect <- min.rect + 1 rect(min.rect, par("usr")[3], max.rect, par("usr")[4], col = 'gray90',density=-2,border = NA) } rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') } for(j in 0:10){ abline(h=j/10,col='lightgray',lty="dotted") } points(1:p,ITP.result$corrected.pval,pch=16) abscissa.new <- seq(abscissa.range[1],abscissa.range[2],length.out=dim(ITP.result$data.eval)[2]) matplot(abscissa.new,t(ITP.result$data.eval),col=ITP.result$labels,type='l',main='Functional data',xlab='Abscissa',ylab='Value',xaxs='i') if(ITP.result$test=='1pop'){ if(length(ITP.result$mu)==1){ abscissa.mu <- abscissa.new mu <- rep(ITP.result$mu,1000) }else{ abscissa.mu <- seq(abscissa.range[1],abscissa.range[2],length.out=length(ITP.result$mu)) mu <- ITP.result$mu } lines(abscissa.mu,mu,col='gray') } }else if(ITP.result$basis=='B-spline'){ min.ascissa <- abscissa.range[1]-(abscissa.range[2]-abscissa.range[1])/2 max.ascissa <- abscissa.range[2]+(abscissa.range[2]-abscissa.range[1])/2 p <- dim(ITP.result$heatmap.matrix)[1] ordinata.grafico <- seq(abscissa.range[1],abscissa.range[2],length.out=p) - abscissa.range[1] colori=rainbow(nlevel,start=0.15,end=0.67) colori <- colori[length(colori):1] layout(rbind(1:2,c(3,0),c(4,0)),widths=c(8,1),heights=c(2,1,1)) par(mar=c(4.1, 4.1, 3, .2),cex.main=1.5,cex.lab=1.1,las=0) matrice.quad <- ITP.result$heatmap.matrix[,(p+1):(3*p)] ascissa.quad <- seq(abscissa.range[1],abscissa.range[2],length.out=p*2) image(ascissa.quad,ordinata.grafico,t(matrice.quad[p:1,]),col=colori,ylab='Interval length',main='p-value heatmap',xlab='Abscissa',zlim=c(0,1),asp=1) min.plot <- par("usr")[1] max.plot <- par("usr")[2] par(mar=c(4.1, 1, 3, 3),las=1) image(1,seq(0,1,length.out=nlevel)-0.025*seq(0,1,length.out=nlevel)+0.025*seq(1,0,length.out=nlevel),t(as.matrix(seq(0,1,length.out=nlevel))),col=colori,xaxt='n',yaxt='n',xlab='',ylab='') axis(4,at=seq(0,1,0.2),padj=0.4) rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') par(mar=c(4.1, 4.1, 3, .2),las=0) abscissa.pval <- seq(abscissa.range[1],abscissa.range[2],length.out=p) plot(abscissa.pval,ITP.result$corrected.pval,pch=16,ylim=c(0,1),xlim=c(min.plot,max.plot),main='Corrected p-values',ylab='p-value',xlab='Component',xaxs='i') difference <- which(ITP.result$corrected.pval<alpha) if(length(difference) >0){ for(j in 1:length(difference)){ min.rect <- abscissa.pval[difference[j]] - (abscissa.pval[2]-abscissa.pval[1])/2 max.rect <- min.rect + (abscissa.pval[2]-abscissa.pval[1]) rect(min.rect, par("usr")[3], max.rect, par("usr")[4], col = 'gray90',density=-2,border = NA) } rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') } for(j in 0:10){ abline(h=j/10,col='lightgray',lty="dotted") } points(abscissa.pval,ITP.result$corrected.pval,pch=16) abscissa.new <- seq(abscissa.range[1],abscissa.range[2],length.out=dim(ITP.result$data.eval)[2]) matplot(abscissa.new,t(ITP.result$data.eval),col=ITP.result$labels,type='l',xlim=c(min.plot,max.plot),main='Functional data',xlab='Abscissa',ylab='Value',xaxs='i') if(length(difference) >0){ for(j in 1:length(difference)){ min.rect <- abscissa.pval[difference[j]] - (abscissa.pval[2]-abscissa.pval[1])/2 max.rect <- min.rect + (abscissa.pval[2]-abscissa.pval[1]) rect(min.rect, par("usr")[3], max.rect, par("usr")[4], col = 'gray90',density=-2,border = NA) } rect(par("usr")[1], par("usr")[3], par("usr")[2], par("usr")[4], col = NULL,border='black') } matplot(abscissa.new,t(ITP.result$data.eval),col=ITP.result$labels,type='l',add=TRUE) if(ITP.result$test=='1pop'){ if(length(ITP.result$mu)==1){ abscissa.mu <- abscissa.new mu <- rep(ITP.result$mu,1000) }else{ abscissa.mu <- seq(abscissa.range[1],abscissa.range[2],length.out=length(ITP.result$mu)) mu <- ITP.result$mu } lines(abscissa.mu,mu,col='blue') } } }
llm <- function(X,Y,threshold_pruning=0.25 , nbr_obs_leaf=100) { if (threshold_pruning < 0 | threshold_pruning> 1){ stop("Enter a valid threshold for pruning value [0,1] (threshold_pruning)") } if (nbr_obs_leaf < 1){ stop("Enter a valid mimimum number of observations per leaf (minimum =1) (nbr_obs_leaf)") } if (nrow(X) != length(Y)){ stop("The number of instances in (X) and (Y) should be the same") } if (nrow(X) == 0 | length(Y)== 0){ stop("There are no instances in (X) or (Y)") } if (length(which(sapply(X, is.numeric)==FALSE))>0){ stop("All variables in the dataframe (X) should be numeric") } if (nlevels(Y) != 2){ stop("Only binary classification is supported at the moment") } .list.rules.party <- function(x, i = NULL, ...) { if (is.null(i)) i <- nodeids(x, terminal = TRUE) if (length(i) > 1) { ret <- sapply(i, .list.rules.party, x = x) names(ret) <- if (is.character(i)) i else names(x)[i] return(ret) } if (is.character(i) && !is.null(names(x))) i <- which(names(x) %in% i) stopifnot(length(i) == 1 & is.numeric(i)) stopifnot(i <= length(x) & i >= 1) i <- as.integer(i) dat <- data_party(x, i) if (!is.null(x$fitted)) { findx <- which("(fitted)" == names(dat))[1] fit <- dat[,findx:ncol(dat), drop = FALSE] dat <- dat[,-(findx:ncol(dat)), drop = FALSE] if (ncol(dat) == 0) dat <- x$data } else { fit <- NULL dat <- x$data } rule <- c() recFun <- function(node) { if (id_node(node) == i) return(NULL) kid <- sapply(kids_node(node), id_node) whichkid <- max(which(kid <= i)) split <- split_node(node) ivar <- varid_split(split) svar <- names(dat)[ivar] index <- index_split(split) if (is.factor(dat[, svar])) { if (is.null(index)) index <- ((1:nlevels(dat[, svar])) > breaks_split(split)) + 1 slevels <- levels(dat[, svar])[index == whichkid] srule <- paste(svar, " %in% c(\"", paste(slevels, collapse = "\", \"", sep = ""), "\")", sep = "") } else { if (is.null(index)) index <- 1:length(kid) breaks <- cbind(c(-Inf, breaks_split(split)), c(breaks_split(split), Inf)) sbreak <- breaks[index == whichkid,] right <- right_split(split) srule <- c() if (is.finite(sbreak[1])) srule <- c(srule, paste(svar, ifelse(right, ">", ">="), sbreak[1])) if (is.finite(sbreak[2])) srule <- c(srule, paste(svar, ifelse(right, "<=", "<"), sbreak[2])) srule <- paste(srule, collapse = " & ") } rule <<- c(rule, srule) return(recFun(node[[whichkid]])) } node <- recFun(node_party(x)) paste(rule, collapse = " & ") } m1 <- RWeka::J48(as.factor(as.character(Y)) ~ ., data = X, control = RWeka::Weka_control(M = nbr_obs_leaf, C= threshold_pruning)) Pm1 = partykit::as.party(m1) Pm1_rules = .list.rules.party(Pm1) TrainPred = stats::predict(Pm1, newdata=X, type="node") listythelist <- vector("list",length(Pm1_rules)) listythelist2 <- vector("list",length(Pm1_rules)) listythelist3 <- vector("list",length(Pm1_rules)) aa <- as.numeric() for (l in 1:length(Pm1_rules)) { train_ss <- X[which(TrainPred==names(Pm1_rules)[l]), ] y_sel <- Y[which(TrainPred==names(Pm1_rules)[l])] LR <- stats::glm(y_sel ~ ., data=train_ss, family=stats::binomial("logit")) LR1 <- stats::glm(y_sel ~ 1, data=train_ss, family=stats::binomial("logit")) listythelist[[l]] <- stats::step(LR1,direction="forward" ,scope = list(lower= LR1, upper = LR), trace = 0) listythelist2[[l]] <- nrow(train_ss) listythelist3[[l]] <- 1 - (table(y_sel)[1]/ length(y_sel)) } myreturn <- list() myreturn[[1]] <- Pm1_rules myreturn[[2]] <- listythelist myreturn[[3]] <- m1 myreturn[[4]] <- listythelist2 myreturn[[5]] <- listythelist3 class(myreturn) <- "logitleafmodel" names(myreturn)[[1]] <- "Segment Rules" names(myreturn)[[2]] <- "Coefficients" names(myreturn)[[3]] <- "Full decision tree for segmentation" names(myreturn)[[4]] <- "Observations per segment" names(myreturn)[[5]] <- "Incidence of dependent per segment" return(myreturn) }
threshold_apply = function(threshold = 0.5, roi_name = "test", video_path = 'image826.avi',radians = 0.217604550320612,xlength = 60,ylength = 242,xstart = 696,ystart = 323, image_list = NULL, fps = NULL) { starttime = Sys.time() output_folder = output_dir(dirname(video_path), use_default = TRUE) scratch_dir(wipe_scratch = TRUE) scratch = scratch_dir(file_name = video_path) unlink(gsub("/$", "", scratch), recursive = TRUE, force = TRUE) dir.create(scratch) filter_string = paste("rotate = '",radians,":out_w=rotw(",radians,"):out_h=roth(",radians,"):c = red',", "crop=",xlength,":",ylength,":",xstart,":",ystart,"", sep = "") if(!is.null(fps)) { filter_string = paste("fps = ",fps,",",filter_string, sep = "") } av::av_encode_video(video_path, paste(scratch, "/%03d_raw.png", sep = ""), vfilter = filter_string, codec = "png") cropped_file_list = list.files(scratch, full.names = TRUE, pattern = "\\_raw.png$") starttime = Sys.time() options(future.rng.onMisuse = "ignore") load.image(cropped_file_list[[1]]) %>% plot() message("Making segmentation") bundlesize = length(cropped_file_list)/as.numeric(availableCores()) split_file_list = split(cropped_file_list, ceiling(seq_along(cropped_file_list)/bundlesize)) foreach(locallist = split_file_list) %dopar% { for(current_frame in locallist) { current_frame_threshold = threshold_image(current_frame, threshold) imager::save.image(current_frame_threshold[[1]], current_frame %>% str_replace("_raw.png", "_threshold.png")) current_frame_threshold[[2]]$filename = current_frame_threshold[[2]]$filename %>% str_replace("_raw", "") utils::write.csv(current_frame_threshold[[2]], current_frame %>% str_replace("_raw.png", "_width.csv")) current_frame_spread = image_intensity_spread(current_frame) current_frame_spread$frame = current_frame_spread$frame %>% str_replace("_raw", "") utils::write.csv(current_frame_spread, current_frame %>% str_replace("_raw.png", "_profile.csv")) } } message("Copying results") output_file_base = paste(output_folder, "/", basename(file_path_sans_ext(video_path)), "_", roi_name, "_", sep = "") file_list = list.files(scratch, full.names = TRUE, pattern = "_raw.png$") av::av_encode_video(file_list, output = paste(output_file_base, "raw.avi", sep = ""),codec = "libx264", verbose = 24) file_list = list.files(scratch, full.names = TRUE, pattern = "_threshold.png$") load.image(file_list[[1]]) %>% plot() av::av_encode_video(file_list, output = paste(output_file_base, "threshold.avi", sep = ""),codec = "libx264", verbose = 24) file_list = list.files(scratch, full.names = TRUE, pattern = "_width.csv$") all_csv = lapply(file_list, read.csv) %>% bind_rows() all_csv = all_csv %>% mutate(X = NULL, y_position = y, y = NULL, y_position_excluded = excluded, excluded = NULL, frame = filename, filename = NULL, roi_name = roi_name) write.csv(all_csv, paste(output_file_base, "width.csv")) file_list = list.files(scratch, full.names = TRUE, pattern = "_profile.csv$") all_csv = lapply(file_list, read.csv) %>% bind_rows() all_csv = all_csv %>% mutate(X = NULL, x_position = x, x = NULL, roi_name = roi_name) write.csv(all_csv, paste(output_file_base, "profile.csv", sep = "")) unlink(gsub("/$", "", scratch), recursive = TRUE, force = TRUE) print(Sys.time() - starttime) }
quilt_form <- function(input_data, page_break_every = 0, question_type, filename) { if(question_type=="dropdown"){ question_type = "[[Question:MC:Dropdown]]" } if(question_type=="select"){ question_type = "[[Question:MC:Select]]" } if(question_type=="multiselect"){ question_type = "[[Question:MC:MultiSelect]]" } if(question_type=="singleanswer"){ question_type = "[[Question:MC:SingleAnswer:Horizontal]]" } if(question_type=="multianswer"){ question_type = "[[Question:MC:MultipleAnswer:Horizontal]]" } if(question_type=="rankorder"){ question_type = "[[Question:RankOrder]]" } if(question_type=="singleline"){ question_type = "[[Question:TextEntry:SingleLine]]" } if(question_type=="essay"){ question_type = "[[Question:TextEntry:Essay]]" } rowID <- NULL variable <- NULL input_data <- addformIDs(input_data) if(page_break_every != 0) { input_data <- pbreak(input_data, page_break_every) } else input_data$rowID = 1:nrow(input_data) quilted_form <- formpaste(input_data, question_type) writeLines(quilted_form, filename) }