code
stringlengths 1
13.8M
|
---|
tam_np_inits <- function(dat, nodes, pweights, probs_init, n_basis, model="2PL")
{
maxK <- apply(dat, 2, max, na.rm=TRUE)
K <- max(maxK)
K1 <- K + 1
TP <- length(nodes)
theta <- nodes
I <- ncol(dat)
items <- colnames(dat)
if ( is.null(probs_init) ){
probs_cum <- probs <- array(0, dim=c(I,K+1,TP) )
for (ii in 1:I){
K_ii <- maxK[ii]
K_ii2 <- K_ii+2
q1 <- stats::qlogis( seq( 0,1, len=K_ii2)[ -c(1,K_ii2) ] )
theta1 <- tam_matrix2(theta, nrow=1, ncol=TP)
for (kk in 1:K_ii){
probs_cum[ii,kk,] <- stats::plogis(q1[kk] - theta1 )
}
probs_cum[ ii, K_ii+1,] <- 1
probs[ii,1,] <- probs_cum[ii,1,]
for (kk in 2:(K_ii+1) ){
probs[ii,kk,] <- probs_cum[ii,kk,] - probs_cum[ii,kk-1, ]
}
}
} else {
probs <- probs_init
}
pi.k <- stats::dnorm(theta, mean=0, sd=1)
pi.k <- pi.k / sum(pi.k)
dat_resp <- ! is.na(dat)
dat2 <- dat
dat2[ ! dat_resp ] <- 0
dat2 <- as.matrix(dat2)
N <- nrow(dat)
if (is.null(pweights)){
pweights <- rep(1,N)
}
pweights <- N * pweights / sum(pweights)
use_basis <- ( n_basis > 0 ) | ( model=="1PL")
res <- list(maxK=maxK, K=K, K1=K1, TP=TP, I=I, probs=probs, pi.k=pi.k,
dat_resp=dat_resp, dat2=dat2, N=N, pweights=pweights, theta=theta,
items=items, use_basis=use_basis)
return(res)
} |
ggdist::geom_interval
ggdist::GeomInterval |
findSNVs = function(hapMat, focalSNV, minWindow = 1) {
if(minWindow > ncol(hapMat$hapmat))
stop("minWindow must not exceed number of SNVs")
absDistFromFocal = abs(hapMat$posns - hapMat$posns[focalSNV])
current = c(focalSNV,focalSNV)
nextSNV = getNextFromFocal(current,absDistFromFocal)
while(checkCompatible(current, nextSNV, hapMat$hapmat) &&
getnSNVs(current) < ncol(hapMat$hapmat)) {
current = c(min(nextSNV, current[1]), max(nextSNV, current[2]))
nextSNV = getNextFromFocal(current, absDistFromFocal)
}
if(getnSNVs(current) == ncol(hapMat$hapmat)) {
SNVwindow = current[1]:current[2]
compat = rep(TRUE, ncol(hapMat$hapmat))
return(list(SNVwindow = SNVwindow, compat = compat))
}
if(nextSNV < current[1]) {
nextSNV = getNextRightFocal(current,absDistFromFocal)
while(!is.na(nextSNV) && checkCompatible(current, nextSNV, hapMat$hapmat)) {
current[2] = nextSNV
nextSNV = getNextRightFocal(current, absDistFromFocal)
}
} else {
nextSNV = getNextLeftFocal(current, absDistFromFocal)
while(!is.na(nextSNV) && checkCompatible(current, nextSNV, hapMat$hapmat)){
current[1] = nextSNV
nextSNV = getNextLeftFocal(current,absDistFromFocal)
}
}
compatInds = (current[1]:current[2])
while(getnSNVs(current)<minWindow) {
nextSNV = getNextFromFocal(current, absDistFromFocal)
current = c(min(nextSNV, current[1]), max(nextSNV, current[2]))
}
SNVwindow = current[1]:current[2]
compat = SNVwindow %in% compatInds
return(list(SNVwindow = SNVwindow, compat = compat))
} |
context("Unit tests for PLR (mulitple treatment case)")
library("mlr3learners")
lgr::get_logger("mlr3")$set_threshold("warn")
on_cran = !identical(Sys.getenv("NOT_CRAN"), "true")
if (on_cran) {
test_cases = expand.grid(
learner = "regr.lm",
dml_procedure = "dml2",
score = "partialling out",
stringsAsFactors = FALSE)
} else {
test_cases = expand.grid(
learner = c("regr.lm", "regr.cv_glmnet"),
dml_procedure = c("dml1", "dml2"),
score = c("IV-type", "partialling out"),
stringsAsFactors = FALSE)
}
test_cases[".test_name"] = apply(test_cases, 1, paste, collapse = "_")
patrick::with_parameters_test_that("Unit tests for PLR:",
.cases = test_cases, {
learner_pars = get_default_mlmethod_plr(learner)
n_rep_boot = 498
n_folds = 5
set.seed(3141)
plr_hat = dml_plr_multitreat(data_plr_multi,
y = "y", d = c("d1", "d2", "d3"),
n_folds = n_folds,
ml_g = learner_pars$ml_g$clone(),
ml_m = learner_pars$ml_m$clone(),
dml_procedure = dml_procedure, score = score)
theta = plr_hat$coef
se = plr_hat$se
t = plr_hat$t
pval = plr_hat$pval
set.seed(3141)
boot_theta = boot_plr_multitreat(plr_hat$thetas, plr_hat$ses,
data_plr_multi,
y = "y", d = c("d1", "d2", "d3"),
n_folds = n_folds, smpls = plr_hat$smpls,
all_preds = plr_hat$all_preds,
bootstrap = "normal", n_rep_boot = n_rep_boot,
score = score)$boot_coef
set.seed(3141)
Xnames = names(data_plr_multi)[names(data_plr_multi) %in% c("y", "d1", "d2", "d3", "z") == FALSE]
data_ml = double_ml_data_from_data_frame(data_plr_multi,
y_col = "y",
d_cols = c("d1", "d2", "d3"), x_cols = Xnames)
double_mlplr_obj = DoubleMLPLR$new(data_ml,
ml_g = learner_pars$ml_g$clone(),
ml_m = learner_pars$ml_m$clone(),
dml_procedure = dml_procedure,
n_folds = n_folds,
score = score)
double_mlplr_obj$fit()
theta_obj = double_mlplr_obj$coef
se_obj = double_mlplr_obj$se
t_obj = double_mlplr_obj$t_stat
pval_obj = double_mlplr_obj$pval
set.seed(3141)
double_mlplr_obj$bootstrap(method = "normal", n_rep_boot = n_rep_boot)
boot_theta_obj = double_mlplr_obj$boot_coef
ci_ptwise_obj = double_mlplr_obj$confint(joint = FALSE, level = 0.95)
ci_joint_obj = double_mlplr_obj$confint(joint = TRUE, level = 0.95)
expect_equal(theta, theta_obj, tolerance = 1e-8)
expect_equal(se, se_obj, tolerance = 1e-8)
expect_equal(t, t_obj, tolerance = 1e-8)
expect_equal(pval, pval_obj, tolerance = 1e-8)
expect_equal(as.vector(boot_theta), as.vector(boot_theta_obj), tolerance = 1e-8)
}
) |
pmpp_data <- function(indata, t_dim = "cols", var_name = "Y") {
if (!is.matrix(indata)) {
indata <- as.matrix(indata)
}
if (t_dim == "cols") {
N <- nrow(indata)
T <- ncol(indata)
Y <- c()
for (i in 1:N) {
Y <- rbind(Y, as.matrix(indata[i, ], ncol = 1))
}
if (is.null(colnames(indata))) {
colnames(indata) <- 1:T
}
if (is.null(rownames(indata))) {
rownames(indata) <- 1:N
}
out <- data.frame(
rep(rownames(indata), each = T),
rep(colnames(indata), N), as.numeric(Y)
)
} else if (t_dim == "rows") {
N <- ncol(indata)
T <- nrow(indata)
Y <- c()
for (i in 1:N) {
Y <- rbind(Y, as.matrix(indata[, i], ncol = 1))
}
if (is.null(colnames(indata))) {
colnames(indata) <- 1:N
}
if (is.null(rownames(indata))) {
rownames(indata) <- 1:T
}
out <- data.frame(
rep(colnames(indata), each = T),
rep(rownames(indata), N), as.numeric(Y)
)
}
colnames(out) <- c("unit", "time", var_name)
return(out)
} |
intpoint_simul <-
function(times, subj, U, y, m, tau, lambda, lambcross, px, d){
H = length(tau)
mtot = ncol(U)
dim = length(subj)
dtot = sum(d)
W = Weight_Ni(y, subj)$W
Wy = W*y
b = c(rep(Wy, H), rep(0, ((H-1)*mtot)), rep(0, (H*(mtot-sum(d)))))
WU = W*U
M0 = matrix(rep(0,(dim*mtot)), ncol=mtot)
Hmtot = rep(mtot,H)
cum_HmtotB = cumsum(Hmtot)
cum_HmtotA = c(1, c(cum_HmtotB+1))
CX=list()
Hdim = rep(dim, H)
cum_HdimB = cumsum(Hdim)
cum_HdimA = c(1, c(cum_HdimB+1))
All_CX = matrix(NA, H*dim, H*mtot)
rhs_CX = matrix(NA, H*mtot, H)
for(h in 1:H){
CX[[h]] = matrix(0, dim, (mtot*H))
CX[[h]][,(cum_HmtotA[h]:cum_HmtotB[h])] = WU
All_CX[cum_HdimA[h]:cum_HdimB[h],]=CX[[h]]
rhs_CX[,h] = t(CX[[h]])%*%rep((1-tau[h]),dim)
}
M1 = matrix(rep(0,(mtot*mtot)), ncol=mtot)
D1 = cbind(-diag(mtot), diag(mtot))
CXNC=list()
HmtotNC = rep(mtot, (H-1))
cum_HmtotNCB = cumsum(HmtotNC)
cum_HmtotNCA = c(1, c(cum_HmtotNCB+1))
All_CXNC = matrix(NA, (H-1)*mtot, H*mtot)
rhs_CXNC = matrix(NA, H*mtot, H-1)
for(h in 1: (H-1)){
CXNC[[h]] = matrix(0, mtot, (mtot*H))
CXNC[[h]][,(cum_HmtotA[h]:cum_HmtotB[h+1])] = lambcross*D1
All_CXNC[cum_HmtotNCA[h]:cum_HmtotNCB[h],]=CXNC[[h]]
rhs_CXNC[,h] = t(CXNC[[h]])%*%rep(1/2, mtot)
}
if((H*px) == length(lambda)) lambdahpx=lambda else lambdahpx = rep(lambda, (H*px))
Hmk = rep(m,H)
Hdk = rep(d,H)
cum_HmkB = cumsum(Hmk)
cum_HmkA = c(1, c(cum_HmkB+1))
CXPS = list()
DPS = list()
Hmkdk = Hmk - Hdk
cum_HmkdkB = cumsum(Hmkdk)
cum_HmkdkA = c(1, c(cum_HmkdkB+1))
All_CXPS = matrix(NA, H*(mtot-dtot), H*mtot)
rhs_CXPS = matrix(NA, H*mtot, H*px)
for(h in 1:(H*px)){
CXPS[[h]] = matrix(0, (Hmk[h]-Hdk[h]), (mtot*H))
DPS[[h]] = diff(diag(Hmk[h]), diff = Hdk[h])
CXPS[[h]][(1:(Hmk[h]-Hdk[h])),(cum_HmkA[h]:cum_HmkB[h])]=lambdahpx[h]*DPS[[h]]
All_CXPS[cum_HmkdkA[h]:cum_HmkdkB[h],]=CXPS[[h]]
rhs_CXPS[,h] = t(CXPS[[h]])%*%rep(1/2, Hmk[h]-Hdk[h])
}
All_CX = as.matrix.csr(All_CX)
All_CXNC = as.matrix.csr(All_CXNC)
All_CXPS = as.matrix.csr(All_CXPS)
FP = rbind(All_CX, All_CXNC, All_CXPS)
rhs = rowSums(rhs_CX) + rowSums(rhs_CXNC) + rowSums(rhs_CXPS)
fit = rq.fit.sfn(FP,b,rhs=rhs)
alpha = fit$coef
intout = list(alpha=alpha, W=W)
return(intout)
} |
read_lines <- function(file, skip = 0, skip_empty_rows = FALSE, n_max = Inf,
locale = default_locale(),
na = character(),
lazy = should_read_lazy(),
num_threads = readr_threads(),
progress = show_progress()) {
if (edition_first()) {
if (is.infinite(n_max)) {
n_max <- -1L
}
if (empty_file(file)) {
return(character())
}
ds <- datasource(file, skip = skip, skip_empty_rows = skip_empty_rows, skip_quote = FALSE)
return(read_lines_(ds, skip_empty_rows = skip_empty_rows, locale_ = locale, na = na, n_max = n_max, progress = progress))
}
vroom::vroom_lines(file,
skip = skip,
locale = locale,
n_max = n_max,
progress = progress,
altrep = lazy,
skip_empty_rows = skip_empty_rows,
na = na,
num_threads = num_threads
)
}
read_lines_raw <- function(file, skip = 0,
n_max = -1L,
num_threads = readr_threads(),
progress = show_progress()) {
if (empty_file(file)) {
return(list())
}
ds <- datasource(file, skip = skip, skip_empty_rows = FALSE, skip_quote = FALSE)
read_lines_raw_(ds, n_max = n_max, progress = progress)
}
write_lines <- function(x, file, sep = "\n", na = "NA", append = FALSE,
num_threads = readr_threads(),
path = deprecated()) {
is_raw <- is.list(x) && inherits(x[[1]], "raw")
if (is_present(path)) {
deprecate_warn("1.4.0", "write_lines(path = )", "write_lines(file = )")
file <- path
}
if (is_raw || edition_first()) {
is_raw <- is.list(x) && inherits(x[[1]], "raw")
if (!is_raw) {
x <- as.character(x)
}
file <- standardise_path(file, input = FALSE)
if (!isOpen(file)) {
on.exit(close(file), add = TRUE)
open(file, if (isTRUE(append)) "ab" else "wb")
}
if (is_raw) {
write_lines_raw_(x, file, sep)
} else {
write_lines_(x, file, na, sep)
}
return(invisible(x))
}
vroom::vroom_write_lines(as.character(x), file, eol = sep, na = na, append = append, num_threads = num_threads)
invisible(x)
} |
rEB.Finite.Bayes<-function(X,z,X.target,z.target,m=c(4,6),m.EB=8, B=10, centering=TRUE,
nsample=min(1000,length(z)), g.method='DL',LP.type='L2', sd0=NULL,
theta.set.prior=seq(-2.5*sd(z),2.5*sd(z),length.out=500),
theta.set.post=seq(z.target-2.5*sd(z),z.target+2.5*sd(z),length.out=500),
post.alpha=0.8, plot=TRUE, ...){
max.iter=2000
extraparms=list(...)
extraparms$X=X;extraparms$z=z;extraparms$X.target=X.target;extraparms$m=m;extraparms$nsample=nsample;extraparms$centering=centering
pb<-txtProgressBar(min=0,max=B,style=3)
setTxtProgressBar(pb,0)
samplegen<-do.call(LASER,args=extraparms)
z.sample<-samplegen$data
if(is.null(sd0)){
sd0<-IQR(z.sample)/1.35
}
data.z <- cbind(z.sample,rep(sd0,length(z.sample)))
reb.start <- BayesGOF::gMLE.nn(data.z[,1], data.z[,2], g.method)$estimate
reb.ds.L2 <- BayesGOF::DS.prior(data.z, max.m = m.EB, g.par = reb.start, family = "Normal", LP.type = LP.type)
prior.list<-post.list<-list()
viter=0
setTxtProgressBar(pb,0.1)
for(iter in 1:max.iter){
te_sample<-DS.sampler(nsample, reb.start, reb.ds.L2$LP.par, 'Normal', LP.type)
y_sample=sapply(te_sample,function(x){stats::rnorm(1,mean=x,sd=sd0)})
data.y <- cbind(y_sample,rep(sd0,length(y_sample)))
reb.start0 <- BayesGOF::gMLE.nn(data.y[,1], data.y[,2], g.method)$estimate
if(reb.start0[2]!=0){
viter=viter+1
reb.ds.iter <- BayesGOF::DS.prior(data.y, max.m = m.EB, g.par = reb.start0, family = "Normal", LP.type = LP.type)
priorfit_parm=approx(reb.ds.iter$prior.fit$theta.vals,reb.ds.iter$prior.fit$parm.prior,
xout=theta.set.prior,method='linear',rule=2)$y
prior.list[[viter]]<-reb.ds.iter
prior.list[[viter]]$prior.fit=data.frame(theta.vals=theta.set.prior,parm.prior=priorfit_parm)
if(is.null(reb.ds.iter$prior.fit$ds.prior)){
prior.list[[viter]]$prior.fit$ds.prior=prior.list[[viter]]$prior.fit$parm.prior
}else{
priorfit_ds=approx(reb.ds.iter$prior.fit$theta.vals,reb.ds.iter$prior.fit$ds.prior,
xout=theta.set.prior,method='linear',rule=2)$y
prior.list[[viter]]$prior.fit$ds.prior=priorfit_ds
}
reb.micro.iter_1 <- BayesGOF::DS.micro.inf(reb.ds.iter, y.0=z.target, n.0=sd0)
reb.micro.iter_fit<-LP.post.conv(theta.set.post, reb.ds.iter, y.0=z.target, n.0=sd0)
post.list[[viter]]<-reb.micro.iter_1
post.list[[viter]]$post.fit<-reb.micro.iter_fit
if(is.null(post.list[[viter]]$post.fit$ds.pos)){
post.list[[viter]]$post.fit$ds.pos=post.list[[viter]]$post.fit$parm.pos
}
setTxtProgressBar(pb,viter)
if(viter>=B){
break
}
}
}
prior.curve<-data.frame(
theta.vals=theta.set.prior,
parm.prior=apply(sapply(prior.list,function(x){x$prior.fit$parm.prior}),1,mean),
ds.prior=apply(sapply(prior.list,function(x){x$prior.fit$ds.prior}),1,mean)
)
post.curve<-data.frame(
theta.vals=theta.set.post,
parm.post=apply(sapply(post.list,function(x){x$post.fit$parm.pos}),1,mean),
ds.pos=apply(sapply(post.list,function(x){x$post.fit$ds.pos}),1,mean)
)
post.curve$ds.pos[post.curve$ds.pos<0]<-0
prior.curve$ds.prior[prior.curve$ds.prior<0]<-0
post.mean=mean(sapply(post.list,function(x){x$DS.mean}))
post.mean.sd=sd(sapply(post.list,function(x){x$DS.mean}))
samp.post <- sample(post.curve$ds.pos, 1e5, replace = TRUE,prob = post.curve$ds.pos)
crit.post <- quantile(samp.post, 1-post.alpha)
hpd.interval<- c(min(post.curve$theta.vals[post.curve$ds.pos >=crit.post]),
max(post.curve$theta.vals[post.curve$ds.pos >=crit.post]))
prior=list(prior.fit=prior.curve)
posterior=list(post.fit=post.curve,
post.mode=post.curve$theta.vals[which.max(post.curve$ds.pos)],
post.mean=post.mean, post.mean.sd=post.mean.sd,
HPD.interval=hpd.interval
)
out=list(prior=prior,posterior=posterior,g.par=reb.start,sd0=sd0,sample=z.sample,LP.coef=samplegen$LPcoef)
x<-y<-score<-lower<-upper<-ystart<-yend<-NULL
if(plot==TRUE){
d0_prior=data.frame(x=prior.curve$theta.vals,y=prior.curve$ds.prior)
d0_post=data.frame(x=post.curve$theta.vals,y=post.curve$ds.pos)
p_prior<-ggplot2::ggplot(data=d0_prior,aes(x=x,y=y))+geom_line(size=.8,color='red')+
ylab('Estimated Prior')+xlab(expression(theta))+ggtitle('')+
theme(text=element_text(size=13),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.text.x = element_text(size=16),
axis.text.y = element_text(size=14),
legend.position="none",
legend.title=element_blank())
p_post<-ggplot2::ggplot()+geom_line(data=d0_post,aes(x=x,y=y),size=.8,color='red')+
ylab('Posterior Distribution')+xlab(expression(theta))+ggtitle('')+
theme(text=element_text(size=13),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.text.x = element_text(size=16),
axis.text.y = element_text(size=14),
legend.position="none",
legend.title=element_blank())
ci.start.ind<-which.min(abs(hpd.interval[1]-post.curve$theta.vals))
ci.end.ind<-which.min(abs(hpd.interval[2]-post.curve$theta.vals))
d_area<-d0_post[ci.start.ind:ci.end.ind,]
p_post<-p_post+geom_area(data=d_area,aes(x=x,y=y),fill='red',alpha=.4)
p_post<-p_post+geom_point(data=data.frame(x=posterior$post.mode,y=0),
aes(x=x,y=y),color='red',size=4,shape=18)
out$plots=list(prior=p_prior,post=p_post)
}
return(out)
} |
branches <- reactive({
input$branch_delete
input$branch_create
input$branch_checkout
req(input$repo_directory)
br <- suppressWarnings(system(paste("git -C", input$repo_directory, "branch -a"), intern = TRUE))
brs <- attr(br, "status")
if (length(br) == 0 || (!is.null(brs) && brs == 128)) {
c()
} else {
br %>% gsub("[\\* ]+", "", .) %>%
{.[!grepl("(^master$)|(^remotes/origin/master$)|(^remotes/origin/HEAD)", .)]}
}
})
observeEvent(input$branch_create, {
req(input$repo_directory)
if (input$branch_create_name != "") {
withProgress(message = "Creating branch", value = 0, style = "old", {
mess <- suppressWarnings(system(paste("git -C", input$repo_directory, "checkout -b", input$branch_create_name), intern = TRUE))
})
if (is_empty(mess)) mess <- "No messages"
showModal(
modalDialog(
title = "Branch create messages",
span(HTML(paste0(mess, collapse = "</br>")))
)
)
}
})
observeEvent(input$branch_create_from_mr, {
req(input$repo_directory)
remote_fetch <- suppressWarnings(system(paste("git -C", input$repo_directory, "config --get-all remote.origin.fetch"), intern = TRUE))
if (!"+refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*" %in% remote_fetch) {
mess <- system(paste("git -C", dir, "config --add remote.origin.fetch +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*"), intern = TRUE)
if (is_empty(mess)) mess <- "No messages"
showModal(
modalDialog(
title = "Branch create from MR messages",
span(HTML(paste0(mess, collapse = "</br>")))
)
)
}
})
observeEvent(input$branch_merge, {
from <- input$branch_merge_from
into <- input$branch_merge_into
req(input$repo_directory)
if (!is.null(from) || !is.null(into)) {
withProgress(message = "Merging branch", value = 0, style = "old", {
mess1 <- suppressWarnings(system(paste("git -C", input$repo_directory, "checkout", into), intern = TRUE))
mess2 <- suppressWarnings(system(paste("git -C", input$repo_directory, "merge", from), inter = TRUE))
})
showModal(
modalDialog(
title = "Branch merge messages",
span(HTML(paste0(c(mess1, mess2), collapse = "</br>")))
)
)
}
})
observeEvent(input$branch_abort, {
req(input$repo_directory)
mess <- suppressWarnings(system(paste("git -C", input$repo_directory, "merge --abort"), intern = TRUE))
if (is_empty(mess)) mess <- "No messages"
showModal(
modalDialog(
title = "Branch merge abort messages",
span(HTML(paste0(mess, collapse = "</br>")))
)
)
})
observeEvent(input$branch_link, {
req(input$repo_directory)
if (input$branch_create_name != "") {
mess <- suppressWarnings(paste("git -C", input$repo_directory, "push --set-upstream origin", input$branch_create_name) %>%
system(intern = TRUE))
if (is_empty(mess)) mess <- "No messages"
showModal(
modalDialog(
title = "Branch link messages",
span(HTML(paste0(mess, collapse = "</br>")))
)
)
}
})
observeEvent(input$branch_unlink, {
req(input$repo_directory)
branch <- input$branch_delete_name
if (is_empty(branch)) input$branch_create_name
if (!is_empty(branch)) {
mess <- c()
for (ib in branch) {
mess <- c(mess, system(paste0("git -C ", input$repo_directory, " branch -d -r origin/", ib), intern = TRUE))
}
showModal(
modalDialog(
title = "Branch create messages",
span(HTML(paste0(mess, collapse = "</br>")))
)
)
}
})
observeEvent(input$branch_delete, {
req(input$repo_directory)
if (!is.null(input$branch_delete_name)) {
withProgress(message = "Deleting branch", value = 0, style = "old", {
mess <- system(paste("git -C", input$repo_directory, "checkout master"), intern = TRUE)
for (ib in input$branch_delete_name) {
mess <- c(mess, system(paste("git -C", input$repo_directory, "branch -D", ib), intern = TRUE))
}
})
showModal(
modalDialog(
title = "Branch create messages",
span(HTML(paste0(mess, collapse = "</br>")))
)
)
}
})
output$ui_branch_create_name <- renderUI({
br <- rbranches()
if (length(br) == 0) {
HTML(paste0("<label>", input$repo_directory, " is not a git repo</label></br>"))
} else {
init <- isolate(input$branch_create_name)
init <- ifelse(is_empty(init), "", init)
textInput("branch_create_name", NULL, value = init, placeholder = "Provide a name for the new branch")
}
})
output$ui_branch_merge_branches <- renderUI({
br <- c("master", branches()) %>% .[!grepl("origin/", .)]
if (length(br) == 1) {
HTML("<label>No branches available to merge</label>")
} else {
tagList(
fillRow(height = "70px", width = "300px",
selectInput("branch_merge_from", "From:", choices = br, selected = br[2]),
selectInput("branch_merge_into", "Into:", choices = br, selected = br[1])
)
)
}
})
rbranches <- reactive({
input$sync; input$sync_unlink; input$branch_link; input$branch_unlink
input$branch_create; input$branch_checkout; input$branch_delete;
input$branch_merge; input$collect_fetch; input$collect
req(input$repo_directory)
br <- suppressWarnings(system(paste("git -C", input$repo_directory, "branch --all"), intern = TRUE))
brs <- attr(br, "status")
if (length(br) == 0 || (!is.null(brs) && brs == 128)) {
c()
} else {
br %>% {unique(c(.[grepl("\\* ", .)], .))} %>%
gsub("[\\* ]+", "", .) %>%
{.[!grepl("(^remotes/origin/master$)|(^remotes/origin/HEAD)", .)]}
}
})
output$ui_branch_checkout_name <- renderUI({
input$branch_create
br <- rbranches()
if (length(br) == 0) {
HTML("<label>No branches available</label>")
} else {
selectInput("branch_checkout_name", NULL, choices = br)
}
})
observeEvent(input$branch_checkout, {
req(input$repo_directory)
if (!is.null(input$branch_checkout_name)) {
withProgress(message = "Checkout branch", value = 0, style = "old", {
mess <- suppressWarnings(system(paste0("git -C ", input$repo_directory, " checkout ", sub("remotes/origin/", "", input$branch_checkout_name)), intern = TRUE))
})
showModal(
modalDialog(
title = "Branch checkout messages",
span(HTML(paste0(mess, collapse = "</br>")))
)
)
}
})
output$ui_branch_delete_name <- renderUI({
resp <- branches() %>% .[!grepl("^remotes/origin", .)]
if (length(resp) == 0) {
HTML("<label>No branches available to delete</label>")
} else {
selectizeInput("branch_delete_name",
label = NULL,
selected = resp[1],
choices = resp,
multiple = TRUE,
options = list(placeholder = "Select branch(es) to delete", plugins = list("remove_button"))
)
}
}) |
getWyEndpoints <- function(rdfXTS)
{
tVals <- zoo::index(rdfXTS[xts::.indexmon(rdfXTS) %in% 8])
ep <- c(0, which(zoo::index(rdfXTS) %in% tVals))
return(ep)
}
getCyEndpoints <- function(rdfXTS)
{
tVals <- zoo::index(rdfXTS[xts::.indexmon(rdfXTS) %in% 11])
ep <- c(0, which(zoo::index(rdfXTS) %in% tVals))
return(ep)
}
getTraceMonthVal <- function(rdfXTS, month)
{
if (any(month <= 0) || any(month > 12))
stop(paste0(
month,
" is not a valid month. Use a month from 1 to 12"
))
outXTS <- rdfXTS[xts::.indexmon(rdfXTS) %in% (month - 1)]
return(outXTS)
}
getTraceAvg <- function(rdfXTS, yearType)
{
if (yearType == "WY")
ep <- getWyEndpoints(rdfXTS)
else
ep <- getCyEndpoints(rdfXTS)
outXTS <- xts::period.apply(rdfXTS, ep, mean)
return(outXTS)
}
getTraceSum <- function(rdfXTS, yearType)
{
if (yearType == "WY")
ep <- getWyEndpoints(rdfXTS)
else
ep <- getCyEndpoints(rdfXTS)
outXTS <- xts::period.apply(rdfXTS, ep, colSums)
return(outXTS)
}
getTraceMin <- function(rdfXTS, yearType)
{
if (yearType == "WY")
ep <- getWyEndpoints(rdfXTS)
else
ep <- getCyEndpoints(rdfXTS)
outXTS <- xts::period.apply(rdfXTS, ep, function(x) apply(x, 2, min))
return(outXTS)
}
getTraceMax <- function(rdfXTS, yearType)
{
if (yearType == "WY")
ep <- getWyEndpoints(rdfXTS)
else
ep <- getCyEndpoints(rdfXTS)
outXTS <- xts::period.apply(rdfXTS, ep, function(x) apply(x, 2, max))
return(outXTS)
}
getArrayPctl <- function(rdfXTS, pctlLevels)
{
toPctls <- function(rdfXTS) stats::quantile(rdfXTS, pctlLevels)
tStep <- paste(xts::periodicity(rdfXTS)$label,"s",sep="")
ep <- xts::endpoints(rdfXTS,tStep)
outXTS <- xts::period.apply(rdfXTS, ep, toPctls)
return(outXTS)
}
getArrayThresholdExceedance <- function(rdfXTS, valueIn, comparison)
{
if (comparison == "GT")
boolArray <- rdfXTS > valueIn
else if (comparison == "LT")
boolArray <- rdfXTS < valueIn
else
stop(paste(
comparison,
" is not a valid input. Use GT for greater than or LT for less than",
sep=""
))
trueCount <- xts::xts(rowSums(boolArray),zoo::index(boolArray))
totalCount <- length(dimnames(boolArray)[[2]])
return(trueCount/totalCount * 100)
} |
recover_data.rsm = function(object, data, mode = c("asis", "coded", "decoded"), ...) {
mode = match.arg(mode)
cod = codings(object)
fcall = object$call
if(is.null(data))
data = emmeans::recover_data(fcall, delete.response(terms(object)),
object$na.action, ...)
if (!is.null(cod) && (mode == "decoded")) {
pred = cpred = attr(data, "predictors")
trms = attr(data, "terms")
data = decode.data(as.coded.data(data, formulas = cod))
for (form in cod) {
vn = all.vars(form)
if (!is.na(idx <- grep(vn[1], pred))) {
pred[idx] = vn[2]
cpred = setdiff(cpred, vn[1])
}
}
attr(data, "predictors") = pred
new.trms = update(trms, reformulate(c("1", cpred)))
attr(new.trms, "orig") = trms
attr(data, "terms") = new.trms
}
data
}
emm_basis.rsm = function(object, trms, xlev, grid,
mode = c("asis", "coded", "decoded"), ...) {
mode = match.arg(mode)
cod = codings(object)
if(!is.null(cod) && mode == "decoded") {
grid = coded.data(grid, formulas = cod)
trms = attr(trms, "orig")
}
m = model.frame(trms, grid, na.action = na.pass, xlev = xlev)
X = model.matrix(trms, m, contrasts.arg = object$contrasts)
bhat = as.numeric(object$coefficients)
V = emmeans::.my.vcov(object, ...)
if (sum(is.na(bhat)) > 0)
nbasis = estimability::nonest.basis(object$qr)
else
nbasis = estimability::all.estble
dfargs = list(df = object$df.residual)
dffun = function(k, dfargs) dfargs$df
list(X = X, bhat = bhat, nbasis = nbasis, V = V,
dffun = dffun, dfargs = dfargs, misc = list())
} |
source("ESEUR_config.r")
library("lattice")
library("lubridate")
library("plyr")
scm=read.csv(paste0(ESEUR_dir, "time-series/smr1615/scmlog.csv.xz"),
as.is=TRUE, quote="\'")
scm$rev=NULL
scm$message=NULL
scm$date=as.Date(scm$date, format="%Y-%m-%d")
start_date=as.Date("1991-01-01", format="%Y-%m-%d")
end_date=as.Date("2012-01-01", format="%Y-%m-%d")
cfl=read.csv(paste0(ESEUR_dir, "time-series/smr1615/commits_files_lines.csv.xz"),
as.is=TRUE, quote="\'")
cfl$date=scm$date[cfl$commit]
cfl=subset(cfl, (date >= start_date) & (date <= end_date))
cfl$week=floor_date(cfl$date, "week")
cfl_week=ddply(cfl, .(week),
function(df) data.frame(num_commits=length(unique(df$commit)),
lines_added=sum(df$added),
lines_deleted=sum(df$removed)))
t=xyplot(lines_added ~ week | equal.count(week, 4, overlap=0.1), cfl_week,
type="l", aspect="xy", strip=FALSE,
xlab="", ylab="Weekly total",
scales=list(x=list(relation="sliced", axs="i", cex=0.6),
y=list(alternating=FALSE, log=TRUE, cex=0.7)))
plot(t) |
myers_simple <- function(target, current) {
path <- myers_simple_int(target, current)
diff_path_to_diff(path, target, current)
}
myers_simple_int <- function(A, B) {
N <- length(A)
M <- length(B)
MAX <- M + N + 1L
OFF <- MAX + 1L
Vl <- vector("list", MAX)
for(D in seq_len(MAX) - 1L) {
Vl[[D + 1L]] <- if(!D) integer(2L * MAX + 1L) else Vl[[D]]
for(k in seq(-D, D, by=2L)) {
V <- Vl[[D + 1L]]
if(k == -D || (k != D && V[k - 1L + OFF] < V[k + 1L + OFF])) {
x <- V[k + 1L + OFF]
} else {
x <- V[k - 1L + OFF] + 1L
}
y <- x - k
while (x < N && y < M && A[x + 1L] == B[y + 1L]) {
x <- x + 1L
y <- y + 1L
}
Vl[[D + 1L]][k + OFF] <- x
if(x >= N && y >= M) {
path.len <- D + max(N, M)
res <- matrix(integer(1L), nrow=path.len, ncol=2)
res[path.len, ] <- c(x, y)
path.len <- path.len - 1L
for(d in rev(seq_len(D))) {
Vp <- Vl[[d]]
break.out <- FALSE
repeat {
shift.up <- Vp[k + 1L + OFF] == x && x
shift.left <- Vp[k - 1L + OFF] == x - 1L && x > 1L
if(x <= 0L && y <= 0L) {
break
} else if(!shift.up && !shift.left) {
x <- max(x - 1L, 0L)
y <- max(y - 1L, 0L)
} else {
if(shift.up) {
y <- y - 1L
k <- k + 1L
} else {
x <- x - 1L
k <- k - 1L
}
break.out <- TRUE
}
res[path.len, ] <- c(x, y)
path.len <- path.len - 1L
if(break.out) break
}
}
if(any(res < 0L)) {
stop(
"Logic Error: diff generated illegal coords; contact maintainer."
)
}
return(res)
}
}
}
stop("Logic Error, should not get here")
}
diff_path_to_diff <- function(path, target, current) {
stopifnot(
is.character(target), is.character(current),
is.matrix(path), is.integer(path), ncol(path) == 2,
all(path[, 1L] %in% c(0L, seq_along(target))),
all(path[, 2L] %in% c(0L, seq_along(current)))
)
get_dupe <- function(x) {
base <- !logical(length(x))
if(!length(y <- which(x != 0L)))
base[[1L]] <- FALSE else base[[min(y)]] <- FALSE
base
}
cur.dup <- as.logical(ave(path[, 1L], path[, 2L], FUN=get_dupe))
tar.dup <- as.logical(ave(path[, 2L], path[, 1L], FUN=get_dupe))
path[!path] <- NA_integer_
path[tar.dup, 1L] <- NA_integer_
path[cur.dup, 2L] <- NA_integer_
tar.path <- target[path[, 1L]]
cur.path <- current[path[, 2L]]
path[which(tar.path == cur.path), ] <- -path[which(tar.path == cur.path), ]
matched <- ifelse(!is.na(path[, 1]) & path[, 1] < 0L, 1L, 0L)
splits <- cumsum(abs(diff(c(0, matched))))
chunks <- split.data.frame(path, splits)
res.tar <- res.cur <- vector("list", length(chunks))
mm.count <- 0L
for(i in seq_along(chunks)) {
x <- chunks[[i]]
if((neg <- any(x < 0L, na.rm=TRUE)) && !all(x < 0L, na.rm=TRUE))
stop("Internal Error: match group error; contact maintainer")
if(neg) {
res.tar[[i]] <- res.cur[[i]] <- integer(nrow(x))
} else {
tar.mm <- Filter(Negate(is.na), x[, 1L])
cur.mm <- Filter(Negate(is.na), x[, 2L])
x.min.len <- min(length(tar.mm), length(cur.mm))
res.tar[[i]] <- res.cur[[i]] <- seq_len(x.min.len) + mm.count
mm.count <- x.min.len + mm.count
length(res.tar[[i]]) <- length(tar.mm)
length(res.cur[[i]]) <- length(cur.mm)
}
}
if(!length(res.tar)) res.tar <- integer()
if(!length(res.cur)) res.cur <- integer()
return(list(target=unlist(res.tar), current=unlist(res.cur)))
} |
context("text_filter")
test_that("'text_filter' has the right defaults", {
f <- text_filter()
expect_equal(f$map_case, TRUE)
expect_equal(f$map_quote, TRUE)
expect_equal(f$remove_ignorable, TRUE)
expect_equal(f$stemmer, NULL)
expect_equal(f$stem_dropped, FALSE)
expect_equal(f$stem_except, NULL)
expect_equal(f$combine, NULL)
expect_equal(f$drop_letter, FALSE)
expect_equal(f$drop_number, FALSE)
expect_equal(f$drop_punct, FALSE)
expect_equal(f$drop_symbol, FALSE)
expect_equal(f$drop, NULL)
expect_equal(f$drop_except, NULL)
expect_equal(f$sent_crlf, FALSE)
expect_equal(f$sent_suppress, abbreviations_en)
})
test_that("'text_filter' has the same defaults for all objects", {
x <- c("hello", "world", "how", "are", "you?")
y <- as_corpus_text(x)
z <- data.frame(text = x)
w <- data.frame(text = y)
expect_equal(text_filter(x), text_filter())
expect_equal(text_filter(y), text_filter())
expect_equal(text_filter(z), text_filter())
expect_equal(text_filter(w), text_filter())
})
test_that("'text_filter' can be assigned to text", {
x <- as_corpus_text("hello")
f0 <- text_filter(x)
d <- data.frame(text = x)
f <- text_filter(map_case = FALSE)
text_filter(x) <- f
expect_equal(text_filter(x), f)
expect_equal(text_filter(d), f0)
})
test_that("'text_filter' can be assigned to data frame with \"text\" column", {
x <- as_corpus_text("hello")
f0 <- text_filter(x)
d <- data.frame(text = x)
f <- text_filter(map_case = FALSE)
text_filter(d) <- f
expect_equal(text_filter(x), f0)
expect_equal(text_filter(d), f)
})
test_that("'text_filter' fails without data frame with \"text\" column", {
x <- as_corpus_text("hello")
d <- data.frame(not_text = x)
f <- text_filter(map_case = FALSE)
expect_error(text_filter(d), "no column named \"text\" in data frame")
expect_error(text_filter(d) <- f, "no column named \"text\" in data frame")
})
test_that("'text_filter' cannot be assigned to character", {
x <- "hello"
d <- data.frame(text = x, stringsAsFactors = FALSE)
f <- text_filter(map_case = FALSE)
expect_error(text_filter(x) <- f,
"setting a text filter for objects of class \"character\" is not allowed",
fixed = TRUE)
expect_error(text_filter(d) <- f,
"setting a text filter for objects of class \"character\" is not allowed",
fixed = TRUE)
})
test_that("setting an unrecognized property gives an error", {
f <- text_filter()
expect_error(f$foo <- "bar",
"unrecognized text filter property: 'foo'",
fixed = TRUE)
expect_error(text_filter(foo = "bar"),
"unrecognized text filter property: 'foo'",
fixed = TRUE)
})
test_that("passing unnamed arguments is not allowed", {
expect_error(text_filter(NULL, TRUE),
"unnamed arguments are not allowed")
x <- as_corpus_text("hello")
expect_error(text_filter(x, TRUE),
"unnamed arguments are not allowed")
})
test_that("giving invalid text to text_filter.corpus_text is not allowed", {
expect_error(text_filter.corpus_text("hello"),
"argument is not a valid text object")
})
test_that("'as_corpus_text' propagates a non-NULL filter argument to character", {
x <- "hello"
f <- text_filter(map_case = FALSE)
x1 <- as_corpus_text("hello", filter = f)
x2 <- as_corpus_text("hello")
x3 <- as_corpus_text("world", filter = f)
expect_false(isTRUE(all.equal(x1, x2)))
expect_false(isTRUE(all.equal(x1, x3)))
expect_equal(text_filter(x1), f)
})
test_that("'as_corpus_text' propagates a non-NULL to text filter to text", {
x <- as_corpus_text("hello")
f0 <- text_filter(map_case = FALSE, map_quote = FALSE)
text_filter(x) <- f0
expect_equal(text_filter(x), f0)
f1 <- text_filter(map_case = TRUE, map_quote = FALSE)
y <- as_corpus_text(x, filter = f1)
expect_equal(text_filter(y), f1)
})
test_that("'as_corpus_text' propagates a non-NULL to text filter to data frame", {
d <- data.frame(text = "hello")
f0 <- text_filter(d)
f <- text_filter(map_case = FALSE)
x <- as_corpus_text(d, filter = f)
expect_equal(text_filter(d), f0)
expect_equal(text_filter(x), f)
})
test_that("'as_corpus_text' propagates a non-NULL to filter to text data frame", {
d <- data.frame(text = as_corpus_text("hello"))
f0 <- text_filter(d)
f <- text_filter(map_case = FALSE)
x <- as_corpus_text(d, filter = f)
expect_equal(text_filter(d), f0)
expect_equal(text_filter(x), f)
})
test_that("'as_corpus_text' with NULL filter leaves it unchanged", {
x <- as_corpus_text("hello")
f0 <- text_filter(map_case = FALSE, map_quote = FALSE)
text_filter(x) <- f0
y <- as_corpus_text(x, filter = NULL)
expect_equal(text_filter(y), f0)
})
test_that("'text_filter' clears the old filter", {
x <- as_corpus_text("wicked")
y <- as_corpus_text(x, filter = text_filter(stemmer = "english"))
toks1 <- text_tokens(y)
expect_equal(text_tokens(y), list("wick"))
toks2 <- text_tokens(x)
expect_equal(toks2, list("wicked"))
})
test_that("'text_filter' can override properties", {
x <- as_corpus_text("hello", remove_ignorable = FALSE)
f <- text_filter(x, map_case = FALSE, stemmer = "english")
f2 <- text_filter(remove_ignorable = FALSE, map_case = FALSE,
stemmer = "english")
expect_equal(f, f2)
})
test_that("'text_filter<-' rejects invalid inputs", {
x <- "hello"
expect_error(`text_filter<-.corpus_text`(x, text_filter()),
"argument is not a valid text object")
})
test_that("'text_filter<-' setting NULL works", {
x <- as_corpus_text("hello")
f <- text_filter(x)
text_filter(x) <- NULL
f2 <- text_filter(x)
expect_equal(f, f2)
})
test_that("setting invalid text_filter properties fails", {
f <- text_filter()
expect_error(f$map_ca <- TRUE,
"unrecognized text filter property: 'map_ca'")
expect_error(f[[c(1,1)]] <- TRUE, "no such text filter property")
expect_error(f[[0]] <- TRUE, "no such text filter property")
expect_error(f[[length(f) + 1]] <- TRUE, "no such text filter property")
expect_error(f[[NA]] <- TRUE, "no such text filter property")
})
test_that("setting numeric properties succeeds", {
f <- text_filter()
i <- match("combine", names(f))
f[[i]] <- "new york city"
expect_equal(f$combine, "new york city")
})
test_that("setting multiple properties works", {
f <- text_filter()
f[c("map_case", "map_quote")] <- FALSE
expect_equal(f, text_filter(map_case = FALSE, map_quote = FALSE))
f[c("map_case", "remove_ignorable", "map_quote")] <- c(FALSE, FALSE, TRUE)
expect_equal(f, text_filter(map_case = FALSE, map_quote = TRUE,
remove_ignorable = FALSE))
})
test_that("invalid operations send errors", {
f <- text_filter()
expect_error(f[c(NA, "map_case", NA)] <- FALSE,
"NAs are not allowed in subscripted assignments")
expect_error(f[c(-1, 2)] <- FALSE,
"only 0's may be mixed with negative subscripts")
expect_error(f[100] <- "hello",
"no such text filter property")
expect_error(f["map_case"] <- c(TRUE, FALSE),
"number of items to replace differs from the replacement length")
expect_error(f[c("map_case", "map_case", "map_quote")] <- c(TRUE, FALSE),
"number of items to replace differs from the replacement length")
})
test_that("text filter printing works", {
f <- text_filter()
expected <- c(
'Text filter with the following options:',
'',
' map_case: TRUE',
' map_quote: TRUE',
' remove_ignorable: TRUE',
' combine: NULL',
' stemmer: NULL',
' stem_dropped: FALSE',
' stem_except: NULL',
' drop_letter: FALSE',
' drop_number: FALSE',
' drop_punct: FALSE',
' drop_symbol: FALSE',
' drop: NULL',
' drop_except: NULL',
' connector: _',
' sent_crlf: FALSE',
' sent_suppress: chr [1:155] "A." "A.D." "a.m." "A.M." "A.S." "AA." ...')
skip_if_not(with(R.Version(), paste(major, minor, sep = "."))
>= "3.4.0", "str output changed on R 3.4.0")
actual <- strsplit(capture_output(print(f), width = 80), "\n")[[1]]
expect_equal(actual, expected)
}) |
gr_cumhaz_flexrsurv_fromto_GA0B0AB<-function(GA0B0AB, var,
Y, X0, X, Z,
step, Nstep,
intTD=intTD_NC, intweightsfunc=intweights_CAV_SIM,
intTD_base=intTD_base_NC,
nT0basis,
Spline_t0=BSplineBasis(knots=NULL, degree=3, keep.duplicates=TRUE), Intercept_t0=TRUE,
ialpha0, nX0,
ibeta0, nX,
ialpha, ibeta,
nTbasis,
Spline_t =BSplineBasis(knots=NULL, degree=3, keep.duplicates=TRUE),
Intercept_t_NPH=rep(TRUE, nX),
debug=FALSE, ...){
if (debug) cat("
if(is.null(Z)){
nZ <- 0
} else {
nZ <- Z@nZ
}
if(Intercept_t0){
tmpgamma0 <- GA0B0AB[1:nT0basis]
}
else {
tmpgamma0 <- c(0, GA0B0AB[1:nT0basis])
}
if( nX0){
PHterm <-exp(X0 %*% GA0B0AB[ialpha0])
} else {
PHterm <- 1
}
if(nZ) {
tBeta <- t(ExpandAllCoefBasis(GA0B0AB[ibeta], ncol=nZ, value=1))
Zalpha <- Z@DM %*%( diag(GA0B0AB[ialpha]) %*% Z@signature )
Zalphabeta <- Zalpha %*% tBeta
if(nX) {
Zalphabeta <- Zalphabeta + X %*% t(ExpandCoefBasis(GA0B0AB[ibeta0],
ncol=nX,
splinebasis=Spline_t,
expand=!Intercept_t_NPH,
value=0))
}
} else {
if(nX) {
Zalphabeta <- X %*% t(ExpandCoefBasis(GA0B0AB[ibeta0],
ncol=nX,
splinebasis=Spline_t,
expand=!Intercept_t_NPH,
value=0))
}
}
if(nX + nZ) {
NPHterm <- intTD(rateTD_gamma0alphabeta, intFrom=Y[,1], intTo=Y[,2], intToStatus=Y[,3],
step=step, Nstep=Nstep, intweightsfunc=intweightsfunc,
gamma0=GA0B0AB[1:nT0basis], Zalphabeta=Zalphabeta,
Spline_t0=Spline_t0*tmpgamma0, Intercept_t0=Intercept_t0,
Spline_t = Spline_t, Intercept_t=TRUE)
Intb0 <- intTD_base(func=rateTD_gamma0alphabeta, intFrom=Y[,1], intTo=Y[,2], intToStatus=Y[,3],
Spline=Spline_t0,
step=step, Nstep=Nstep, intweightsfunc=intweightsfunc,
gamma0=GA0B0AB[1:nT0basis], Zalphabeta=Zalphabeta,
Spline_t0=Spline_t0*tmpgamma0, Intercept_t0=Intercept_t0,
Spline_t = Spline_t, Intercept_t=TRUE,
debug=debug)
if( identical(Spline_t0, Spline_t)){
Intb <- Intb0
}
else {
Intb <- intTD_base(func=rateTD_gamma0alphabeta, intFrom=Y[,1], intTo=Y[,2], intToStatus=Y[,3],
Spline=Spline_t,
step=step, Nstep=Nstep, intweightsfunc=intweightsfunc,
gamma0=GA0B0AB[1:nT0basis], Zalphabeta=Zalphabeta,
Spline_t0=Spline_t0*tmpgamma0, Intercept_t0=Intercept_t0,
Spline_t = Spline_t, Intercept_t=TRUE)
}
if(!Intercept_t0){
Intb0<- Intb0[,-1]
}
indx_without_intercept <- 2:getNBases(Spline_t)
}
else {
NPHterm <- intTD(rateTD_gamma0, intFrom=Y[,1], intTo=Y[,2], intToStatus=Y[,3],
step=step, Nstep=Nstep, intweightsfunc=intweightsfunc,
gamma0=GA0B0AB[1:nT0basis],
Spline_t0=Spline_t0*tmpgamma0, Intercept_t0=Intercept_t0)
Intb0 <- intTD_base(func=rateTD_gamma0, intFrom=Y[,1], intTo=Y[,2], intToStatus=Y[,3],
Spline=Spline_t0,
step=step, Nstep=Nstep, intweightsfunc=intweightsfunc,
gamma0=GA0B0AB[1:nT0basis],
Spline_t0=Spline_t0*tmpgamma0, Intercept_t0=Intercept_t0,
debug=debug)
if(!Intercept_t0){
Intb0<- Intb0[,-1]
}
Intb <- NULL
}
if(nX + nZ) {
if(nX0>0) {
Intb <- Intb * c(PHterm)
}
}
Intb0 <- Intb0 * c(PHterm)
dLdgamma0 <- Intb0
if (nX0) {
dLdalpha0 <- X0 * c(PHterm * NPHterm)
}
else {
dLdalpha0 <- NULL
}
if (nX){
dLdbeta0 <- NULL
for(i in 1:nX){
if ( Intercept_t_NPH[i] ){
dLdbeta0 <- cbind(dLdbeta0, X[,i] * Intb)
}
else {
dLdbeta0 <- cbind(dLdbeta0, X[,i] * Intb[,indx_without_intercept])
}
}
}
else {
dLdbeta0 <- NULL
}
if (nZ) {
baseIntb <- Intb %*% t(tBeta)
indZ <- getIndex(Z)
dLdalpha <- NULL
dLdbeta <- NULL
for(iZ in 1:nZ){
dLdalpha <- cbind(dLdalpha, Z@DM[,indZ[iZ,1]:indZ[iZ,2]] * baseIntb[,iZ])
dLdbeta <- cbind(dLdbeta, Intb[,-1, drop=FALSE] * Zalpha[,iZ])
}
}
else {
dLdalpha <- NULL
dLdbeta <- NULL
}
rep <- cbind(dLdgamma0,
dLdalpha0,
dLdbeta0,
dLdalpha,
dLdbeta )
if(debug){
attr(rep, "intb0") <- Intb0
attr(rep, "intb") <- Intb
}
rep
} |
getGeneFromKGene <-
function(keggGeneList){
pkgEnv <- new.env(parent=emptyenv())
if(!exists("keggGene2gene", pkgEnv)) {
data("keggGene2gene", package="TPEA", envir=pkgEnv)
da1<-pkgEnv[["keggGene2gene"]]
}
keggGeneList<-as.character(keggGeneList)
keggGene2gene<-da1
geneList<-unique(as.character(sapply(strsplit(as.character(keggGene2gene[as.character(keggGene2gene[,1]) %in% keggGeneList,2]),":"),function(x) return (x[2]))))
return(geneList)
} |
source("tutorials/fannie_mae/00_setup.r")
library(disk.frame)
acqall1 = disk.frame(file.path(outpath, "appl_mdl_data"))
system.time(xy <- acqall1[,c("default_next_12m", "oltv"), keep=c("default_next_12m", "oltv")])
dtrain <- xgb.DMatrix(label = xy$default_next_12m, data = as.matrix(xy[,"oltv"]))
portfolio_default_rate = xy[,sum(default_next_12m, na.rm = T)/.N]
pt = proc.time()
m <- xgboost(
data=dtrain,
nrounds = 1,
objective = "binary:logitraw",
tree_method="exact",
monotone_constraints = 1,
base_score = portfolio_default_rate)
timetaken(pt)
prev_pred = predict(m, dtrain)
map_chr(xgb.dump(m), ~str_extract(.x,"\\[f0<[\\d]+\\.[\\d]+\\]")) %>%
keep(~!is.na(.x)) %>%
map_dbl(~str_extract(.x, "[\\d]+\\.[\\d]+") %>% as.numeric) %>%
sort %>%
floor -> bins
bb = xy[,.(ndef = sum(default_next_12m), .N, m1 = min(oltv), m2 = max(oltv)), .(bins = cut(oltv,c(-Inf,bins,Inf)))]
new_bins = sort(unique( bb$m2))
bb = xy[,.(ndef = sum(default_next_12m), .N), .(bins = cut(oltv,c(-Inf,new_bins,Inf)))][order(bins)]
setkey(bb, bins)
bb %>%
filter(!is.na(bins)) %>%
mutate(`Orig LTV Band` = bins, `Default Rate%` = ndef/N) %>%
ggplot +
geom_bar(aes(x = `Orig LTV Band`, y = `Default Rate%`), stat = 'identity') +
coord_flip()
if(F) {
system.time(xyz <- acqall1[,c("default_next_12m", "oltv", "frst_dte"), keep=c("default_next_12m", "oltv", "frst_dte")])
xyz[,frst_yr := substr(frst_dte,4,7) %>% as.integer]
xyz[,frst_dte:=NULL]
bb = xyz[,.(ndef = sum(default_next_12m), .N), .(bins = cut(oltv,c(-Inf,bins,Inf)), frst_yr)]
bb[,binton := sum(N), bins]
bb[,dr := ndef/binton]
setkey(bb, bins)
bb[order(frst_yr,decreasing = T),text_y_pos := cumsum(dr) - dr/2, bins]
bb[,text := substr(frst_yr, 3,4)]
bb %>%
filter(!is.na(bins)) %>%
mutate(`Yr of Orig` = as.factor(frst_yr), `Orig LTV Band` = bins, `Default Rate%` = dr) %>%
ggplot +
geom_bar(aes(x = `Orig LTV Band`, y = `Default Rate%`, fill = `Yr of Orig`), stat = 'identity') +
geom_text(aes(x = `Orig LTV Band`, y = text_y_pos, label = text)) +
coord_flip()
}
xy[oltv > 80, oltv_round := ceiling(oltv/5)*5]
xy[oltv <= 80, oltv_round := ceiling(oltv/10)*10]
xy[oltv <= 40, oltv_round := ceiling(oltv/20)*20]
xy[is.na(oltv_round),]
xy[,.N, oltv_round]
dtrain <- xgb.DMatrix(label = xy$default_next_12m, data = as.matrix(xy[,"oltv_round"]))
pt = proc.time()
m <- xgboost(
data=dtrain,
nrounds = 1,
objective = "binary:logitraw",
tree_method="exact",
monotone_constraints = 1,
base_score = portfolio_default_rate)
timetaken(pt)
map_chr(xgb.dump(m), ~str_extract(.x,"\\[f0<[\\d]+[\\.]{0,1}[\\d]+\\]")) %>%
keep(~!is.na(.x)) %>%
map_dbl(~str_extract(.x, "[\\d]+[\\.]{0,1}[\\d]+") %>% as.numeric) %>%
sort -> bins
bb = xy[,.(ndef = sum(default_next_12m), .N, m1 = min(oltv_round), m2 = max(oltv_round)), .(bins = cut(oltv_round,c(-Inf,bins,Inf)))]
new_bins = sort(unique( bb$m2))
bb = xy[,.(ndef = sum(default_next_12m), .N), .(bins = cut(oltv_round,c(-Inf,new_bins,Inf)))][order(bins)]
bb[,odr := ndef/N]
setkey(bb, bins)
bb %>%
filter(!is.na(bins)) %>%
mutate(`Orig LTV Band` = bins, `Default Rate%` = ndef/N) %>%
ggplot +
geom_bar(aes(x = `Orig LTV Band`, y = `Default Rate%`), stat = 'identity') +
coord_flip()
prev_pred = predict(m, dtrain)
prev_pred1 = predict(m, dtrain, predcontrib=T)
target = "default_next_12m"
feature = "orig_amt"
df = acqall1
format_fn = base::I
existing_model = prev_pred
monotone_constraints = -1
auc <- function(target, score) {
df = data.table(target, score)
df1 = df[,.(nt = sum(target), n = .N, score)]
setkey(df1, score)
}
add_var_to_scorecard <- function(df, target, feature, monotone_constraints = 0, prev_pred = NULL, format_fn = base::I) {
xy = df %>%
srckeep(c(target, feature)) %>%
collect(parallel = T)
code = glue::glue("xy = xy %>% mutate({feature} = format_fn({feature}))")
eval(parse(text = code))
dtrain <- xgb.DMatrix(label = xy[,target, with = F][[1]], data = as.matrix(xy[,c(feature), with = F]))
if(is.null(prev_pred)) {
pt = proc.time()
m2 <- xgboost(
data=dtrain,
nrounds = 1,
objective = "binary:logitraw",
tree_method="exact",
monotone_constraints = monotone_constraints
)
timetaken(pt)
} else {
setinfo(dtrain, "base_margin", prev_pred)
pt = proc.time()
m2 <- xgboost(
data=dtrain,
nrounds = 1,
objective = "binary:logitraw",
tree_method="exact",
monotone_constraints = monotone_constraints
)
timetaken(pt)
a2 = predict(m2, dtrain)
a3 = predict(m2, dtrain, predcontrib = T)
}
map_chr(xgb.dump(m2), ~str_extract(.x,"\\[f0<[\\d]+[\\.]{0,1}[\\d]+\\]")) %>%
keep(~!is.na(.x)) %>%
map_dbl(~str_extract(.x, "[\\d]+[\\.]{0,1}[\\d]+") %>% as.numeric) %>%
sort -> bins
code = glue::glue("bb = xy[,.(ndef = sum({target}), .N, m1 = min({feature}), m2 = max({feature})), .(bins = cut({feature},c(-Inf,bins,Inf)))]")
eval(parse(text = code))
new_bins = sort(unique(bb$m2))
code1 = glue::glue("bb = xy[,.(ndef = sum(default_next_12m), .N), .(bins = cut({feature},c(-Inf,new_bins,Inf)))][order(bins)]")
eval(parse(text = code1))
setkey(bb, bins)
bb %>%
filter(!is.na(bins)) %>%
mutate(`Orig LTV Band` = bins, `Default Rate%` = ndef/N) %>%
ggplot +
geom_bar(aes(x = `Orig LTV Band`, y = `Default Rate%`), stat = 'identity') +
coord_flip()
} |
library(copula)
library(lattice)
do.animation <- require("animation") && (!exists("dont.animate") || !dont.animate)
options(warn=1)
eep.fun <- function(family, alpha, d, n.MC=5000){
vapply(alpha, function(alph)
{
th <- 1/alph
cop <- onacopulaL(family, list(th, 1:d))
U <- rnacopula(n.MC, cop)
switch(family,
"Gumbel" =
{
mean(rowSums(cop@copula@iPsi(U, th))^alph)
},
"Joe" =
{
U. <- (1-U)^th
lh <- rowSums(log1p(-U.))
l1_h <- log(-expm1(lh))
mean(exp(lh-l1_h))
}, stop("wrong family in eep.fun()"))
}, NA_real_)
}
plot.poly <- function(family, xlim, ylim, method, alpha, d, n.out = 128,
pch = 4, cex = 0.4)
{
stopifnot(is.numeric(alpha), (len <- length(alpha)) >= 1, is.numeric(d), d == round(d),
is.numeric(xlim), xlim > 0, is.character(method))
cols <- colorRampPalette(c("red", "orange", "darkgreen", "turquoise", "blue"),
space="Lab")(len)
switch(family,
"Gumbel" = {
FUN <- copula:::polyG
str <- "G"
},
"Joe" = {
FUN <- copula:::polyJ
str <- "J"
},
stop("wrong 'family'"))
tit <- paste("poly", str, "(log(x), alpha=..., d=", d,
", log=TRUE, method=\"",method,"\")", sep="")
xx <- seq(xlim[1], xlim[2], length = n.out)
lx <- log(xx)
R <- sapply(alpha, function(ALP)
FUN(lx, alpha= ALP, d=d, method=method, log=TRUE))
matplot(xx, R, xlim=xlim, ylim=ylim, main = tit, type = "o", pch=pch, cex=cex,
xlab="x", ylab=paste("log(poly",str,"(log(x), ...))", sep=""),
lty = 1, lwd = 1.4, col=cols)
label <- as.expression(lapply(1:len, function(i)
substitute(alpha == A, list(A = alpha[i]))))
legend("bottomright", label, bty="n", lwd=1.4, col=cols, pch=pch, pt.cex=cex)
invisible(list(f.x = R, x = xx))
}
if(do.animation)
poly.ani <- function(family, m, d, method, xlim, ylim)
{
switch(family,
"Gumbel" = {
fun <- copula:::polyG
str <- "G"
},
"Joe" = {
fun <- copula:::polyJ
str <- "J"
},
{stop("wrong family in plot.poly")})
alphas <- (1:m)/(m+1)
eep <- eep.fun(family, alphas, d)
x <- seq(xlim[1], xlim[2], length.out=1000)
lx <- log(x)
lapply(1:m, function(i) {
if(i %% 5 == 1) print(paste(formatC(round(i/m*100), width=3),"% done",sep=""))
y <- fun(lx, alpha=alphas[i], d=d, method=method, log=TRUE)
p <- xyplot(y~x, type="l", aspect = 1, xlab= "x",
ylab=paste("log(poly",str,"(log(x), ...))",sep=""),
xlim=xlim, ylim=ylim, key=
list(x=0.35, y=0.1,
lines=list(lty=1, col="black"),
text=list(paste("expected x-value for alpha=", alphas[i],sep=""))),
panel=function(...){
panel.xyplot(...)
panel.abline(v=eep[i])
}, main=paste("poly",str,"(log(x), alpha=",alphas[i],
", d=",d,", method=",method,", log=TRUE)",sep=""))
list(y=y, plot=p)
})
}
family <- "Gumbel"
polyG <- copula:::polyG
polyG.meths <- eval(formals(polyG)$method, envir = asNamespace("copula"))
alpha <- c(0.99, 0.5, 0.01)
xlim <- c(1e-16, 1000)
ylim <- c(-40, 40)
(ev <- eep.fun(family, alpha=alpha, d=5))
stopifnot(all(xlim[1] < ev, ev < xlim[2]))
(my.polyG.meths <- polyG.meths[!(polyG.meths %in% c("dsumSibuya", "dsSib.RmpfrM"))])
pp5 <- sapply(my.polyG.meths, function(met) {
r <- plot.poly(family, xlim=xlim, ylim=ylim, method = met, alpha=alpha, d=5)
Sys.sleep(2)
r
}, simplify = FALSE)
t(sapply(pp5, function(L) apply(L$f.x, 2, function(.) sum(!is.finite(.)))))
xlim <- c(1e-16, 200)
ylim <- c(300, 600)
(ev <- eep.fun(family, alpha, d=100))
stopifnot(all(xlim[1] < ev, ev < xlim[2]))
pp100 <- sapply(my.polyG.meths, function(met) {
r <- plot.poly(family, xlim=xlim, ylim=ylim, method = met, alpha=alpha, d=100)
Sys.sleep(2)
r
}, simplify = FALSE)
t(sapply(pp100, function(L) apply(L$f.x, 2, function(.) sum(!is.finite(.)))))
plot.poly(family, xlim=xlim, ylim=ylim, method="pois", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="pois.direct", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="stirling", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="stirling.horner", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="sort", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="horner", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="direct", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="dsumSibuya", alpha=alpha, d=100)
plot.poly(family, xlim=xlim, ylim=ylim, method="dsSib.Rmpfr", alpha=alpha, d=100)
set.seed(1)
x <- runif(100000, min=0.01, max=120)
lx <- log(x)
system.time(y.pois <- polyG(lx, alpha=0.99, d=100, method="pois", log=TRUE))
stopifnot(all(is.finite(y.pois)))
system.time(y.pois.d <- polyG(lx, alpha=0.99, d=100, method="pois.direct", log=TRUE))
stopifnot(all(is.finite(y.pois.d)))
system.time(y.stirl <- polyG(lx, alpha=0.5, d=100, method="stirling", log=TRUE))
stopifnot(all(is.finite(y.stirl)))
system.time(y.stirl.Ho <- polyG(lx, alpha=0.5, d=100, method="stirling.horner",
log=TRUE))[[1]]
stopifnot(all(is.finite(y.stirl.Ho)))
system.time(y.dsSib.log <- polyG(lx, alpha=0.99, d=100, method="dsSib.log", log=TRUE))
stopifnot(all(is.finite(y.dsSib.log)))
v1 <- polyG(log(1), alpha=0.01, d=100, log=TRUE)
v2 <- polyG(log(1), alpha=0.5 , d=100, log=TRUE)
v3 <- polyG(log(1), alpha=0.99, d=100, log=TRUE)
M.v <- c(354.52779560, 356.56733266, 350.99662083)
stopifnot(all.equal(c(v1,v2,v3), M.v))
v1 <- polyG(log(17), alpha=0.01, d=100, log=TRUE)
v2 <- polyG(log(17), alpha=0.5 , d=100, log=TRUE)
v3 <- polyG(log(17), alpha=0.99, d=100, log=TRUE)
M.v <- c(358.15179523, 374.67231305, 370.20372192)
stopifnot(all.equal(c(v1,v2,v3), M.v))
M.v <- c(362.38428102, 422.83827969, 435.36899283)
v1 <- polyG(log(77), alpha=0.01, d=100, log=TRUE)
v2 <- polyG(log(77), alpha=0.5 , d=100, log=TRUE)
v3 <- polyG(log(77), alpha=0.99, d=100, log=TRUE)
stopifnot(all.equal(c(v1,v2,v3), M.v, tolerance=1e-6))
m <- 49
ylim <- c(200, 700)
polyG.ani.dsumSibuya <- poly.ani(family, m, d=100, method="dsumSibuya",
xlim=c(1e-16,200), ylim=ylim)
if(do.animation)
saveHTML(for(i in 1:m) print(polyG.ani.dsumSibuya[[i]]$plot),
outdir=file.path(tempdir(),"G_dsumSib"))
polyG.ani.pois.direct <- poly.ani(family, m, d=100, method="pois.direct",
xlim=c(1e-16,200), ylim=ylim)
if(do.animation)
saveHTML(for(i in 1:m) print(polyG.ani.pois.direct[[i]]$plot),
outdir=file.path(tempdir(),"G_pois.direct"))
polyG.ani.stirling <- poly.ani(family, m, d=100, method="stirling",
xlim=c(1e-16,200), ylim=ylim)
if(do.animation)
saveHTML(for(i in 1:m) print(polyG.ani.stirling[[i]]$plot),
outdir=file.path(tempdir(),"G_stirling"))
polyG.ani.default <- poly.ani(family, m, d=100, method="default",
xlim=c(1e-16,200), ylim=ylim)
if(do.animation)
saveHTML(for(i in 1:m) print(polyG.ani.default[[i]]$plot),
outdir=file.path(tempdir(),"G_default"))
family <- "Joe"
polyJ <- copula:::polyJ
alpha <- c(0.05, 0.5, 0.99)
xlim <- c(1e-16, 1e120)
ylim <- c(0, 1200)
set.seed(1)
(ev <- eep.fun(family, alpha, d=5, n.MC=100000))
if(!all(xlim[1] < ev, ev < xlim[2])) warning("ev outside xlim")
Jmeths <- eval(formals(polyJ)$method)
Jpp5 <- sapply(Jmeths, function(met) {
r <- plot.poly(family, xlim=xlim, ylim=ylim, method = met, alpha=alpha, d=5)
Sys.sleep(2)
r
}, simplify = FALSE)
t(sapply(Jpp5, function(L) apply(L$f.x, 2, function(.) sum(!is.finite(.)))))
set.seed(1)
xlim <- c(1e-16, 1e120)
ylim <- c(0, 30000)
system.time(ev <- eep.fun(family, alpha, d=100, n.MC=100000))
ev
if(!all(xlim[1] < ev, ev < xlim[2])) warning("ev outside xlim")
Jpp100 <- sapply(Jmeths, function(met) {
r <- plot.poly(family, xlim=xlim, ylim=ylim, method = met, alpha=alpha, d=100)
Sys.sleep(2)
r
}, simplify = FALSE)
t(sapply(Jpp100, function(L) apply(L$f.x, 2, function(.) sum(!is.finite(.)))))
set.seed(1)
x <- runif(100000, min=0.01, max=1e100)
lx <- log(x)
system.time(y.log.poly <- polyJ(lx, alpha=0.5, d=100, method="log.poly",
log=TRUE))[[1]]
stopifnot(all(is.finite(y.log.poly)))
system.time(y.log1p <- polyJ(lx, alpha=0.5, d=100,
method="log1p", log=TRUE))[[1]]
stopifnot(all(is.finite(y.log1p)))
v1 <- polyJ(log(1), alpha=0.01, d=100, log=TRUE)
v2 <- polyJ(log(1), alpha=0.5, d=100, log=TRUE)
v3 <- polyJ(log(1), alpha=0.99, d=100, log=TRUE)
M.v <- c(395.73694325, 393.08027226, 386.96715831)
stopifnot(all.equal(c(v1,v2,v3), M.v))
v1 <- polyJ(log(1e20), alpha=0.01, d=100, log=TRUE)
v2 <- polyJ(log(1e20), alpha=0.5, d=100, log=TRUE)
v3 <- polyJ(log(1e20), alpha=0.99, d=100, log=TRUE)
M.v <- c(4918.2008336, 4915.3815020, 4909.1039909)
stopifnot(all.equal(c(v1,v2,v3), M.v))
v1 <- polyJ(log(1e100), alpha=0.01, d=100, log=TRUE)
v2 <- polyJ(log(1e100), alpha=0.5, d=100, log=TRUE)
v3 <- polyJ(log(1e100), alpha=0.99, d=100, log=TRUE)
M.v <- c(23154.67477009, 23151.85543852, 23145.57792740)
stopifnot(all.equal(c(v1,v2,v3), M.v))
polyJ.ani.default <- poly.ani(family, m, d=100, method="log.poly",
xlim=c(1e-16,1e120), ylim=ylim)
if(do.animation)
saveHTML(for(i in 1:m) print(polyJ.ani.default[[i]]$plot),
outdir=file.path(tempdir(),"J_log.poly")) |
if (grepl("Documents",getwd())){
path <- ".."
} else {
path <- "/home/ben"
}
password = as.character(read.delim(glue::glue('{path}/gh.txt'))$pw)
library(nflfastR)
library(tidyverse)
path <- "../nflfastR-raw/raw"
write_season <- function(y) {
message(glue::glue('Year {y}: scraping play-by-play of {
nrow(fast_scraper_schedules(y))
} games'))
pbp <- fast_scraper_schedules(y) %>%
pull(game_id) %>%
fast_scraper(pp = TRUE, dir = path) %>%
clean_pbp() %>%
add_qb_epa() %>%
add_xyac()
message(glue::glue('Year {y}: writing to file'))
saveRDS(pbp, glue::glue('data/play_by_play_{y}.rds'))
write_csv(pbp, glue::glue('data/play_by_play_{y}.csv.gz'))
arrow::write_parquet(pbp, glue::glue('data/play_by_play_{y}.parquet'))
write_csv(pbp, glue::glue("data/play_by_play_{x}.csv"))
utils::zip(glue::glue("data/play_by_play_{x}.zip"), c(glue::glue("data/play_by_play_{x}.csv")))
file.remove(glue::glue("data/play_by_play_{x}.csv"))
}
walk(1999:2010, write_season)
closeAllConnections()
walk(2011:2019, write_season)
y = 2020
sched <- fast_scraper_schedules(y) %>%
filter(season_type %in% c("REG", "POST")) %>%
select(game_id, week, season_type)
pbp <- sched %>% pull(game_id) %>%
fast_scraper(pp = TRUE) %>%
clean_pbp() %>%
add_qb_epa() %>%
add_xyac()
write_csv(pbp, glue::glue('data/play_by_play_{y}.csv.gz'))
saveRDS(pbp, glue::glue('data/play_by_play_{y}.rds'))
arrow::write_parquet(pbp, glue::glue('data/play_by_play_{y}.parquet'))
data_repo <- git2r::repository('./')
git2r::add(data_repo, 'data/*')
git2r::commit(data_repo, message = glue::glue("Updated {Sys.time()} using nflfastR version {utils::packageVersion('nflfastR')}"))
git2r::pull(data_repo)
git2r::push(data_repo, credentials = git2r::cred_user_pass(username = 'guga31bb', password = paste(password)))
message(paste('Successfully uploaded to GitHub values as of',Sys.time()))
games <- readRDS(url("https://github.com/leesharpe/nfldata/blob/master/data/games.rds?raw=true")) %>%
select(game_id, season, game_type, week, gameday, weekday, gametime, away_team,
home_team, away_score, home_score, home_result = result, stadium, location, roof, surface, old_game_id)
max_s <- max(games$season)
min_s <- min(games$season)
write_season_schedule <- function(s){
g <- games %>% filter(season == s)
saveRDS(g, glue::glue('schedules/sched_{s}.rds'))
}
walk(min_s:max_s, write_season_schedule) |
kpPolygon <- function(karyoplot, data=NULL, chr=NULL, x=NULL, y=NULL, ymin=NULL, ymax=NULL,
data.panel=1, r0=NULL, r1=NULL, clipping=TRUE, ...) {
if(!methods::is(karyoplot, "KaryoPlot")) stop("'karyoplot' must be a valid 'KaryoPlot' object")
karyoplot$beginKpPlot()
on.exit(karyoplot$endKpPlot())
pp <- prepareParameters2("kpPolygon", karyoplot=karyoplot, data=data, chr=chr, x=x, y=y,
ymin=ymin, ymax=ymax, r0=r0, r1=r1, data.panel=data.panel, ...)
ccf <- karyoplot$coord.change.function
xplot <- ccf(chr=pp$chr, x=pp$x, data.panel=data.panel)$x
yplot <- ccf(chr=pp$chr, y=pp$y, data.panel=data.panel)$y
processClipping(karyoplot=karyoplot, clipping=clipping, data.panel=data.panel)
graphics::polygon(x=xplot, y=yplot, ...)
invisible(karyoplot)
} |
Encode <- function(value, map, strs, params, N, id = NULL,
cohort = NULL, B = NULL, BP = NULL) {
k <- params$k
p <- params$p
q <- params$q
f <- params$f
h <- params$h
m <- params$m
if (is.null(cohort)) {
cohort <- sample(1:m, 1)
}
if (is.null(id)) {
id <- sample(N, 1)
}
ind <- which(value == strs)
if (is.null(B)) {
B <- as.numeric(map[[cohort]][, ind])
}
if (is.null(BP)) {
BP <- sapply(B, function(x) sample(c(0, 1, x), 1,
prob = c(0.5 * f, 0.5 * f, 1 - f)))
}
rappor <- sapply(BP, function(x) rbinom(1, 1, ifelse(x == 1, q, p)))
list(value = value, rappor = rappor, B = B, BP = BP, cohort = cohort, id = id)
}
ExamplePlot <- function(res, k, ebs = 1, title = "", title_cex = 4,
voff = .17, acex = 1.5, posa = 2, ymin = 1,
horiz = FALSE) {
PC <- function(k, report) {
char <- as.character(report)
if (k > 128) {
char[char != ""] <- "|"
}
char
}
anc <- "darkorange2"
colors <- c("lavenderblush3", "maroon4")
par(omi = c(0, .55, 0, 0))
plot(1:k, rep(1, k), ylim = c(ymin, 4), type = "n",
xlab = "Bloom filter bits",
yaxt = "n", ylab = "", xlim = c(0, k), bty = "n", xaxt = "n")
mtext(paste0("Participant ", res$id, " in cohort ", res$cohort), 3, 2,
adj = 1, col = anc, cex = acex)
axis(1, 2^(0:15), 2^(0:15))
abline(v = which(res$B == 1), lty = 2, col = "grey")
text(k / 2, 4, paste0('"', paste0(title, as.character(res$value)), '"'),
cex = title_cex, col = colors[2], xpd = NA)
points(1:k, rep(3, k), pch = PC(k, res$B), col = colors[res$B + 1],
cex = res$B + 1)
text(k, 3 + voff, paste0(sum(res$B), " signal bits"), cex = acex,
col = anc, pos = posa)
points(1:k, rep(2, k), pch = PC(k, res$BP), col = colors[res$BP + 1],
cex = res$BP + 1)
text(k, 2 + voff, paste0(sum(res$BP), " bits on"),
cex = acex, col = anc, pos = posa)
report <- res$rappor
points(1:k, rep(1, k), pch = PC(k, as.character(report)),
col = colors[report + 1], cex = report + 1)
text(k, 1 + voff, paste0(sum(res$rappor), " bits on"), cex = acex,
col = anc, pos = posa)
mtext(c("True value:", "Bloom filter (B):",
"Fake Bloom \n filter (B'):", "Report sent\n to server:"),
2, 1, at = 4:1, las = 2)
legend("topright", legend = c("0", "1"), fill = colors, bty = "n",
cex = 1.5, horiz = horiz)
legend("topleft", legend = ebs, plot = FALSE)
}
PlotPopulation <- function(probs, detected, detection_frequency) {
cc <- c("gray80", "darkred")
color <- rep(cc[1], length(probs))
color[detected] <- cc[2]
bp <- barplot(probs, col = color, border = color)
inds <- c(1, c(max(which(probs > 0)), length(probs)))
axis(1, bp[inds], inds)
legend("topright", legend = c("Detected", "Not-detected"),
fill = rev(cc), bty = "n")
abline(h = detection_frequency, lty = 2, col = "grey")
} |
generate_scatter_chart = function(shots, base_court, court_theme = court_themes$dark, alpha = 0.8, size = 2.5) {
base_court +
geom_point(
data = shots,
aes(x = loc_x, y = loc_y, color = shot_made_flag),
alpha = alpha, size = size
) +
scale_color_manual(
"",
values = c(made = court_theme$made, missed = court_theme$missed)
)
} |
get_gsod_apsim_met <- function(lonlat, dates, wrt.dir = ".", filename = NULL,
distance = 100, fillin.radn = FALSE){
if(!requireNamespace("GSODR", quietly = TRUE)){
warning("The GSODR package is required for this function")
return(NULL)
}
if(missing(filename)) filename <- "noname.met"
if(!grepl(".met", filename, fixed = TRUE)) stop("filename should end in .met")
yr1 <- as.numeric(format(as.Date(dates[1]), "%Y"))
yr2 <- as.numeric(format(as.Date(dates[2]), "%Y"))
nr.st <- GSODR::nearest_stations(LAT = lonlat[2], LON = lonlat[1], distance = distance)
if(length(nr.st) == 0) stop("No stations found. Try increasing the distance.")
nr.st1 <- nr.st[1]
dts <- as.numeric(format(as.Date(dates), "%Y"))
yrs <- seq(from = dts[1], to = dts[2])
gsd <- GSODR::get_GSOD(years = yrs, station = nr.st1)
stnid <- gsd$STNID[1]
lati <- gsd$LATITUDE[1]
longi <- gsd$LONGITUDE[1]
if(fillin.radn){
if(!requireNamespace("nasapower", quietly = TRUE)){
warning("The nasapower package is required for this function")
return(NULL)
}
pwr <- get_power_apsim_met(lonlat = lonlat,
dates = c(gsd$YEARMODA[1], gsd$YEARMODA[nrow(gsd)]))
pwr <- add_column_apsim_met(pwr,
value = as.Date(c(1:nrow(pwr)-1), origin = paste0(yr1,"-01-01")),
name = "date", units = "()")
pwr <- subset(pwr, select = c("date", "radn"))
names(pwr) <- c("date", "RADN")
gsd$date <- gsd$YEARMODA
gsd <- merge(gsd, pwr, by = "date")
}else{
gsd$RADN <- NA
}
gsd <- subset(as.data.frame(gsd), select = c("YEAR", "YDAY","RADN",
"MAX", "MIN", "PRCP", "RH", "WDSP"))
names(gsd) <- c("year", "day", "radn", "maxt", "mint", "rain", "rh", "windspeed")
units <- c("()", "()", "(MJ/m2/day)", "(oC)", "(oC)", "(mm)", "(%)", "(m/s)")
if(fillin.radn){
comments <- paste("!data from GSODR R package. Radiation from nasapower R. retrieved: ", Sys.time())
}else{
comments <- paste("!data from GSODR R package. retrieved: ", Sys.time())
}
attr(gsd, "filename") <- filename
attr(gsd, "site") <- paste("site =", "station-ID", stnid)
attr(gsd, "latitude") <- paste("latitude =", lati)
attr(gsd, "longitude") <- paste("longitude =", longi)
attr(gsd, "tav") <- paste("tav =", mean(colMeans(gsd[,c("maxt","mint")], na.rm=TRUE), na.rm=TRUE))
attr(gsd, "amp") <- paste("amp =", mean(gsd$maxt, na.rm=TRUE) - mean(gsd$mint, na.rm = TRUE))
attr(gsd, "colnames") <- names(gsd)
attr(gsd, "units") <- units
attr(gsd, "comments") <- comments
class(gsd) <- c("met", "data.frame")
if(filename != "noname.met"){
write_apsim_met(gsd, wrt.dir = wrt.dir, filename = filename)
}
return(invisible(gsd))
} |
opt22 <- eventReactive(input$RunOpt22, {
Gprint(MODE_DEBUG, "Opt22\n")
ficout = tempfile()
ficin = GenepopFile()$datapath
out = TRUE
if (is.null(ficin)) {
out = FALSE
} else {
Gprint(MODE_DEBUG, ficin)
setRandomSeed(getSeed(input$randomSeed))
show("spinner")
tryCatch(write_LD_tables(ficin, outputFile = ficout), error = function(e) {
file.create(ficout)
write(paste("Exeption : ", e$message), file = ficout)
}, finally = hide("spinner"))
file.rename("cmdline.txt", "cmdline.old")
}
data.frame(file = ficout, output = out)
})
output$Opt22out <- renderText({
opt <- opt22()
if (opt$output) {
filePath <- toString(opt$file)
if (file.size(filePath) > 300) {
fileText <- readLines(filePath)
nblig = grep("Number of loci detected", fileText)
fileText <- paste(fileText[(nblig + 2):length(fileText)], collapse = "\n")
shinyjs::enable("downloadOpt22All")
} else {
fileText <- readLines(filePath)
}
} else {
fileText <- "No genepop file found! please upload a file"
}
fileText
})
output$downloadOpt22All <- downloadHandler(filename = function() {
paste("result_opt22_", Sys.Date(), ".txt", sep = "")
}, content = function(con) {
opt <- opt22()
if (opt$output) {
filePath <- toString(opt$file)
fileText <- readLines(filePath)
} else {
fileText <- "No genepop file found! please upload a file"
}
write(fileText, con)
}) |
knitr::opts_chunk$set(echo = TRUE,
warning = FALSE,
message = FALSE,
fig.align = "center",
fig.width = 6,
fig.height = 5,
out.width = "60%",
tidy.opts = list(width.cutoff = 65),
tidy = FALSE)
set.seed(12314159)
library(loon.data)
library(loon)
library(gridExtra)
imageDirectory <- file.path(".", "images", "savingLoonPlots")
dataDirectory <- file.path(".", "data", "savingLoonPlots")
p_savedStates <- l_getSavedStates(file = file.path(dataDirectory, "p_savedStates"))
names(p_savedStates)
p_focusOnVersicolor <- l_getSavedStates(file = file.path(dataDirectory, "p_focusOnVersicolor")) |
test_that("binwidth is respected", {
df <- data_frame(x = c(1, 1, 1, 2), y = c(1, 1, 1, 2))
base <- ggplot(df, aes(x, y)) +
stat_bin2d(geom = "tile", binwidth = 0.25)
out <- layer_data(base)
expect_equal(nrow(out), 2)
expect_equal(out$xmin, c(1, 1.75), tolerance = 1e-7)
expect_equal(out$xmax, c(1.25, 2), tolerance = 1e-7)
})
test_that("breaks override binwidth", {
integer_breaks <- (0:4) - 0.5
half_breaks <- seq(0, 3.5, 0.5)
df <- data_frame(x = 0:3, y = 0:3)
base <- ggplot(df, aes(x, y)) +
stat_bin2d(
breaks = list(x = integer_breaks, y = NULL),
binwidth = c(0.5, 0.5)
)
out <- layer_data(base)
expect_equal(out$xbin, cut(df$x, adjust_breaks(integer_breaks), include.lowest = TRUE, labels = FALSE))
expect_equal(out$ybin, cut(df$y, adjust_breaks(half_breaks), include.lowest = TRUE, labels = FALSE))
})
test_that("breaks are transformed by the scale", {
df <- data_frame(x = c(1, 10, 100, 1000), y = 0:3)
base <- ggplot(df, aes(x, y)) +
stat_bin_2d(
breaks = list(x = c(5, 50, 500), y = c(0.5, 1.5, 2.5)))
out1 <- layer_data(base)
out2 <- layer_data(base + scale_x_log10())
expect_equal(out1$x, c(27.5, 275))
expect_equal(out2$x, c(1.19897, 2.19897))
}) |
numeric_FisherInformation <- function(model){
model <- expectedmodel(model)
0.5 * numDeriv::jacobian(psychonetrics_gradient,parVector(model),model=model)
}
psychonetrics_FisherInformation <- function(model, analytic = TRUE){
if (!analytic){
return(numeric_FisherInformation(model))
}
if (model@cpp){
prep <- prepareModel_cpp(parVector(model), model)
} else {
prep <- prepareModel(parVector(model), model)
}
if (model@cpp){
estimatorHessian <- switch(
model@estimator,
"ML" = switch(model@distribution,
"Gaussian" = expected_hessian_Gaussian_cpp,
"Ising" = expected_hessian_Ising
),
"ULS" = switch(model@distribution,
"Gaussian" = expected_hessian_ULS_Gaussian_cpp
),
"WLS" = switch(model@distribution,
"Gaussian" = expected_hessian_ULS_Gaussian_cpp
),
"DWLS" = switch(model@distribution,
"Gaussian" = expected_hessian_ULS_Gaussian_cpp
),
"FIML" = switch(model@distribution,
"Gaussian" = expected_hessian_fiml_Gaussian_cppVersion
)
)
} else {
estimatorHessian <- switch(
model@estimator,
"ML" = switch(model@distribution,
"Gaussian" = expected_hessian_Gaussian,
"Ising" = expected_hessian_Ising
),
"ULS" = switch(model@distribution,
"Gaussian" = expected_hessian_ULS_Gaussian
),
"WLS" = switch(model@distribution,
"Gaussian" = expected_hessian_ULS_Gaussian
),
"DWLS" = switch(model@distribution,
"Gaussian" = expected_hessian_ULS_Gaussian
),
"FIML" = switch(model@distribution,
"Gaussian" = expected_hessian_fiml_Gaussian
)
)
}
estimatorPart <- estimatorHessian(prep)
if (model@cpp){
modelJacobian <- switch(
model@model,
"varcov" = d_phi_theta_varcov_cpp,
"lvm" = d_phi_theta_lvm_cpp,
"var1" = d_phi_theta_var1_cpp,
"dlvm1" = d_phi_theta_dlvm1_cpp,
"tsdlvm1" = d_phi_theta_tsdlvm1_cpp,
"meta_varcov" = d_phi_theta_meta_varcov_cpp,
"Ising" = d_phi_theta_Ising_cpp,
"ml_lvm" = d_phi_theta_ml_lvm_cpp
)
} else {
modelJacobian <- switch(
model@model,
"varcov" = d_phi_theta_varcov,
"lvm" = d_phi_theta_lvm,
"var1" = d_phi_theta_var1,
"dlvm1" = d_phi_theta_dlvm1,
"tsdlvm1" = d_phi_theta_tsdlvm1,
"meta_varcov" = d_phi_theta_meta_varcov,
"Ising" = d_phi_theta_Ising,
"ml_lvm" = d_phi_theta_ml_lvm
)
}
modelPart <- sparseordense(modelJacobian(prep))
if (model@cpp){
manualPart <- Mmatrix_cpp(model@parameters)
} else {
manualPart <- Mmatrix(model@parameters)
}
if (model@cpp){
if (is(modelPart, "sparseMatrix")){
Fisher <- FisherInformation_inner_cpp_DSS(as.matrix(estimatorPart), modelPart, manualPart)
} else {
Fisher <- FisherInformation_inner_cpp_DDS(as.matrix(estimatorPart), as.matrix(modelPart), manualPart)
}
} else {
Fisher <- 0.5 * t(manualPart) %*% t(modelPart) %*% estimatorPart %*% modelPart %*% manualPart
}
as.matrix(Fisher)
} |
NULL
specially <- function(x,
fn,
preconditions = NULL,
actions = NULL,
step_id = NULL,
label = NULL,
brief = NULL,
active = TRUE) {
segments <- NULL
segments_list <-
resolve_segments(
x = x,
seg_expr = segments,
preconditions = preconditions
)
if (is_a_table_object(x)) {
secret_agent <-
create_agent(x, label = "::QUIET::") %>%
specially(
fn = fn,
preconditions = preconditions,
actions = prime_actions(actions),
label = label,
brief = brief,
active = active
) %>%
interrogate()
return(x)
}
agent <- x
if (is.null(brief)) {
brief <-
create_autobrief(
agent = agent,
assertion_type = "specially"
)
}
step_id <- normalize_step_id(step_id, columns = "column", agent)
i_o <- get_next_validation_set_row(agent)
check_step_id_duplicates(step_id, agent)
for (i in seq_along(segments_list)) {
seg_col <- names(segments_list[i])
seg_val <- unname(unlist(segments_list[i]))
agent <-
create_validation_step(
agent = agent,
assertion_type = "specially",
i_o = i_o,
columns_expr = NULL,
column = NULL,
values = fn,
na_pass = NULL,
preconditions = preconditions,
seg_expr = segments,
seg_col = seg_col,
seg_val = seg_val,
actions = covert_actions(actions, agent),
step_id = step_id,
label = label,
brief = brief,
active = active
)
}
agent
}
expect_specially <- function(object,
fn,
preconditions = NULL,
threshold = 1) {
fn_name <- "expect_specially"
vs <-
create_agent(tbl = object, label = "::QUIET::") %>%
specially(
fn = fn,
preconditions = {{ preconditions }},
actions = action_levels(notify_at = threshold)
) %>%
interrogate() %>%
.$validation_set
x <- vs$notify %>% all()
threshold_type <- get_threshold_type(threshold = threshold)
if (threshold_type == "proportional") {
failed_amount <- vs$f_failed
} else {
failed_amount <- vs$n_failed
}
act <- testthat::quasi_label(enquo(x), arg = "object")
testthat::expect(
ok = identical(!as.vector(act$val), TRUE),
failure_message = glue::glue(
failure_message_gluestring(
fn_name = fn_name, lang = "en"
)
)
)
act$val <- object
invisible(act$val)
}
test_specially <- function(object,
fn,
preconditions = NULL,
threshold = 1) {
vs <-
create_agent(tbl = object, label = "::QUIET::") %>%
specially(
fn = fn,
preconditions = {{ preconditions }},
actions = action_levels(notify_at = threshold)
) %>%
interrogate() %>%
.$validation_set
if (inherits(vs$capture_stack[[1]]$warning, "simpleWarning")) {
warning(conditionMessage(vs$capture_stack[[1]]$warning))
}
if (inherits(vs$capture_stack[[1]]$error, "simpleError")) {
stop(conditionMessage(vs$capture_stack[[1]]$error))
}
all(!vs$notify)
} |
isoph.ti=function(TIME, STATUS, Z, ZNAME, P, Q, shape, K, maxiter, eps){
data.all=data.frame(X=TIME,DELTA=STATUS,Z)
data=data.all[order(data.all$Z1),]
n.total=nrow(data)
DELTA.Z1=aggregate(data$DELTA,by=list(Z1=data$Z1),sum)
if(shape=='increasing'){
if(DELTA.Z1[1,2]==0){
Z.star=DELTA.Z1[which(DELTA.Z1[,2]>0)[1],1]
data=data[data$Z1>=Z.star,]
}
}else if(shape=='decreasing'){
if(DELTA.Z1[nrow(DELTA.Z1),2]==0){
Z.star=DELTA.Z1[max(which(DELTA.Z1[,2]>0)),1]
data=data[data$Z1<=Z.star,]
}
}
n=nrow(data)
t=data$X
delta=data$DELTA
z=data$Z1
w=data[,-c(1:3)]
if(Q==1){; w=matrix(data[,-c(1:3)])
}else if(Q>=2){; w=as.matrix(data[,-c(1:3)])
}
z.obs=unique(z[delta==1])
m=length(z.obs)
t.obs=sort(unique(t))
nt=length(t.obs)
k=sum(z.obs<K)
if(k==0) k=1
Zk=z.obs[k]
Y=dN=matrix(0,n,nt)
for(i in 1:n){
rank.t=which(t[i]==t.obs)
Y[i,][1:rank.t]=1
if(delta[i]==1) dN[i,][rank.t]=1
}
data.all$Z.BAR=data.all$Z1-Zk
formula="survival::Surv(X,DELTA)~Z.BAR"
if(Q>0) formula=paste(c(formula,paste0("+W",1:Q)),collapse ="")
res.initial=isoph.initial(formula,data.all,Q,shape,z.obs,Zk)
psi=res.initial$psi
beta=res.initial$beta
if(Q==0){
rpa.Y=isoph.RPA.ti(n, nt, m, z, z.obs, Y, dN, shape)
Y2=rpa.Y$Y2
dN2=rpa.Y$dN2
dNsum=colSums(dN2)
Delta=rowSums(dN2)
dist=0; exp.beta=NA
picm=isoph.picm(psi,m,z.obs,Zk,k, dN2,Y2,dNsum,Delta, eps,maxiter, shape)
psi.new=picm$psi.new
iter=picm$iter
conv=picm$conv
}else{
iter=0; dist=1; beta.new=rep(NA,Q)
while(dist>=eps){
iter=iter+1
if(iter>maxiter) break
Yest=matrix(NA,n,nt)
for(j in 1:nt) Yest[,j]=Y[,j]*exp(w%*%beta)
rpa.Y=isoph.RPA.ti(n, nt, m, z, z.obs, Yest, dN, shape)
Y2=rpa.Y$Y2
dN2=rpa.Y$dN2
dNsum=colSums(dN2)
Delta=rowSums(dN2)
picm=isoph.picm(psi,m,z.obs,Zk,k, dN2,Y2,dNsum,Delta, eps,maxiter, shape)
psi.new=picm$psi.new
psi.full=isoph.BTF(m, n, z,z.obs, psi.new,shape)
if(picm$conv==0) stop
beta.new=isoph.NR(w,beta,Q,psi.full,n,nt,Y,dN, maxiter,eps)
dist=sqrt(sum((psi.new-psi)^2))+sqrt(sum((beta.new-beta)^2))
psi=psi.new
beta=beta.new
}
conv="not converged"
if(dist<eps) conv="converged"
}
z.full=sort(data.all$Z1)
psi.full=disoph.BTF2(n.total,m,psi.new,z.full,z.obs,shape)
iso.cov=data.frame(z=z.full,psi.hat=psi.full)
colnames(iso.cov)=c(ZNAME[1],"psi.hat")
beta.res=NA
if(Q>0){
beta.res=data.frame(est=beta.new, HR=exp(beta.new))
rownames(beta.res)=ZNAME[-1]
}
res=list(iso.cov=iso.cov,beta=beta.res,
conv=conv,iter=iter,Zk=Zk,shape=shape)
} |
test_that("Check glassbrain", {
p = ggseg3d(atlas = aseg_3d) %>%
add_glassbrain()
expect_is(p, c("plotly", "htmlwidget"))
expect_equal(length(p$x$attrs), 37)
p = ggseg3d(atlas = aseg_3d) %>%
add_glassbrain(hemisphere = "left")
expect_is(p, c("plotly", "htmlwidget"))
expect_equal(length(p$x$attrs), 35)
p = ggseg3d(atlas = aseg_3d) %>%
add_glassbrain(hemisphere = "left",
colour = "red")
expect_equal(length(p$x$attrs), 35)
}) |
ChunkedArray <- R6Class("ChunkedArray",
inherit = ArrowDatum,
public = list(
length = function() ChunkedArray__length(self),
type_id = function() ChunkedArray__type(self)$id,
chunk = function(i) Array$create(ChunkedArray__chunk(self, i)),
as_vector = function() ChunkedArray__as_vector(self, option_use_threads()),
Slice = function(offset, length = NULL) {
if (is.null(length)) {
ChunkedArray__Slice1(self, offset)
} else {
ChunkedArray__Slice2(self, offset, length)
}
},
Take = function(i) {
if (is.numeric(i)) {
i <- as.integer(i)
}
if (is.integer(i)) {
i <- Array$create(i)
}
call_function("take", self, i)
},
Filter = function(i, keep_na = TRUE) {
if (is.logical(i)) {
i <- Array$create(i)
}
call_function("filter", self, i, options = list(keep_na = keep_na))
},
SortIndices = function(descending = FALSE) {
assert_that(is.logical(descending))
assert_that(length(descending) == 1L)
assert_that(!is.na(descending))
call_function(
"sort_indices",
self,
options = list(names = "", orders = as.integer(descending))
)
},
View = function(type) {
ChunkedArray__View(self, as_type(type))
},
Validate = function() {
ChunkedArray__Validate(self)
},
ToString = function() {
ChunkedArray__ToString(self)
},
Equals = function(other, ...) {
inherits(other, "ChunkedArray") && ChunkedArray__Equals(self, other)
}
),
active = list(
null_count = function() ChunkedArray__null_count(self),
num_chunks = function() ChunkedArray__num_chunks(self),
chunks = function() map(ChunkedArray__chunks(self), Array$create),
type = function() ChunkedArray__type(self)
)
)
ChunkedArray$create <- function(..., type = NULL) {
if (!is.null(type)) {
type <- as_type(type)
}
ChunkedArray__from_list(list2(...), type)
}
chunked_array <- ChunkedArray$create |
matrix_add_by_name <- function(M, ...) {
add.by.name <- function(M, M2) {
if (is.null(colnames(M2)) && ncol(M2) == 1) colnames(M2) <- name.M2
if (is.null(rownames(M2)) && nrow(M2) == 1) rownames(M2) <- name.M2
the.colnames <- colnames(M2)
the.rownames <- rownames(M2)
if (is.null(colnames(M)) || is.null(rownames(M)) ||
is.null(colnames(M2)) || is.null(rownames(M2))) {
stop("Li, matrix.add.by.name: null name of the first matrix")
}
if (any(!(the.colnames %in% colnames(M)))) {
print(paste(the.colnames[!(the.colnames %in% colnames(M))]))
stop("Li: wrong colnames")
}
if (any(!(the.rownames %in% rownames(M)))) {
print(paste(the.rownames[!(the.rownames %in% rownames(M))]))
stop("Li: wrong rownames")
}
M[the.rownames, the.colnames] <- M[the.rownames, the.colnames] + M2
return(M)
}
result <- as.matrix(M)
M.list <- list(...)
if (length(M.list) > 0) {
name.list <- match.call(expand.dots = FALSE)$`...`
for (k in seq_along(M.list)) {
name.M2 <- as.character(name.list[[k]])
M2 <- as.matrix(M.list[[k]])
result <- add.by.name(result, M2)
}
}
return(result)
} |
Residual.null <- function(param,fixed=0,model,I0,data,lev,fact,sumlev,sposFirst,dim.data)
{
.C("residual_null",
param = as.double(param),
fixed = as.double(fixed),
lev = as.integer(lev),
fact = as.integer(fact),
sumlev = as.integer(sumlev),
spos_first = as.integer(sposFirst),
in_st = as.integer(I0),
observed = as.double(data),
dimdata = as.integer(dim.data),
model = as.integer(model),
RSS = as.double(0),
NAOK = TRUE,
PACKAGE = "rAverage"
)$RSS
}
Residual.eq <- function(param,fixed,data,lev,fact,sumlev,dim.data)
{
.C("residual_eq",
param = as.double(param),
fixed = as.double(fixed),
lev = as.integer(lev),
fact = as.integer(fact),
sumlev = as.integer(sumlev),
observed = as.double(data),
dimdata = as.integer(dim.data),
RSS = as.double(0),
NAOK = TRUE,
PACKAGE = "rAverage"
)$RSS
}
Residual <- function(param,fixed,data,lev,fact,sumlev,dim.data,Dt,nwfix)
{
.C("residual",
param = as.double(param),
fixed = as.double(fixed),
lev = as.integer(lev),
fact = as.integer(fact),
sumlev = as.integer(sumlev),
observed = as.double(data),
dimdata = as.integer(dim.data),
deltaweights = as.double(Dt),
numfix = as.integer(nwfix$num),
valfix = as.double(nwfix$nwval),
RSS = as.double(0),
NAOK = TRUE,
PACKAGE = "rAverage"
)$RSS
}
optimization.IC <- function(
data, fact, lev, sumlev, pos, N, dim.data,
model.start, par.base, nwfix, fixed,
I0, Dt, IC.diff, all, verbose, IC.break,
lower, upper, method, control, change)
{
START <- list(
param = model.start@param,
RSS = model.start@RSS,
IC = c(model.start@BIC,model.start@AIC),
n.pars = [email protected],
conv = 0,
msg = ""
)
BEST <- list(
param = NULL,
RSS = NULL,
IC = NULL,
n.pars = NULL,
comb = NULL,
conv = NULL,
msg = NULL
)
selected <- rep.int(FALSE,sumlev[1])
bounds <- method=="L-BFGS-B"
logN <- log(N)
if(verbose) {
cat("Model selection by information criterion","\n\n")
cat("-> start \t",
"RSS:",sprintf("%.2f",START$RSS),"\t",
"BIC:",sprintf("%.2f",START$IC[1]),"\t",
"AIC:",sprintf("%.2f",START$IC[2]),"\n"
)
}
for(i in 1:sumlev[1]) {
if(verbose) cat("
START$param[pos$fixed] <- fixed[pos$fixed]
BEST$IC <- START$IC
accepted <- FALSE
decision <- " Refused"
cc <- combin(sumlev[1],i)
dim.cc <- dim(cc)
if(nwfix$num) {
cc.sel <- matrix(FALSE,dim.cc[1],dim.cc[2])
for(j in 1:nwfix$num)
cc.sel <- cc.sel + (cc==nwfix$pos[j])
cc.sel <- which(rowSums(cc.sel)==0)
cc <- cc[cc.sel,]
if(is.vector(cc)) {
cc <- t(cc)
if(i==1) cc <- t(cc)
}
dim.cc[1] <- nrow(cc)
if(length(cc)==0 | dim.cc[2]<i) next
}
if(all==FALSE & (i>1 & i<sumlev[1]-1) & dim.cc[1]>1) {
if(i>1 & dim.cc[1]>1) {
cc.sel <- FALSE
elem <- length(vet<-(1:sumlev[1])[selected])
if(elem!=0) {
for(k in 1:elem) cc.sel <- cc.sel+(cc[,]==vet[k])
cc <- as.matrix(cc[rowSums(as.matrix(cc.sel))==elem,])
}
}
dim.cc[1] <- nrow(cc)
}
for(j in 1:dim.cc[1]) {
eachfixed <- fixed
eachfixed[pos$wpos[-cc[j,]]] <- START$param[pos$wpos[-cc[j,]]]
output <- optim(par=START$param, fn=Residual, fixed=eachfixed, data=data,
lev=lev, fact=fact, sumlev=sumlev, dim.data=dim.data, Dt=Dt,
nwfix=nwfix[c(1,3)], method=method, lower=lower, upper=upper, control=control
)
if(!I0)
output$par[pos$wpos] <- output$par[pos$wpos]-mean(output$par[pos$wpos])
else
output$par[pos$w0wpos] <- output$par[pos$w0wpos]-mean(output$par[pos$w0wpos])
output$par[pos$fixed] <- fixed[pos$fixed]
output$par <- parmeanlast(output$par,fixed,sumlev,Dt,nwfix)
if(nwfix$num==0)
output$n.pars <- par.base+numpar(output$par[pos$wpos],sumlev[1])-1
else
output$n.pars <- par.base+numpar(output$par[pos$wpos[-nwfix$pos]],sumlev[1]-nwfix$num)-1
output$value <- Residual(output$par,fixed,data,lev,fact,sumlev,dim.data,Dt,nwfix)
output$IC <- c(
N*log(output$value/N)+output$n.pars*logN,
N*log(output$value/N)+2*output$n.pars
)
if(N/output$n.pars < 40) {
output$IC[1] <- output$IC[1]+(output$n.pars*logN*(output$n.pars+1))/(N-output$n.pars-1)
output$IC[2] <- output$IC[2]+(2*output$n.pars*(output$n.pars+1))/(N-output$n.pars-1)
}
if((output$IC[1]+IC.diff[1]<BEST$IC[1]) |
((output$IC[1]<BEST$IC[1]) & (output$IC[2]+IC.diff[2]<BEST$IC[2]))) {
BEST$param <- output$par
BEST$RSS <- output$value
BEST$IC <- output$IC
BEST$n.pars <- output$n.pars
BEST$comb <- cc[j,]
BEST$conv <- output$convergence
BEST$msg <- output$message
accepted <- change <- TRUE
decision <- "Accepted"
}
if(verbose) {
if(output$convergence==0)
convergence <- "converged"
else
convergence <- "not converged"
cat("Free W:",cc[j,],"\t",
"RSS:",sprintf("%.2f",output$value),"\t",
"BIC:",sprintf("%.2f",output$IC[1]),"\t",
"AIC:",sprintf("%.2f",output$IC[2]),"\t",
decision,"\t", convergence,"\n"
)
decision <- " Refused"
}
}
if(accepted) {
START <- BEST
selected[BEST$comb] <- TRUE
}
}
if(verbose)
cat("-> select","\t",
"RSS:",round(START$RSS,2),"\t",
"BIC:",round(START$IC[1],2),"\t",
"AIC:",round(START$IC[2],2),"\n\n"
)
return(
list(
par = START$param,
value = START$RSS,
convergence = START$conv,
message = START$msg,
n.pars = START$n.pars,
change = change
)
)
} |
ssocs_ref1 <- c(" c0014_r c0526 c0528 ",
" Principal :1619 Min. : 0.000 Min. : 0.00 ",
" Vice-principal or disciplinarian: 351 1st Qu.: 1.000 1st Qu.:10.00 ",
" Security staff : 20 Median : 4.000 Median :12.00 ",
" Other school-level staff : 72 Mean : 9.498 Mean :13.86 ",
" Superintendent or district staff: 7 3rd Qu.: 12.000 3rd Qu.:17.00 ",
" Max. :100.000 Max. :96.00 ")
ssocs_ref2 <- c(" c0134 c0198 c0534 ",
" Yes: 441 0-25% :372 Min. : 0.00 ",
" No :2321 26-50% :653 1st Qu.: 50.00 ",
" 51-75% :710 Median : 68.00 ",
" 76-100% :854 Mean : 62.69 ",
" Does not offer:173 3rd Qu.: 80.00 ",
" Max. :100.00 ")
ssocs_refTbl1 <- c("", "Formula: vioinc16 ~ c0600 ",
"",
"Weight variable: 'finalwgt'",
"Variance method: jackknife",
"JK replicates: 50",
"full data n: 2092",
"n used: 2092",
"",
"",
"Summary Table:",
" c0600 N WTD_N PCT SE(PCT) MEAN SE(MEAN)",
" Yes 996 34762.08 41.58557 1.557152 11.508763 0.6838331",
" No 1096 48829.60 58.41443 1.557152 9.518731 0.7048793")
ssocs_refTbl2 <- c("", "Formula: schid ~ c0610 + c0134 ",
"",
"Weight variable: 'finalwgt'",
"Variance method: jackknife",
"JK replicates: 50",
"full data n: 2092",
"n used: 2092",
"",
"",
"Summary Table:",
" c0610 c0134 N WTD_N PCT SE(PCT)",
" Yes Yes 224 8216.959 20.58818 1.668273",
" Yes No 1136 31694.097 79.41182 1.668273",
" No Yes 132 9735.372 22.28762 2.021483",
" No No 600 33945.256 77.71238 2.021483")
ssocs_refTbl3 <- c("", "Formula: incid18 ~ c0669 + c0560 ",
"",
"Weight variable: 'finalwgt'",
"Variance method: jackknife",
"JK replicates: 50",
"full data n: 2762",
"n used: 1131",
"",
"",
"Summary Table:",
" c0669 c0560 N WTD_N PCT SE(PCT) MEAN SE(MEAN)",
" Yes High level of crime 102 2977.7645 10.772062 1.520821 40.741138 3.735516",
" Yes Moderate level of crime 231 6400.6924 23.154502 1.880035 31.575244 4.105128",
" Yes Low level of crime 536 15036.3585 54.394021 2.261935 14.311370 1.147264",
" Yes Students come from areas with very different levels of crime 150 3228.5879 11.679415 1.143869 25.331130 2.914940",
" No High level of crime 5 180.0330 4.634943 2.516350 26.108075 8.521599",
" No Moderate level of crime 31 953.3728 24.544545 5.296237 18.111184 4.049076",
" No Low level of crime 60 1928.6608 49.653296 6.109887 11.365244 1.800395",
" No Students come from areas with very different levels of crime 16 822.1887 21.167216 5.824951 6.252847 1.828095")
ssocs_refCorr1 <- c("Method: Pearson",
"full data n: 2762",
"n used: 2762",
"",
"Correlation: 0.4155861",
"Standard Error: 0.0427424",
"Confidence Interval: [0.3180694, 0.5044011]")
ssocs_refLM1 <- c("(Intercept) c0532 vioinc16 ",
"0.446830271 0.009463642 0.018524504 ")
ssocs_refLogit1 <- c(" (Intercept) c0532 ",
"-4.509334913 -0.002386365 ")
ssocs_refWald <- c("Wald test:", "----------",
"H0:",
"c0532 = 0",
"",
"Chi-square test:",
"X2 = 0.14, df = 1, P(> X2) = 0.71",
"",
"F test:",
"W = 0.14, df1 = 1, df2 = 60, P(> W) = 0.71") |
tcensReg_newton<-function(y, X, a = -Inf, v = NULL, epsilon = 1e-4,
tol_val = 1e-6, max_iter = 100, step_max = 10,
theta_init = NULL){
i <- 1
if(is.null(theta_init) == TRUE & (a != -Inf & is.null(v) == FALSE)){
cens_mod <- suppressWarnings(tcensReg(y ~ X - 1, v = v))
theta_init <- unname(cens_mod$theta)
} else{
lm_mod <- lm(y ~ X - 1)
theta_init <- c(unname(coef(lm_mod)), log(unname(summary(lm_mod)$sigma)))
}
theta <- theta_init
p <- length(theta)
f_0 <- tcensReg_llike(theta, y, X, a, v)
tol_check <- 10 * tol_val
null_ll <- f_0
grad_vec <- tcensReg_gradient(theta, y, X, a, v)
ihess_matrix <- solve(tcensReg_hess(theta, y, X, a, v))
while(i <= max_iter & sum(abs(grad_vec)) > epsilon & tol_check > tol_val){
theta_pot <- theta - ihess_matrix %*% grad_vec
f_1 <- tcensReg_llike(theta_pot, y, X, a, v)
step_counter <- 1
if(f_0 < f_1){
theta <- theta_pot
}else{
while(f_0 >= f_1 & step_counter < step_max){
theta_pot <- theta - ((1 / 2) ^ step_counter) * ihess_matrix %*% grad_vec
f_1 <- tcensReg_llike(theta_pot, y, X, a, v)
step_counter <- step_counter + 1
}
if(step_counter == step_max){warning("Line search error. Reached max step size.", call. = FALSE)}
}
theta <- theta_pot
tol_check <- abs(f_0 - f_1)
f_0 <- f_1
grad_vec <- tcensReg_gradient(theta, y, X, a, v)
ihess_matrix <- solve(tcensReg_hess(theta, y, X, a, v))
i <- i + 1
}
v_cov <- -ihess_matrix
if(i == max_iter + 1) warning("Maximum iterations reached. Interpret results with caution.", call. = FALSE)
row.names(theta) <- c(colnames(X),"log_sigma")
colnames(theta) <- "Estimate"
row.names(v_cov) <- row.names(theta)
colnames(v_cov) <- row.names(theta)
return(list(theta = theta, iterations = i - 1, initial_ll = null_ll,
final_ll = f_0, var_cov = v_cov, method="Newton"))
} |
context("GScholar")
test_that("Can retrieve by dates, keep incomplete", {
skip_on_cran()
if (httr::http_error("https://scholar.google.com"))
skip("Couldn't connect to GS")
out <- ReadGS(scholar.id = "vqW0UqUAAAAJ", sort.by.date = TRUE,
check.entries = "warn", limit = 1)
expect_is(out, "BibEntry")
expect_equal(length(out), 1L)
})
test_that("check drop incomplete", {
skip_on_cran()
if (httr::http_error("https://scholar.google.com"))
skip("Couldn't connect to GS")
Sys.sleep(3)
num.dropped <- 0
lim <- 6
frame.number <- sys.nframe()
out <- withCallingHandlers(ReadGS(scholar.id = "mXSv_1UAAAAJ", limit = lim,
sort.by.date = TRUE,
check.entries = "error"),
message = function(w){
if (any(grepl("information for entry", w)))
assign("num.dropped", num.dropped + 1L,
envir = sys.frame(frame.number))
w
})
expect_is(out, "BibEntry")
if (num.dropped > 0)
expect_lt(length(out), lim)
})
test_that("check read by cites", {
skip_on_cran()
if (httr::http_error("https://scholar.google.com"))
skip("Couldn't connect to GS")
Sys.sleep(5)
expect_warning(out <- ReadGS(scholar.id = "CJOHNoQAAAAJ",
check.entries = "warn",
sort.by.date = FALSE, limit = 10),
"Incomplete")
expect_is(out, "BibEntry")
expect_true(!is.null(out[[1L]]$title))
})
test_that("CreateBibKey works with non-ascii characters", {
skip_on_cran()
if (httr::http_error("https://scholar.google.com"))
skip("Couldn't connect to GS")
out <- ReadGS(scholar.id = "KfQwll4AAAAJ", limit = 7, sort.by.date = TRUE)
expect_is(out, "BibEntry")
}) |
test_that("multiplying linear terms", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
x2 <- x * 2
expect_equal(x2$coefficient, 2)
x2 <- 2 * x
expect_equal(x2$coefficient, 2)
})
test_that("dividing linear terms by a numeric", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
x2 <- x / 2
expect_equal(x2$coefficient, 1 / 2)
})
test_that("unary +/- for linear terms", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
expect_equal(+x, x)
x2 <- -x
expect_equal(x2$coefficient, -1)
})
test_that("addition creates linear functions but the terms are", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
x2 <- x + 2
expect_equal(x2$constant, 2)
expect_s3_class(x2, "LinearFunction")
x2 <- 2 + x
expect_equal(x2$constant, 2)
expect_s3_class(x2, "LinearFunction")
})
test_that("adding and substracting two linear terms", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
y <- new_linear_term(variable = new_linear_variable(2), coefficient = 5)
res <- x + y
expect_s3_class(res, "LinearFunction")
expect_equal(length(terms_list(res)), 2)
expect_equal(res$constant, 0)
})
test_that("adding a constant to a linear functions", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
x2 <- (x + 2) + 2
expect_equal(x2$constant, 4)
expect_s3_class(x2, "LinearFunction")
x2 <- 2 + (2 + x)
expect_equal(x2$constant, 4)
expect_s3_class(x2, "LinearFunction")
})
test_that("substracting a constant to a linear functions", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
x2 <- (x + 2) - 2
expect_equal(x2$constant, 0)
expect_s3_class(x2, "LinearFunction")
x2 <- 2 - (2 + x)
expect_equal(x2$constant, 0)
expect_s3_class(x2, "LinearFunction")
})
test_that("multiplying a linear function by a function", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1) + 1
x2 <- x * 10
expect_equal(x2$constant, 10)
expect_equal(terms_list(x2)[[1]]$coefficient, 10)
expect_error(x2 <- 10 * x, "bug")
})
test_that("dividing a linear function by a function", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1) + 1
x2 <- x / 2
expect_equal(x2$constant, 1 / 2)
expect_equal(terms_list(x2)[[1]]$coefficient, 1 / 2)
})
test_that("adding a linear function and linear terms", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1) + 1
y <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
z <- new_linear_term(variable = new_linear_variable(2), coefficient = 1)
res <- (x + y) + z
expect_equal(length(terms_list(res)), 2)
})
test_that("substracting a linear function and linear terms", {
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1) + 1
y <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
z <- new_linear_term(variable = new_linear_variable(2), coefficient = 42)
res <- (x - y) - z
expect_equal(length(terms_list(res)), 2)
expect_equal(res$constant, 1)
expect_setequal(
vapply(terms_list(res), function(x) x$coefficient, numeric(1)),
c(0, -42)
)
x <- new_linear_term(variable = new_linear_variable(1), coefficient = 1) + 1
y <- new_linear_term(variable = new_linear_variable(1), coefficient = 1)
z <- new_linear_term(variable = new_linear_variable(2), coefficient = 42)
res <- z - (x - y)
expect_equal(length(terms_list(res)), 2)
expect_equal(res$constant, -1)
expect_setequal(
vapply(terms_list(res), function(x) x$coefficient, numeric(1)),
c(0, 42)
)
})
test_that("unary addition/substraction for LinearFunctions", {
y <- -(new_linear_term(variable = new_linear_variable(1), coefficient = 1) + 1)
z <- +(new_linear_term(variable = new_linear_variable(1), coefficient = 1) + 1)
expect_equal(y$constant, -1)
expect_equal(terms_list(y)[["1"]]$coefficient, -1)
expect_equal(z$constant, 1)
expect_equal(terms_list(z)[["1"]]$coefficient, 1)
}) |
rlongonly <- function( m, n=2, k=n, segments=NULL, x.t=1, x.l=0, x.u=x.t, max.iter=1000 )
{
if ( missing( m ) )
stop( "Argument 'm' is missing" )
if ( m <= 0 )
stop( "Argument 'm' is not positive" )
by.case <- function( case, number, size, theseSegments, total, lower, upper, iterations )
{
return( random.longonly( n=number, k=size, segments=theseSegments, x.t=total,
x.l=lower, x.u=upper, max.iter=iterations ) )
}
weights <- t( sapply( 1:m, by.case, n, k, segments, x.t, x.l, x.u, max.iter ) )
if ( n == 1 ) {
weights <- t( weights )
}
return( weights )
} |
library("testthat")
library("lme4")
testLevel <- if (nzchar(s <- Sys.getenv("LME4_TEST_LEVEL"))) as.numeric(s) else 1
if (testLevel>1) {
context("glmer.nb")
test_that("basic", {
set.seed(101)
dd <- expand.grid(f1 = factor(1:3),
f2 = LETTERS[1:2], g=1:9, rep=1:15,
KEEP.OUT.ATTRS=FALSE)
mu <- 5*(-4 + with(dd, as.integer(f1) + 4*as.numeric(f2)))
dd$y <- rnbinom(nrow(dd), mu = mu, size = 0.5)
require("MASS")
m.glm <- glm.nb(y ~ f1*f2, data=dd)
m.nb <- glmer.nb(y ~ f1*f2 + (1|g), data=dd)
expect_equal(unname(fixef(m.nb)),
c(1.65008, 0.76715, 1.01147, 1.51241, -0.61506, -0.6104),
tol=1e-5)
expect_is(m.nb,"glmerMod")
expect_true(grepl("negative\\.binomial\\(theta *= *[0-9]*\\.[0-9]+\\)",
deparse(m.nb@call$family)))
expect_null(m.nb@call$verbose)
expect_equal(fixef(m.nb), coef (m.glm), tol=1e-5)
m.nb1 <- glmer(Reaction > 250 ~ Days + (1|Subject),
data = sleepstudy, family=poisson)
m.nb2 <- glmer.nb(y ~ f1*f2 + (1|g), data=dd,
subset = g!=8)
expect_equal(unname(ngrps(m.nb2)),8)
expect_equal(unname(fixef(m.nb2)),
c(1.629240234, 0.76028840, 1.008629913, 1.6172507,
-0.6814426, -0.66468330),tol=1e-5)
old.opts <- options(warning=2)
m.nb2 <- glmer.nb(round(Reaction) ~ Days + (1|Subject),
data = sleepstudy, subset = Subject != 370,
control=glmerControl(check.conv.grad="ignore"))
expect_is(m.nb2,"glmerMod")
options(old.opts)
m.nb3 <- glmer.nb(y~f1+(1|g),
data=dd,
contrasts=list(f1=contr.sum))
expect_equal(fixef(m.nb3),
structure(c(2.93061, -0.29779, 0.02586),
.Names = c("(Intercept)",
"f11", "f12")),tol=1e-5)
m.nb4 <- glmer.nb(y~f1+(1|g), dd)
expect_equal(names(m.nb4@call),c("","formula","data","family"))
m.nb2 <- glmer.nb(y~f1+(1|g),
data=dd,
offset=rep(0,nrow(dd)))
})
} |
check_genderdata_package <- function() {
genderdata_version <- "0.6.0"
if (!requireNamespace("genderdata", quietly = TRUE)) {
message("The genderdata package needs to be installed.")
install_genderdata_package()
} else if (utils::packageVersion("genderdata") < genderdata_version) {
message("The genderdata package needs to be updated.")
install_genderdata_package()
}
}
install_genderdata_package <- function() {
instructions <- paste(" Please try installing the package for yourself",
"using the following command: \n",
" remotes::install_github(\"lmullen/genderdata\")\n")
error_func <- function(e) {
message(e)
cat(paste("\nFailed to install the genderdata package.\n", instructions))
}
if (interactive()) {
input <- utils::menu(c("Yes", "No"),
title = "Install the genderdata package?")
if (input == 1) {
message("Installing the genderdata package.")
tryCatch(remotes::install_github("lmullen/[email protected]"),
error = error_func, warning = error_func)
} else {
stop(paste("The genderdata package is necessary for that method.\n",
instructions))
}
} else {
stop(paste("Failed to install the genderdata package.\n", instructions))
}
} |
generator_funs$clone_method <- function(deep = FALSE) {
remap_func_envs <- function(objs, old_new_env_pairs) {
lapply(objs, function(x) {
if (is.function(x)) {
func_env <- environment(x)
for (i in seq_along(old_new_env_pairs)) {
if (identical(func_env, old_new_env_pairs[[i]]$old)) {
environment(x) <- old_new_env_pairs[[i]]$new
break
}
}
}
x
})
}
list2env2 <- function(x, envir = NULL, parent = emptyenv(),
hash = (length(x) > 100),
size = max(29L, length(x)),
empty_to_null = TRUE) {
if (is.null(envir)) {
envir <- new.env(hash = hash, parent = parent, size = size)
}
if (length(x) == 0) {
if (empty_to_null)
return(NULL)
else
return(envir)
}
list2env(x, envir)
}
old <- list(
list(
enclosing = .subset2(self, ".__enclos_env__"),
binding = self,
private = NULL
)
)
if (!is.environment(old[[1]]$enclosing)) {
stop("clone() must be called from an R6 object.")
}
old[[1]]$private <- old[[1]]$enclosing$private
has_private <- !is.null(old[[1]]$private)
portable <- !identical(old[[1]]$binding, old[[1]]$enclosing)
i <- 1
while (TRUE) {
if (is.null(old[[i]]$enclosing$super)) {
break
}
old[[i+1]] <- list(
binding = old[[i]]$enclosing$super,
enclosing = old[[i]]$enclosing$super$.__enclos_env__
)
i <- i + 1
}
if (deep) {
if (has_private && is.function(old[[1]]$private$deep_clone)) {
deep_clone <- old[[1]]$private$deep_clone
} else {
deep_clone <- function(name, value) {
if (is.environment(value) && !is.null(value$`.__enclos_env__`)) {
return(value$clone(deep = TRUE))
}
value
}
}
}
old_1_binding <- old[[1]]$binding
old_1_private <- old[[1]]$private
make_first_new_slice <- function(old_slice, portable) {
new_slice <- list(
enclosing = NULL,
binding = NULL
)
has_private <- !is.null(old_slice$private)
if (portable) {
enclosing_parent <- parent.env(old_slice$enclosing)
binding_parent <- emptyenv()
if (has_private) {
private_parent <- emptyenv()
new_slice$private <- new.env(private_parent, hash = FALSE)
}
new_slice$binding <- new.env(binding_parent, hash = FALSE)
new_slice$enclosing <- new.env(enclosing_parent, hash = FALSE)
} else {
if (has_private) {
private_parent <- parent.env(old_slice$private)
new_slice$private <- new.env(private_parent, hash = FALSE)
binding_parent <- new_slice$private
new_slice$binding <- new.env(binding_parent, hash = FALSE)
} else {
binding_parent <- parent.env(old_slice$binding)
new_slice$binding <- new.env(binding_parent, hash = FALSE)
}
new_slice$enclosing <- new_slice$binding
}
new_slice$enclosing$self <- new_slice$binding
if (has_private) {
new_slice$enclosing$private <- new_slice$private
}
new_slice$binding$.__enclos_env__ <- new_slice$enclosing
new_slice
}
make_new_slice <- function(old_slice, self, private, enclosing_parent) {
enclosing <- new.env(enclosing_parent, hash = FALSE)
binding <- new.env(emptyenv(), hash = FALSE)
enclosing$self <- self
if (!is.null(private)) {
enclosing$private <- private
}
binding$.__enclos_env__ <- enclosing
list(
enclosing = enclosing,
binding = binding
)
}
new <- list(
make_first_new_slice(old[[1]], portable)
)
new_1_binding <- new[[1]]$binding
new_1_private <- new[[1]]$private
new_1_enclosing <- new[[1]]$enclosing
if (length(old) > 1) {
for (i in seq.int(2, length(old))) {
if (portable) {
enclosing_parent <- parent.env(old[[i]]$enclosing)
} else {
enclosing_parent <- new_1_enclosing
}
new[[i]] <- make_new_slice(
old[[i]],
new_1_binding,
new_1_private,
enclosing_parent
)
}
for (i in seq.int(1, length(old)-1)) {
new[[i]]$enclosing$super <- new[[i+1]]$binding
}
}
copy_slice <- function(old_slice, new_slice, old_new_enclosing_pairs, first_slice = FALSE) {
binding_names <- ls(old_slice$binding, all.names = TRUE)
if (!is.null(old_slice$enclosing$`.__active__`)) {
binding_names <- setdiff(binding_names, names(old_slice$enclosing$`.__active__`))
}
binding_copies <- mget(binding_names, envir = old_slice$binding)
keep_idx <- !(names(binding_copies) %in% c("self", "private", "super", ".__enclos_env__"))
binding_copies <- binding_copies[keep_idx]
binding_copies <- remap_func_envs(binding_copies, old_new_enclosing_pairs)
if (deep) {
binding_copies <- mapply(
deep_clone,
names(binding_copies),
binding_copies,
SIMPLIFY = FALSE
)
}
list2env2(binding_copies, new_slice$binding)
if (!is.null(old_slice$enclosing$`.__active__`)) {
active_copies <- remap_func_envs(old_slice$enclosing$`.__active__`, old_new_enclosing_pairs)
for (name in names(active_copies)) {
makeActiveBinding(name, active_copies[[name]], new_slice$binding)
}
new_slice$enclosing$`.__active__` <- active_copies
}
if (!is.null(old_slice$private)) {
private_copies <- as.list.environment(old_slice$private, all.names = TRUE)
if (deep) {
private_copies <- mapply(
deep_clone,
names(private_copies),
private_copies,
SIMPLIFY = FALSE
)
}
private_copies <- remap_func_envs(private_copies, old_new_enclosing_pairs)
list2env2(private_copies, new_slice$private)
}
if (first_slice) {
method_envs <- lapply(old_new_enclosing_pairs, `[[`, "new")
is_method <- function(f, method_envs) {
env <- environment(f)
for (i in seq_along(method_envs)) {
if (identical(env, method_envs[[i]])) {
return(TRUE)
}
}
FALSE
}
for (name in names(binding_copies)) {
if (is_method(new_slice$binding[[name]], method_envs))
lockBinding(name, new_slice$binding)
}
if (has_private) {
for (name in names(private_copies)) {
if (is_method(new_slice$private[[name]], method_envs))
lockBinding(name, new_slice$private)
}
}
}
}
old_new_enclosing_pairs <- list()
for (i in seq_along(old)) {
old_new_enclosing_pairs[[i]] <- list(
old = old[[i]]$enclosing,
new = new[[i]]$enclosing
)
}
for (i in seq_along(old)) {
copy_slice(
old[[i]],
new[[i]],
old_new_enclosing_pairs[seq.int(i, length(old))],
(i == 1)
)
}
if (environmentIsLocked(old_1_binding)) {
lockEnvironment(new_1_binding)
}
if (has_private && environmentIsLocked(old_1_private)) {
lockEnvironment(new_1_private)
}
if (is.function(.subset2(new_1_binding, "finalize"))) {
finalizer_wrapper <- function(e) {
.subset2(e, "finalize")()
}
environment(finalizer_wrapper) <- baseenv()
reg.finalizer(
new_1_binding,
finalizer_wrapper,
onexit = TRUE
)
}
if (has_private) {
if (is.function(.subset2(new_1_private, "finalize"))) {
finalizer_wrapper <- function(e) {
.subset2(e, ".__enclos_env__")$private$finalize()
}
environment(finalizer_wrapper) <- baseenv()
reg.finalizer(
new_1_binding,
finalizer_wrapper,
onexit = TRUE
)
}
}
class(new_1_binding) <- class(old_1_binding)
new_1_binding
} |
long2mitml.list <- function(x, split, exclude = NULL){
i1 <- which(colnames(x) == split)
f <- x[,i1]
if(!is.null(exclude)){
i2 <- if(length(exclude) == 1) f != exclude else !f %in% exclude
x <- x[i2, , drop = F]
f <- f[i2]
if(is.factor(f)) f <- droplevels(f)
}
out <- split(x[, -i1, drop = F], f = f)
names(out) <- NULL
class(out) <- c("mitml.list", "list")
return(out)
} |
answer = 42 |
knitr::opts_chunk$set(
collapse = TRUE,
comment = "
fig.path = "man/figures/README-",
out.width = "100%",
fig.width = 16 / 2,
fig.height = 9 / 2,
message = FALSE,
warning = FALSE,
cache = FALSE
)
set.seed(76)
library(ggplot2)
library(dplyr)
library(tidyr)
library(stringr)
library(forestecology)
library(patchwork)
library(blockCV)
filter <- dplyr::filter
census_1_ex
ggplot() +
geom_sf(
data = census_1_ex %>% sf::st_as_sf(coords = c("gx", "gy")),
aes(col = sp, size = dbh)
)
growth_ex <-
compute_growth(
census_1 = census_1_ex %>%
mutate(sp = to_any_case(sp) %>% factor()),
census_2 = census_2_ex %>%
filter(!str_detect(codes, "R")) %>%
mutate(sp = to_any_case(sp) %>% factor()),
id = "ID"
) %>%
mutate(basal_area = 0.0001 * pi * (dbh1 / 2)^2)
comp_dist <- 1
growth_ex <- growth_ex %>%
add_buffer_variable(size = comp_dist, region = study_region_ex)
buffer_region <- study_region_ex %>%
compute_buffer_region(size = comp_dist)
base_plot <- ggplot() +
geom_sf(data = study_region_ex, fill = "transparent") +
geom_sf(data = buffer_region, fill = "transparent", linetype = "dashed")
base_plot +
geom_sf(data = growth_ex, aes(col = buffer), size = 2)
fold1 <- rbind(c(0, 0), c(5, 0), c(5, 5), c(0, 5), c(0, 0))
fold2 <- rbind(c(5, 0), c(10, 0), c(10, 5), c(5, 5), c(5, 0))
blocks_ex <- bind_rows(
sf_polygon(fold1),
sf_polygon(fold2)
) %>%
mutate(folds = c(1, 2) %>% factor())
SpatialBlock_ex <- blockCV::spatialBlock(
speciesData = growth_ex, k = 2, selection = "systematic", blocks = blocks_ex,
showBlocks = FALSE, verbose = FALSE
)
growth_ex <- growth_ex %>%
mutate(foldID = SpatialBlock_ex$foldID %>% factor())
base_plot +
geom_sf(data = growth_ex, aes(col = buffer, shape = foldID), size = 2) +
geom_sf(data = blocks_ex, fill = "transparent", col = "orange")
focal_vs_comp_ex <- growth_ex %>%
create_focal_vs_comp(comp_dist, blocks = blocks_ex, id = "ID", comp_x_var = "basal_area")
focal_vs_comp_ex
focal_vs_comp_ex %>%
unnest(cols = "comp")
comp_bayes_lm_ex <- focal_vs_comp_ex %>%
comp_bayes_lm(prior_param = NULL)
comp_bayes_lm_ex
p1 <- autoplot(comp_bayes_lm_ex, type = "intercepts")
p2 <- autoplot(comp_bayes_lm_ex, type = "dbh_slopes")
p3 <- autoplot(comp_bayes_lm_ex, type = "competition")
(p1 | p2) / p3
focal_vs_comp_ex <- focal_vs_comp_ex %>%
mutate(growth_hat = predict(comp_bayes_lm_ex, newdata = focal_vs_comp_ex))
focal_vs_comp_ex
focal_vs_comp_ex %>%
rmse(truth = growth, estimate = growth_hat) %>%
pull(.estimate)
focal_vs_comp_ex <- focal_vs_comp_ex %>%
run_cv(comp_dist = comp_dist, blocks = blocks_ex)
focal_vs_comp_ex %>%
rmse(truth = growth, estimate = growth_hat) %>%
pull(.estimate) |
context("Lun2Params")
params <- newLun2Params()
test_that("printing works", {
expect_output(show(params), "Lun2Params")
})
test_that("nCells checks work", {
expect_error(setParam(params, "nCells", 1),
"nCells cannot be set directly, set cell.plates instead")
expect_error(setParam(params, "nPlates", 1),
"nPlates cannot be set directly, set cell.plates instead")
})
test_that("gene.params checks work", {
expect_error(setParam(params, "gene.params", data.frame(A = 1, B = 1)),
"gene.params: Incorrect column names")
expect_error(setParam(params, "gene.params",
data.frame(Mean = 1, Disp = "a")),
"gene.params: May only contain the following types: \\{numeric\\}")
}) |
team_advanced_stats <- function(df1,df2,m){
minutes <- (df2[1,2]/df2[1,1])/5
minutes <- trunc(minutes)
tm_poss <- df1[1,4] - df1[1,15] / (df1[1,15] + df2[1,16]) * (df1[1,4] - df1[1,3]) * 1.07 + df1[1,21] + 0.4 * df1[1,13]
opp_poss <- df2[1,4] - df2[1,15] / (df2[1,15] + df1[1,16]) * (df2[1,4] - df2[1,3]) * 1.07 + df2[1,21] + 0.4 * df2[1,13]
pace <- round(m * ((tm_poss + opp_poss) / (2 * (df1[1,2] / 5))),2)
stats <- cbind(df1[1],df1[2])
offrtg <- round(100 * (df1[1,23]/tm_poss),2)
defrtg <- round(100 * (df2[1,23]/opp_poss),2)
netrtg <- round(offrtg - defrtg,2)
TPAr <- round(df1[1,7] / df1[1,4],3)
FTr <- round(df1[1,13] / df1[1,4],3)
ts <- round(df1[1,23] / (2 * (df1[1,4] + 0.44 * df1[1,13])),3)
efg <- round((df1[1,3] + 0.5 * df1[1,6]) / df1[1,4],3)
ast <- round(df1[1,18] / df1[1,3],3)
ast_to <- round(df1[1,18] / df1[1,21],2)
ast_ratio <- round((df1[1,18] * 100) / tm_poss,2)
orb <- round(df1[1,15] / (df1[1,15] + df2[1,16]),3)
fta_rate <- round(df1[1,12] / df1[1,4],3)
tov <- round(df1[1,21] / (df1[1,4] +0.44 * df1[1,13] + df1[1,21]),3)
eFG_opp <- round((df2[1,3] + 0.5 * df2[1,6]) / df2[1,4],3)
tov_opp <- round(df2[1,21] / (df2[1,4] +0.44 * df2[1,13] + df2[1,21]),3)
offRB_opp <- round(df1[1,16] / (df1[1,16] + df2[1,15]),3)
fta_rate_opp <- round(df2[1,12] / df2[1,4],3)
stats <- cbind(stats,offrtg,defrtg,netrtg,pace,TPAr,FTr,ts,efg,ast,ast_to,ast_ratio,orb,tov,fta_rate,eFG_opp,tov_opp,offRB_opp,fta_rate_opp)
names(stats) = c("G","MP","ORtg","DRtg",'NetRtg','Pace',"3PAr","FTr",'TS%','eFG%',"AST%","AST/TO","ASTRATIO%","ORB%","TOV%","FT/FGA","Opp eFG%","Opp TOV%","DRB%","Opp FTr")
return(stats)
} |
"print.floated" <-
function(x, digits=max(3, getOption("digits") - 3), level = 0.95, ...)
{
K <- qnorm((1+level)/2)
n <- length(x$coef)
mat <- matrix("", n, 4)
ci.mat <- matrix(0, n, 2)
cm <- x$coefmat
cat("Floating treatment contrasts for factor ", x$factor, "\n\n")
mat[,1] <- names(x$coef)
se <- sqrt(x$var)
ci.mat[, 1] <- x$coef - K * se
ci.mat[, 2] <- x$coef + K * se
mat[,2] <- format(x$coef, digits=digits)
mat[,3] <- format(se, digits=digits)
ci.mat <- format(ci.mat, digits=digits)
mat[,4] <- paste("(", ci.mat[,1], ",", ci.mat[,2], ")", sep="")
dimnames(mat) <- list(rep("", n), c("Level", "Coefficient",
"Std. Error", "95% Floating CI"))
print(mat, quote=FALSE)
cat("\nError limits over all contrasts: ",
paste(format(c(0.99, x$limits),
digits=2)[-1], collapse=","),"\n")
} |
shiny_oursins <-
function(data,fondMaille,fondContour,fondSuppl=NULL,idDataDepart,idDataArrivee,varFlux,decalageAllerRetour=0,decalageCentroid=0,emprise="FRM",fondEtranger=NULL)
{
options("stringsAsFactors"=FALSE)
msg_error1<-msg_error2<-msg_error3<-msg_error4<-msg_error5<-msg_error6<-msg_error7<-msg_error8<-msg_error9<-msg_error10<-msg_error11<-msg_error12<-msg_error13<-msg_error14<-msg_error15<-msg_error16<-msg_error17<-msg_error18<-msg_error19<-msg_error20 <- NULL
if(any(class(data)!="data.frame")) msg_error1 <- "Les donnees doivent etre dans un data.frame / "
if(any(!any(class(fondMaille) %in% "sf"),!any(class(fondMaille) %in% "data.frame"))) msg_error2 <- "Le fond de maille doit etre un objet sf / "
if(any(!any(class(fondContour) %in% "sf"),!any(class(fondContour) %in% "data.frame"))) msg_error3 <- "Le fond de contour doit etre un objet sf / "
if(!is.null(fondSuppl)) if(any(!any(class(fondSuppl) %in% "sf"),!any(class(fondSuppl) %in% "data.frame"))) msg_error4 <- "Le fond supplementaire doit etre un objet sf / "
if(any(class(idDataDepart)!="character")) msg_error5 <- "Le nom de la variable de depart doit etre de type caractere / "
if(any(class(idDataArrivee)!="character")) msg_error6 <- "Le nom de la variable d'arrivee doit etre de type caractere / "
if(any(class(varFlux)!="character")) msg_error7 <- "Le nom de la variable doit etre de type caractere / "
if(any(class(decalageAllerRetour)!="numeric")) msg_error8 <- "La variable decalageAllerRetour doit etre de type numerique / "
if(any(class(decalageCentroid)!="numeric")) msg_error9 <- "La variable decalageCentroid doit etre de type numerique / "
if(any(class(emprise)!="character")) msg_error10 <- "La valeur doit etre de type caractere ('FRM', '971', '972', '973', '974', '976' ou '999') / "
if(length(names(data))<3) msg_error11 <- "Le tableau des donnees n'est pas conforme. Il doit contenir au minimum une variable identifiant de depart, une variable identifiant d'arrivee et la variable a representer / "
if(length(names(fondMaille))<3) msg_error12 <- "Le fond de maille n'est pas conforme. La table doit contenir au minimum une variable identifiant, une variable libelle et la geometry / "
if(length(names(fondContour))<3) msg_error13 <- "Le fond de contour n'est pas conforme. La table doit contenir au minimum une variable identifiant, une variable libelle et la geometry / "
if(!is.null(fondSuppl)) if(length(names(fondSuppl))<3) msg_error14 <- "Le fond supplementaire n'est pas conforme. La table doit contenir au minimum une variable identifiant, une variable libelle et la geometry / "
if(!any(names(data) %in% idDataDepart)) msg_error15 <- "La variable identifiant de depart n'existe pas dans la table des donnees / "
if(!any(names(data) %in% idDataArrivee)) msg_error16 <- "La variable identifiant d'arrivee n'existe pas dans la table des donnees / "
if(!any(names(data) %in% varFlux)) msg_error17 <- "La variable a representer n'existe pas dans la table des donnees / "
if(!emprise %in% c("FRM","971","972","973","974","976","999")) msg_error18 <- "La variable emprise doit etre 'FRM', '971', '972', '973', '974', '976' ou '999' / "
if(!is.null(fondEtranger)) if(any(!any(class(fondEtranger) %in% "sf"),!any(class(fondEtranger) %in% "data.frame"))) msg_error19 <- "Le fond etranger doit etre un objet sf / "
if(!is.null(fondEtranger)) if(length(names(fondEtranger))<3) msg_error20 <- "Le fond etranger n'est pas conforme. La table doit contenir au minimum une variable identifiant, une variable libelle et la geometry / "
if(any(!is.null(msg_error1),!is.null(msg_error2),!is.null(msg_error3),!is.null(msg_error4),
!is.null(msg_error5),!is.null(msg_error6),!is.null(msg_error7),!is.null(msg_error8),
!is.null(msg_error10),!is.null(msg_error11),!is.null(msg_error12),!is.null(msg_error13),
!is.null(msg_error14),!is.null(msg_error15),!is.null(msg_error16),!is.null(msg_error17),
!is.null(msg_error18),!is.null(msg_error19),!is.null(msg_error20)))
{
stop(simpleError(paste0(msg_error1,msg_error2,msg_error3,msg_error4,msg_error5,msg_error6,msg_error7,msg_error8,
msg_error10,msg_error11,msg_error12,msg_error13,msg_error14,msg_error15,msg_error16,msg_error17,msg_error18,msg_error19,msg_error20)))
}
nb_up <- reactiveValues(a=0)
nb_down <- reactiveValues(a=0)
ordre_analyse <- reactiveValues(a=1,b=2)
insert_save <- reactiveValues(a=0)
remove_carte <- reactiveValues(a=0)
liste_fonds <- reactiveValues(a=c("analyse","maille","contour"))
m_save_ou <- reactiveValues(a=0)
flux_min <- reactiveValues(a=100)
distance_max <- reactiveValues(a=300)
flux_majeur <- reactiveValues(a=10)
erreur_maille <- reactiveValues(a=FALSE)
sourc <- "Source : Insee"
names(data)[names(data)==idDataDepart] <- "CODE1"
names(data)[names(data)==idDataArrivee] <- "CODE2"
names(fondMaille)[1] <- "CODE"
names(fondMaille)[2] <- "LIBELLE"
names(fondContour)[1] <- "CODE"
names(fondContour)[2] <- "LIBELLE"
epsg_etranger <- NULL
if(!is.null(fondEtranger))
{
names(fondEtranger)[1] <- "CODE"
names(fondEtranger)[2] <- "LIBGEO"
fondEtranger$LIBGEO<-iconv(fondEtranger$LIBGEO,"latin1","utf8")
if(substr(st_crs(fondEtranger)[1]$input,1,5) == "EPSG:")
{
epsg_etranger <- substr(st_crs(fondEtranger)[1]$input,6,9)
}else
{
epsg_etranger <- st_crs(fondEtranger)[1]$input
}
if(is.na(epsg_etranger) | epsg_etranger=="4326")
{
epsg_etranger <- "3395"
}
}
if(!is.null(fondSuppl))
{
names(fondSuppl)[1] <- "CODE"
names(fondSuppl)[2] <- "LIBELLE"
fondSuppl$LIBELLE<-iconv(fondSuppl$LIBELLE,"latin1","utf8")
}
fondMaille$LIBELLE<-iconv(fondMaille$LIBELLE,"latin1","utf8")
fondContour$LIBELLE<-iconv(fondContour$LIBELLE,"latin1","utf8")
ui <- navbarPage("OCEANIS", id="menu",
theme = shinytheme("superhero"),
tabPanel("Carte",value="carte",
sidebarLayout(
sidebarPanel(width = 3,
style = "overflow-y:scroll; min-height: 1000px; max-height: 1000px",
h4(HTML("<b><font color=
uiOutput("variable_flux_ou"),
tags$hr(style="border: 5px solid
h4(HTML("<b><font color=
fluidRow(
column(width=9, offset=0.5,
uiOutput("ordre_fonds_ou")
),
column(width=1,
br(),
br(),
htmlOutput("monter_fond_ou", inline=FALSE),
htmlOutput("descendre_fond_ou", inline=FALSE)
)
),
uiOutput("ajout_territoire_ou"),
uiOutput("ajout_reg_ou"),
uiOutput("ajout_dep_ou"),
tags$hr(style="border: 5px solid
h4(HTML("<b><font color=
uiOutput("flux_min_ou"),
uiOutput("distance_max_ou"),
uiOutput("flux_majeur_ou"),
uiOutput("epaisseur_trait_ou"),
uiOutput("decalage_aller_retour_ou"),
uiOutput("decalage_centroid_ou"),
tags$hr(style="border: 5px solid
h4(HTML("<b><font color=
uiOutput("save_carte_ou"),
br(),
tags$div(class="dropup",
HTML('<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Exporter en projet Qgis
<span class="caret"></span>
</button>'),
tags$ul(class="dropdown-menu",
wellPanel(
style="background:
h4("Export de la carte en projet Qgis"),
br(),
uiOutput("sortie_qgis_ou"),
br(),
uiOutput("titre1_qgis_ou"),
uiOutput("titre2_qgis_ou"),
uiOutput("source_qgis_ou"),
tags$head(tags$style(HTML('
uiOutput("export_qgis_ou")
)
)
),
br(),
uiOutput("aide_image_ou"),
br()
),
mainPanel(
tags$head(
tags$style(HTML(".leaflet-container { background:
),
tabsetPanel(id="onglets_ou",
tabPanel(title=HTML("<b>Carte</b>"),value="carte",
leafletOutput("mymap_ou",width="112%",height = 950)
),
tabPanel(title=HTML(paste0("<b>Donn","\u00e9","es</b>")),value="donnees",
h5("S\u00e9lectionnez une ou plusieurs lignes pour ensuite les visualiser sur la carte."),
DT::dataTableOutput("mydonnees_ou",width="112%",height = 950)),
tabPanel(title=HTML("<b>Maille</b>"),value="maille",
h5("S\u00e9lectionnez une ou plusieurs lignes pour ensuite les visualiser sur la carte."),
DT::dataTableOutput("mymaille_ou",width="112%",height = 950)),
tabPanel(title=HTML("<b>Contour</b>"),value="contour",
h5("S\u00e9lectionnez une ou plusieurs lignes pour ensuite les visualiser sur la carte."),
DT::dataTableOutput("mycontour_ou",width="112%",height = 950))
)
)
)
)
)
server <- function(input, output, session) {
observe({
output$variable_flux_ou <- renderUI({
selectInput("variable_flux_ou_id", label=h5("Variable des flux (en volume)"), choices = varFlux, selected = varFlux)
})
output$ordre_fonds_ou <- renderUI({
selectInput("ordre_fonds_ou_id", label=h5("Modifier l'ordre des fonds"), choices = liste_fonds$a, multiple=TRUE, selectize=FALSE, selected = "analyse")
})
output$monter_fond_ou <- renderUI({
actionButton("monter_fond_ou_id", label="", icon=icon("arrow-up"))
})
output$descendre_fond_ou <- renderUI({
actionButton("descendre_fond_ou_id", label="", icon=icon("arrow-down"))
})
output$ajout_territoire_ou <- renderUI({
checkboxInput("ajout_territoire_ou_id", label = "Afficher le fond des territoires",
value = if(is.null(fondSuppl)) FALSE else TRUE)
})
output$ajout_reg_ou <- renderUI({
checkboxInput("ajout_reg_ou_id", label = "Afficher le fond des r\u00e9gions",
value = FALSE)
})
output$ajout_dep_ou <- renderUI({
checkboxInput("ajout_dep_ou_id", label = "Afficher le fond des d\u00e9partements",
value = FALSE)
})
output$flux_min_ou <- renderUI({
numericInput("flux_min_ou_id", label = h5("Seuil de flux minimal"), value=flux_min$a, step=10)
})
output$distance_max_ou <- renderUI({
numericInput("distance_max_ou_id", label = h5("Seuil de distance maximale (km)"), value=distance_max$a, step=10)
})
output$flux_majeur_ou <- renderUI({
numericInput("flux_majeur_ou_id", label = h5("Nombre de flux majeurs"), value=flux_majeur$a, step=1)
})
output$epaisseur_trait_ou <- renderUI({
sliderInput("epaisseur_trait_ou_id", label = h5(paste0("Epaisseur des traits")), value=2, min=1, max=5, step=1, ticks = TRUE)
})
output$decalage_aller_retour_ou <- renderUI({
numericInput("decalage_aller_retour_ou_id", label = h5(paste0("D","\u00e9","calage des lignes allers-retours (km)")), value=decalageAllerRetour, step=1)
})
output$decalage_centroid_ou <- renderUI({
numericInput("decalage_centroid_ou_id", label = h5(paste0("D","\u00e9","calage des lignes du centroid (km)")), value=decalageCentroid, step=1)
})
output$save_carte_ou <- renderUI({
actionButton("save_carte_ou_id", label=HTML("<font size=3>Sauvegarder la carte dans un onglet</font>"), style="color:
})
output$entrees_qgis_ou <- renderUI({
actionButton("entrees_qgis_ou_id", label="Exporter en projet Qgis")
})
output$sortie_qgis_ou <- renderUI({
tags$div(class="input-group",
HTML('<input type="text" id="sortie_qgis_ou_id" class="form-control" placeholder="Nom du projet" aria-describedby="sortie_qgis_ou_id">
<span class="input-group-addon" id="sortie_qgis_ou_id">.qgs</span>'))
})
output$titre1_qgis_ou <- renderUI({
textInput("titre1_qgis_ou_id", label = h5("Titre informatif"), value = "", placeholder= "Facultatif")
})
output$titre2_qgis_ou <- renderUI({
textInput("titre2_qgis_ou_id", label = h5("Titre descriptif"), value = "", placeholder= "Facultatif")
})
output$source_qgis_ou <- renderUI({
textInput("source_qgis_ou_id", label = h5("Source de la carte"), value = sourc)
})
output$aide_image_ou <- renderUI({
tags$div(class="dropup",
HTML(paste0('<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
<i class="fa fa-book fa-fw" aria-hidden="true"></i>
Proc','\u00e9','dure pour capture d\'','\u00e9','cran
<span class="caret"></span>
</button>')),
tags$ul(class="dropdown-menu",
wellPanel(
style="background:
div(
HTML("<font size=2>Deux possibilit\u00e9s :</font>"),
br(),
br(),
strong(HTML("<font size=3>Par l'Outil Capture</font>")),
br(),
HTML("<font size=2>1- Ouvrir un logiciel de capture (Outil Capture de Windows par exemple).</font>"),
br(),
HTML(paste0("<font size=2>2- S\u00e9lectionner la zone \u00e0 capturer.</font>")),
br(),
HTML("<font size=2>3- Enregistrer l'image ou copier la dans le presse-papier.</font>"),
br(),
br(),
strong(HTML(paste0("<font size=3>Par impression d'","\u00e9","cran</font>"))),
br(),
HTML("<font size=2>1- Appuyer sur la touche clavier \"Impr ecran\".</font>"),
br(),
HTML("<font size=2>2- Ouvrir un logiciel de retouche image (Paint par exemple).</font>"),
br(),
HTML("<font size=2>3- Coller l'image et l'enregistrer au format voulu (.jpg, .png, .bmp).</font>")
)
)
)
)
})
})
observeEvent(list(input$monter_fond_ou_id,input$descendre_fond_ou_id),{
if(as.numeric(input$monter_fond_ou_id)==0 & as.numeric(input$descendre_fond_ou_id)==0) return(NULL)
ordre <- c()
if(as.numeric(input$monter_fond_ou_id)>nb_up$a)
{
ordre <- c(2,3)
nb_up$a <- nb_up$a+1
}
if(as.numeric(input$descendre_fond_ou_id)>nb_down$a)
{
ordre <- c(1,2)
nb_down$a <- nb_down$a+1
}
if(is.null(input$ordre_fonds_ou_id)) pos_select <- 0 else pos_select <- which(liste_fonds$a==input$ordre_fonds_ou_id)
if(pos_select>0)
{
if(pos_select==ordre[1]) liste_fonds$a <- liste_fonds$a[c(2,1,3)]
if(pos_select==ordre[2]) liste_fonds$a <- liste_fonds$a[c(1,3,2)]
updateSelectInput(session, "ordre_fonds_ou_id",
choices = liste_fonds$a,
selected = input$ordre_fonds_ou_id
)
}
},ignoreInit = TRUE)
flux_min_ou <- reactive({
if(is.null(input$flux_min_ou_id)) return(flux_min$a)
return(input$flux_min_ou_id)
})
distance_max_ou <- reactive({
if(is.null(input$distance_max_ou_id)) return(distance_max$a)
return(input$distance_max_ou_id)
})
flux_majeur_ou <- reactive({
if(is.null(input$flux_majeur_ou_id)) return(flux_majeur$a)
return(input$flux_majeur_ou_id)
})
output$export_qgis_ou <- renderUI({
downloadButton("downloadProjetQgis_ou", label="Exporter")
})
output$downloadProjetQgis_ou <- downloadHandler(contentType = "zip",
filename = function(){
paste0(input$sortie_qgis_ou_id,".zip")
},
content = function(file){
owd <- setwd(tempdir())
on.exit(setwd(owd))
rep_sortie <- dirname(file)
dir.create("layers",showWarnings = F)
files <- EXPORT_PROJET_QGIS_OU(file)
zip::zip(zipfile = paste0("./",basename(file)),
files = files,
mode = "cherry-pick")
}
)
EXPORT_PROJET_QGIS_OU <- function(file)
{
showModal(modalDialog(HTML("<i class=\"fa fa-spinner fa-spin fa-2x fa-fw\"></i> <font size=+1>Export du projet Qgis en cours...</font> "), size="m", footer=NULL, style = "color:
sortie <- input$sortie_qgis_ou_id
files <- c("layers", paste0(sortie,".qgs"))
rep_sortie <- dirname(file)
fond_flux <- analyse_apres_filtre_ou()[[1]]
fond_flux <- st_transform(fond_flux, crs= as.numeric(code_epsg_ou()))
fond_maille <- st_transform(fondMaille, crs= as.numeric(code_epsg_ou()))
fond_contour <- st_transform(fondContour, crs= as.numeric(code_epsg_ou()))
if(!is.null(fondSuppl) && input$ajout_territoire_ou_id) fond_territoire <- st_transform(fond_territoire_ou(), crs= as.numeric(code_epsg_ou()))
if(input$ajout_dep_ou_id) fond_departement <- st_transform(fond_departement_ou(), crs= as.numeric(code_epsg_ou()))
if(input$ajout_reg_ou_id) fond_region <- st_transform(fond_region_ou(), crs= as.numeric(code_epsg_ou()))
fond_france <- st_transform(fond_habillage_ou()[[1]], crs= as.numeric(code_epsg_ou()))
fond_pays <- st_transform(fond_habillage_ou()[[2]], crs= as.numeric(code_epsg_ou()))
suppressWarnings(st_write(fond_flux, paste0(rep_sortie,"/layers/fond_flux.shp"), delete_dsn = TRUE, quiet = TRUE))
suppressWarnings(st_write(fond_maille, paste0(rep_sortie,"/layers/fond_maille.shp"), delete_dsn = TRUE, quiet = TRUE))
suppressWarnings(st_write(fond_contour,paste0(rep_sortie,"/layers/fond_contour.shp"), delete_dsn = TRUE, quiet = TRUE))
if(exists("fond_territoire")) if(!is.null(fond_territoire)) suppressWarnings(st_write(fond_territoire, paste0(rep_sortie,"/layers/fond_territoire.shp"), delete_dsn = TRUE, quiet = TRUE))
if(exists("fond_departement")) if(!is.null(fond_departement)) suppressWarnings(st_write(fond_departement, paste0(rep_sortie,"/layers/fond_departement.shp"), delete_dsn = TRUE, quiet = TRUE))
if(exists("fond_region")) if(!is.null(fond_region)) suppressWarnings(st_write(fond_region,paste0(rep_sortie,"/layers/fond_region.shp"), delete_dsn = TRUE, quiet = TRUE))
suppressWarnings(st_write(fond_france,paste0(rep_sortie,"/layers/fond_france.shp"), delete_dsn = TRUE, quiet = TRUE))
if(exists("fond_pays")) if(!is.null(fond_pays)) suppressWarnings(st_write(fond_pays,paste0(rep_sortie,"/layers/fond_pays.shp"), delete_dsn = TRUE, quiet = TRUE))
chemin_fonds <- rep_sortie
titre1 <- paste0(input$titre1_qgis_ou_id,"\n")
titre2 <- input$titre2_qgis_ou_id
source <- input$source_qgis_ou_id
annee <- format(Sys.time(), format = "%Y")
variable_a_representer <- varFlux
l <- c()
l <- c(l,"fond_flux")
l <- c(l,"fond_france","fond_contour","fond_maille")
if(exists("fond_territoire")) l <- c(l,"fond_territoire")
if(exists("fond_departement")) l <- c(l,"fond_departement")
if(exists("fond_region")) l <- c(l,"fond_region")
if(exists("fond_pays")) l <- c(l,"fond_pays")
export_projet_qgis_oursins(l,rep_sortie,sortie,titre1,titre2,source,2,"
removeModal()
showModal(modalDialog(HTML(paste0("<font size=+1>Le projet Qgis a \u00e9t\u00e9 cr","\u00e9","ee.</font>")), size="m", footer=NULL, easyClose = TRUE, style = "color:
return(files)
}
code_epsg_ou <- reactive({
code_epsg <- switch(emprise,
"FRM"="2154",
"971"="5490",
"972"="5490",
"973"="2972",
"974"="2975",
"976"="4471",
"999"=epsg_etranger)
return(code_epsg)
})
analyse_ou <- reactive({
req(input$decalage_aller_retour_ou_id,input$decalage_centroid_ou_id)
suppressWarnings(test_k_oursins <- try(k_oursins(fondMaille,names(fondMaille)[1],data,"CODE1","CODE2",varFlux,input$decalage_aller_retour_ou_id,input$decalage_centroid_ou_id),silent=TRUE))
if(!class(test_k_oursins) %in% "try-error")
{
analyse<-k_oursins(fondMaille,names(fondMaille)[1],data,"CODE1","CODE2",varFlux,input$decalage_aller_retour_ou_id,input$decalage_centroid_ou_id)
}else
{
showModal(modalDialog(HTML(paste0("<font size=+1>La maille ne correspond pas au niveau g\u00e9ographique du fichier de donn","\u00e9","es.<br><br>Veuillez svp choisir une maille adapt","\u00e9","e ou modifier le fichier de donn","\u00e9","es.</font>")), size="l", footer=NULL, easyClose = TRUE, style = "color:
erreur_maille$a <- TRUE
return(NULL)
}
if(is.null(analyse))
{
showModal(modalDialog(HTML(paste0("<font size=+1>La maille ne correspond pas au niveau g\u00e9ographique du fichier de donn","\u00e9","es.<br><br>Veuillez svp choisir une maille adapt","\u00e9","e ou modifier le fichier de donn","\u00e9","es.</font>")), size="l", footer=NULL, easyClose = TRUE, style = "color:
erreur_maille$a <- TRUE
return(NULL)
}
analyse_WGS84 <- st_transform(analyse[[1]],crs=4326)
return(list(analyse[[1]],analyse_WGS84))
})
fond_habillage_ou <- reactive({
if(emprise=="FRM")
{
fond_pays <- st_transform(sf_paysm(),crs=4326)
fond_france <- st_transform(sf_fram(),crs=4326)
}else if(emprise!="999")
{
if(emprise=="971")
{
fond_france <- st_transform(sf_reg01(),crs=4326)
fond_pays <- fond_france
}
if(emprise=="972")
{
fond_france <- st_transform(sf_reg02(),crs=4326)
fond_pays <- fond_france
}
if(emprise=="973")
{
fond_france <- st_transform(sf_reg03(),crs=4326)
fond_pays <- st_transform(sf_pays973(),crs=4326)
}
if(emprise=="974")
{
fond_france <- st_transform(sf_reg04(),crs=4326)
fond_pays <- fond_france
}
if(emprise=="976")
{
fond_france <- st_transform(sf_reg06(),crs=4326)
fond_pays <- fond_france
}
}else if(emprise=="999")
{
fond_france <- st_transform(fondEtranger,crs=4326)
fond_pays <- fond_france
}else{}
return(list(fond_france,fond_pays))
})
fond_contour_maille_ou <- reactive({
test_contour <- try(st_transform(fondContour,crs=4326), silent = TRUE)
test_maille <- try(st_transform(fondMaille,crs=4326), silent = TRUE)
if(any(list(class(test_contour),class(test_maille)) %in% "try-error"))
{
showModal(modalDialog(HTML(paste0("<font size=+1>Une erreur est survenue dans la cr","\u00e9","ation du territoire.<br><br>Veuillez svp v\u00e9rifier vos donn","\u00e9","es et les variables choisies.</font>")), size="m", footer=NULL, easyClose = TRUE, style = "color:
erreur_maille$a <- TRUE
return(NULL)
}else
{
contour_WGS84 <- st_transform(fondContour,crs=4326)
maille_WGS84 <- st_transform(fondMaille,crs=4326)
}
return(list(contour_WGS84,maille_WGS84))
})
list_bbox_ou <- reactive({
req(fond_contour_maille_ou())
list_bbox <- list(c(st_bbox(fond_contour_maille_ou()[[1]])[1],st_bbox(fond_contour_maille_ou()[[1]])[3]),c(st_bbox(fond_contour_maille_ou()[[1]])[2],st_bbox(fond_contour_maille_ou()[[1]])[4]))
return(list_bbox)
})
fond_territoire_ou <- reactive({
if(!is.null(fondSuppl))
{
fond_territoire <- st_transform(fondSuppl,crs=4326)
return(fond_territoire)
}else
{
return(NULL)
}
})
fond_region_ou <- reactive({
fond_region <- st_transform(sf_regm(),crs=4326)
return(fond_region)
})
fond_departement_ou <- reactive({
fond_departement <- st_transform(sf_depm(),crs=4326)
return(fond_departement)
})
fond_select_donnees_ou <- reactive({
req(analyse_apres_filtre_ou())
fond_donnees <- analyse_apres_filtre_ou()[[1]][input$mydonnees_ou_rows_selected,]
return(fond_donnees)
})
fond_select_maille_ou <- reactive({
req(fond_contour_maille_ou())
fond_maille <- fond_contour_maille_ou()[[2]][as.data.frame(fond_contour_maille_ou()[[2]])[,"CODE"] %in% as.data.frame(fondMaille)[input$mymaille_ou_rows_selected,"CODE"],]
return(fond_maille)
})
fond_select_contour_ou <- reactive({
req(fond_contour_maille_ou())
fond_contour <- fond_contour_maille_ou()[[1]][as.data.frame(fond_contour_maille_ou()[[1]])[,"CODE"] %in% as.data.frame(fondContour)[input$mycontour_ou_rows_selected,"CODE"],]
return(fond_contour)
})
analyse_apres_filtre_ou <- reactive({
req(analyse_ou(),flux_majeur_ou(),distance_max_ou(),flux_min_ou())
if(flux_majeur_ou()>nrow(analyse_ou()[[2]]))
{
nb_flux_majeur <- nrow(analyse_ou()[[2]])
}else
{
nb_flux_majeur <- flux_majeur_ou()
if(nb_flux_majeur<1) nb_flux_majeur <- 1
}
analyse_WGS84_list <- split(analyse_ou()[[2]],factor(analyse_ou()[[2]]$CODE1))
analyse_WGS84_1 <- data.frame()
aa <- lapply(1:length(analyse_WGS84_list), function(x) analyse_WGS84_1 <<- rbind(analyse_WGS84_1,as.data.frame(analyse_WGS84_list[[x]])[rev(order(as.data.frame(analyse_WGS84_list[[x]])[,varFlux]))[c(1:nb_flux_majeur)],]))
analyse_WGS84_1 <- analyse_WGS84_1[!is.na(analyse_WGS84_1[,varFlux]),]
analyse_WGS84_list <- split(analyse_ou()[[2]],factor(analyse_ou()[[2]]$CODE2))
analyse_WGS84_2 <- data.frame()
aa <- lapply(1:length(analyse_WGS84_list), function(x) analyse_WGS84_2 <<- rbind(analyse_WGS84_2,as.data.frame(analyse_WGS84_list[[x]])[rev(order(as.data.frame(analyse_WGS84_list[[x]])[,varFlux]))[c(1:nb_flux_majeur)],]))
analyse_WGS84_2 <- analyse_WGS84_2[!is.na(analyse_WGS84_2[,varFlux]),]
analyse_WGS84 <- unique(rbind(analyse_WGS84_1,analyse_WGS84_2))
analyse_WGS84 <- st_as_sf(analyse_WGS84)
analyse_WGS84 <- analyse_WGS84[as.vector(st_length(analyse_WGS84))<=distance_max_ou()*1000,]
analyse_WGS84 <- analyse_WGS84[as.data.frame(analyse_WGS84)[,varFlux]>=flux_min_ou(),]
analyse_WGS84 <- analyse_WGS84[rev(order(as.data.frame(analyse_WGS84)[,varFlux])),]
donnees <- merge(as.data.frame(analyse_WGS84)[,c("CODE1","CODE2")],data,by=c("CODE1","CODE2"),all.x=T)
donnees <- sort(donnees[,varFlux], decreasing = TRUE)
return(list(analyse_WGS84,donnees))
})
analyse_apres_filtre_init_ou <- reactive({
req(analyse_ou())
if(nrow(analyse_ou()[[2]])<10)
{
nb_flux_majeur <- nrow(analyse_ou()[[2]])
}else
{
nb_flux_majeur <- 10
}
analyse_WGS84_list <- split(analyse_ou()[[2]],factor(analyse_ou()[[2]]$CODE1))
analyse_WGS84_1 <- data.frame()
aa <- lapply(1:length(analyse_WGS84_list), function(x) analyse_WGS84_1 <<- rbind(analyse_WGS84_1,as.data.frame(analyse_WGS84_list[[x]])[rev(order(as.data.frame(analyse_WGS84_list[[x]])[,varFlux]))[c(1:nb_flux_majeur)],]))
analyse_WGS84_1 <- analyse_WGS84_1[!is.na(analyse_WGS84_1[,varFlux]),]
analyse_WGS84_list <- split(analyse_ou()[[2]],factor(analyse_ou()[[2]]$CODE2))
analyse_WGS84_2 <- data.frame()
aa <- lapply(1:length(analyse_WGS84_list), function(x) analyse_WGS84_2 <<- rbind(analyse_WGS84_2,as.data.frame(analyse_WGS84_list[[x]])[rev(order(as.data.frame(analyse_WGS84_list[[x]])[,varFlux]))[c(1:nb_flux_majeur)],]))
analyse_WGS84_2 <- analyse_WGS84_2[!is.na(analyse_WGS84_2[,varFlux]),]
analyse_WGS84 <- unique(rbind(analyse_WGS84_1,analyse_WGS84_2))
analyse_WGS84 <- st_as_sf(analyse_WGS84)
analyse_WGS84 <- analyse_WGS84[as.vector(st_length(analyse_WGS84))<=300*1000,]
analyse_WGS84 <- analyse_WGS84[as.data.frame(analyse_WGS84)[,varFlux]>=100,]
analyse_WGS84 <- analyse_WGS84[rev(order(as.data.frame(analyse_WGS84)[,varFlux])),]
donnees <- merge(as.data.frame(analyse_WGS84)[,c("CODE1","CODE2")],data,by=c("CODE1","CODE2"),all.x=T)
donnees <- sort(donnees[,varFlux], decreasing = TRUE)
return(list(analyse_WGS84,donnees))
})
react_fond_ou <- reactive({
if(input$menu=="carte")
{
showModal(modalDialog(HTML("<i class=\"fa fa-spinner fa-spin fa-2x fa-fw\"></i><font size=+1>\u00c9laboration de la carte...</font> "), size="m", footer=NULL, style = "color:
if(is.null(fondEtranger))
{
proj4 <- st_crs(fondMaille)$proj4string
}else{
proj4 <- st_crs(fondEtranger)$proj4string
}
m <- leaflet(padding = 0,
options = leafletOptions(
preferCanvas = TRUE,
transition = 2,
crs = leafletCRS(crsClass = "L.Proj.CRS",
code = paste0("EPSG:", code_epsg_ou()),
proj4def = proj4,
resolutions = 2^(16:1)
)
)) %>%
setMapWidgetStyle(list(background = "
addTiles_insee(attribution = paste0("<a href=\"http://www.insee.fr\">OCEANIS - \u00A9 IGN - INSEE ",format(Sys.time(), format = "%Y"),"</a>")) %>%
fitBounds(lng1 = min(list_bbox_ou()[[1]]),
lat1 = min(list_bbox_ou()[[2]]),
lng2 = max(list_bbox_ou()[[1]]),
lat2 = max(list_bbox_ou()[[2]])
) %>%
addScaleBar(position = 'bottomright',
options = scaleBarOptions(metric = TRUE, imperial = FALSE)
) %>%
addMapPane(name = "fond_pays", zIndex = 401) %>%
addMapPane(name = "fond_france", zIndex = 402) %>%
addMapPane(name = "fond_dep", zIndex = 403) %>%
addMapPane(name = "fond_reg", zIndex = 404) %>%
addMapPane(name = "fond_territoire", zIndex = 405) %>%
addMapPane(name = "fond_trio3", zIndex = 406) %>%
addMapPane(name = "fond_trio2", zIndex = 407) %>%
addMapPane(name = "fond_trio1", zIndex = 408) %>%
addMapPane(name = "selection", zIndex = 409) %>%
addMapPane(name = "fond_legende", zIndex = 410)
if(emprise %in% c("FRM","973"))
{
m <- addPolygons(map = m, data = fond_habillage_ou()[[2]][,"LIBGEO"], opacity = 1,
stroke = TRUE, color = "white",
weight = 1,
options = pathOptions(pane = "fond_pays", clickable = F),
fill = T, fillColor = "
)
}
m <- addPolygons(map = m, data = fond_habillage_ou()[[1]][,"LIBGEO"], opacity = 1,
stroke = TRUE, color = "black",
weight = 1.5,
options = pathOptions(pane = "fond_france", clickable = F),
fill = T, fillColor = "white", fillOpacity = 1
)
m_save_ou$a <- m
if(!is.null(fondSuppl))
{
m <- addPolygons(map = m, data = fond_territoire_ou(),
stroke = TRUE, color = "
weight = 0.5,
options = pathOptions(pane = "fond_territoire", clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.001,
group = "territoire"
)
}
m <- addPolygons(map = m, data = fond_contour_maille_ou()[[1]], opacity = 0.3,
stroke = TRUE, color = "black", weight = 3,
options = pathOptions(pane = "fond_trio3", clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.3,
group = "maille_contour"
)
m <- addPolygons(map = m, data = fond_contour_maille_ou()[[2]], opacity = 1,
stroke = TRUE, color = "grey", weight = 1,
options = pathOptions(pane = "fond_trio2", clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.001,
group = "maille_contour"
)
analyse_WGS84 <- analyse_apres_filtre_init_ou()[[1]]
donnees <- analyse_apres_filtre_init_ou()[[2]]
m <- addPolylines(map = m,
data = analyse_WGS84,
stroke = TRUE, color = "
opacity = 1,
weight = 2,
options = pathOptions(pane = "fond_trio1", clickable = T),
popup = paste0("<b><font color=
group = "fleche"
)
removeModal()
showModal(modalDialog(HTML("<font size=+1>Veuillez patientez svp, la carte va s'afficher dans quelques secondes...</font> "), size="m", footer=NULL, easyClose = TRUE, style = "color:
return(m)
}
})
observeEvent(input$ajout_territoire_ou_id,{
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "territoire")
if(!is.null(fondSuppl))
{
if(input$ajout_territoire_ou_id)
{
proxy <- addPolygons(map = proxy, data = fond_territoire_ou(),
stroke = TRUE, color = "
weight = 0.5,
options = pathOptions(pane = "fond_territoire", clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.001,
group = "territoire"
)
}
}
},ignoreInit = TRUE)
observeEvent(input$ajout_reg_ou_id,{
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "region")
if(emprise=="FRM")
{
if(input$ajout_reg_ou_id)
{
proxy <- addPolygons(map = proxy, data = fond_region_ou(),
stroke = TRUE, color = "grey", opacity = 1,
weight = 1.5,
options = pathOptions(pane = "fond_reg", clickable = F),
fill = F,
group = "region"
)
}
}
},ignoreInit = TRUE)
observeEvent(input$ajout_dep_ou_id,{
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "departement")
if(emprise=="FRM")
{
if(input$ajout_dep_ou_id)
{
proxy <- addPolygons(map = proxy, data = fond_departement_ou(),
stroke = TRUE, color = "grey", opacity = 1,
weight = 0.5,
options = pathOptions(pane = "fond_dep", clickable = F),
fill = F,
group = "departement"
)
}
}
},ignoreInit = TRUE)
observeEvent(list(input$monter_fond_ou_id,input$descendre_fond_ou_id),{
if(as.numeric(input$monter_fond_ou_id)==0 & as.numeric(input$descendre_fond_ou_id)==0) return(NULL)
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "maille_contour")
clearGroup(map = proxy, group = "fleche")
i <- 1
for(fond in liste_fonds$a)
{
if(fond=="analyse")
{
analyse_WGS84 <- analyse_apres_filtre_ou()[[1]]
donnees <- analyse_apres_filtre_ou()[[2]]
proxy <- addPolylines(map = proxy,
data = analyse_WGS84,
stroke = TRUE, color = "
opacity = 1,
weight = input$epaisseur_trait_ou_id,
options = pathOptions(pane = paste0("fond_trio",i), clickable = T),
popup = paste0("<b><font color=
group = "fleche"
)
ordre_analyse$a <- i
}
if(fond=="maille")
{
proxy <- addPolygons(map = proxy, data = fond_contour_maille_ou()[[2]], opacity = 1,
stroke = TRUE, color = "grey", weight = 1,
options = pathOptions(pane = paste0("fond_trio",i), clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.001,
group = "maille_contour"
)
}
if(fond=="contour")
{
proxy <- addPolygons(map = proxy, data = fond_contour_maille_ou()[[1]], opacity = 0.3,
stroke = TRUE, color = "black", weight = 3,
options = pathOptions(pane = paste0("fond_trio",i), clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.3,
group = "maille_contour"
)
}
i <- i + 1
}
},ignoreInit = TRUE)
observeEvent(list(input$flux_min_ou_id,input$distance_max_ou_id,input$flux_majeur_ou_id,input$epaisseur_trait_ou_id,input$decalage_aller_retour_ou_id,input$decalage_centroid_ou_id),{
req(input$flux_min_ou_id,input$distance_max_ou_id,input$flux_majeur_ou_id,input$epaisseur_trait_ou_id,input$decalage_aller_retour_ou_id,input$decalage_centroid_ou_id)
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "fleche")
analyse_WGS84 <- analyse_apres_filtre_ou()[[1]]
donnees <- analyse_apres_filtre_ou()[[2]]
proxy <- addPolylines(map = proxy,
data = analyse_WGS84,
stroke = TRUE, color = "
opacity = 1,
weight = input$epaisseur_trait_ou_id,
options = pathOptions(pane = paste0("fond_trio",ordre_analyse$a), clickable = T),
popup = paste0("<b><font color=
group = "fleche"
)
},ignoreInit = TRUE)
observeEvent(input$onglets_ou,{
req(input$onglets_ou)
if(input$onglets_ou == "carte")
{
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "select_donnees")
if(!is.null(input$mydonnees_ou_rows_selected))
{
fond_select_donnees <- st_transform(fond_select_donnees_ou(),crs=4326)
proxy <- addPolylines(map = proxy,
data = fond_select_donnees,
stroke = TRUE, color = "
opacity = 1,
weight = input$epaisseur_trait_ou_id,
options = pathOptions(pane = "selection", clickable = F),
fill = F,
group = "select_donnees"
)
}
}
},ignoreInit = TRUE)
observeEvent(input$onglets_ou,{
req(input$onglets_ou)
if(input$onglets_ou == "carte")
{
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "select_maille")
if(!is.null(input$mymaille_ou_rows_selected))
{
proxy <- addPolygons(map = proxy, data = fond_select_maille_ou(),
stroke = FALSE,
options = pathOptions(pane = "selection", clickable = F),
fill = T,
fillColor = "
fillOpacity = 1,
group = "select_maille"
)
}
}
},ignoreInit = TRUE)
observeEvent(input$onglets_ou,{
req(input$onglets_ou)
if(input$onglets_ou == "carte")
{
proxy <- leafletProxy("mymap_ou")
clearGroup(map = proxy, group = "select_contour")
if(!is.null(input$mycontour_ou_rows_selected))
{
proxy <- addPolygons(map = proxy, data = fond_select_contour_ou(),
stroke = FALSE,
options = pathOptions(pane = "selection", clickable = F),
fill = T,
fillColor = "
fillOpacity = 1,
group = "select_contour"
)
}
}
},ignoreInit = TRUE)
observeEvent(input$save_carte_ou_id,{
showModal(modalDialog(HTML("<i class=\"fa fa-spinner fa-spin fa-2x fa-fw\"></i><font size=+1>Sauvegarde de la carte en cours...</font> "), size="m", footer=NULL, style = "color:
insert_save$a <- insert_save$a + 1
nb_save_carte <- insert_save$a-remove_carte$a
m_save <- m_save_ou$a
if(nb_save_carte>6)
{
insert_save$a <- insert_save$a - 1
showModal(modalDialog(HTML("<font size=+1>Vous ne pouvez pas sauvegarger plus de 6 cartes. Veuillez en supprimer avant de continuer.</font> "), size="l", footer=NULL, easyClose = TRUE, style = "color:
return(NULL)
}
output[[paste0("mymap_save_",insert_save$a,"_ou")]] <- renderLeaflet({
if(!is.null(fondSuppl))
{
if(isolate(input$ajout_territoire_ou_id))
{
m_save <- addPolygons(map = m_save, data = isolate(fond_territoire_ou()),
stroke = TRUE, color = "
weight = 0.5,
options = pathOptions(pane = "fond_territoire", clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.001
)
}
}
if(isolate(input$ajout_reg_ou_id))
{
m_save <- addPolygons(map = m_save, data = isolate(fond_region_ou()),
stroke = TRUE, color = "grey", opacity = 1,
weight = 1.5,
options = pathOptions(pane = "fond_reg", clickable = F),
fill = F
)
}
if(isolate(input$ajout_dep_ou_id))
{
m_save <- addPolygons(map = m_save, data = isolate(fond_departement_ou()),
stroke = TRUE, color = "grey", opacity = 1,
weight = 0.5,
options = pathOptions(pane = "fond_dep", clickable = F),
fill = F
)
}
i <- 1
for(fond in isolate(liste_fonds$a))
{
if(fond=="analyse")
{
analyse_WGS84 <- isolate(analyse_apres_filtre_ou())[[1]]
donnees <- isolate(analyse_apres_filtre_ou())[[2]]
m_save <- addPolylines(map = m_save,
data = analyse_WGS84,
stroke = TRUE, color = "
opacity = 1,
weight = isolate(input$epaisseur_trait_ou_id),
options = pathOptions(pane = paste0("fond_trio",i), clickable = T),
popup = paste0("<b><font color=
)
}
if(fond=="maille")
{
m_save <- addPolygons(map = m_save, data = isolate(fond_contour_maille_ou())[[2]], opacity = 1,
stroke = TRUE, color = "grey", weight = 1,
options = pathOptions(pane = paste0("fond_trio",i), clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.001
)
}
if(fond=="contour")
{
m_save <- addPolygons(map = m_save, data = isolate(fond_contour_maille_ou())[[1]], opacity = 0.3,
stroke = TRUE, color = "black", weight = 3,
options = pathOptions(pane = paste0("fond_trio",i), clickable = T),
popup = paste0("<b> <font color=
fill = T, fillColor = "white", fillOpacity = 0.3
)
}
i <- i + 1
}
removeModal()
m_save
})
output[[paste0("remove_carte_",nb_save_carte,"_ou")]] <- renderUI({
actionButton(paste0("remove_carte_",nb_save_carte,"_ou_id"),label="X Supprimer la carte", style="color:
})
appendTab(inputId = "onglets_ou",
tabPanel(title=HTML(paste0("<font color=
select = TRUE,
session = session
)
}, ignoreInit = TRUE)
observeEvent(input$remove_carte_1_ou_id,{
remove_carte$a <- remove_carte$a + 1
removeTab(inputId = "onglets_ou",
target = "carte1",
session = session
)
}, ignoreInit = TRUE)
observeEvent(input$remove_carte_2_ou_id,{
remove_carte$a <- remove_carte$a + 1
removeTab(inputId = "onglets_ou",
target = "carte2",
session = session
)
}, ignoreInit = TRUE)
observeEvent(input$remove_carte_3_ou_id,{
remove_carte$a <- remove_carte$a + 1
removeTab(inputId = "onglets_ou",
target = "carte3",
session = session
)
}, ignoreInit = TRUE)
observeEvent(input$remove_carte_4_ou_id,{
remove_carte$a <- remove_carte$a + 1
removeTab(inputId = "onglets_ou",
target = "carte4",
session = session
)
}, ignoreInit = TRUE)
observeEvent(input$remove_carte_5_ou_id,{
remove_carte$a <- remove_carte$a + 1
removeTab(inputId = "onglets_ou",
target = "carte5",
session = session
)
}, ignoreInit = TRUE)
observeEvent(input$remove_carte_6_ou_id,{
remove_carte$a <- remove_carte$a + 1
removeTab(inputId = "onglets_ou",
target = "carte6",
session = session
)
}, ignoreInit = TRUE)
output$mydonnees_ou <- DT::renderDataTable(DT::datatable({
analyse_WGS84 <- analyse_apres_filtre_ou()[[1]]
data <- as.data.frame(analyse_WGS84)
tableau_donnees <- data[,c("CODE1","CODE2",varFlux)]
}, style = 'bootstrap'
))
output$mymaille_ou <- DT::renderDataTable(DT::datatable({
data <- as.data.frame(fondMaille)
tableau_maille <- data[,c(1:2)]
}, style = 'bootstrap'
))
output$mycontour_ou <- DT::renderDataTable(DT::datatable({
data <- as.data.frame(fondContour)
tableau_contour <- data[,c(1:2)]
}, style = 'bootstrap'
))
output$mymap_ou <- renderLeaflet({
react_fond_ou()
})
}
runApp(shinyApp(ui = ui, server = server), launch.browser = TRUE)
} |
library(raster)
library(mlr)
library(sf)
library(tmap)
library(parallelMap)
data("lsl", package = "spDataLarge")
coords = lsl[, c("x", "y")]
data = dplyr::select(lsl, -x, -y)
task = makeClassifTask(data = data,
target = "lslpts",
positive = "TRUE",
coordinates = coords)
listLearners(task)
lrn_ksvm = makeLearner("classif.ksvm",
predict.type = "prob",
kernel = "rbfdot")
getLearnerPackages(lrn_ksvm)
helpLearner(lrn_ksvm)
perf_level = makeResampleDesc("SpRepCV", folds = 5, reps = 100)
tune_level = makeResampleDesc("SpCV", iters = 5)
ctrl = makeTuneControlRandom(maxit = 50)
ps = makeParamSet(
makeNumericParam("C", lower = -12, upper = 15, trafo = function(x) 2^x),
makeNumericParam("sigma", lower = -15, upper = 6, trafo = function(x) 2^x)
)
wrapper_ksvm = makeTuneWrapper(learner = lrn_ksvm,
resampling = tune_level,
par.set = ps,
control = ctrl,
show.info = FALSE,
measures = mlr::auc)
configureMlr(on.learner.error = "warn", on.error.dump = TRUE)
if (Sys.info()["sysname"] %in% c("Linux, Darwin")) {
parallelStart(mode = "multicore",
level = "mlr.tuneParams",
cpus = round(parallel::detectCores() / 2),
mc.set.seed = TRUE)
}
if (Sys.info()["sysname"] == "Windows") {
parallelStartSocket(level = "mlr.tuneParams",
cpus = round(parallel::detectCores() / 2))
}
set.seed(12345)
resa_svm_spatial = mlr::resample(learner = wrapper_ksvm,
task = task,
resampling = perf_level,
extract = getTuneResult,
show.info = TRUE,
measures = mlr::auc)
parallelStop()
saveRDS(resa_svm_spatial, "extdata/spatial_cv_result.rds")
resa_svm_spatial$runtime / 60
resa_svm_spatial$aggr
mean(resa_svm_spatial$measures.test$auc)
resa_svm_spatial$extract[[1]]
resa_svm_spatial$measures.test[1, ] |
options(width=60, prompt = "R> ", continue = "+ ", useFancyQuotes = FALSE)
library("graphics")
library("stats")
library("flexmix")
library("lattice")
ltheme <- canonical.theme("postscript", FALSE)
lattice.options(default.theme=ltheme)
data("NPreg", package = "flexmix")
data("dmft", package = "flexmix")
source("myConcomitant.R")
par(mfrow=c(1,2))
plot(yn~x, col=class, pch=class, data=NPreg)
plot(yp~x, col=class, pch=class, data=NPreg)
suppressWarnings(RNGversion("3.5.0"))
set.seed(1802)
library("flexmix")
data("NPreg", package = "flexmix")
Model_n <- FLXMRglm(yn ~ . + I(x^2))
Model_p <- FLXMRglm(yp ~ ., family = "poisson")
m1 <- flexmix(. ~ x, data = NPreg, k = 2, model = list(Model_n, Model_p),
control = list(verbose = 10))
print(plot(m1))
m1.refit <- refit(m1)
summary(m1.refit, which = "model", model = 1)
print(plot(m1.refit, layout = c(1,3), bycluster = FALSE,
main = expression(paste(yn *tilde(" ")* x + x^2))),
split= c(1,1,2,1), more = TRUE)
print(plot(m1.refit, model = 2,
main = expression(paste(yp *tilde(" ")* x)),
layout = c(1,2), bycluster = FALSE),
split = c(2,1,2,1))
Model_n2 <- FLXMRglmfix(yn ~ . + 0, nested = list(k = c(1, 1),
formula = c(~ 1 + I(x^2), ~ 0)))
m2 <- flexmix(. ~ x, data = NPreg, cluster = posterior(m1),
model = list(Model_n2, Model_p))
m2
c(BIC(m1), BIC(m2))
data("betablocker", package = "flexmix")
betaGlm <- glm(cbind(Deaths, Total - Deaths) ~ Treatment,
family = "binomial", data = betablocker)
betaGlm
betaMixFix <- stepFlexmix(cbind(Deaths, Total - Deaths) ~ 1 | Center,
model = FLXMRglmfix(family = "binomial", fixed = ~ Treatment),
k = 2:4, nrep = 5, data = betablocker)
betaMixFix
betaMixFix_3 <- getModel(betaMixFix, which = "BIC")
betaMixFix_3 <- relabel(betaMixFix_3, "model", "Intercept")
parameters(betaMixFix_3)
library("grid")
betablocker$Center <- with(betablocker, factor(Center, levels = Center[order((Deaths/Total)[1:22])]))
clusters <- factor(clusters(betaMixFix_3), labels = paste("Cluster", 1:3))
print(dotplot(Deaths/Total ~ Center | clusters, groups = Treatment, as.table = TRUE,
data = betablocker, xlab = "Center", layout = c(3, 1),
scales = list(x = list(cex = 0.7, tck = c(1, 0))),
key = simpleKey(levels(betablocker$Treatment), lines = TRUE, corner = c(1,0))))
betaMixFix.fitted <- fitted(betaMixFix_3)
for (i in 1:3) {
seekViewport(trellis.vpname("panel", i, 1))
grid.lines(unit(1:22, "native"), unit(betaMixFix.fitted[1:22, i], "native"), gp = gpar(lty = 1))
grid.lines(unit(1:22, "native"), unit(betaMixFix.fitted[23:44, i], "native"), gp = gpar(lty = 2))
}
betaMix <- stepFlexmix(cbind(Deaths, Total - Deaths) ~ Treatment | Center,
model = FLXMRglm(family = "binomial"), k = 3, nrep = 5,
data = betablocker)
betaMix <- relabel(betaMix, "model", "Treatment")
parameters(betaMix)
c(BIC(betaMixFix_3), BIC(betaMix))
print(plot(betaMixFix_3, nint = 10, mark = 1, col = "grey", layout = c(3, 1)))
print(plot(betaMixFix_3, nint = 10, mark = 2, col = "grey", layout = c(3, 1)))
table(clusters(betaMix))
predict(betaMix,
newdata = data.frame(Treatment = c("Control", "Treated")))
betablocker[c(1, 23), ]
fitted(betaMix)[c(1, 23), ]
summary(refit(betaMix))
ModelNested <- FLXMRglmfix(family = "binomial", nested = list(k = c(2, 1),
formula = c(~ Treatment, ~ 0)))
betaMixNested <- flexmix(cbind(Deaths, Total - Deaths) ~ 1 | Center,
model = ModelNested, k = 3, data = betablocker,
cluster = posterior(betaMix))
parameters(betaMixNested)
c(BIC(betaMix), BIC(betaMixNested), BIC(betaMixFix_3))
data("bioChemists", package = "flexmix")
data("bioChemists", package = "flexmix")
Model1 <- FLXMRglm(family = "poisson")
ff_1 <- stepFlexmix(art ~ ., data = bioChemists, k = 1:3, model = Model1)
ff_1 <- getModel(ff_1, "BIC")
print(plot(refit(ff_1), bycluster = FALSE,
scales = list(x = list(relation = "free"))))
Model2 <- FLXMRglmfix(family = "poisson", fixed = ~ kid5 + mar + ment)
ff_2 <- flexmix(art ~ fem + phd, data = bioChemists,
cluster = posterior(ff_1), model = Model2)
c(BIC(ff_1), BIC(ff_2))
summary(refit(ff_2))
Model3 <- FLXMRglmfix(family = "poisson", fixed = ~ kid5 + mar + ment)
ff_3 <- flexmix(art ~ fem, data = bioChemists, cluster = posterior(ff_2),
model = Model3)
c(BIC(ff_2), BIC(ff_3))
print(plot(refit(ff_3), bycluster = FALSE, scales = list(x = list(relation = "free"))))
Model4 <- FLXMRglmfix(family = "poisson", fixed = ~ kid5 + mar + ment)
ff_4 <- flexmix(art ~ 1, data = bioChemists, cluster = posterior(ff_2),
concomitant = FLXPmultinom(~ fem), model = Model4)
parameters(ff_4)
summary(refit(ff_4), which = "concomitant")
BIC(ff_4)
Model5 <- FLXMRglmfix(family = "poisson", fixed = ~ kid5 + ment + fem)
ff_5 <- flexmix(art ~ 1, data = bioChemists, cluster = posterior(ff_2),
model = Model5)
BIC(ff_5)
pp <- predict(ff_5, newdata = data.frame(kid5 = 0,
mar = factor("Married", levels = c("Single", "Married")),
fem = c("Men", "Women"), ment = mean(bioChemists$ment)))
matplot(0:12, sapply(unlist(pp), function(x) dpois(0:12, x)),
type = "b", lty = 1, xlab = "Number of articles", ylab = "Probability")
legend("topright", paste("Comp.", rep(1:2, each = 2), ":",
c("Men", "Women")), lty = 1, col = 1:4, pch = paste(1:4), bty = "n")
data("dmft", package = "flexmix")
Model <- FLXMRziglm(family = "poisson")
Fitted <- flexmix(End ~ log(Begin + 0.5) + Gender + Ethnic + Treatment,
model = Model, k = 2 , data = dmft, control = list(minprior = 0.01))
summary(refit(Fitted))
print(plot(refit(Fitted), components = 2, box.ratio = 3))
Concomitant <- FLXPmultinom(~ yb)
MyConcomitant <- myConcomitant(~ yb)
set.seed(1234)
m2 <- flexmix(. ~ x, data = NPreg, k = 2, model = list(Model_n, Model_p),
concomitant = Concomitant)
m3 <- flexmix(. ~ x, data = NPreg, k = 2, model = list(Model_n, Model_p),
cluster = posterior(m2), concomitant = MyConcomitant)
summary(m2)
summary(m3)
determinePrior <- function(object) {
object@concomitant@fit(object@concomitant@x,
posterior(object))[!duplicated(object@concomitant@x), ]
}
determinePrior(m2)
determinePrior(m3)
SI <- sessionInfo()
pkgs <- paste(sapply(c(SI$otherPkgs, SI$loadedOnly), function(x)
paste("\\\\pkg{", x$Package, "} ",
x$Version, sep = "")), collapse = ", ") |
pac_compare_versions <- function(pac,
old = NULL,
new = NULL,
fields = c("Imports", "Depends", "LinkingTo"),
lib.loc = NULL,
repos = "https://cran.rstudio.com/") {
stopifnot((length(pac) == 1) && is.character(pac))
stopifnot(pac_isin(pac, repos))
stopifnot(is.null(old) || (length(old) == 1) && is.character(old))
stopifnot(is.null(new) || (length(new) == 1) && is.character(new))
stopifnot(all(fields %in% c("Depends", "Imports", "Suggests", "LinkingTo")))
stopifnot(is.character(repos))
stopifnot(is.null(lib.loc) || all(lib.loc %in% .libPaths()))
if (is.null(old)) {
stopifnot(pac %in% rownames(installed_packages(lib.loc = lib.loc)))
old <- pac_description(pac, local = TRUE)$Version
}
if (is.null(new)) {
new <- pac_last(pac)
}
stopifnot(utils::compareVersion(new, old) >= 0)
one_desc <- pac_description(pac, version = old, lib.loc = lib.loc, repos = repos)
if (length(one_desc) == 0) stop(sprintf("Version %s is not exists for %s.", old, pac))
one_base <- paste(Filter(function(x) length(x) > 0, one_desc[fields]), collapse = ",")
one_e <- extract_deps(one_base)
s_remote <- unique(data.frame(
Package = one_e$packages[[1]], Version = replaceNA(one_e$versions[[1]], ""),
stringsAsFactors = FALSE
))
two_desc <- pac_description(pac, version = new, lib.loc = lib.loc, repos = repos)
if (length(two_desc) == 0) stop(sprintf("Version %s is not exists for %s.", new, pac))
two_base <- paste(Filter(function(x) length(x) > 0, two_desc[fields]), collapse = ",")
two_e <- extract_deps(two_base)
s_remote2 <- unique(data.frame(
Package = two_e$packages[[1]], Version = replaceNA(two_e$versions[[1]], ""),
stringsAsFactors = FALSE
))
res <- merge(s_remote, s_remote2, by = c("Package"), all = TRUE, suffix = paste0(".", c(old, new)))
col_old <- paste0("Version.", old)
col_new <- paste0("Version.", new)
res$version_status <- apply(res, 1, function(x) utils::compareVersion(x[col_new], x[col_old]))
rownames(res) <- NULL
attr(res, "package") <- pac
attr(res, "old") <- old
attr(res, "new") <- new
res
}
pac_compare_namespace <- function(pac,
old = NULL,
new = NULL,
lib.loc = NULL,
repos = "https://cran.rstudio.com/") {
stopifnot((length(pac) == 1) && is.character(pac))
stopifnot(pac_isin(pac, repos))
stopifnot(is.null(old) || (length(old) == 1) && is.character(old))
stopifnot(is.null(new) || (length(new) == 1) && is.character(new))
stopifnot(is.character(repos))
stopifnot(is.null(lib.loc) || all(lib.loc %in% .libPaths()))
if (is.null(old)) {
stopifnot(pac %in% rownames(installed_packages(lib.loc = lib.loc)))
old <- pac_description(pac, local = TRUE)$Version
}
if (is.null(new)) {
new <- pac_last(pac)
}
stopifnot(utils::compareVersion(new, old) >= 0)
result <- list()
fields <- c("imports", "exports", "exportPatterns", "importClasses", "importMethods", "exportClasses", "exportMethods", "exportClassPatterns", "dynlibs", "S3methods")
one_nam <- pac_namespace(pac, old, lib.loc = lib.loc, repos = repos)
if (length(one_nam) == 0) stop(sprintf("Version %s is not exists for %s.", old, pac))
two_nam <- pac_namespace(pac, new, lib.loc = lib.loc, repos = repos)
if (length(two_nam) == 0) stop(sprintf("Version %s is not exists for %s.", new, pac))
for (f in fields) {
if (f == "S3methods") {
old_f <- as.data.frame(one_nam[[f]])
old_f$id <- seq_len(nrow(old_f))
new_f <- as.data.frame(two_nam[[f]])
new_f$id <- seq_len(nrow(new_f))
merged <- merge(old_f, new_f, by = c("V1", "V2", "V3", "V4"), all = TRUE)
added <- merged[is.na(merged$id.x) & !is.na(merged$id.y), 1:4]
rownames(added) <- NULL
removed <- merged[!is.na(merged$id.x) & is.na(merged$id.y), 1:4]
rownames(removed) <- NULL
result[[f]] <- list(removed = removed, added = added)
} else {
old_f <- unlist(one_nam[[f]])
new_f <- unlist(two_nam[[f]])
result[[f]] <- list(removed = setdiff(old_f, new_f), added = setdiff(new_f, old_f))
}
}
structure(result, package = pac, old = old, new = new)
} |
divOnline <- function(){
runApp(system.file('diveRsity-online', package = 'diveRsity'))
} |
NULL
.servicecatalog$accept_portfolio_share_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), PortfolioShareType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$accept_portfolio_share_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_budget_with_resource_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(BudgetName = structure(logical(0), tags = list(type = "string")), ResourceId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_budget_with_resource_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_principal_with_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), PrincipalARN = structure(logical(0), tags = list(type = "string")), PrincipalType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_principal_with_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_product_with_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), SourcePortfolioId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_product_with_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_service_action_with_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ServiceActionId = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_service_action_with_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_tag_option_with_resource_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ResourceId = structure(logical(0), tags = list(type = "string")), TagOptionId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$associate_tag_option_with_resource_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$batch_associate_service_action_with_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionAssociations = structure(list(structure(list(ServiceActionId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$batch_associate_service_action_with_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(FailedServiceActionAssociations = structure(list(structure(list(ServiceActionId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ErrorCode = structure(logical(0), tags = list(type = "string")), ErrorMessage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$batch_disassociate_service_action_from_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionAssociations = structure(list(structure(list(ServiceActionId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$batch_disassociate_service_action_from_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(FailedServiceActionAssociations = structure(list(structure(list(ServiceActionId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ErrorCode = structure(logical(0), tags = list(type = "string")), ErrorMessage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$copy_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), SourceProductArn = structure(logical(0), tags = list(type = "string")), TargetProductId = structure(logical(0), tags = list(type = "string")), TargetProductName = structure(logical(0), tags = list(type = "string")), SourceProvisioningArtifactIdentifiers = structure(list(structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map"))), tags = list(type = "list")), CopyOptions = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$copy_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(CopyProductToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_constraint_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Parameters = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_constraint_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ConstraintDetail = structure(list(ConstraintId = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ConstraintParameters = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), ProviderName = structure(logical(0), tags = list(type = "string")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioDetail = structure(list(Id = structure(logical(0), tags = list(type = "string")), ARN = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), ProviderName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_portfolio_share_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), AccountId = structure(logical(0), tags = list(type = "string")), OrganizationNode = structure(list(Type = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ShareTagOptions = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_portfolio_share_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioShareToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string")), ProductType = structure(logical(0), tags = list(type = "string")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), ProvisioningArtifactParameters = structure(list(Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Info = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), Type = structure(logical(0), tags = list(type = "string")), DisableTemplateValidation = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductViewDetail = structure(list(ProductViewSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Status = structure(logical(0), tags = list(type = "string")), ProductARN = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure")), ProvisioningArtifactDetail = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Active = structure(logical(0), tags = list(type = "boolean")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_provisioned_product_plan_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PlanName = structure(logical(0), tags = list(type = "string")), PlanType = structure(logical(0), tags = list(type = "string")), NotificationArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), PathId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ProvisioningParameters = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), UsePreviousValue = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_provisioned_product_plan_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PlanName = structure(logical(0), tags = list(type = "string")), PlanId = structure(logical(0), tags = list(type = "string")), ProvisionProductId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Parameters = structure(list(Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Info = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), Type = structure(logical(0), tags = list(type = "string")), DisableTemplateValidation = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisioningArtifactDetail = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Active = structure(logical(0), tags = list(type = "boolean")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Info = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_service_action_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Name = structure(logical(0), tags = list(type = "string")), DefinitionType = structure(logical(0), tags = list(type = "string")), Definition = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), Description = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_service_action_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionDetail = structure(list(ServiceActionSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), DefinitionType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Definition = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_tag_option_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$create_tag_option_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(TagOptionDetail = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean")), Id = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_constraint_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_constraint_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_portfolio_share_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), AccountId = structure(logical(0), tags = list(type = "string")), OrganizationNode = structure(list(Type = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_portfolio_share_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioShareToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_provisioned_product_plan_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PlanId = structure(logical(0), tags = list(type = "string")), IgnoreErrors = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_provisioned_product_plan_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_service_action_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Id = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_service_action_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_tag_option_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$delete_tag_option_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_constraint_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_constraint_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ConstraintDetail = structure(list(ConstraintId = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ConstraintParameters = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_copy_product_status_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), CopyProductToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_copy_product_status_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(CopyProductStatus = structure(logical(0), tags = list(type = "string")), TargetProductId = structure(logical(0), tags = list(type = "string")), StatusDetail = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioDetail = structure(list(Id = structure(logical(0), tags = list(type = "string")), ARN = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), ProviderName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), TagOptions = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean")), Id = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), Budgets = structure(list(structure(list(BudgetName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_portfolio_share_status_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioShareToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_portfolio_share_status_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioShareToken = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), OrganizationNodeValue = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), ShareDetails = structure(list(SuccessfulShares = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), ShareErrors = structure(list(structure(list(Accounts = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), Message = structure(logical(0), tags = list(type = "string")), Error = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_portfolio_shares_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioId = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_portfolio_shares_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(NextPageToken = structure(logical(0), tags = list(type = "string")), PortfolioShareDetails = structure(list(structure(list(PrincipalId = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Accepted = structure(logical(0), tags = list(type = "boolean")), ShareTagOptions = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductViewSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ProvisioningArtifacts = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), Budgets = structure(list(structure(list(BudgetName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchPaths = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_product_as_admin_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), SourcePortfolioId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_product_as_admin_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductViewDetail = structure(list(ProductViewSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Status = structure(logical(0), tags = list(type = "string")), ProductARN = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure")), ProvisioningArtifactSummaries = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisioningArtifactMetadata = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map"))), tags = list(type = "structure"))), tags = list(type = "list")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), TagOptions = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean")), Id = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), Budgets = structure(list(structure(list(BudgetName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_product_view_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_product_view_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductViewSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ProvisioningArtifacts = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioned_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioned_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProductDetail = structure(list(Name = structure(logical(0), tags = list(type = "string")), Arn = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), StatusMessage = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), IdempotencyToken = structure(logical(0), tags = list(type = "string")), LastRecordId = structure(logical(0), tags = list(type = "string")), LastProvisioningRecordId = structure(logical(0), tags = list(type = "string")), LastSuccessfulProvisioningRecordId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), CloudWatchDashboards = structure(list(structure(list(Name = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioned_product_plan_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PlanId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioned_product_plan_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProductPlanDetails = structure(list(CreatedTime = structure(logical(0), tags = list(type = "timestamp")), PathId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PlanName = structure(logical(0), tags = list(type = "string")), PlanId = structure(logical(0), tags = list(type = "string")), ProvisionProductId = structure(logical(0), tags = list(type = "string")), ProvisionProductName = structure(logical(0), tags = list(type = "string")), PlanType = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), NotificationArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), ProvisioningParameters = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), UsePreviousValue = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), StatusMessage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ResourceChanges = structure(list(structure(list(Action = structure(logical(0), tags = list(type = "string")), LogicalResourceId = structure(logical(0), tags = list(type = "string")), PhysicalResourceId = structure(logical(0), tags = list(type = "string")), ResourceType = structure(logical(0), tags = list(type = "string")), Replacement = structure(logical(0), tags = list(type = "string")), Scope = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), Details = structure(list(structure(list(Target = structure(list(Attribute = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), RequiresRecreation = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Evaluation = structure(logical(0), tags = list(type = "string")), CausingEntity = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactName = structure(logical(0), tags = list(type = "string")), ProductName = structure(logical(0), tags = list(type = "string")), Verbose = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisioningArtifactDetail = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Active = structure(logical(0), tags = list(type = "boolean")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Info = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioning_parameters_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProductName = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactName = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), PathName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_provisioning_parameters_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisioningArtifactParameters = structure(list(structure(list(ParameterKey = structure(logical(0), tags = list(type = "string")), DefaultValue = structure(logical(0), tags = list(type = "string")), ParameterType = structure(logical(0), tags = list(type = "string")), IsNoEcho = structure(logical(0), tags = list(type = "boolean")), Description = structure(logical(0), tags = list(type = "string")), ParameterConstraints = structure(list(AllowedValues = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), AllowedPattern = structure(logical(0), tags = list(type = "string")), ConstraintDescription = structure(logical(0), tags = list(type = "string")), MaxLength = structure(logical(0), tags = list(type = "string")), MinLength = structure(logical(0), tags = list(type = "string")), MaxValue = structure(logical(0), tags = list(type = "string")), MinValue = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))), tags = list(type = "list")), ConstraintSummaries = structure(list(structure(list(Type = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), UsageInstructions = structure(list(structure(list(Type = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), TagOptions = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Values = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list")), ProvisioningArtifactPreferences = structure(list(StackSetAccounts = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), StackSetRegions = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure")), ProvisioningArtifactOutputs = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_record_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_record_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetail = structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), RecordOutputs = structure(list(structure(list(OutputKey = structure(logical(0), tags = list(type = "string")), OutputValue = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_service_action_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Id = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_service_action_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionDetail = structure(list(ServiceActionSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), DefinitionType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Definition = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_service_action_execution_parameters_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ServiceActionId = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_service_action_execution_parameters_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionParameters = structure(list(structure(list(Name = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), DefaultValues = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_tag_option_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Id = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$describe_tag_option_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(TagOptionDetail = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean")), Id = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disable_aws_organizations_access_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disable_aws_organizations_access_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_budget_from_resource_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(BudgetName = structure(logical(0), tags = list(type = "string")), ResourceId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_budget_from_resource_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_principal_from_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), PrincipalARN = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_principal_from_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_product_from_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_product_from_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_service_action_from_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ServiceActionId = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_service_action_from_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_tag_option_from_resource_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ResourceId = structure(logical(0), tags = list(type = "string")), TagOptionId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$disassociate_tag_option_from_resource_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$enable_aws_organizations_access_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$enable_aws_organizations_access_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$execute_provisioned_product_plan_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PlanId = structure(logical(0), tags = list(type = "string")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$execute_provisioned_product_plan_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetail = structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$execute_provisioned_product_service_action_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ServiceActionId = structure(logical(0), tags = list(type = "string")), ExecuteToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string")), Parameters = structure(list(structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "map"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$execute_provisioned_product_service_action_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetail = structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$get_aws_organizations_access_status_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$get_aws_organizations_access_status_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AccessStatus = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$get_provisioned_product_outputs_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), OutputKeys = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$get_provisioned_product_outputs_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Outputs = structure(list(structure(list(OutputKey = structure(logical(0), tags = list(type = "string")), OutputValue = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$import_as_provisioned_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), PhysicalId = structure(logical(0), tags = list(type = "string")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$import_as_provisioned_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetail = structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_accepted_portfolio_shares_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PortfolioShareType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_accepted_portfolio_shares_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioDetails = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), ARN = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), ProviderName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_budgets_for_resource_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ResourceId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_budgets_for_resource_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Budgets = structure(list(structure(list(BudgetName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_constraints_for_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_constraints_for_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ConstraintDetails = structure(list(structure(list(ConstraintId = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_launch_paths_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_launch_paths_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(LaunchPathSummaries = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), ConstraintSummaries = structure(list(structure(list(Type = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), Name = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_organization_portfolio_access_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), OrganizationNodeType = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_organization_portfolio_access_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(OrganizationNodes = structure(list(structure(list(Type = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_portfolio_access_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), OrganizationParentId = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_portfolio_access_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AccountIds = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_portfolios_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_portfolios_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioDetails = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), ARN = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), ProviderName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_portfolios_for_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_portfolios_for_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioDetails = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), ARN = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), ProviderName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_principals_for_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_principals_for_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Principals = structure(list(structure(list(PrincipalARN = structure(logical(0), tags = list(type = "string")), PrincipalType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_provisioned_product_plans_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProvisionProductId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string")), AccessLevelFilter = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_provisioned_product_plans_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProductPlans = structure(list(structure(list(PlanName = structure(logical(0), tags = list(type = "string")), PlanId = structure(logical(0), tags = list(type = "string")), ProvisionProductId = structure(logical(0), tags = list(type = "string")), ProvisionProductName = structure(logical(0), tags = list(type = "string")), PlanType = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_provisioning_artifacts_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_provisioning_artifacts_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisioningArtifactDetails = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Active = structure(logical(0), tags = list(type = "boolean")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_provisioning_artifacts_for_service_action_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_provisioning_artifacts_for_service_action_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisioningArtifactViews = structure(list(structure(list(ProductViewSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ProvisioningArtifact = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_record_history_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), AccessLevelFilter = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), SearchFilter = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_record_history_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetails = structure(list(structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_resources_for_tag_option_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(TagOptionId = structure(logical(0), tags = list(type = "string")), ResourceType = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_resources_for_tag_option_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ResourceDetails = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), ARN = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure"))), tags = list(type = "list")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_service_actions_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_service_actions_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionSummaries = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), DefinitionType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_service_actions_for_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_service_actions_for_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionSummaries = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), DefinitionType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_stack_instances_for_provisioned_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_stack_instances_for_provisioned_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(StackInstances = structure(list(structure(list(Account = structure(logical(0), tags = list(type = "string")), Region = structure(logical(0), tags = list(type = "string")), StackInstanceStatus = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_tag_options_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Filters = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$list_tag_options_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(TagOptionDetails = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean")), Id = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$provision_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProductName = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactName = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), PathName = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), ProvisioningParameters = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), ProvisioningPreferences = structure(list(StackSetAccounts = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), StackSetRegions = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), StackSetFailureToleranceCount = structure(logical(0), tags = list(type = "integer")), StackSetFailureTolerancePercentage = structure(logical(0), tags = list(type = "integer")), StackSetMaxConcurrencyCount = structure(logical(0), tags = list(type = "integer")), StackSetMaxConcurrencyPercentage = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NotificationArns = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), ProvisionToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$provision_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetail = structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$reject_portfolio_share_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), PortfolioShareType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$reject_portfolio_share_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$scan_provisioned_products_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), AccessLevelFilter = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$scan_provisioned_products_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProducts = structure(list(structure(list(Name = structure(logical(0), tags = list(type = "string")), Arn = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), StatusMessage = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), IdempotencyToken = structure(logical(0), tags = list(type = "string")), LastRecordId = structure(logical(0), tags = list(type = "string")), LastProvisioningRecordId = structure(logical(0), tags = list(type = "string")), LastSuccessfulProvisioningRecordId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$search_products_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Filters = structure(list(structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "map")), PageSize = structure(logical(0), tags = list(type = "integer")), SortBy = structure(logical(0), tags = list(type = "string")), SortOrder = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$search_products_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductViewSummaries = structure(list(structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), ProductViewAggregations = structure(list(structure(list(structure(list(Value = structure(logical(0), tags = list(type = "string")), ApproximateCount = structure(logical(0), tags = list(type = "integer"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "map")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$search_products_as_admin_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), Filters = structure(list(structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "map")), SortBy = structure(logical(0), tags = list(type = "string")), SortOrder = structure(logical(0), tags = list(type = "string")), PageToken = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), ProductSource = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$search_products_as_admin_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductViewDetails = structure(list(structure(list(ProductViewSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Status = structure(logical(0), tags = list(type = "string")), ProductARN = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure"))), tags = list(type = "list")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$search_provisioned_products_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), AccessLevelFilter = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Filters = structure(list(structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "map")), SortBy = structure(logical(0), tags = list(type = "string")), SortOrder = structure(logical(0), tags = list(type = "string")), PageSize = structure(logical(0), tags = list(type = "integer")), PageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$search_provisioned_products_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProducts = structure(list(structure(list(Name = structure(logical(0), tags = list(type = "string")), Arn = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), StatusMessage = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), IdempotencyToken = structure(logical(0), tags = list(type = "string")), LastRecordId = structure(logical(0), tags = list(type = "string")), LastProvisioningRecordId = structure(logical(0), tags = list(type = "string")), LastSuccessfulProvisioningRecordId = structure(logical(0), tags = list(type = "string")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), PhysicalId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProductName = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactName = structure(logical(0), tags = list(type = "string")), UserArn = structure(logical(0), tags = list(type = "string")), UserArnSession = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), TotalResultsCount = structure(logical(0), tags = list(type = "integer")), NextPageToken = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$terminate_provisioned_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProductName = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), TerminateToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string")), IgnoreErrors = structure(logical(0), tags = list(type = "boolean")), AcceptLanguage = structure(logical(0), tags = list(type = "string")), RetainPhysicalResources = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$terminate_provisioned_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetail = structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_constraint_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Parameters = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_constraint_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ConstraintDetail = structure(list(ConstraintId = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ConstraintParameters = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_portfolio_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), ProviderName = structure(logical(0), tags = list(type = "string")), AddTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RemoveTags = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_portfolio_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioDetail = structure(list(Id = structure(logical(0), tags = list(type = "string")), ARN = structure(logical(0), tags = list(type = "string")), DisplayName = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), ProviderName = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_portfolio_share_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), PortfolioId = structure(logical(0), tags = list(type = "string")), AccountId = structure(logical(0), tags = list(type = "string")), OrganizationNode = structure(list(Type = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), ShareTagOptions = structure(logical(0), tags = list(type = "boolean", box = TRUE))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_portfolio_share_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(PortfolioShareToken = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string")), AddTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RemoveTags = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProductViewDetail = structure(list(ProductViewSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string")), ShortDescription = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), Distributor = structure(logical(0), tags = list(type = "string")), HasDefaultPath = structure(logical(0), tags = list(type = "boolean")), SupportEmail = structure(logical(0), tags = list(type = "string")), SupportDescription = structure(logical(0), tags = list(type = "string")), SupportUrl = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Status = structure(logical(0), tags = list(type = "string")), ProductARN = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp"))), tags = list(type = "structure")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_provisioned_product_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProductName = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactName = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), PathName = structure(logical(0), tags = list(type = "string")), ProvisioningParameters = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), UsePreviousValue = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))), tags = list(type = "list")), ProvisioningPreferences = structure(list(StackSetAccounts = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), StackSetRegions = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "list")), StackSetFailureToleranceCount = structure(logical(0), tags = list(type = "integer")), StackSetFailureTolerancePercentage = structure(logical(0), tags = list(type = "integer")), StackSetMaxConcurrencyCount = structure(logical(0), tags = list(type = "integer")), StackSetMaxConcurrencyPercentage = structure(logical(0), tags = list(type = "integer")), StackSetOperationType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Tags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), UpdateToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_provisioned_product_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(RecordDetail = structure(list(RecordId = structure(logical(0), tags = list(type = "string")), ProvisionedProductName = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), UpdatedTime = structure(logical(0), tags = list(type = "timestamp")), ProvisionedProductType = structure(logical(0), tags = list(type = "string")), RecordType = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), PathId = structure(logical(0), tags = list(type = "string")), RecordErrors = structure(list(structure(list(Code = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), RecordTags = structure(list(structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "list")), LaunchRoleArn = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_provisioned_product_properties_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProvisionedProductProperties = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), IdempotencyToken = structure(logical(0), tags = list(idempotencyToken = TRUE, type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_provisioned_product_properties_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisionedProductId = structure(logical(0), tags = list(type = "string")), ProvisionedProductProperties = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), RecordId = structure(logical(0), tags = list(type = "string")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_provisioning_artifact_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(AcceptLanguage = structure(logical(0), tags = list(type = "string")), ProductId = structure(logical(0), tags = list(type = "string")), ProvisioningArtifactId = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_provisioning_artifact_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ProvisioningArtifactDetail = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), Type = structure(logical(0), tags = list(type = "string")), CreatedTime = structure(logical(0), tags = list(type = "timestamp")), Active = structure(logical(0), tags = list(type = "boolean")), Guidance = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Info = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), Status = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_service_action_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Definition = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map")), Description = structure(logical(0), tags = list(type = "string")), AcceptLanguage = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_service_action_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(ServiceActionDetail = structure(list(ServiceActionSummary = structure(list(Id = structure(logical(0), tags = list(type = "string")), Name = structure(logical(0), tags = list(type = "string")), Description = structure(logical(0), tags = list(type = "string")), DefinitionType = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure")), Definition = structure(list(structure(logical(0), tags = list(type = "string"))), tags = list(type = "map"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_tag_option_input <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(Id = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean"))), tags = list(type = "structure"))
return(populate(args, shape))
}
.servicecatalog$update_tag_option_output <- function(...) {
args <- c(as.list(environment()), list(...))
shape <- structure(list(TagOptionDetail = structure(list(Key = structure(logical(0), tags = list(type = "string")), Value = structure(logical(0), tags = list(type = "string")), Active = structure(logical(0), tags = list(type = "boolean")), Id = structure(logical(0), tags = list(type = "string")), Owner = structure(logical(0), tags = list(type = "string"))), tags = list(type = "structure"))), tags = list(type = "structure"))
return(populate(args, shape))
} |
simpute.als<-function (x, J = 2, thresh = 1e-05,lambda=0,maxit=100,trace.it=TRUE, warm.start=NULL, final.svd=TRUE)
{
n <- dim(x)
m <- n[2]
n <- n[1]
this.call=match.call()
a=names(attributes(x))
binames=c("biScale:row","biScale:column")
if(all(match(binames,a,FALSE))){
biats=attributes(x)[binames]
} else biats=NULL
xnas <- is.na(x)
nz=m*n-sum(xnas)
xfill <- x
if(!is.null(warm.start)){
if(!all(match(c("u","d","v"),names(warm.start),0)>0))stop("warm.start does not have components u, d and v")
warm=TRUE
D=warm.start$d
JD=sum(D>0)
if(JD >= J){
U=warm.start$u[,seq(J),drop=FALSE]
V=warm.start$v[,seq(J),drop=FALSE]
Dsq=D[seq(J)]
}
else{
Dsq=c(D,rep(D[JD],J-JD))
Ja=J-JD
U=warm.start$u
Ua=matrix(rnorm(n*Ja),n,Ja)
Ua=Ua-U%*% (t(U)%*%Ua)
Ua=svd(Ua)$u
U=cbind(U,Ua)
V=cbind(warm.start$v,matrix(0,m,Ja))
}
xfill[xnas]=(U%*%(Dsq*t(V)))[xnas]
}
else
{
V=matrix(0,m,J)
U=matrix(rnorm(n*J),n,J)
U=svd(U)$u
Dsq=rep(1,J)
xfill[xnas]=0
}
ratio <- 1
iter <- 0
while ((ratio > thresh)&(iter<maxit)) {
iter <- iter + 1
U.old=U
V.old=V
Dsq.old=Dsq
B=t(U)%*%xfill
if(lambda>0)B=B*(Dsq/(Dsq+lambda))
Bsvd=svd(t(B))
V=Bsvd$u
Dsq=(Bsvd$d)
U=U%*%Bsvd$v
xhat=U %*%(Dsq*t(V))
xfill[xnas]=xhat[xnas]
if(trace.it) obj=(.5*sum( (xfill-xhat)[!xnas]^2)+lambda*sum(Dsq))/nz
A=t(xfill%*%V)
if(lambda>0)A=A*(Dsq/(Dsq+lambda))
Asvd=svd(t(A))
U=Asvd$u
Dsq=Asvd$d
V=V %*% Asvd$v
xhat=U %*%(Dsq*t(V))
xfill[xnas]=xhat[xnas]
ratio=Frob(U.old,Dsq.old,V.old,U,Dsq,V)
if(trace.it) cat(iter, ":", "obj",format(round(obj,5)),"ratio", ratio, "\n")
}
if(iter==maxit)warning(paste("Convergence not achieved by",maxit,"iterations"))
if(lambda>0&final.svd){
U=xfill%*%V
sU=svd(U)
U=sU$u
Dsq=sU$d
V=V%*%sU$v
Dsq=pmax(Dsq-lambda,0)
if(trace.it){
xhat=U %*%(Dsq*t(V))
obj=(.5*sum( (xfill-xhat)[!xnas]^2)+lambda*sum(Dsq))/nz
cat("final SVD:", "obj",format(round(obj,5)),"\n")
}
}
J=min(sum(Dsq>0)+1,J)
out=list(u=U[,seq(J)],d=Dsq[seq(J)],v=V[,seq(J)])
attributes(out)=c(attributes(out),list(lambda=lambda,call=this.call),biats)
out
} |
context("Check that epiobs_ parse model frame correctly")
levels <- 3
dates <- 5
start <- as.Date("2020-05-01")
df <- data.frame(group = gl(levels, dates), date = rep(start + seq(0, dates-1), levels), C = 1, D = 1, E = runif(15), F = runif(15))
tol <- .Machine$double.eps
test_that("observation vector stored correctly", {
obs <- epiobs(formula = C ~ E + F, i2o = 1)
out <- epiobs_(obs, df)
expect_true(max(abs(out$y- df$C)) < tol)
obs <- epiobs(formula = C + 2 ~ E, i2o=1)
out <- epiobs_(obs, df)
expect_true(max(abs(out$y- 3)) < tol)
})
test_that("offset is captured", {
obs <- epiobs(formula = C ~ 1, i2o=1)
out <- epiobs_(obs, df)
expect_true(length(out$offset) == 15)
expect_true(max(abs(out$offset)) < tol)
obs <- epiobs(formula = C ~ offset(E) + F, i2o=1)
out <- epiobs_(obs,df)
expect_equal(out$offset, df$E)
})
test_that("autocor is captured", {
df$time <- df$date
obs <- epiobs(formula = C ~ E, i2o=1)
out <- epiobs_(obs, df)
expect_identical(out$autocor, NULL)
df$time <- df$date
obs <- epiobs(formula = C ~ E + rw(time=time), i2o=1)
out <- epiobs_(obs, df)
expect_true(is.list(out$autocor))
})
test_that("empty response", {
expect_error(obs <- epiobs(formula = ~E+F, i2o=1), "response")
})
test_that("non-integer warning", {
df$y <- 1 + runif(15, 0,0.15)
obs <- epiobs(formula = y ~ 1, i2o=1)
expect_warning(out <- epiobs_(obs, df), "integer")
obs <- epiobs(formula = y ~ 1, i2o=1, family="normal")
expect_warning(out <- epiobs_(obs, df), NA)
expect_equal(as.numeric(out$y), df$y)
})
test_that("negative values caught", {
df$y <- 1
df$y[3] <- -1
obs <- epiobs(formula = y ~ 1, i2o=1)
expect_error(out <- epiobs_(obs, df), NA)
df$y[3] <- -0.5
expect_error(out <- epiobs_(obs, df), "negative")
})
test_that("NAs handling", {
df[3,"E"] <- NA
obs <- epiobs(formula = C ~ F, i2o=1)
out <- epiobs_(obs, df)
expect_equal(as.numeric(out$y), df$C)
expect_equal(out$time, df$date)
expect_equal(out$gr, df$group)
obs <- epiobs(formula = C ~ E, i2o = 1)
out <- epiobs_(obs, df)
expect_equal(as.numeric(out$y), df$C[-3])
expect_equal(out$time, df$date[-3])
expect_equal(out$gr, df$group[-3])
obs <- epiobs(formula = C ~ E, i2o=1, na.action = na.fail)
expect_error(out <- epiobs_(obs, df), regexp="missing values")
obs <- epiobs(formula = C ~ E + rw(time=date), i2o=1)
expect_error(out <- epiobs_(obs, df), "increment")
}) |
total_weight_at_dose <- function(x, dose, ...) {
UseMethod("total_weight_at_dose")
}
total_weight_at_dose.default <- function(x, dose = NULL, ...) {
if(is.null(dose)) {
weights <- weights_at_dose(x, dose = dose)
map_dbl(weights, sum)
} else {
sum(x$dat$weights[x$doses == dose])
}
} |
ccglmreg <- function(x, ...) UseMethod("ccglmreg")
ccglmreg.default <- function(x, ...) {
if (extends(class(x), "Matrix"))
return(ccglmreg.matrix(x = x, ...))
stop("no method for objects of class ", sQuote(class(x)),
" implemented")
}
ccglmreg.formula <- function(formula, data, weights, offset=NULL, contrasts=NULL, ...){
if(!attr(terms(formula, data=data), "intercept"))
stop("non-intercept model is not implemented")
if(missing(data)) data <- environment(formula)
mf <- match.call(expand.dots = FALSE)
m <- match(c("formula", "data", "weights",
"offset"), names(mf), 0L)
mf <- mf[c(1L, m)]
mf$drop.unused.levels <- TRUE
mf[[1L]] <- as.name("model.frame")
mf <- eval(mf, parent.frame())
mt <- attr(mf, "terms")
Y <- model.response(mf, "any")
if(length(dim(Y)) == 1L) {
nm <- rownames(Y)
dim(Y) <- NULL
if(!is.null(nm)) names(Y) <- nm
}
X <- if (!is.empty.model(mt)) model.matrix(mt, mf, contrasts) else matrix(,NROW(Y), 0L)
weights <- as.vector(model.weights(mf))
if(!length(weights)) weights <- rep(1, nrow(mf))
else if(any(weights < 0)) stop("negative weights not allowed")
if(!is.null(weights) && !is.numeric(weights))
stop("'weights' must be a numeric vector")
if(length(weights) != length(Y))
stop("'weights' must be the same length as response variable")
offset <- as.vector(model.offset(mf))
if(!is.null(offset)) {
if(length(offset) != NROW(Y))
stop(gettextf("number of offsets is %d should equal %d (number of observations)", length(offset), NROW(Y)), domain = NA)
}
RET <- ccglmreg_fit(X[,-1], Y, weights=weights, offset=offset, ...)
RET$call <- match.call()
RET <- c(RET, list(formula=formula, terms = mt, data=data,
contrasts = attr(X, "contrasts"),
xlevels = .getXlevels(mt, mf)))
class(RET) <- "ccglmreg"
RET
}
ccglmreg.matrix <- function(x, y, weights, offset=NULL, ...){
RET <- ccglmreg_fit(x, y, weights, offset=offset, ...)
RET$call <- match.call()
return(RET)
}
ccglmreg_fit <- function(x,y, weights, offset, cfun="ccave", dfun="gaussian",
s=NULL, delta=0.1, fk=NULL, iter=10, reltol=1e-5, penalty=c("enet","mnet","snet"), nlambda=100, lambda=NULL, type.path=c("active", "nonactive"), decreasing=TRUE, lambda.min.ratio=ifelse(nobs<nvars,.05, .001),alpha=1, gamma=3, rescale=TRUE, standardize=TRUE, intercept=TRUE, penalty.factor = NULL, maxit=1000, type.init=c("bst", "co", "heu"), init.family=NULL, mstop.init=10, nu.init=0.1, eps=.Machine$double.eps, epscycle=10, thresh=1e-6, parallel=FALSE, n.cores=2, theta, trace=FALSE, tracelevel=1){
compute.h <- function(rfamily, y, fk_old, s, B){
if(rfamily=="clossR")
h <- gradient(family=rfamily, u=y-fk_old, s=s)/B+fk_old
else if(rfamily %in% c("closs", "gloss", "qloss"))
h <- -y*gradient(family=rfamily, u=y*fk_old, s=s)/B+fk_old
h
}
dfunold2 <- dfun
dfunold <- dfun[[1]]
if(dfunold %in%c("gaussian","gaussianC") || dfunold %in%c(1,4)) rescale <- FALSE
cfunold <- cfun
cfun <- cfun2num(cfun)
dfun <- dfun2num(dfunold)
if(!(cfun %in% 1:8)) stop("cfun is not implemented\n")
if(!(dfun %in% c(1, 4, 5, 8, 9))) stop("dfun is not implemented\n")
if(dfun==1 | dfun==4) dfunnew <- "gaussian"
else dfunnew <- dfunold
if(dfunold=="poisson"){
theta <- 1
family <- 3
}else if(dfunold=="negbin"){
if(missing(theta)) stop("theta has to be provided for family=negbin()")
family <- 4
}else theta <- 0
call <- match.call()
penalty <- match.arg(penalty)
type.path <- match.arg(type.path)
type.init <- match.arg(type.init)
if(type.path=="active")
active <- 1
else active <- 0
if (!is.null(lambda) && length(lambda) > 1 && all(lambda == cummin(lambda))){
decreasing <- TRUE
}
else if(!is.null(lambda) && length(lambda) > 1 && all(lambda == cummax(lambda)))
decreasing <- FALSE
if(!is.null(init.family)) rfamily <- init.family else{
if(cfun==4 && dfun==1) rfamily <- "clossR"
else if(cfun==4 && dfun==4) rfamily <- "closs"
else rfamily <- "gaussian"
}
if(dfun %in% 4:6)
y <- y2num(y)
if(!is.matrix(x)) x <- matrix(x)
nm <- dim(x)
nobs <- n <- nm[1]
if(length(y)!=n) stop("length of y is different from row of x\n")
nvars <- m <- nm[2]
if(missing(weights)) weights=rep(1,nobs)
weights <- as.vector(weights)
w <- weights/sum(weights)
if(!is.null(weights) && !is.numeric(weights))
stop("'weights' must be a numeric vector")
if( !is.null(weights) && any(weights < 0) ){
stop("negative weights not allowed")
}
if (is.null(offset)){
is.offset <- FALSE
offset <- rep.int(0, nobs)
}else is.offset <- TRUE
pentype <- switch(penalty,
"enet"=1,
"mnet"=2,
"snet"=3)
if(is.null(penalty.factor))
penalty.factor <- rep(1, nvars)
if(all(penalty.factor==0)){
lambda <- rep(0, nvars)
penalty.factor <- rep(1, nvars)
}
xold <- x
if(is.null(s) || is.na(s)) s <- assign_s(cfun, y) else check_s(cfun, s)
if(cfun==6)
if(s > 1) delta <- (s-1)/2 else
if(s==1) delta <- 0 else{
if(is.null(delta)) stop("delta must be provided")
if(delta <= 0) stop("delta must be positive")
}
penfac <- penalty.factor/sum(penalty.factor) * nvars
zscore <- function(rfamily, RET, s){
if(rfamily=="clossR"){
z <- gradient(family=rfamily, u=y-RET$fitted.values, s=s)
scores <- abs(crossprod(x, w*z))/(penfac*alpha)
}
else if(rfamily=="closs"){
z <- gradient(family=rfamily, u=y*RET$fitted.values, s=s)
scores <- abs(crossprod(x, w*(y*z)))/(penfac*alpha)
}
}
start <- NULL
if(is.null(fk) || is.null(lambda)){
if(type.init %in% c("co", "heu")){
RET <- ccglm(y~1, data=data.frame(cbind(y, rep(1, n))), iter=10000, reltol=1e-20, weights=weights, s=s, cfun=cfun, dfun=dfunold2, init.family=init.family, trace=FALSE)
if(type.init=="co") start <- c(coef(RET), rep(0, nvars))
else if(type.init=="heu"){
v <- zscore(rfamily, RET, s)
ix <- which(v >= quantile(v, 0.9))
b0.1 <- coef(RET)
beta.1 <- rep(0, nvars)
beta.1[ix] <- 1
start <- c(b0.1, beta.1)
RET$fitted.values <- x %*% beta.1 + b0.1
}
}
else if(type.init=="bst")
{
RET <- bst(x, y, family=rfamily, ctrl = bst_control(mstop=mstop.init, nu=nu.init, s=s, intercept=TRUE))
RET$fitted.values <- RET$yhat
RET$weights_update <- weights_update <- weights
start <- c(attributes(coef(RET))$intercept, coef(RET))
}
}
else {
RET <- NULL
RET$fitted.values <- fk
}
if(dfun==5) ytmp <- (y+1)/2 else ytmp <- y
if(is.null(lambda)){
lambda <- try(glmreg_fit(x, ytmp, weights=RET$weights_update, offset=offset, lambda.min.ratio=lambda.min.ratio, nlambda=nlambda, alpha=alpha,gamma=gamma, rescale=FALSE, standardize=standardize, intercept=intercept, penalty.factor = penalty.factor, maxit=1, eps=eps, family=dfunnew, penalty=penalty)$lambda)
if(inherits(lambda, "try-error"))
stop("Initial value can't compute penalty lambda values. Possible reason: initial weights are all zero. Try to enlarge s value, or change type.init/init.family\n")
if(!decreasing)
lambda <- rev(lambda)
}
nlambda <- length(lambda)
beta <- matrix(0, ncol=nlambda, nrow=m)
fitted <- matrix(NA, ncol=nlambda, nrow=n)
b0 <- rep(0, nlambda)
weights_cc <- matrix(0, nrow=n, ncol=nlambda)
mustart <- rep(0, n)
etastart <- rep(0, n)
fk_old <- RET$fitted.values
if(type.init %in% c("bst", "co") && dfun==5)
tmp <- init(RET$weights_update/sum(RET$weights_update), ytmp, offset, family=dfunnew)
else if(type.init%in%c("bst","co"))
tmp <- init(RET$weights_update, ytmp, offset, family=dfunnew)
mustart <- tmp$mu
etastart <- tmp$eta
stopit <- FALSE
if(isTRUE(parallel)){
i <- 1
cl <- parallel::makeCluster(n.cores, outfile="")
registerDoParallel(cl)
fitall <- foreach(i=1:nlambda, .packages=c("mpath")) %dopar%{
RET <- .Fortran("ccglmreg_onelambda",
x_act=as.double(x),
y=as.double(y),
weights=as.double(weights),
n=as.integer(n),
m_act=as.integer(m),
start_act=as.double(start),
etastart=as.double(etastart),
mustart=as.double(mustart),
yhat=as.double(rep(0, n)),
offset=as.double(offset),
lambda_i=as.double(lambda[i]),
alpha=as.double(alpha),
gam=as.double(gamma),
rescale=as.integer(rescale),
standardize=as.integer(standardize),
intercept=as.integer(intercept),
penaltyfactor_act=as.double(penalty.factor),
maxit=as.integer(maxit),
eps=as.double(eps),
theta=as.double(theta),
penalty=as.integer(pentype),
trace=as.integer(trace),
iter=as.integer(iter),
del=as.double(reltol),
cfun=as.integer(cfun),
dfun=as.integer(dfun),
s=as.double(s),
thresh=as.double(thresh),
beta_1=as.double(rep(0, m)),
b0_1=as.double(0),
fk=as.double(rep(0, n)),
delta=as.double(delta),
weights_update=as.double(rep(0, n)),
PACKAGE="mpath")
list(beta=RET$beta, b0=RET$b0, yhat=RET$yhat, weights_update=RET$weights_update)
}
parallel::stopCluster(cl)
RET <- fitall[[nlambda]]
for(k in 1:nlambda){
beta[,k] <- fitall[[k]]$beta
b0[k] <- fitall[[k]]$b0
fitted[,k] <- fitall[[k]]$yhat
weights_cc[,k] <- fitall[[k]]$weights_update
}
tmp <- list(beta=beta, b0=b0, RET=RET, fitted=fitted, weights_cc=weights_cc)
}
typeA <- function(beta, b0){
if(dfun %in% c(1, 4)) dfuntmp <- 1 else if(dfun==5) dfuntmp <- 2
else if(dfun==8) dfuntmp <- 3 else if(dfun==9) dfuntmp <- 4
else if(dfun==6)
if(all(x[,1]==1)) xtmp <- x[,-1] else xtmp <- x
i <- 1
los <- pll <- matrix(NA, nrow=iter, ncol=nlambda)
weights_cc <- matrix(NA, nrow=n, ncol=nlambda)
if(trace && tracelevel==2) tracel <- 1 else tracel <- 0
while(i <= nlambda){
if(trace) message("\nloop in lambda:", i, ", lambda=", lambda[i], "\n")
if(trace) {
cat(" COCO iterations ...\n")
}
k <- 1
d1 <- 10
weights_update <- weights
satu <- 0
while(d1 > reltol && k <= iter && satu==0){
fitted.values <- fk
RET <- .Fortran("glmreg_fit_fortran",
x=as.double(x),
y=as.double(ytmp),
weights=as.double(weights_update),
n=as.integer(n),
m=as.integer(m),
start=as.double(start),
etastart=as.double(etastart),
mustart=as.double(mustart),
offset=as.double(offset),
nlambda=as.integer(1),
lambda=as.double(lambda[i]),
alpha=as.double(alpha),
gam=as.double(gamma),
rescale=as.integer(rescale),
standardize=as.integer(standardize),
intercept=as.integer(intercept),
penaltyfactor=as.double(penalty.factor),
thresh=as.double(thresh),
epsbino=as.double(0),
maxit=as.integer(maxit),
eps=as.double(eps),
theta=as.double(theta),
family=as.integer(dfuntmp),
penalty=as.integer(pentype),
trace=as.integer(tracel),
beta=as.double(matrix(0, ncol=1, nrow=m)),
b0=as.double(0),
yhat=as.double(rep(0, n)),
satu=as.integer(0),
PACKAGE="mpath")
satu <- RET$satu
if(satu==1) warnings("saturated binomial model")
fk <- RET$yhat
etastart <- RET$etastart
mustart <- RET$mustart
if(dfun%in%c(1,4,5)){
weights_update <- .Fortran("update_wt",
n=as.integer(n),
weights=as.double(weights),
y=as.double(y),
f=as.double(etastart),
cfun=as.integer(cfun),
dfun=as.integer(dfun),
s=as.double(s),
delta=as.double(delta),
weights_update=as.double(rep(0, n)),
PACKAGE="mpath")$weights_update
los[k, i] <- .Fortran("loss2",
n=as.integer(n),
y=as.double(y),
f=as.double(etastart),
weights=as.double(weights),
cfun=as.integer(cfun),
dfun=as.integer(dfun),
s=as.double(s),
delta=as.double(delta),
los=as.double(0.0),
PACKAGE="mpath")$los
}
else{
weights_update <- compute_wt3(y,mustart,theta,weights,cfun,family,s,delta)
los[k, i] <- sum(loss3(y,mustart,theta,weights,cfun,family,s,delta)$tmp)
}
if(dfun!=5) start <- c(RET$b0, RET$beta)
penval <- .Fortran("penGLM",
start=as.double(RET$beta),
m=as.integer(m),
lambda=as.double(lambda[i]*penalty.factor),
alpha=as.double(alpha),
gam=as.double(gamma),
penalty=as.integer(pentype),
pen=as.double(0.0),
PACKAGE="mpath")$pen
if(standardize)
pll[k, i] <- los[k, i] + n*penval
else pll[k, i] <- los[k, i] + penval
if(k > 1)
d1 <- abs((pll[k, i] - pll[k-1, i])/pll[k-1, i])
if(trace) cat("\n iteration", k, ": relative change of fk", d1, ", robust loss value", los[k, i], ", penalized loss value", pll[k, i], "\n")
if(trace) cat(" d1=", d1, ", k=", k, ", d1 > reltol && k <= iter: ", (d1 > reltol && k <= iter), "\n")
k <- k + 1
}
beta[,i] <- RET$beta
b0[i] <- RET$b0
weights_cc[,i] <- weights_update
i <- i + 1
}
list(beta=beta, b0=b0, RET=RET, risk=los, pll=pll, weights_cc=weights_cc)
}
typeBB <- function(beta, b0){
if(trace && tracelevel==2) tracel <- 1 else tracel <- 0
if(type.path=="active" && decreasing)
RET <- .Fortran("ccglmreg_ad",
x=as.double(x),
y=as.double(y),
weights=as.double(weights),
n=as.integer(n),
m=as.integer(m),
start=as.double(start),
etastart=as.double(etastart),
mustart=as.double(mustart),
offset=as.double(offset),
iter=as.integer(iter),
nlambda=as.integer(nlambda),
lambda=as.double(lambda),
alpha=as.double(alpha),
gam=as.double(gamma),
rescale=as.integer(rescale),
standardize=as.integer(standardize),
intercept=as.integer(intercept),
penaltyfactor=as.double(penalty.factor),
maxit=as.integer(maxit),
eps=as.double(eps),
theta=as.double(theta),
epscycle=as.double(epscycle),
penalty=as.integer(pentype),
trace=as.integer(tracel),
del=as.double(reltol),
cfun=as.integer(cfun),
dfun=as.integer(dfun),
s=as.double(s),
thresh=as.double(thresh),
decreasing=as.integer(decreasing),
beta=as.double(beta),
b0=as.double(b0),
yhat=as.double(RET$fitted.values),
los=as.double(rep(0, nlambda)),
pll=as.double(rep(0, nlambda)),
nlambdacal=as.integer(0),
delta=as.double(delta),
weights_cc=as.double(matrix(0, nrow=n, ncol=nlambda)),
PACKAGE="mpath")
else
RET <- .Fortran("ccglmreg_fortran",
x=as.double(x),
y=as.double(y),
weights=as.double(weights),
n=as.integer(n),
m=as.integer(m),
start=as.double(start),
etastart=as.double(etastart),
mustart=as.double(mustart),
offset=as.double(offset),
iter=as.integer(iter),
nlambda=as.integer(nlambda),
lambda=as.double(lambda),
alpha=as.double(alpha),
gam=as.double(gamma),
rescale=as.integer(rescale),
standardize=as.integer(standardize),
intercept=as.integer(intercept),
penaltyfactor=as.double(penalty.factor),
maxit=as.integer(maxit),
eps=as.double(eps),
theta=as.double(theta),
penalty=as.integer(pentype),
trace=as.integer(tracel),
del=as.double(reltol),
cfun=as.integer(cfun),
dfun=as.integer(dfun),
s=as.double(s),
thresh=as.double(thresh),
decreasing=as.integer(decreasing),
active=as.integer(active),
beta=as.double(beta),
b0=as.double(b0),
yhat=as.double(RET$fitted.values),
los=as.double(rep(0, nlambda)),
pll=as.double(rep(0, nlambda)),
nlambdacal=as.integer(0),
delta=as.double(delta),
weights_cc=as.double(matrix(0, nrow=n, ncol=nlambda)),
PACKAGE="mpath")
list(beta=matrix(RET$beta, ncol=nlambda), b0=RET$b0, RET=RET, risk=RET$los, pll=RET$pll, nlambdacal=RET$nlambdacal, weights_cc=RET$weights_cc)
}
if(is.null(parallel)) tmp <- typeA(beta, b0) else
if(!parallel) tmp <- typeBB(beta, b0)
beta <- tmp$beta
b0 <- tmp$b0
RET <- tmp$RET
RET$weights_update <- tmp$weights_cc
if(!is.null(parallel) && standardize && dfun%in%c(5,8,9)){
tmp1 <- stan(x, weights)
meanx <- tmp1$meanx
normx <- tmp1$normx
beta <- beta/normx
b0 <- b0 - crossprod(meanx, beta)
}
if(is.null(colnames(x))) varnames <- paste("V", 1:ncol(x), sep="")
else varnames <- colnames(x)
dimnames(beta) <- list(varnames, round(lambda, digits=4))
RET$beta <- beta
RET$b0 <- matrix(b0, nrow=1)
RET$x <- xold
RET$y <- y
RET$call <- call
RET$lambda <- lambda
RET$nlambda <- nlambda
RET$penalty <- penalty
RET$s <- s
RET$nlambdacal <- tmp$nlambdacal
RET$cfun <- cfunold
RET$dfun <- dfunold
RET$type.init <- type.init
RET$mstop.init <- mstop.init
RET$nu.init <- nu.init
RET$decreasing <- decreasing
RET$type.path <- type.path
RET$is.offset <- is.offset
RET$fitted.values <- fitted
class(RET) <- "ccglmreg"
RET
}
co_evalerr <- function(dfun, y, yhat){
if(dfun %in% c(1:3,8,9))
mean((y - yhat)^2)
else if(dfun %in% 4:7)
(mean(y != sign(yhat)))
}
predict.ccglmreg <- function(object, newdata=NULL, weights=NULL, newy=NULL, newoffset=NULL, which=1:object$nlambda, type=c("link", "response","class","loss", "error", "coefficients", "nonzero"), na.action=na.pass, ...){
type=match.arg(type)
if(is.null(newdata)){
if(!match(type,c("coefficients", "nonzero"),FALSE))stop("You need to supply a value for 'newdata'")
ynow <- object$y
}
else{
if(!is.null(object$terms)){
mf <- model.frame(delete.response(object$terms), newdata, na.action = na.action, xlev = object$xlevels)
ynow <- model.frame(object$terms, newdata)[,1]
newdata <- model.matrix(delete.response(object$terms), mf, contrasts = object$contrasts)
if(!is.null(ynow) && !is.null(newy))
warnings("response y is used from newdata, but newy is also provided. Check if newdata contains the same y as newy\n")
}
else ynow <- newy
}
if(type=="coefficients") return(coef.glmreg(object)[,which])
if(type=="nonzero"){
nbeta <- object$beta[,which]
if(length(which)>1) return(eval(parse(text="glmnet:::nonzeroCoef(nbeta[,,drop=FALSE],bystep=TRUE)")))
else return(which(abs(nbeta) > 0))
}
if(is.null(newdata))
newx <- as.data.frame(object$x)
else newx <- as.data.frame(newdata)
if(dim(newx)[2]==dim(object$beta)[1])
newx <- cbind(1, newx)
if(object$is.offset)
if(is.null(newoffset))
stop("offset is used in the estimation but not provided in prediction\n")
else offset <- newoffset
else offset <- rep(0, length(ynow))
res <- offset + as.matrix(newx) %*% rbind(object$b0, object$beta)
if(type=="link") return(res[, which])
if(type %in% c("link", "response")) return(predict(object, newx=newx, newoffset=newoffset, which=which, type=type))
if(type %in% c("loss", "error") && is.null(ynow)) stop("response variable y missing\n")
if(type=="loss"){
object$cfun <- cfun2num(object$cfun)
object$dfun <- dfun2num(object$dfun)
if(object$dfun %in% 4:5) ynow <- y2num(ynow)
tmp <- rep(NA, length(which))
n <- length(ynow)
if(missing(weights)) weights <- rep(1/n, n)
for(i in 1:length(which)){
if(object$dfun %in% c(1,4,5))
tmp[i] <- .Fortran("loss2",
n=as.integer(n),
y=as.double(ynow),
f=as.double(res[,which[i]]),
weights=as.double(weights),
cfun=as.integer(object$cfun),
dfun=as.integer(object$dfun),
s=as.double(object$s),
delta=as.double(object$delta),
los=as.double(0.0),
PACKAGE="mpath")$los
else{
mu <- predict(object, newx=newx, newoffset=newoffset,which=which[i], type="response")
tmp[i] <- sum(loss3(object$y,mu,object$theta,weights,object$cfun,family,object$s,object$delta)$tmp)
}
}
return(tmp)
}
if(type=="error"){
object$dfun <- dfun2num(object$dfun)
if(object$dfun %in% 4:5) ynow <- y2num(ynow)
tmp <- rep(NA, length(which))
for(i in 1:length(which))
tmp[i] <- co_evalerr(object$dfun, ynow, res[,which[i]])
return(tmp)
}
}
coef.ccglmreg <- function(object, ...)
coef.glmreg(object) |
ozRegion <- function(states = TRUE, coast = TRUE, xlim = NULL,
ylim = NULL, eps = 0.25,
sections = NULL, visible = NULL)
{
if (!is.null(xlim) || !is.null(ylim)) {
if (is.null(xlim))
rx <- c(113, 154)
else
rx <- xlim
if (is.null(ylim))
ry <- c(-44, -10)
else
ry <- ylim
}
else {
rx <- NULL
ry <- NULL
if (!is.null(sections)) {
for(i in sections) {
rx <- range(c(rx, .Oz.limits[[i]]$x))
ry <- range(c(ry, .Oz.limits[[i]]$y))
}
rx <- rx + c( - eps, eps)
ry <- ry + c( - eps, eps)
}
else {
rx <- c(113, 154)
ry <- c(-44, -10)
}
}
option <- rep(FALSE, 16)
if (!is.null(visible)) {
option[visible] <- TRUE
}
else if (!states) {
option[1:7] <- TRUE
}
else if (!coast) {
option[8:16] <- TRUE
}
else if (!is.null(sections)) {
option[sections] <- TRUE
}
else
option[1:16] <- TRUE
".Oz.in2la" <- function(internal) {
latitude <- (internal - 1998)/52.600000000000001 - 10
latitude
}
".Oz.in2lo" <- function(internal) {
longitude <- (internal - 420)/52.600000000000001 + 120
longitude
}
".Oz.rc" <- function(r1, r2) {
!((max(r1) < min(r2)) || (min(r1) > max(r2)))
}
for(i in 1:16) {
option[i] <- (option[i] &&
.Oz.rc(rx, .Oz.limits[[i]]$x) &&
.Oz.rc(ry, .Oz.limits[[i]]$y))
}
lines <- list(sum(option))
index <- 1
for (i in (1:16)[option]) {
lines[[index]] <- list(x=.Oz.in2lo(.Oz.sections[[i]]$x),
y=.Oz.in2la(.Oz.sections[[i]]$y))
index <- index + 1
}
region <- list(rangex=rx, rangey=ry, lines=lines)
class(region) <- "ozRegion"
region
}
oz <- function(states = TRUE, coast = TRUE, xlim = NULL,
ylim = NULL, add = FALSE, ar = 1, eps = 0.25,
sections = NULL, visible = NULL, ...) {
if (add) {
xlim <- par("usr")[1:2]
ylim <- par("usr")[3:4]
}
region <- ozRegion(states, coast, xlim, ylim, eps, sections, visible)
oldpar <- par(err = -1)
on.exit(par(oldpar))
if(!add) {
frame()
pxy <- par("pin")
rx <- region$rangex
ry <- region$rangey
dx <- ar * (rx[2] - rx[1])
dy <- ry[2] - ry[1]
coord <- min(pxy[1] / dx, pxy[2]/dy)
xextra <- ((pxy[1] / coord - dx) * 0.5)/ar
yextra <- (pxy[2] / coord - dy) * 0.5
par(usr = c(rx[1] - xextra, rx[2] + xextra,
ry[1] - yextra, ry[2] + yextra))
}
for(i in region$lines)
lines(i$x, i$y, ...)
}
"nsw"<-
function(...)
{
oz(sections = c(4, 13:15), ...)
}
"nt"<-
function(...)
{
oz(sections = c(2, 9:11), ...)
}
"qld"<-
function(...)
{
oz(sections = c(3, 11:13), ...)
}
"sa"<-
function(...)
{
oz(sections = c(7, 8, 10, 12, 14, 16), ...)
}
"tas"<-
function(...)
{
oz(sections = 6, ...)
}
"vic"<-
function(...)
{
oz(sections = c(5, 15, 16), ...)
}
"wa"<-
function(...)
{
oz(sections = c(1, 8, 9), ...)
}
".Oz.cities"<-
list(name = c("Adelaide", "Albury", "Alice_Springs", "Brisbane", "Broome",
"Cairns", "Canberra", "Darwin", "Hobart", "Melbourne", "Newcastle",
"Perth", "Sydney", "Townsville"),
x = c(138.5333333333333, 146.83333333333329, 133.8833333333333,
152.41666666666671, 122.25, 145.84999999999999, 149.1333333333333,
130.83333333333329, 147.34999999999999, 145, 151.81666666666669,
115.8666666666667, 151.16666666666671, 146.75),
y = c(-34.916666666666657, -36, -23.600000000000001, -27, -18,
-16.916666666666671, -35.25, -12.33333333333333,
-42.833333333333343, -37.666666666666657, -32.866666666666667,
-31.949999999999999, -33.883333333333333, -19.25))
".Oz.limits" <-
list(list(x = c(113.194, 129.011),
y = c(-35.113999999999997, -13.763999999999999)),
list(x = c(129.011, 138.00399999999999),
y = c(-16.369, -11.045999999999999)),
list(x = c(138.00399999999999, 153.47900000000001),
y = c(-28.137, -10.932)),
list(x = c(149.65799999999999, 153.66900000000001),
y = c(-37.451999999999998, -28.079999999999998)),
list(x = c(140.95099999999999, 149.791),
y = c(-39.048999999999999, -37.414000000000001)),
list(x = c(144.63900000000001, 148.346),
y = c(-43.593000000000004, -40.589000000000013)),
list(x = c(129.011, 140.97),
y = c(-37.966000000000008, -31.425999999999998)),
list(x = c(129.011, 129.011),
y = c(-31.577999999999999, -25.989000000000001)),
list(x = c(129.011, 129.011),
y = c(-25.989000000000001, -14.829000000000001)),
list(x = c(129.011, 138.00399999999999),
y = c(-25.989000000000001, -25.989000000000001)),
list(x = c(138.00399999999999, 138.00399999999999),
y = c(-25.989000000000001, -16.369)),
list(x = c(138.00399999999999, 141.00800000000001),
y = c(-28.992000000000001, -25.989000000000001)),
list(x = c(141.00800000000001, 153.47900000000001),
y = c(-29.163, -28.137)),
list(x = c(141.00800000000001, 141.00800000000001),
y = c(-34.048999999999999, -28.992000000000001)),
list(x = c(141.00800000000001, 149.65799999999999),
y = c(-37.414000000000001, -33.915999999999997)),
list(x = c(140.95099999999999, 141.00800000000001),
y = c(-37.927999999999997, -34.048999999999999)))
".Oz.sections" <-
list(list(x = c(894, 879, 872, 867, 861, 848, 835, 832, 825, 810, 797, 791,
785, 780, 780, 776, 767, 750, 744, 738, 735, 730, 727, 639,
636, 633, 632, 632, 629, 626, 623, 622, 621, 620, 618, 616,
612, 611, 608, 608, 606, 604, 600, 598, 596, 596, 594, 592,
591, 587, 586, 581, 580, 578, 577, 534, 530, 526, 525, 523,
522, 519, 518, 516, 515, 514, 511, 509, 502, 500, 497, 494,
489, 444, 437, 431, 429, 425, 423, 423, 422, 420, 418, 414,
410, 409, 408, 408, 404, 404, 402, 401, 400, 399, 396, 396,
395, 395, 394, 394, 395, 395, 393, 392, 391, 389, 388, 388,
389, 389, 387, 382, 381, 381, 380, 379, 377, 376, 373, 369,
369, 370, 369, 368, 367, 366, 365, 364, 363, 363, 362, 360,
357, 355, 354, 355, 354, 354, 353, 353, 351, 350, 342, 342,
339, 339, 337, 337, 336, 336, 335, 334, 335, 330, 322, 322,
328, 329, 328, 327, 327, 328, 329, 329, 328, 327, 327, 326,
324, 323, 321, 320, 318, 317, 310, 308, 307, 306, 304, 304,
278, 279, 277, 274, 271, 269, 267, 266, 266, 265, 264, 262,
259, 258, 257, 255, 250, 248, 246, 242, 239, 234, 233, 230,
228, 227, 227, 229, 230, 232, 228, 226, 225, 225, 226, 226,
224, 222, 220, 217, 212, 210, 207, 206, 202, 202, 200, 199,
196, 196, 195, 190, 187, 184, 182, 178, 174, 157, 159, 161,
162, 164, 169, 170, 171, 176, 179, 181, 183, 185, 187, 187,
188, 188, 190, 190, 192, 192, 191, 189, 189, 188, 188, 189,
191, 191, 190, 191, 193, 194, 194, 195, 196, 197, 195, 195,
194, 194, 195, 195, 196, 196, 197, 199, 199, 199, 198, 199,
198, 200, 201, 203, 202, 202, 199, 198, 198, 197, 196, 197,
196, 197, 197, 196, 197, 197, 196, 195, 195, 193, 193, 189,
185, 184, 180, 178, 175, 171, 171, 169, 168, 165, 163, 161,
157, 159, 159, 160, 160, 158, 158, 157, 158, 160, 161, 161,
160, 159, 157, 159, 159, 158, 158, 156, 154, 154, 151, 148,
143, 138, 137, 137, 138, 137, 137, 135, 133, 131, 129, 127,
126, 119, 116, 113, 113, 112, 112, 113, 113, 112, 112, 110,
108, 106, 100, 98, 95, 89, 87, 84, 83, 81, 80, 75, 74, 73, 70,
69, 66, 65, 64, 64, 63, 62, 63, 67, 68, 68, 69, 70, 70, 71,
71, 72, 74, 74, 75, 76, 78, 78, 80, 80, 82, 82, 84, 84, 86,
86, 87, 89, 90, 91, 93, 96, 97, 99, 99, 98, 97, 96, 95, 90,
88, 86, 85, 84, 82, 82, 81, 81, 80, 80, 81, 80, 78, 75, 74,
75, 79, 79, 80, 81, 81, 82, 85, 85, 86, 90, 92, 92, 91, 92,
94, 96, 98, 98, 100, 100, 101, 103, 101, 97, 91, 89, 89, 88,
86, 84, 80, 76, 75, 78, 79, 79, 78, 75, 74, 72, 77, 78, 79,
80, 83, 87, 88, 90, 93, 95, 96, 96, 94, 94, 92, 91, 90, 89,
93, 95, 96, 96, 100, 104, 106, 107, 109, 110, 110, 111, 111,
95, 94, 94, 92, 92, 91, 91, 89, 87, 88, 89, 91, 92, 95, 97,
97, 100, 100, 102, 103, 106, 109, 110, 112, 114, 114, 112,
112, 111, 109, 109, 110, 110, 112, 112, 113, 113, 114, 114,
115, 115, 116, 117, 117, 118, 120, 122, 124, 126, 127, 128,
128, 129, 129, 132, 134, 135, 137, 138, 141, 143, 146, 151,
161, 163, 163, 164, 166, 167, 169, 166, 167, 168, 170, 171,
171, 174, 176, 177, 179, 180, 181, 184, 185, 189, 191, 194,
200, 203, 207, 207, 211, 212, 221, 222, 222, 227, 227, 226,
228, 232, 237, 242, 243, 244, 247, 249, 251, 252, 251, 252,
254, 255, 257, 257, 255, 256, 263, 264, 264, 264, 263, 264,
267, 268, 269, 272, 273, 274, 275, 276, 276, 275, 276, 277,
286, 289, 294, 297, 301, 304, 305, 307, 308, 313, 315, 316,
316, 318, 319, 324, 340, 344, 346, 348, 353, 359, 362, 367,
368, 370, 372, 374, 377, 380, 383, 387, 389, 389, 390, 392,
393, 397, 399, 403, 409, 412, 414, 417, 446, 452, 456, 460,
463, 469, 475, 484, 489, 491, 492, 495, 499, 504, 505, 505,
506, 506, 507, 507, 508, 512, 515, 516, 514, 514, 517, 520,
523, 531, 531, 534, 535, 535, 539, 543, 543, 542, 539, 538,
538, 537, 537, 535, 534, 532, 532, 534, 534, 533, 534, 533,
533, 535, 536, 540, 541, 540, 542, 544, 546, 548, 552, 554,
555, 555, 554, 554, 556, 559, 563, 565, 567, 569, 571, 571,
572, 579, 581, 578, 577, 577, 579, 580, 580, 581, 583, 583,
584, 585, 587, 589, 589, 591, 593, 595, 598, 599, 603, 606,
606, 608, 610, 610, 611, 610, 608, 608, 607, 614, 616, 618,
620, 621, 620, 621, 622, 621, 618, 613, 609, 607, 604, 602,
602, 604, 606, 608, 609, 607, 603, 602, 611, 612, 610, 606,
606, 607, 610, 611, 612, 615, 615, 613, 613, 615, 616, 617,
618, 618, 617, 617, 616, 616, 617, 619, 620, 625, 626, 629,
631, 631, 632, 635, 635, 637, 637, 638, 638, 639, 640, 641,
643, 644, 644, 646, 648, 650, 650, 649, 649, 648, 652, 653,
652, 657, 660, 661, 661, 659, 658, 653, 653, 651, 651, 650,
650, 649, 651, 651, 650, 650, 651, 651, 660, 662, 662, 663,
663, 665, 665, 666, 666, 665, 665, 666, 668, 668, 670, 671,
673, 674, 676, 679, 679, 681, 681, 682, 687, 688, 688, 687,
687, 685, 681, 680, 679, 678, 677, 678, 685, 683, 680, 678,
677, 676, 675, 678, 681, 684, 685, 686, 685, 685, 686, 688,
689, 690, 691, 691, 690, 692, 692, 694, 697, 698, 699, 699,
700, 701, 702, 702, 704, 705, 705, 709, 713, 712, 712, 711,
709, 707, 706, 704, 703, 703, 704, 703, 704, 704, 703, 703,
702, 701, 700, 699, 698, 698, 697, 697, 698, 698, 697, 697,
695, 694, 693, 693, 695, 695, 696, 696, 697, 698, 698, 697,
697, 698, 697, 696, 697, 696, 700, 700, 701, 701, 703, 704,
704, 706, 708, 710, 711, 712, 714, 715, 716, 717, 717, 718,
717, 718, 718, 717, 718, 718, 717, 717, 714, 713, 713, 714,
715, 716, 717, 719, 721, 721, 720, 719, 718, 718, 719, 719,
721, 722, 725, 726, 726, 727, 727, 730, 730, 734, 734, 733,
733, 732, 732, 735, 737, 739, 739, 740, 740, 741, 741, 740,
740, 741, 744, 745, 744, 743, 741, 738, 737, 736, 738, 739,
741, 742, 744, 744, 742, 740, 739, 744, 747, 749, 750, 751,
751, 750, 750, 749, 749, 750, 751, 751, 748, 748, 752, 754,
755, 756, 755, 755, 754, 755, 759, 762, 764, 765, 766, 766,
765, 764, 764, 765, 765, 764, 765, 767, 767, 768, 769, 771,
770, 770, 771, 771, 773, 775, 776, 778, 777, 773, 774, 782,
783, 784, 784, 782, 781, 777, 775, 777, 780, 789, 790, 789,
789, 790, 792, 792, 793, 795, 799, 801, 804, 805, 809, 810,
812, 814, 815, 817, 819, 819, 818, 819, 820, 821, 821, 822,
823, 826, 829, 830, 834, 835, 835, 836, 837, 841, 848, 849,
851, 851, 852, 852, 853, 853, 854, 854, 855, 856, 855, 853,
853, 851, 850, 849, 848, 848, 847, 847, 845, 845, 846, 845,
845, 844, 844, 846, 848, 848, 849, 849, 850, 850, 851, 851,
852, 852, 853, 854, 855, 856, 857, 857, 858, 857, 856, 855,
855, 854, 854, 852, 854, 855, 857, 859, 860, 861, 861, 862,
863, 863, 865, 865, 864, 863, 861, 861, 862, 863, 865, 866,
867, 867, 870, 872, 873, 874, 876, 877, 878, 879, 884, 888,
889, 892, 893, 894),
y = c(863, 857, 852, 851, 847, 844, 840, 838, 838, 834, 831, 831,
829, 829, 828, 827, 827, 829, 832, 832, 831, 830, 828, 793,
791, 790, 789, 788, 783, 779, 774, 768, 765, 756, 753, 751,
750, 749, 743, 741, 740, 741, 741, 739, 739, 740, 740, 741,
740, 740, 737, 735, 735, 736, 738, 735, 735, 738, 741, 743,
745, 746, 746, 745, 745, 744, 743, 744, 746, 747, 746, 747,
747, 742, 740, 741, 741, 740, 742, 744, 744, 743, 741, 738,
738, 737, 737, 736, 735, 734, 733, 732, 730, 729, 728, 726,
724, 721, 720, 717, 716, 715, 715, 716, 716, 715, 714, 712,
712, 710, 710, 712, 711, 710, 708, 708, 709, 709, 712, 712,
711, 711, 712, 712, 713, 713, 712, 713, 711, 709, 708, 708,
709, 708, 707, 706, 706, 705, 704, 703, 701, 701, 698, 697,
696, 694, 692, 690, 689, 688, 686, 686, 685, 685, 680, 681,
686, 685, 685, 684, 683, 683, 681, 682, 680, 681, 680, 681,
681, 682, 682, 681, 680, 679, 679, 680, 682, 682, 680, 679,
681, 683, 683, 680, 680, 681, 681, 680, 679, 677, 678, 679,
679, 677, 677, 678, 678, 679, 679, 677, 677, 679, 679, 681,
681, 682, 683, 683, 684, 684, 688, 688, 687, 685, 685, 684,
684, 687, 687, 689, 689, 690, 690, 692, 694, 696, 697, 701,
704, 705, 708, 713, 715, 716, 718, 718, 719, 759, 757, 757,
756, 756, 754, 754, 753, 756, 757, 762, 765, 771, 772, 776,
776, 778, 780, 781, 786, 789, 795, 802, 806, 809, 814, 816,
818, 812, 810, 808, 807, 810, 813, 815, 816, 818, 819, 821,
822, 834, 836, 843, 845, 846, 848, 848, 849, 848, 849, 848,
840, 840, 843, 845, 846, 845, 842, 842, 844, 848, 850, 851,
851, 850, 851, 851, 850, 851, 853, 853, 854, 859, 863, 873,
877, 879, 883, 886, 894, 900, 905, 910, 914, 919, 926, 929,
933, 934, 936, 937, 938, 945, 948, 953, 956, 956, 958, 959,
960, 962, 969, 975, 980, 983, 987, 990, 995, 999, 1004, 1007,
1010, 1017, 1020, 1023, 1027, 1028, 1032, 1034, 1038, 1041,
1042, 1044, 1046, 1053, 1055, 1056, 1058, 1061, 1073, 1077,
1079, 1081, 1084, 1092, 1095, 1100, 1109, 1113, 1117, 1123,
1126, 1128, 1130, 1132, 1134, 1139, 1140, 1142, 1145, 1148,
1151, 1153, 1153, 1154, 1156, 1156, 1155, 1155, 1157, 1163,
1163, 1162, 1150, 1149, 1146, 1147, 1155, 1158, 1160, 1159,
1154, 1152, 1148, 1149, 1146, 1140, 1136, 1133, 1136, 1134,
1132, 1130, 1128, 1130, 1132, 1132, 1134, 1136, 1140, 1144,
1146, 1150, 1152, 1155, 1157, 1158, 1160, 1164, 1167, 1168,
1170, 1173, 1173, 1172, 1172, 1174, 1176, 1178, 1181, 1185,
1189, 1191, 1190, 1186, 1183, 1183, 1179, 1176, 1173, 1167,
1162, 1156, 1154, 1153, 1152, 1159, 1160, 1163, 1156, 1151,
1149, 1197, 1199, 1210, 1216, 1219, 1227, 1229, 1231, 1235,
1238, 1240, 1243, 1244, 1246, 1248, 1251, 1252, 1255, 1259,
1268, 1272, 1272, 1276, 1281, 1285, 1288, 1292, 1295, 1302,
1307, 1326, 1333, 1335, 1337, 1337, 1342, 1344, 1347, 1352,
1357, 1360, 1370, 1376, 1377, 1379, 1379, 1380, 1381, 1381,
1383, 1317, 1319, 1321, 1325, 1329, 1331, 1332, 1336, 1338,
1340, 1341, 1346, 1347, 1354, 1356, 1359, 1365, 1368, 1371,
1374, 1379, 1382, 1381, 1382, 1378, 1374, 1370, 1367, 1364,
1363, 1361, 1359, 1358, 1358, 1347, 1345, 1344, 1342, 1339,
1339, 1338, 1339, 1342, 1344, 1345, 1345, 1344, 1342, 1342,
1341, 1343, 1351, 1354, 1360, 1368, 1370, 1372, 1374, 1378,
1380, 1382, 1384, 1385, 1390, 1390, 1388, 1388, 1392, 1392,
1393, 1393, 1394, 1393, 1394, 1394, 1393, 1393, 1394, 1395,
1395, 1396, 1396, 1399, 1401, 1405, 1405, 1408, 1408, 1410,
1416, 1417, 1424, 1424, 1428, 1430, 1431, 1432, 1433, 1433,
1433, 1435, 1438, 1440, 1440, 1441, 1442, 1444, 1445, 1448,
1449, 1449, 1450, 1449, 1450, 1449, 1445, 1444, 1444, 1443,
1445, 1443, 1442, 1441, 1444, 1443, 1443, 1446, 1446, 1444,
1443, 1441, 1440, 1439, 1439, 1438, 1438, 1439, 1439, 1440,
1440, 1441, 1442, 1443, 1443, 1448, 1448, 1451, 1453, 1454,
1455, 1457, 1457, 1458, 1458, 1459, 1459, 1461, 1464, 1466,
1470, 1472, 1473, 1475, 1477, 1476, 1476, 1475, 1474, 1475,
1475, 1474, 1474, 1476, 1476, 1478, 1478, 1477, 1477, 1476,
1484, 1486, 1488, 1489, 1491, 1494, 1496, 1503, 1506, 1509,
1512, 1517, 1521, 1525, 1527, 1530, 1532, 1536, 1538, 1543,
1544, 1545, 1547, 1549, 1553, 1554, 1557, 1557, 1558, 1566,
1569, 1574, 1577, 1578, 1578, 1582, 1584, 1585, 1586, 1586,
1584, 1584, 1583, 1582, 1584, 1586, 1589, 1594, 1602, 1607,
1611, 1614, 1618, 1622, 1625, 1627, 1629, 1631, 1633, 1636,
1638, 1637, 1636, 1637, 1640, 1642, 1644, 1645, 1646, 1646,
1649, 1651, 1656, 1659, 1661, 1664, 1666, 1666, 1664, 1661,
1658, 1655, 1653, 1651, 1650, 1649, 1648, 1644, 1642, 1641,
1635, 1632, 1630, 1627, 1625, 1622, 1615, 1611, 1609, 1606,
1613, 1617, 1620, 1622, 1624, 1626, 1628, 1631, 1632, 1632,
1630, 1630, 1631, 1633, 1635, 1635, 1637, 1640, 1642, 1649,
1653, 1653, 1657, 1659, 1661, 1661, 1659, 1660, 1662, 1664,
1665, 1666, 1666, 1668, 1670, 1670, 1673, 1673, 1676, 1676,
1675, 1676, 1677, 1678, 1679, 1680, 1680, 1679, 1679, 1678,
1677, 1676, 1676, 1673, 1672, 1672, 1670, 1670, 1669, 1669,
1668, 1669, 1668, 1668, 1667, 1666, 1665, 1664, 1663, 1662,
1660, 1660, 1658, 1658, 1659, 1661, 1666, 1668, 1670, 1673,
1675, 1676, 1678, 1680, 1681, 1681, 1684, 1687, 1695, 1694,
1690, 1683, 1684, 1687, 1692, 1693, 1694, 1697, 1702, 1704,
1706, 1708, 1709, 1711, 1711, 1710, 1711, 1712, 1713, 1714,
1716, 1717, 1720, 1720, 1721, 1722, 1722, 1721, 1719, 1717,
1716, 1715, 1715, 1712, 1708, 1708, 1709, 1709, 1711, 1713,
1714, 1716, 1718, 1719, 1719, 1717, 1718, 1720, 1721, 1723,
1728, 1730, 1729, 1727, 1727, 1728, 1730, 1731, 1733, 1734,
1734, 1736, 1737, 1738, 1739, 1739, 1738, 1738, 1737, 1734,
1732, 1730, 1729, 1727, 1727, 1726, 1726, 1727, 1726, 1726,
1725, 1726, 1725, 1725, 1726, 1726, 1729, 1729, 1730, 1731,
1731, 1732, 1731, 1732, 1732, 1733, 1734, 1735, 1736, 1738,
1738, 1739, 1739, 1738, 1739, 1738, 1738, 1741, 1742, 1743,
1746, 1747, 1749, 1750, 1752, 1752, 1753, 1754, 1754, 1755,
1757, 1758, 1758, 1758, 1757, 1758, 1757, 1757, 1758, 1758,
1757, 1757, 1757, 1758, 1757, 1758, 1758, 1757, 1756, 1756,
1757, 1757, 1756, 1757, 1757, 1756, 1757, 1758, 1760, 1761,
1761, 1762, 1763, 1763, 1764, 1765, 1766, 1767, 1770, 1772,
1774, 1774, 1775, 1774, 1774, 1772, 1772, 1770, 1770, 1768,
1767, 1766, 1764, 1762, 1760, 1761, 1761, 1762, 1760, 1759,
1756, 1750, 1749, 1753, 1757, 1758, 1760, 1760, 1761, 1761,
1762, 1762, 1763, 1763, 1764, 1767, 1768, 1770, 1774, 1775,
1774, 1776, 1778, 1779, 1783, 1786, 1788, 1789, 1788, 1787,
1789, 1789, 1787, 1790, 1790, 1791, 1793, 1793, 1794, 1793,
1793, 1792, 1788, 1787, 1785, 1784, 1783, 1781, 1780, 1779,
1776, 1774, 1776, 1774, 1776, 1777, 1779, 1781, 1782, 1784,
1786, 1789, 1790, 1790, 1789, 1786, 1785, 1785, 1784, 1784,
1782, 1781, 1781, 1780, 1776, 1775, 1775, 1777, 1779, 1780,
1782, 1783, 1783, 1782, 1784, 1786, 1786, 1788, 1790, 1790,
1789, 1789, 1791, 1793, 1796, 1798, 1800, 1800, 1799, 1799,
1798, 1798, 1797, 1797, 1793, 1792, 1791, 1790, 1790, 1791,
1791, 1790, 1790, 1789, 1789, 1788, 1787, 1786, 1784, 1785,
1785, 1783, 1783, 1782, 1776, 1775, 1772, 1770, 1769, 1766,
1762, 1762, 1761, 1760, 1758, 1756, 1752, 1752, 1750, 1749,
1748, 1747, 1747, 1746, 1746, 1744, 1744, 1743, 1743, 1741,
1740, 1740, 1741, 1741, 1739, 1734, 1732, 1731, 1726, 1724,
1722, 1720, 1715, 1713, 1710, 1706, 1710, 1716, 1719, 1722,
1723, 1722, 1722, 1720, 1719, 1715, 1714, 1712, 1711, 1711,
1709, 1711, 1716, 1717, 1719, 1720, 1722, 1724, 1728, 1732,
1734, 1736, 1738, 1739, 1739, 1740, 1736, 1735, 1736, 1737,
1739, 1742, 1743, 1743, 1745, 1746, 1747, 1747, 1746, 1745,
1745, 1744, 1744, 1743, 1744, 1743, 1743, 1742, 1742, 1741,
1741, 1742, 1743, 1743, 1744, 1744) ),
list(x = c(894, 897, 898, 899, 901, 902, 906, 907, 911, 912, 913, 917,
917, 919, 920, 920, 921, 921, 923, 923, 925, 925, 926, 927,
928, 929, 930, 932, 934, 934, 932, 931, 929, 929, 928, 928,
929, 935, 936, 939, 941, 942, 942, 941, 938, 935, 933, 930,
929, 926, 925, 925, 928, 929, 931, 932, 930, 927, 926, 925,
924, 922, 921, 917, 916, 916, 917, 917, 918, 920, 924, 924,
925, 925, 926, 926, 925, 925, 926, 928, 928, 929, 931, 933,
933, 935, 935, 934, 935, 938, 938, 939, 939, 938, 938, 939,
940, 940, 941, 941, 942, 943, 944, 944, 945, 945, 946, 946,
953, 954, 956, 958, 959, 960, 961, 962, 964, 965, 965, 962,
961, 959, 957, 957, 958, 958, 957, 962, 963, 965, 965, 970,
970, 971, 972, 976, 978, 979, 980, 980, 981, 979, 977, 978,
978, 979, 980, 980, 981, 980, 980, 983, 984, 985, 986, 988,
989, 991, 992, 993, 993, 994, 994, 995, 996, 998, 998, 997,
999, 1000, 1001, 1001, 998, 996, 994, 993, 995, 996, 999,
1000, 1000, 998, 997, 995, 993, 993, 994, 996, 998, 1000,
1001, 1002, 1001, 1001, 1002, 1005, 1009, 1014, 1015, 1015,
1014, 1014, 1017, 1017, 1018, 1018, 1019, 1019, 1020, 1022,
1023, 1025, 1031, 1031, 1033, 1034, 1036, 1037, 1039, 1040,
1043, 1046, 1046, 1048, 1048, 1049, 1051, 1054, 1055, 1058,
1058, 1060, 1060, 1062, 1063, 1065, 1068, 1069, 1069, 1068,
1066, 1066, 1068, 1071, 1074, 1075, 1076, 1076, 1077, 1078,
1080, 1083, 1084, 1085, 1085, 1084, 1084, 1081, 1080, 1079,
1079, 1081, 1082, 1082, 1083, 1084, 1084, 1087, 1087, 1084,
1082, 1080, 1077, 1074, 1064, 1059, 1058, 1055, 1054, 1052,
1051, 1048, 1044, 1043, 1043, 1044, 1046, 1049, 1050, 1051,
1053, 1053, 1054, 1056, 1057, 1057, 1058, 1058, 1059, 1060,
1060, 1061, 1063, 1064, 1064, 1063, 1063, 1062, 1064, 1064,
1065, 1065, 1066, 1066, 1068, 1070, 1071, 1071, 1072, 1072,
1073, 1073, 1074, 1073, 1074, 1074, 1075, 1076, 1077, 1078,
1079, 1080, 1080, 1079, 1079, 1078, 1079, 1078, 1079, 1079,
1081, 1083, 1083, 1084, 1084, 1085, 1085, 1084, 1085, 1084,
1083, 1082, 1082, 1084, 1088, 1089, 1091, 1091, 1092, 1092,
1093, 1094, 1095, 1095, 1097, 1098, 1098, 1096, 1096, 1098,
1105, 1108, 1108, 1109, 1109, 1110, 1111, 1110, 1110, 1109,
1109, 1112, 1114, 1113, 1114, 1113, 1114, 1113, 1113, 1114,
1114, 1115, 1116, 1117, 1117, 1119, 1124, 1125, 1127, 1130,
1131, 1132, 1132, 1133, 1137, 1138, 1139, 1143, 1143, 1144,
1145, 1146, 1148, 1149, 1150, 1150, 1148, 1147, 1146, 1146,
1145, 1145, 1146, 1147, 1150, 1152, 1153, 1155, 1156, 1156,
1158, 1158, 1160, 1160, 1159, 1160, 1161, 1165, 1165, 1164,
1164, 1165, 1165, 1167, 1168, 1168, 1167, 1167, 1168, 1169,
1170, 1172, 1174, 1174, 1175, 1176, 1178, 1179, 1180, 1180,
1181, 1182, 1184, 1186, 1191, 1192, 1194, 1195, 1197, 1197,
1198, 1199, 1199, 1200, 1202, 1208, 1212, 1212, 1214, 1216,
1219, 1223, 1223, 1224, 1225, 1228, 1229, 1229, 1230, 1234,
1234, 1235, 1237, 1239, 1241, 1242, 1242, 1243, 1243, 1242,
1244, 1243, 1243, 1244, 1244, 1244, 1245, 1245, 1244, 1244,
1246, 1248, 1250, 1252, 1252, 1253, 1253, 1252, 1252, 1251,
1251, 1252, 1253, 1253, 1254, 1254, 1256, 1259, 1263, 1265,
1265, 1262, 1262, 1263, 1264, 1264, 1265, 1265, 1266, 1267,
1267, 1269, 1270, 1271, 1272, 1274, 1276, 1278, 1279, 1279,
1278, 1277, 1276, 1275, 1276, 1275, 1273, 1273, 1274, 1279,
1282, 1284, 1285, 1287, 1288, 1287, 1286, 1286, 1285, 1285,
1286, 1288, 1290, 1290, 1291, 1292, 1292, 1293, 1293, 1294,
1296, 1299, 1301, 1302, 1303, 1301, 1300, 1299, 1301, 1303,
1304, 1306, 1307, 1310, 1312, 1313, 1314, 1315, 1315, 1312,
1310, 1307, 1307, 1305, 1305, 1306, 1303, 1303, 1301, 1300,
1302, 1304, 1303, 1301, 1299, 1294, 1294, 1293, 1293, 1291,
1285, 1284, 1287, 1291, 1291, 1294, 1295, 1294, 1294, 1292,
1290, 1290, 1286, 1286, 1283, 1281, 1281, 1280, 1279, 1279,
1278, 1277, 1274, 1272, 1271, 1270, 1268, 1267, 1267, 1266,
1263, 1262, 1258, 1260, 1259, 1260, 1261, 1259, 1259, 1257,
1257, 1256, 1257, 1257, 1261, 1264, 1265, 1266, 1267, 1267,
1266, 1266, 1265, 1265, 1264, 1261, 1261, 1257, 1252, 1251,
1248, 1242, 1240, 1237, 1237, 1240, 1243, 1244, 1244, 1245,
1246, 1248, 1250, 1251, 1253, 1257, 1267, 1275, 1278, 1281,
1281, 1283, 1286, 1286, 1287, 1287, 1290, 1291, 1292, 1293,
1294, 1296, 1299, 1301, 1303, 1306, 1307, 1309, 1313, 1314,
1317, 1320, 1322, 1323, 1324, 1324, 1326, 1327, 1330, 1333,
1334, 1335, 1338, 1344, 1347, 1351, 1367),
y = c(1744, 1743, 1744, 1743, 1742, 1743, 1741, 1742, 1740, 1740,
1739, 1739, 1738, 1738, 1737, 1734, 1734, 1731, 1730, 1728,
1726, 1724, 1724, 1725, 1725, 1726, 1726, 1724, 1725, 1727,
1728, 1729, 1730, 1736, 1738, 1741, 1742, 1745, 1746, 1747,
1747, 1748, 1749, 1748, 1748, 1747, 1747, 1750, 1752, 1755,
1755, 1756, 1759, 1759, 1760, 1761, 1760, 1760, 1761, 1761,
1763, 1763, 1764, 1764, 1766, 1773, 1776, 1779, 1780, 1785,
1787, 1788, 1789, 1790, 1787, 1785, 1784, 1783, 1783, 1787,
1788, 1788, 1789, 1791, 1792, 1794, 1796, 1797, 1798, 1798,
1800, 1800, 1802, 1803, 1804, 1807, 1808, 1810, 1811, 1813,
1813, 1815, 1815, 1816, 1815, 1814, 1812, 1810, 1810, 1811,
1811, 1813, 1813, 1814, 1816, 1816, 1817, 1817, 1818, 1821,
1824, 1826, 1830, 1839, 1841, 1845, 1847, 1850, 1852, 1854,
1857, 1857, 1856, 1856, 1858, 1858, 1857, 1856, 1856, 1858,
1859, 1860, 1860, 1862, 1866, 1867, 1869, 1871, 1871, 1872,
1873, 1873, 1871, 1871, 1869, 1867, 1865, 1864, 1863, 1863,
1861, 1861, 1860, 1858, 1857, 1858, 1859, 1859, 1857, 1857,
1858, 1859, 1862, 1863, 1865, 1865, 1867, 1866, 1865, 1866,
1868, 1869, 1870, 1871, 1871, 1874, 1875, 1876, 1876, 1877,
1878, 1880, 1882, 1883, 1884, 1884, 1882, 1882, 1883, 1884,
1887, 1889, 1890, 1889, 1889, 1886, 1886, 1882, 1880, 1879,
1878, 1877, 1877, 1876, 1876, 1878, 1878, 1879, 1879, 1880,
1881, 1881, 1880, 1878, 1877, 1875, 1873, 1873, 1872, 1873,
1875, 1877, 1878, 1880, 1882, 1884, 1884, 1883, 1882, 1880,
1878, 1880, 1882, 1882, 1881, 1881, 1883, 1885, 1886, 1888,
1888, 1885, 1886, 1888, 1889, 1890, 1891, 1891, 1891, 1892,
1894, 1895, 1897, 1899, 1902, 1903, 1905, 1908, 1911, 1914,
1917, 1917, 1919, 1920, 1920, 1918, 1917, 1918, 1920, 1922,
1925, 1928, 1928, 1929, 1931, 1933, 1933, 1935, 1935, 1934,
1934, 1938, 1938, 1937, 1936, 1933, 1931, 1927, 1925, 1925,
1924, 1923, 1923, 1925, 1927, 1928, 1937, 1938, 1937, 1935,
1936, 1937, 1937, 1938, 1938, 1936, 1936, 1934, 1934, 1931,
1929, 1928, 1928, 1927, 1927, 1932, 1934, 1933, 1933, 1932,
1932, 1934, 1936, 1938, 1940, 1941, 1942, 1942, 1943, 1942,
1942, 1940, 1939, 1938, 1937, 1936, 1935, 1933, 1932, 1931,
1929, 1928, 1924, 1923, 1919, 1919, 1918, 1917, 1917, 1918,
1918, 1919, 1921, 1922, 1922, 1924, 1925, 1927, 1928, 1928,
1925, 1922, 1921, 1919, 1918, 1918, 1917, 1916, 1914, 1913,
1912, 1909, 1909, 1908, 1908, 1908, 1909, 1909, 1908, 1909,
1908, 1909, 1908, 1908, 1909, 1907, 1907, 1906, 1907, 1907,
1906, 1906, 1901, 1900, 1903, 1905, 1906, 1908, 1909, 1909,
1910, 1909, 1907, 1905, 1905, 1904, 1902, 1902, 1901, 1900,
1900, 1899, 1898, 1898, 1899, 1898, 1899, 1899, 1898, 1899,
1897, 1898, 1898, 1897, 1897, 1898, 1900, 1900, 1899, 1899,
1898, 1898, 1896, 1896, 1895, 1891, 1890, 1888, 1889, 1891,
1892, 1893, 1893, 1892, 1891, 1891, 1890, 1889, 1890, 1888,
1887, 1885, 1884, 1884, 1886, 1887, 1887, 1888, 1888, 1889,
1889, 1888, 1887, 1885, 1884, 1883, 1881, 1880, 1880, 1878,
1879, 1879, 1883, 1883, 1884, 1884, 1885, 1886, 1886, 1890,
1891, 1890, 1890, 1888, 1887, 1887, 1886, 1886, 1887, 1886,
1886, 1885, 1886, 1886, 1885, 1884, 1885, 1884, 1884, 1887,
1888, 1888, 1889, 1889, 1890, 1890, 1887, 1886, 1883, 1881,
1877, 1876, 1876, 1877, 1878, 1879, 1881, 1881, 1883, 1883,
1879, 1873, 1871, 1870, 1868, 1863, 1862, 1860, 1858, 1858,
1865, 1863, 1863, 1861, 1861, 1863, 1863, 1867, 1867, 1868,
1869, 1869, 1870, 1872, 1877, 1879, 1879, 1882, 1882, 1887,
1887, 1889, 1889, 1890, 1890, 1887, 1888, 1887, 1888, 1887,
1885, 1884, 1882, 1881, 1881, 1879, 1877, 1875, 1872, 1871,
1872, 1872, 1874, 1876, 1877, 1879, 1879, 1881, 1882, 1882,
1881, 1881, 1879, 1876, 1875, 1875, 1873, 1872, 1870, 1869,
1865, 1861, 1863, 1865, 1867, 1867, 1864, 1862, 1862, 1860,
1860, 1858, 1856, 1854, 1851, 1848, 1846, 1845, 1844, 1845,
1845, 1844, 1843, 1839, 1838, 1836, 1833, 1832, 1829, 1829,
1827, 1824, 1820, 1819, 1818, 1818, 1816, 1816, 1818, 1821,
1821, 1819, 1819, 1820, 1822, 1823, 1823, 1821, 1817, 1819,
1818, 1819, 1817, 1813, 1812, 1812, 1811, 1807, 1805, 1803,
1802, 1800, 1799, 1796, 1798, 1800, 1800, 1798, 1797, 1794,
1790, 1791, 1791, 1789, 1785, 1778, 1774, 1771, 1764, 1759,
1753, 1745, 1745, 1744, 1739, 1737, 1732, 1732, 1731, 1730,
1728, 1726, 1725, 1724, 1723, 1718, 1712, 1708, 1706, 1706,
1704, 1699, 1696, 1688, 1687, 1685, 1682, 1677, 1675, 1680,
1681, 1682, 1681, 1684, 1684, 1683, 1681, 1681, 1682, 1683,
1684, 1684, 1683, 1684, 1683, 1682, 1681, 1679, 1675, 1673,
1673, 1671, 1669, 1667, 1665, 1663, 1663)),
list(x = c(1367, 1368, 1368, 1371, 1372, 1373, 1375, 1376, 1378, 1380,
1381, 1383, 1385, 1386, 1389, 1390, 1392, 1399, 1401, 1407,
1408, 1410, 1411, 1413, 1415, 1417, 1419, 1420, 1422, 1424,
1426, 1426, 1427, 1427, 1430, 1430, 1431, 1431, 1432, 1432,
1434, 1436, 1436, 1437, 1437, 1438, 1438, 1442, 1443, 1446,
1447, 1450, 1451, 1452, 1454, 1455, 1456, 1456, 1457, 1459,
1460, 1462, 1462, 1464, 1466, 1468, 1469, 1470, 1473, 1473,
1475, 1475, 1477, 1478, 1479, 1481, 1485, 1487, 1488, 1488,
1489, 1490, 1492, 1493, 1495, 1497, 1498, 1499, 1501, 1502,
1503, 1505, 1507, 1509, 1511, 1511, 1512, 1515, 1515, 1516,
1517, 1517, 1518, 1520, 1522, 1522, 1523, 1523, 1524, 1524,
1525, 1525, 1524, 1525, 1525, 1528, 1528, 1529, 1531, 1532,
1533, 1535, 1536, 1537, 1540, 1541, 1542, 1541, 1541, 1540,
1541, 1541, 1542, 1542, 1544, 1544, 1546, 1546, 1548, 1548,
1549, 1550, 1552, 1552, 1553, 1553, 1554, 1554, 1555, 1556,
1556, 1558, 1560, 1560, 1561, 1561, 1560, 1562, 1563, 1563,
1562, 1562, 1560, 1560, 1557, 1557, 1556, 1556, 1557, 1557,
1558, 1559, 1559, 1558, 1559, 1559, 1558, 1558, 1557, 1556,
1556, 1555, 1555, 1556, 1556, 1557, 1557, 1558, 1558, 1560,
1564, 1564, 1563, 1562, 1562, 1560, 1561, 1561, 1565, 1566,
1566, 1567, 1569, 1570, 1571, 1572, 1572, 1573, 1573, 1574,
1574, 1576, 1578, 1578, 1577, 1577, 1579, 1578, 1577, 1575,
1574, 1574, 1572, 1572, 1575, 1573, 1572, 1569, 1567, 1567,
1565, 1562, 1560, 1560, 1561, 1561, 1562, 1563, 1563, 1562,
1562, 1563, 1563, 1562, 1564, 1565, 1566, 1566, 1567, 1568,
1568, 1569, 1573, 1574, 1575, 1576, 1577, 1577, 1579, 1579,
1580, 1582, 1583, 1582, 1581, 1580, 1579, 1579, 1576, 1577,
1579, 1579, 1580, 1580, 1581, 1581, 1582, 1582, 1581, 1581,
1580, 1581, 1582, 1582, 1583, 1586, 1587, 1587, 1590, 1614,
1614, 1617, 1617, 1618, 1618, 1619, 1619, 1621, 1621, 1620,
1620, 1621, 1621, 1622, 1623, 1623, 1625, 1626, 1626, 1627,
1628, 1630, 1631, 1635, 1637, 1638, 1639, 1640, 1640, 1638,
1637, 1636, 1635, 1635, 1634, 1634, 1635, 1635, 1637, 1638,
1640, 1642, 1643, 1644, 1644, 1650, 1651, 1652, 1652, 1651,
1650, 1650, 1651, 1651, 1652, 1654, 1657, 1658, 1658, 1657,
1656, 1656, 1658, 1658, 1659, 1659, 1660, 1662, 1662, 1661,
1661, 1662, 1662, 1663, 1664, 1665, 1665, 1666, 1667, 1667,
1669, 1669, 1670, 1670, 1671, 1671, 1672, 1674, 1676, 1685,
1686, 1687, 1690, 1692, 1692, 1693, 1694, 1702, 1703, 1704,
1706, 1707, 1708, 1710, 1712, 1713, 1713, 1715, 1717, 1716,
1716, 1718, 1719, 1719, 1721, 1722, 1756, 1759, 1760, 1762,
1763, 1753, 1756, 1754, 1753, 1753, 1754, 1756, 1757, 1755,
1753, 1752, 1752, 1753, 1753, 1752, 1752, 1753, 1755, 1756,
1758, 1756, 1756, 1755, 1754, 1754, 1752, 1752, 1753, 1752,
1752, 1753, 1753, 1754, 1754, 1755, 1756, 1756, 1757, 1757,
1756, 1756, 1758, 1760, 1761, 1762, 1762, 1761, 1761, 1760,
1760, 1761, 1760, 1762, 1763, 1766, 1768, 1768, 1770, 1771,
1771, 1776, 1778, 1778, 1779, 1779, 1780, 1780, 1787, 1787,
1786, 1786, 1785, 1784, 1787, 1787, 1788, 1788, 1789, 1790,
1790, 1791, 1792, 1792, 1794, 1794, 1795, 1795, 1796, 1796,
1795, 1797, 1797, 1796, 1796, 1795, 1794, 1793, 1793, 1792,
1792, 1803, 1804, 1804, 1805, 1808, 1808, 1807, 1807, 1806,
1805, 1805, 1806, 1807, 1807, 1809, 1810, 1812, 1813, 1817,
1819, 1820, 1823, 1825, 1827, 1829, 1830, 1830, 1832, 1833,
1839, 1840, 1841, 1841, 1843, 1844, 1845, 1846, 1845, 1844,
1844, 1847, 1847, 1848, 1850, 1851, 1852, 1854, 1855, 1858,
1859, 1862, 1863, 1862, 1862, 1863, 1863, 1864, 1865, 1865,
1866, 1868, 1868, 1869, 1869, 1871, 1872, 1872, 1873, 1871,
1871, 1872, 1874, 1876, 1878, 1880, 1882, 1883, 1883, 1882,
1880, 1882, 1882, 1881, 1882, 1883, 1887, 1887, 1888, 1892,
1894, 1896, 1898, 1899, 1900, 1900, 1901, 1903, 1904, 1906,
1907, 1908, 1908, 1910, 1910, 1914, 1915, 1916, 1918, 1919,
1919, 1918, 1918, 1922, 1922, 1923, 1924, 1924, 1925, 1925,
1926, 1926, 1928, 1929, 1930, 1931, 1932, 1932, 1933, 1934,
1934, 1936, 1938, 1938, 1937, 1937, 1938, 1938, 1939, 1940,
1940, 1942, 1942, 1944, 1945, 1946, 1946, 1944, 1943, 1943,
1942, 1941, 1939, 1933, 1932, 1931, 1931, 1930, 1930, 1931,
1932, 1932, 1935, 1935, 1937, 1937, 1939, 1940, 1940, 1941,
1942, 1943, 1945, 1945, 1947, 1948, 1950, 1951, 1951, 1950,
1950, 1956, 1957, 1958, 1960, 1960, 1959, 1959, 1960, 1960,
1963, 1963, 1966, 1965, 1965, 1964, 1964, 1968, 1970, 1970,
1971, 1971, 1970, 1970, 1971, 1971, 1972, 1972, 1973, 1974,
1974, 1975, 1975, 1976, 1976, 1977, 1977, 1976, 1980, 1982,
1982, 1984, 1985, 1985, 1988, 1988, 1989, 1989, 1990, 1991,
1994, 1994, 1995, 1995, 1997, 1997, 1999, 2000, 2000, 1997,
1997, 1998, 1998, 2001, 2003, 2005, 2005, 2006, 2006, 2007,
2007, 2009, 2011, 2012, 2021, 2022, 2024, 2027, 2029, 2029,
2028, 2028, 2029, 2029, 2028, 2028, 2027, 2026, 2026, 2025,
2031, 2031, 2032, 2034, 2034, 2035, 2035, 2033, 2033, 2034,
2034, 2035, 2035, 2038, 2038, 2039, 2039, 2040, 2039, 2040,
2039, 2039, 2038, 2037, 2037, 2038, 2038, 2040, 2040, 2041,
2042, 2043, 2043, 2041, 2041, 2040, 2039, 2040, 2041, 2044,
2044, 2048, 2048, 2049, 2050, 2050, 2051, 2053, 2055, 2057,
2058, 2059, 2059, 2062, 2064, 2066, 2073, 2075, 2077, 2078,
2080, 2081, 2082, 2082, 2081, 2083, 2086, 2086, 2087, 2086,
2090, 2090, 2092, 2098, 2099, 2100, 2101, 2101, 2102, 2102,
2103, 2103, 2106, 2108, 2113, 2112, 2112, 2114, 2117, 2118,
2121, 2122, 2125, 2126, 2128, 2130, 2132, 2133, 2134, 2134,
2133, 2132, 2136, 2140, 2143, 2144, 2145, 2147, 2149, 2150,
2150, 2151, 2150, 2150, 2151, 2152, 2154, 2156, 2158, 2159,
2160, 2160, 2163, 2163, 2159, 2159, 2161, 2161, 2162, 2163,
2164, 2164, 2163, 2163, 2162, 2162, 2160, 2159, 2159, 2160,
2160, 2162, 2163, 2171, 2173, 2173, 2178, 2179, 2179, 2178,
2178, 2177, 2177, 2178, 2178, 2180, 2181),
y = c(1663, 1662, 1660, 1657, 1657, 1656, 1656, 1655, 1655, 1653,
1653, 1652, 1652, 1651, 1650, 1650, 1648, 1648, 1647, 1647,
1646, 1646, 1645, 1645, 1644, 1644, 1643, 1643, 1642, 1640,
1640, 1639, 1638, 1637, 1637, 1636, 1635, 1634, 1633, 1632,
1631, 1628, 1627, 1627, 1620, 1619, 1618, 1616, 1615, 1615,
1614, 1615, 1614, 1612, 1611, 1610, 1610, 1609, 1608, 1607,
1607, 1605, 1604, 1604, 1604, 1603, 1604, 1604, 1601, 1600,
1599, 1598, 1597, 1597, 1596, 1597, 1597, 1598, 1599, 1598,
1598, 1597, 1598, 1599, 1599, 1600, 1600, 1601, 1602, 1602,
1603, 1603, 1605, 1605, 1607, 1608, 1607, 1607, 1608, 1610,
1611, 1610, 1610, 1609, 1611, 1616, 1618, 1623, 1624, 1628,
1629, 1632, 1633, 1634, 1635, 1638, 1639, 1639, 1643, 1644,
1646, 1648, 1650, 1651, 1657, 1658, 1660, 1661, 1663, 1664,
1665, 1667, 1668, 1669, 1671, 1675, 1678, 1681, 1683, 1686,
1687, 1687, 1689, 1699, 1700, 1705, 1707, 1711, 1712, 1715,
1716, 1718, 1723, 1725, 1727, 1729, 1730, 1731, 1733, 1735,
1738, 1743, 1745, 1751, 1758, 1764, 1766, 1767, 1769, 1772,
1773, 1775, 1778, 1780, 1783, 1784, 1785, 1786, 1787, 1789,
1792, 1794, 1801, 1803, 1809, 1811, 1814, 1815, 1816, 1821,
1825, 1830, 1831, 1831, 1837, 1839, 1841, 1842, 1846, 1848,
1851, 1853, 1855, 1854, 1854, 1853, 1852, 1850, 1849, 1848,
1847, 1845, 1845, 1847, 1848, 1851, 1853, 1854, 1853, 1853,
1854, 1856, 1857, 1860, 1863, 1863, 1862, 1862, 1863, 1864,
1864, 1861, 1861, 1862, 1864, 1865, 1867, 1867, 1869, 1870,
1871, 1872, 1876, 1879, 1881, 1881, 1882, 1887, 1889, 1890,
1891, 1891, 1895, 1895, 1894, 1892, 1891, 1890, 1892, 1893,
1894, 1894, 1895, 1895, 1896, 1896, 1897, 1899, 1902, 1904,
1905, 1908, 1910, 1912, 1912, 1917, 1918, 1938, 1939, 1941,
1942, 1942, 1943, 1944, 1944, 1947, 1947, 1948, 1949, 1944,
1943, 1940, 1939, 1938, 1936, 1934, 1928, 1926, 1920, 1919,
1916, 1914, 1912, 1908, 1908, 1905, 1900, 1899, 1898, 1898,
1897, 1897, 1896, 1898, 1898, 1897, 1897, 1896, 1893, 1891,
1889, 1889, 1887, 1886, 1885, 1883, 1882, 1878, 1877, 1877,
1875, 1874, 1872, 1871, 1868, 1862, 1860, 1860, 1859, 1858,
1856, 1847, 1847, 1848, 1849, 1850, 1850, 1848, 1844, 1843,
1841, 1835, 1833, 1822, 1821, 1820, 1819, 1815, 1813, 1811,
1801, 1799, 1795, 1792, 1791, 1788, 1787, 1786, 1784, 1783,
1778, 1777, 1775, 1772, 1772, 1771, 1771, 1769, 1766, 1766,
1767, 1769, 1769, 1770, 1773, 1776, 1777, 1777, 1778, 1778,
1779, 1780, 1780, 1779, 1777, 1775, 1772, 1772, 1770, 1769,
1766, 1763, 1763, 1762, 1761, 1760, 1760, 1758, 1756, 1756,
1755, 1746, 1746, 1745, 1744, 1743, 1742, 1742, 1741, 1736,
1734, 1732, 1731, 1729, 1728, 1728, 1726, 1725, 1725, 1726,
1726, 1725, 1724, 1723, 1720, 1719, 1718, 1715, 1714, 1713,
1711, 1711, 1709, 1708, 1705, 1700, 1698, 1694, 1693, 1692,
1690, 1688, 1688, 1687, 1686, 1684, 1671, 1671, 1670, 1669,
1666, 1665, 1665, 1663, 1660, 1657, 1654, 1653, 1651, 1651,
1650, 1645, 1644, 1642, 1641, 1640, 1640, 1641, 1641, 1640,
1639, 1635, 1634, 1632, 1629, 1627, 1626, 1624, 1623, 1621,
1619, 1617, 1616, 1614, 1612, 1608, 1607, 1605, 1604, 1600,
1600, 1595, 1594, 1592, 1585, 1583, 1575, 1572, 1571, 1569,
1568, 1557, 1557, 1556, 1555, 1555, 1552, 1551, 1548, 1547,
1545, 1540, 1539, 1537, 1536, 1533, 1530, 1528, 1528, 1524,
1523, 1522, 1522, 1520, 1520, 1522, 1522, 1517, 1516, 1516,
1514, 1515, 1515, 1518, 1520, 1520, 1518, 1517, 1517, 1516,
1514, 1514, 1511, 1511, 1509, 1509, 1508, 1508, 1507, 1507,
1508, 1508, 1509, 1510, 1511, 1513, 1515, 1514, 1512, 1511,
1509, 1508, 1507, 1506, 1505, 1501, 1500, 1499, 1498, 1497,
1495, 1494, 1493, 1489, 1486, 1486, 1485, 1487, 1490, 1490,
1491, 1491, 1492, 1493, 1494, 1494, 1490, 1489, 1487, 1483,
1483, 1485, 1485, 1484, 1484, 1482, 1482, 1481, 1480, 1479,
1478, 1478, 1477, 1477, 1472, 1470, 1470, 1469, 1470, 1470,
1472, 1473, 1474, 1474, 1475, 1475, 1474, 1471, 1470, 1469,
1469, 1468, 1467, 1467, 1466, 1466, 1464, 1463, 1462, 1462,
1464, 1464, 1463, 1462, 1461, 1460, 1459, 1457, 1456, 1456,
1455, 1453, 1452, 1450, 1448, 1447, 1446, 1447, 1447, 1448,
1449, 1451, 1453, 1453, 1454, 1454, 1452, 1449, 1445, 1443,
1443, 1442, 1439, 1438, 1436, 1434, 1433, 1432, 1430, 1429,
1429, 1430, 1430, 1431, 1431, 1430, 1429, 1429, 1428, 1427,
1424, 1424, 1423, 1421, 1420, 1419, 1418, 1412, 1411, 1410,
1410, 1408, 1404, 1403, 1402, 1400, 1397, 1397, 1394, 1393,
1393, 1390, 1389, 1384, 1383, 1379, 1377, 1374, 1372, 1371,
1368, 1366, 1364, 1363, 1357, 1357, 1355, 1353, 1353, 1352,
1350, 1348, 1348, 1345, 1345, 1346, 1347, 1348, 1350, 1350,
1347, 1345, 1343, 1341, 1339, 1338, 1338, 1339, 1343, 1351,
1354, 1356, 1359, 1356, 1355, 1353, 1352, 1351, 1350, 1350,
1349, 1347, 1346, 1345, 1341, 1341, 1339, 1339, 1340, 1342,
1344, 1346, 1345, 1346, 1345, 1346, 1346, 1347, 1348, 1349,
1349, 1348, 1348, 1346, 1345, 1345, 1343, 1341, 1339, 1338,
1337, 1336, 1337, 1337, 1338, 1336, 1333, 1331, 1328, 1326,
1324, 1319, 1317, 1316, 1314, 1313, 1305, 1301, 1295, 1293,
1293, 1292, 1289, 1287, 1286, 1286, 1285, 1285, 1284, 1284,
1285, 1285, 1284, 1284, 1283, 1282, 1281, 1281, 1278, 1276,
1276, 1275, 1274, 1271, 1270, 1267, 1264, 1262, 1262, 1261,
1262, 1261, 1261, 1262, 1264, 1265, 1265, 1264, 1265, 1265,
1261, 1259, 1258, 1252, 1252, 1251, 1249, 1247, 1244, 1241,
1239, 1237, 1235, 1232, 1230, 1231, 1230, 1229, 1226, 1223,
1222, 1219, 1218, 1215, 1213, 1208, 1207, 1204, 1204, 1202,
1202, 1200, 1198, 1197, 1197, 1198, 1197, 1197, 1195, 1192,
1187, 1186, 1183, 1177, 1174, 1173, 1168, 1166, 1165, 1164,
1164, 1162, 1156, 1155, 1145, 1131, 1127, 1123, 1122, 1119,
1118, 1114, 1113, 1111, 1108, 1098, 1093, 1093, 1092, 1089,
1087, 1086, 1084, 1076, 1072, 1070, 1057, 1057, 1058, 1058,
1059, 1060, 1058, 1055, 1054, 1050, 1044)),
list(x = c(2181, 2181, 2182, 2182, 2184, 2184, 2185, 2185, 2186, 2187,
2188, 2186, 2186, 2189, 2191, 2191, 2190, 2190, 2188, 2186,
2184, 2184, 2182, 2182, 2181, 2180, 2178, 2176, 2176, 2174,
2174, 2175, 2174, 2173, 2174, 2174, 2173, 2173, 2170, 2171,
2170, 2169, 2169, 2168, 2168, 2167, 2168, 2168, 2167, 2166,
2166, 2164, 2164, 2162, 2160, 2159, 2160, 2159, 2159, 2157,
2156, 2156, 2157, 2157, 2158, 2160, 2160, 2159, 2159, 2160,
2159, 2159, 2158, 2158, 2157, 2157, 2156, 2154, 2153, 2153,
2151, 2151, 2148, 2148, 2147, 2146, 2145, 2145, 2144, 2143,
2142, 2142, 2141, 2138, 2136, 2132, 2131, 2131, 2130, 2130,
2131, 2132, 2132, 2131, 2129, 2127, 2125, 2123, 2122, 2121,
2119, 2119, 2118, 2118, 2117, 2117, 2116, 2114, 2109, 2108,
2104, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112,
2113, 2113, 2112, 2111, 2101, 2101, 2099, 2099, 2098, 2098,
2096, 2095, 2095, 2096, 2096, 2094, 2094, 2093, 2093, 2094,
2094, 2093, 2093, 2092, 2091, 2091, 2090, 2090, 2086, 2086,
2085, 2084, 2084, 2083, 2083, 2082, 2082, 2083, 2086, 2086,
2085, 2085, 2084, 2084, 2083, 2082, 2083, 2083, 2082, 2081,
2080, 2078, 2078, 2079, 2080, 2080, 2081, 2081, 2080, 2080,
2079, 2079, 2078, 2077, 2077, 2076, 2076, 2074, 2072, 2072,
2071, 2071, 2070, 2070, 2071, 2071, 2070, 2070, 2069, 2069,
2068, 2068, 2065, 2064, 2063, 2065, 2065, 2066, 2068, 2068,
2066, 2066, 2063, 2063, 2062, 2061, 2061, 2058, 2059, 2063,
2063, 2061, 2061, 2060, 2060, 2061, 2060, 2058, 2057, 2056,
2054, 2054, 2053, 2053, 2052, 2051, 2051, 2050, 2049, 2050,
2050, 2048, 2046, 2044, 2044, 2047, 2047, 2046, 2046, 2045,
2046, 2046, 2045, 2045, 2044, 2044, 2043, 2043, 2041, 2042,
2043, 2043, 2042, 2043, 2043, 2042, 2041, 2039, 2038, 2037,
2038, 2037, 2037, 2038, 2037, 2039, 2040, 2041, 2042, 2042,
2036, 2034, 2033, 2033, 2032, 2032, 2029, 2029, 2028, 2027,
2025, 2025, 2026, 2026, 2025, 2025, 2024, 2024, 2022, 2022,
2023, 2022, 2022, 2021, 2016, 2016, 2014, 2010, 2008, 2006,
2007, 2009, 2010, 2011, 2011, 2009, 2008, 2007, 2008, 2010,
2009, 2009, 2007, 2006, 2006, 2007, 2008, 2008, 2007, 2006,
2007, 2005, 2006, 2006, 2005, 2006, 2005, 2004, 2003, 2003,
2004, 2003, 2003, 2002, 2002, 2001, 2001, 2000, 1999, 1999,
1998, 1998, 1996, 1996, 1995, 1995, 1996, 1997, 1997, 1996,
1996, 1998, 2000, 2001, 2001, 2002, 2002, 2000, 1999, 2000,
2000, 1999, 2000, 1999, 1999, 1997, 1995, 1991, 1990, 1989,
1986, 1985, 1984, 1983, 1984, 1980),
y = c(1044, 1047, 1046, 1044, 1042, 1041, 1040, 1039, 1037, 1036,
1034, 1029, 1021, 1020, 1018, 1017, 1014, 1006, 1002, 1001,
997, 994, 992, 990, 989, 986, 985, 983, 981, 976, 974, 974,
975, 976, 972, 961, 958, 955, 949, 948, 946, 945, 944, 943,
942, 941, 940, 935, 933, 932, 931, 929, 930, 928, 924, 923,
921, 919, 916, 916, 913, 912, 909, 897, 897, 895, 896, 896,
894, 893, 892, 887, 886, 884, 883, 881, 880, 874, 873, 871,
866, 865, 859, 856, 855, 853, 852, 849, 848, 846, 845, 844,
842, 839, 838, 835, 835, 833, 832, 824, 823, 820, 817, 819,
819, 818, 816, 815, 814, 812, 812, 811, 811, 810, 810, 809,
809, 810, 810, 811, 811, 808, 807, 808, 807, 808, 808, 807,
807, 806, 806, 804, 804, 803, 803, 802, 802, 801, 801, 800,
800, 800, 802, 803, 802, 802, 801, 801, 800, 800, 795, 794,
792, 791, 791, 790, 790, 789, 789, 792, 792, 790, 789, 789,
788, 787, 786, 787, 787, 784, 782, 781, 780, 779, 778, 779,
780, 781, 781, 780, 780, 778, 776, 777, 777, 775, 775, 774,
774, 772, 771, 770, 769, 769, 768, 767, 765, 765, 767, 766,
767, 765, 765, 763, 761, 760, 759, 755, 754, 752, 751, 750,
747, 747, 746, 746, 745, 745, 743, 740, 740, 741, 741, 738,
738, 737, 738, 737, 736, 736, 734, 733, 732, 733, 732, 733,
734, 733, 733, 731, 731, 729, 729, 728, 727, 725, 723, 721,
720, 719, 717, 715, 714, 714, 713, 713, 710, 709, 707, 707,
705, 702, 701, 700, 699, 698, 697, 696, 694, 692, 691, 690,
689, 688, 687, 687, 686, 688, 687, 687, 687, 686, 687, 686,
685, 685, 684, 684, 683, 681, 681, 682, 683, 684, 684, 681,
678, 677, 677, 676, 676, 674, 673, 671, 669, 667, 666, 665,
664, 663, 663, 661, 660, 660, 655, 651, 651, 653, 653, 654,
651, 651, 649, 648, 646, 644, 644, 642, 642, 640, 638, 635,
636, 635, 632, 632, 632, 633, 633, 632, 632, 630, 629, 622,
621, 619, 619, 617, 616, 614, 613, 611, 608, 606, 603, 602,
599, 598, 596, 592, 591, 590, 589, 588, 588, 587, 585, 585,
580, 579, 578, 578, 574, 573, 572, 571, 569, 569, 566, 565,
559, 558, 556, 556, 554, 554, 555, 555, 557, 558, 558, 559,
559, 557, 556, 556)),
list(x = c(1980, 1984, 1986, 1987, 1986, 1984, 1983, 1983, 1983, 1982,
1982, 1981, 1979, 1975, 1974, 1972, 1964, 1961, 1957, 1952,
1947, 1946, 1945, 1945, 1946, 1946, 1944, 1942, 1923, 1922,
1919, 1915, 1913, 1911, 1907, 1906, 1901, 1901, 1899, 1898,
1897, 1896, 1896, 1897, 1896, 1896, 1895, 1893, 1886, 1885,
1879, 1878, 1879, 1880, 1880, 1879, 1877, 1875, 1873, 1872,
1870, 1869, 1866, 1864, 1863, 1861, 1858, 1857, 1855, 1855,
1857, 1859, 1863, 1864, 1867, 1869, 1870, 1871, 1875, 1877,
1878, 1879, 1882, 1884, 1884, 1886, 1887, 1895, 1895, 1891,
1889, 1887, 1880, 1878, 1876, 1876, 1870, 1869, 1867, 1866,
1864, 1861, 1856, 1853, 1851, 1849, 1847, 1844, 1842, 1840,
1837, 1835, 1835, 1832, 1830, 1829, 1827, 1826, 1826, 1818,
1816, 1814, 1813, 1812, 1810, 1809, 1807, 1805, 1802, 1801,
1801, 1800, 1801, 1802, 1803, 1804, 1803, 1804, 1804, 1805,
1810, 1811, 1811, 1813, 1813, 1814, 1815, 1814, 1814, 1813,
1813, 1814, 1813, 1814, 1813, 1813, 1812, 1812, 1810, 1808,
1806, 1802, 1801, 1800, 1800, 1799, 1797, 1797, 1796, 1796,
1795, 1793, 1792, 1791, 1790, 1790, 1789, 1788, 1787, 1786,
1785, 1783, 1782, 1781, 1779, 1778, 1778, 1779, 1779, 1778,
1778, 1779, 1778, 1779, 1778, 1778, 1776, 1775, 1772, 1771,
1769, 1767, 1763, 1762, 1761, 1760, 1759, 1759, 1763, 1764,
1764, 1765, 1766, 1768, 1768, 1766, 1765, 1765, 1763, 1763,
1761, 1760, 1759, 1755, 1753, 1752, 1750, 1749, 1747, 1747,
1746, 1743, 1742, 1740, 1739, 1736, 1735, 1736, 1734, 1732,
1728, 1726, 1724, 1722, 1721, 1721, 1727, 1731, 1734, 1736,
1736, 1737, 1737, 1739, 1740, 1741, 1740, 1741, 1742, 1742,
1743, 1743, 1744, 1744, 1742, 1740, 1739, 1736, 1735, 1735,
1734, 1732, 1732, 1731, 1730, 1728, 1724, 1723, 1722, 1720,
1719, 1714, 1707, 1704, 1705, 1707, 1712, 1721, 1721, 1722,
1722, 1721, 1720, 1720, 1721, 1721, 1720, 1718, 1716, 1711,
1709, 1706, 1705, 1701, 1702, 1701, 1700, 1698, 1693, 1692,
1691, 1688, 1687, 1686, 1684, 1680, 1678, 1677, 1675, 1674,
1671, 1656, 1654, 1653, 1652, 1651, 1650, 1649, 1648, 1646,
1644, 1642, 1639, 1636, 1631, 1630, 1627, 1626, 1624, 1623,
1621, 1617, 1616, 1613, 1612, 1610, 1604, 1601, 1600, 1599,
1597, 1593, 1591, 1588, 1584, 1583, 1577, 1574, 1571, 1570,
1564, 1561, 1557, 1557, 1558, 1557, 1558, 1557, 1556, 1554,
1552, 1551, 1549, 1548, 1546, 1545, 1543, 1543, 1544, 1543,
1543, 1544, 1544, 1537, 1528, 1523, 1522),
y = c(556, 556, 552, 552, 550, 550, 548, 549, 550, 550, 549, 549,
548, 544, 544, 543, 543, 544, 544, 546, 546, 547, 546, 545,
545, 544, 544, 543, 543, 542, 543, 543, 544, 543, 543, 542,
542, 544, 543, 543, 544, 543, 541, 541, 540, 539, 539, 541,
541, 540, 540, 539, 538, 538, 535, 534, 534, 532, 531, 531,
530, 531, 531, 530, 529, 529, 530, 529, 528, 525, 525, 526,
527, 528, 528, 529, 530, 530, 532, 532, 533, 533, 536, 536,
537, 537, 538, 538, 537, 536, 535, 535, 532, 530, 529, 528,
525, 523, 522, 521, 520, 517, 514, 510, 508, 507, 504, 503,
501, 500, 497, 497, 498, 498, 496, 496, 494, 494, 493, 493,
492, 493, 492, 493, 494, 493, 494, 493, 493, 492, 491, 490,
489, 487, 487, 486, 483, 483, 482, 482, 484, 485, 484, 484,
483, 483, 482, 481, 477, 476, 474, 474, 473, 472, 472, 471,
471, 470, 470, 471, 474, 478, 480, 481, 483, 485, 487, 486,
486, 485, 486, 486, 487, 487, 485, 484, 483, 483, 484, 484,
486, 488, 491, 492, 496, 496, 498, 498, 499, 499, 498, 498,
497, 497, 498, 497, 496, 494, 494, 495, 496, 498, 500, 501,
501, 502, 502, 505, 510, 510, 511, 511, 510, 511, 513, 515,
517, 518, 518, 519, 519, 520, 519, 519, 520, 519, 518, 516,
514, 512, 512, 509, 507, 507, 506, 505, 505, 504, 505, 505,
509, 510, 512, 512, 513, 514, 514, 512, 512, 514, 515, 515,
516, 518, 518, 519, 520, 522, 521, 522, 523, 524, 525, 531,
532, 532, 534, 537, 539, 540, 541, 541, 538, 538, 536, 536,
533, 533, 532, 531, 530, 528, 528, 525, 523, 523, 525, 525,
523, 522, 521, 519, 519, 517, 517, 515, 514, 514, 515, 515,
514, 514, 513, 511, 511, 510, 510, 508, 505, 505, 504, 503,
502, 500, 499, 495, 494, 493, 492, 492, 491, 481, 481, 482,
484, 484, 485, 485, 486, 486, 485, 485, 488, 490, 492, 493,
494, 495, 495, 496, 497, 497, 498, 499, 501, 503, 506, 506,
507, 508, 509, 509, 507, 508, 508, 509, 512, 512, 514, 514,
516, 516, 514, 512, 511, 511, 510, 509, 507, 508, 508, 509,
509, 510, 509, 510, 510, 512, 515, 515, 514, 514, 516, 523,
527, 527, 529)),
list(x = c(1837, 1837, 1836, 1835, 1832, 1831, 1825, 1824, 1823, 1821,
1820, 1819, 1818, 1818, 1817, 1816, 1816, 1814, 1812, 1811,
1810, 1807, 1807, 1806, 1805, 1803, 1801, 1800, 1799, 1798,
1797, 1797, 1796, 1795, 1792, 1792, 1791, 1790, 1789, 1789,
1786, 1786, 1787, 1787, 1789, 1790, 1791, 1792, 1795, 1795,
1796, 1796, 1797, 1797, 1790, 1789, 1787, 1786, 1784, 1782,
1781, 1781, 1780, 1781, 1781, 1782, 1782, 1781, 1780, 1779,
1774, 1772, 1772, 1771, 1771, 1770, 1770, 1769, 1767, 1765,
1763, 1763, 1762, 1761, 1761, 1760, 1760, 1759, 1759, 1757,
1757, 1756, 1756, 1755, 1755, 1752, 1749, 1749, 1750, 1750,
1751, 1751, 1750, 1750, 1748, 1748, 1747, 1747, 1746, 1746,
1748, 1748, 1749, 1749, 1750, 1750, 1751, 1751, 1752, 1753,
1754, 1754, 1757, 1757, 1758, 1758, 1759, 1760, 1760, 1761,
1762, 1763, 1763, 1764, 1764, 1765, 1762, 1761, 1759, 1759,
1758, 1757, 1757, 1756, 1755, 1755, 1754, 1754, 1753, 1753,
1752, 1751, 1751, 1750, 1749, 1749, 1748, 1748, 1747, 1746,
1744, 1744, 1741, 1740, 1739, 1739, 1738, 1737, 1735, 1734,
1734, 1732, 1732, 1731, 1730, 1730, 1728, 1726, 1724, 1724,
1723, 1724, 1724, 1722, 1722, 1721, 1721, 1719, 1719, 1721,
1721, 1720, 1719, 1718, 1716, 1716, 1717, 1717, 1718, 1719,
1719, 1718, 1718, 1719, 1719, 1721, 1721, 1722, 1723, 1723,
1724, 1725, 1726, 1727, 1729, 1730, 1732, 1733, 1734, 1735,
1736, 1739, 1739, 1740, 1740, 1741, 1742, 1743, 1748, 1748,
1750, 1750, 1751, 1751, 1752, 1753, 1753, 1754, 1755, 1756,
1757, 1760, 1761, 1762, 1763, 1764, 1766, 1767, 1768, 1769,
1770, 1772, 1773, 1775, 1775, 1777, 1779, 1780, 1782, 1783,
1783, 1787, 1788, 1789, 1790, 1794, 1796, 1797, 1797, 1798,
1799, 1800, 1801, 1802, 1803, 1804, 1804, 1805, 1806, 1806,
1808, 1810, 1812, 1817, 1817, 1818, 1819, 1819, 1821, 1823,
1825, 1826, 1828, 1828, 1829, 1829, 1830, 1833, 1834, 1835,
1835, 1837, 1838, 1838, 1839, 1839, 1840, 1840, 1841, 1842,
1843, 1843, 1845, 1843, 1842, 1841, 1840, 1839, 1839, 1838,
1838, 1836, 1835, 1835, 1834, 1831, 1831, 1832, 1832, 1835,
1835, 1836, 1840, 1841, 1842, 1843, 1846, 1848, 1849, 1849,
1850, 1851, 1852, 1854, 1855, 1864, 1866, 1868, 1871, 1872,
1873, 1879, 1883, 1884, 1885, 1886, 1886, 1887, 1888, 1888,
1889, 1889, 1890, 1891, 1896, 1897, 1897, 1899, 1900, 1901,
1902, 1903, 1904, 1904, 1907, 1906, 1908, 1908, 1909, 1909,
1908, 1908, 1907, 1907, 1908, 1908, 1907, 1907, 1908, 1909,
1909, 1910, 1910, 1909, 1909, 1908, 1908, 1907, 1905, 1905,
1906, 1906, 1907, 1907, 1908, 1908, 1907, 1907, 1908, 1908,
1907, 1905, 1905, 1906, 1906, 1909, 1908, 1908, 1909, 1909,
1910, 1910, 1911, 1911, 1910, 1910, 1909, 1908, 1908, 1907,
1907, 1905, 1905, 1906, 1906, 1905, 1905, 1904, 1903, 1901,
1901, 1900, 1901, 1905, 1904, 1899, 1897, 1897, 1896, 1895,
1895, 1894, 1894, 1892, 1892, 1891, 1891, 1893, 1893, 1894,
1894, 1893, 1893, 1894, 1894, 1891, 1889, 1889, 1888, 1888,
1889, 1890, 1891, 1891, 1892, 1892, 1891, 1891, 1890, 1888,
1888, 1887, 1887, 1886, 1886, 1887, 1888, 1888, 1889, 1892,
1893, 1893, 1892, 1891, 1891, 1894, 1894, 1892, 1891, 1890,
1889, 1889, 1888, 1887, 1887, 1886, 1885, 1884, 1883, 1880,
1880, 1879, 1879, 1877, 1876, 1875, 1875, 1876, 1878, 1878,
1879, 1881, 1881, 1880, 1880, 1881, 1883, 1885, 1886, 1888,
1888, 1884, 1884, 1883, 1883, 1882, 1880, 1878, 1876, 1875,
1875, 1874, 1872, 1871, 1868, 1867, 1866, 1866, 1867, 1870,
1870, 1869, 1868, 1868, 1869, 1869, 1866, 1862, 1862, 1863,
1863, 1864, 1865, 1865, 1864, 1865, 1864, 1863, 1862, 1862,
1861, 1861, 1860, 1859, 1858, 1858, 1857, 1855, 1855, 1854,
1851, 1851, 1853, 1854, 1854, 1856, 1857, 1858, 1858, 1859,
1859, 1860, 1861, 1861, 1860, 1860, 1858, 1856, 1856, 1855,
1855, 1853, 1852, 1851, 1850, 1848, 1848, 1847, 1846, 1844,
1844, 1843, 1843, 1842, 1841, 1841, 1840, 1839, 1839, 1838,
1838, 1839, 1839, 1840, 1840, 1841, 1842, 1843, 1844, 1845,
1845, 1842, 1841, 1840, 1839, 1843, 1843, 1842, 1841, 1840,
1839, 1838, 1838, 1837, 1837, 1838, 1839, 1839, 1838, 1839,
1839, 1836, 1836, 1835, 1835, 1836, 1836, 1837, 1837, 1835,
1834),
y = c(233, 232, 232, 231, 231, 232, 232, 233, 233, 235, 235, 236,
236, 237, 238, 238, 239, 239, 237, 237, 236, 236, 237, 237,
238, 238, 239, 240, 240, 239, 239, 238, 238, 239, 239, 237,
237, 238, 238, 240, 243, 245, 245, 246, 246, 247, 247, 246,
246, 245, 245, 244, 244, 248, 248, 249, 249, 250, 251, 253,
253, 254, 253, 253, 252, 252, 250, 250, 251, 251, 256, 257,
258, 259, 260, 261, 265, 266, 266, 267, 267, 268, 269, 269,
272, 272, 274, 275, 276, 276, 280, 280, 282, 282, 283, 286,
286, 287, 287, 288, 289, 290, 291, 292, 294, 295, 297, 303,
304, 308, 308, 307, 307, 306, 306, 305, 305, 304, 304, 303,
303, 302, 302, 301, 301, 300, 300, 299, 297, 296, 297, 297,
298, 299, 300, 301, 301, 302, 302, 303, 304, 304, 305, 306,
306, 307, 307, 308, 308, 309, 310, 310, 309, 308, 309, 310,
311, 317, 318, 320, 321, 322, 325, 325, 327, 328, 328, 329,
330, 331, 335, 335, 336, 336, 337, 344, 346, 347, 347, 348,
349, 350, 351, 353, 354, 355, 357, 359, 365, 367, 368, 368,
369, 369, 370, 373, 374, 375, 375, 376, 380, 381, 383, 384,
387, 388, 389, 388, 388, 387, 387, 386, 386, 385, 385, 384,
384, 383, 383, 384, 383, 383, 382, 382, 381, 381, 380, 381,
381, 386, 386, 384, 383, 382, 382, 381, 380, 380, 379, 379,
378, 378, 377, 377, 376, 376, 375, 375, 374, 374, 373, 373,
372, 372, 371, 371, 369, 369, 368, 368, 367, 367, 366, 366,
365, 365, 363, 363, 362, 362, 363, 363, 362, 362, 363, 363,
362, 361, 361, 360, 360, 362, 363, 363, 362, 361, 361, 365,
365, 366, 366, 367, 367, 366, 365, 364, 364, 361, 361, 360,
359, 357, 357, 355, 355, 354, 354, 353, 353, 352, 352, 351,
351, 353, 353, 354, 354, 355, 356, 356, 359, 361, 361, 362,
363, 363, 368, 368, 369, 369, 370, 370, 372, 371, 371, 370,
370, 369, 369, 370, 370, 371, 371, 373, 372, 372, 373, 373,
376, 376, 377, 377, 375, 376, 376, 377, 378, 378, 379, 380,
381, 382, 382, 383, 383, 382, 381, 381, 380, 380, 379, 379,
378, 377, 374, 373, 371, 370, 369, 368, 368, 365, 365, 361,
360, 357, 357, 353, 353, 354, 355, 355, 354, 354, 353, 352,
349, 349, 347, 346, 346, 342, 342, 340, 340, 337, 336, 334,
334, 332, 332, 330, 328, 327, 326, 323, 322, 319, 319, 317,
316, 314, 313, 307, 306, 305, 305, 306, 311, 312, 313, 315,
316, 317, 318, 318, 319, 319, 318, 318, 317, 316, 315, 315,
314, 314, 313, 310, 310, 309, 307, 307, 306, 304, 303, 303,
302, 302, 301, 301, 300, 299, 295, 294, 291, 291, 292, 291,
291, 289, 289, 288, 288, 287, 286, 285, 284, 281, 281, 279,
278, 277, 276, 275, 274, 273, 273, 274, 274, 271, 271, 269,
269, 268, 263, 260, 258, 256, 256, 257, 257, 258, 259, 258,
257, 257, 256, 256, 257, 257, 260, 261, 262, 262, 263, 263,
267, 267, 269, 270, 269, 269, 268, 267, 266, 266, 264, 264,
265, 265, 266, 270, 271, 271, 272, 272, 273, 273, 274, 274,
275, 276, 276, 277, 277, 278, 278, 277, 276, 276, 275, 275,
274, 273, 272, 268, 265, 265, 267, 267, 266, 267, 267, 268,
269, 270, 270, 269, 270, 272, 273, 274, 275, 275, 276, 277,
277, 279, 280, 281, 281, 280, 280, 279, 278, 276, 276, 275,
274, 274, 273, 272, 272, 270, 270, 266, 265, 265, 254, 253,
252, 252, 251, 251, 252, 252, 255, 257, 257, 255, 254, 254,
255, 255, 257, 262, 260, 260, 259, 258, 256, 255, 254, 254,
253, 253, 252, 252, 251, 251, 249, 249, 248, 248, 247, 247,
244, 243, 243, 242, 243, 243, 242, 242, 241, 241, 240, 239,
239, 238, 237, 237, 236, 236, 235, 235, 234, 234, 233, 231,
231)),
list(x = c(1522, 1523, 1520, 1515, 1505, 1501, 1497, 1496, 1495, 1495,
1493, 1493, 1492, 1492, 1490, 1490, 1489, 1490, 1491, 1491,
1493, 1493, 1494, 1492, 1491, 1491, 1490, 1489, 1488, 1488,
1482, 1479, 1478, 1478, 1477, 1475, 1473, 1469, 1465, 1459,
1460, 1461, 1462, 1461, 1461, 1460, 1460, 1459, 1458, 1459,
1460, 1462, 1463, 1464, 1465, 1465, 1466, 1465, 1465, 1464,
1464, 1463, 1463, 1459, 1455, 1453, 1447, 1442, 1435, 1431,
1429, 1427, 1425, 1425, 1424, 1422, 1422, 1424, 1425, 1425,
1424, 1425, 1426, 1428, 1429, 1430, 1430, 1429, 1429, 1434,
1420, 1419, 1418, 1417, 1413, 1411, 1411, 1407, 1406, 1400,
1398, 1395, 1390, 1382, 1379, 1378, 1378, 1379, 1388, 1390,
1395, 1398, 1398, 1399, 1399, 1400, 1400, 1399, 1399, 1398,
1398, 1397, 1395, 1396, 1397, 1397, 1394, 1389, 1387, 1385,
1383, 1381, 1378, 1376, 1376, 1375, 1372, 1370, 1370, 1369,
1367, 1366, 1366, 1364, 1364, 1363, 1360, 1358, 1357, 1357,
1355, 1351, 1344, 1337, 1335, 1333, 1331, 1329, 1324, 1318,
1317, 1316, 1313, 1313, 1316, 1316, 1317, 1318, 1319, 1320,
1324, 1327, 1329, 1331, 1335, 1338, 1341, 1343, 1345, 1346,
1345, 1345, 1344, 1344, 1345, 1345, 1343, 1344, 1344, 1345,
1345, 1347, 1347, 1349, 1351, 1354, 1356, 1359, 1361, 1361,
1363, 1364, 1366, 1368, 1368, 1366, 1366, 1365, 1365, 1364,
1364, 1367, 1369, 1370, 1370, 1369, 1369, 1368, 1368, 1367,
1367, 1366, 1364, 1363, 1362, 1362, 1361, 1361, 1360, 1358,
1358, 1359, 1359, 1358, 1359, 1359, 1358, 1356, 1354, 1348,
1346, 1343, 1342, 1341, 1341, 1340, 1340, 1339, 1339, 1338,
1338, 1337, 1314, 1312, 1314, 1315, 1316, 1315, 1313, 1310,
1308, 1306, 1305, 1301, 1296, 1294, 1292, 1290, 1286, 1283,
1282, 1282, 1278, 1278, 1277, 1276, 1274, 1273, 1273, 1274,
1274, 1271, 1266, 1264, 1264, 1263, 1259, 1258, 1258, 1259,
1258, 1258, 1260, 1266, 1265, 1265, 1264, 1264, 1262, 1258,
1258, 1257, 1257, 1252, 1250, 1250, 1249, 1244, 1242, 1240,
1238, 1237, 1236, 1234, 1233, 1232, 1230, 1228, 1226, 1226,
1224, 1223, 1222, 1222, 1221, 1222, 1222, 1223, 1225, 1226,
1228, 1229, 1230, 1232, 1235, 1236, 1238, 1240, 1240, 1239,
1236, 1235, 1235, 1234, 1234, 1233, 1232, 1231, 1227, 1226,
1227, 1229, 1229, 1228, 1226, 1226, 1225, 1222, 1222, 1220,
1219, 1215, 1211, 1208, 1208, 1207, 1206, 1207, 1207, 1206,
1203, 1200, 1200, 1198, 1198, 1194, 1194, 1195, 1195, 1192,
1192, 1190, 1190, 1188, 1185, 1183, 1182, 1180, 1179, 1178,
1178, 1179, 1179, 1177, 1174, 1173, 1172, 1172, 1171, 1168,
1167, 1167, 1168, 1168, 1167, 1167, 1168, 1170, 1173, 1173,
1174, 1176, 1177, 1177, 1178, 1177, 1177, 1175, 1172, 1165,
1163, 1159, 1158, 1158, 1157, 1157, 1158, 1159, 1157, 1156,
1155, 1121, 1119, 1116, 1115, 1113, 1110, 1109, 1106, 1106,
1103, 1102, 1102, 1099, 1098, 1086, 1083, 1081, 1071, 1071,
1070, 1065, 1063, 1063, 1039, 1037, 1037, 1034, 1033, 1032,
1031, 1029, 1027, 1026, 1025, 1022, 1019, 1014, 1013, 1006,
1005, 998, 991, 990, 989, 986, 983, 980, 973, 965, 957, 955,
948, 947, 942, 940, 937, 913, 908, 901, 898, 894),
y = c(529, 527, 528, 528, 530, 530, 532, 534, 535, 537, 540, 543,
545, 546, 547, 548, 546, 542, 540, 539, 535, 534, 533, 533,
535, 537, 538, 542, 544, 545, 551, 556, 556, 557, 557, 558,
560, 563, 565, 573, 575, 575, 577, 578, 580, 582, 583, 584,
586, 587, 589, 590, 592, 593, 596, 597, 598, 600, 602, 604,
607, 609, 612, 620, 624, 630, 638, 642, 649, 652, 653, 655,
655, 656, 659, 659, 660, 660, 659, 662, 662, 663, 663, 664,
664, 665, 666, 666, 667, 667, 665, 664, 664, 663, 663, 662,
663, 663, 662, 660, 658, 658, 657, 657, 658, 658, 661, 663,
668, 671, 674, 679, 680, 682, 683, 686, 688, 691, 694, 697,
700, 702, 703, 702, 702, 703, 709, 714, 718, 721, 723, 729,
731, 733, 735, 735, 731, 727, 726, 723, 721, 717, 713, 709,
707, 703, 698, 691, 689, 686, 682, 682, 684, 684, 682, 682,
681, 681, 679, 679, 677, 677, 681, 685, 693, 696, 696, 697,
697, 696, 696, 695, 695, 694, 695, 695, 699, 703, 709, 710,
712, 720, 722, 720, 720, 721, 723, 726, 737, 738, 740, 740,
749, 751, 751, 754, 754, 757, 757, 760, 762, 764, 766, 770,
771, 776, 778, 779, 780, 782, 786, 789, 789, 792, 793, 795,
798, 798, 804, 807, 809, 810, 815, 816, 818, 820, 823, 826,
831, 827, 821, 819, 810, 809, 808, 801, 799, 798, 798, 792,
791, 788, 786, 785, 783, 782, 781, 781, 780, 779, 777, 775,
759, 757, 757, 758, 756, 755, 754, 754, 753, 753, 752, 750,
745, 745, 744, 742, 740, 737, 735, 732, 728, 727, 726, 724,
724, 722, 720, 720, 719, 719, 717, 715, 714, 712, 708, 706,
704, 703, 703, 702, 703, 703, 702, 700, 698, 693, 693, 696,
697, 697, 698, 698, 696, 693, 693, 698, 701, 703, 707, 707,
708, 708, 709, 711, 712, 714, 715, 714, 712, 712, 713, 714,
716, 718, 719, 720, 720, 718, 717, 717, 714, 712, 712, 710,
710, 712, 713, 714, 714, 713, 712, 714, 728, 731, 731, 733,
734, 735, 739, 742, 745, 747, 747, 748, 750, 753, 754, 754,
756, 758, 761, 761, 762, 764, 765, 768, 777, 779, 782, 783,
785, 787, 788, 788, 787, 786, 785, 785, 786, 786, 787, 787,
789, 789, 790, 791, 792, 792, 791, 789, 787, 788, 794, 794,
796, 800, 801, 801, 803, 804, 806, 808, 810, 812, 812, 811,
807, 806, 807, 808, 809, 814, 815, 815, 816, 819, 822, 822,
821, 821, 822, 825, 828, 829, 830, 830, 834, 837, 838, 838,
839, 839, 840, 844, 845, 847, 848, 849, 851, 850, 851, 851,
852, 852, 849, 848, 848, 846, 844, 845, 846, 849, 852, 854,
856, 857, 858, 858, 859, 860, 860, 862, 863, 864, 867, 869,
870, 870, 871, 871, 868, 868, 867, 866, 866, 865, 865, 868,
868, 869, 869, 868, 866, 866, 865, 865, 864, 864, 863, 863)),
list(x = c(894, 894), y = c(863, 1157)),
list(x = c(894, 894), y = c(1157, 1744)),
list(x = c(894, 1367), y = c(1157, 1157)),
list(x = c(1367, 1367), y = c(1157, 1663)),
list(x = c(1367, 1525, 1525 ), y = c(1157, 1157, 999)),
list(x = c(2181, 2181, 2178, 2177, 2174, 2173, 2172, 2171, 2169, 2168,
2167, 2166, 2164, 2164, 2161, 2161, 2158, 2158, 2152, 2151,
2142, 2142, 2137, 2135, 2132, 2130, 2131, 2130, 2130, 2128,
2127, 2126, 2125, 2124, 2123, 2122, 2121, 2118, 2117, 2112,
2111, 2109, 2109, 2108, 2106, 2106, 2107, 2107, 2108, 2108,
2109, 2109, 2110, 2110, 2109, 2109, 2108, 2107, 2102, 2099,
2098, 2098, 2094, 2093, 2092, 2091, 2088, 2087, 2085, 2083,
2082, 2082, 2081, 2081, 2080, 2080, 2077, 2073, 2072, 2072,
2071, 2070, 2070, 2069, 2069, 2068, 2068, 2067, 2067, 2066,
2066, 2065, 2063, 2060, 2059, 2058, 2058, 2054, 2053, 2052,
2052, 2051, 2050, 2048, 2046, 2043, 2043, 2040, 2039, 2037,
2036, 2032, 2031, 2028, 2026, 2025, 2023, 2022, 2022, 2021,
2016, 2016, 2008, 2007, 1999, 1998, 1996, 1995, 1992, 1991,
1988, 1987, 1986, 1986, 1985, 1983, 1983, 1982, 1982, 1979,
1979, 1978, 1977, 1977, 1975, 1974, 1974, 1973, 1973, 1972,
1972, 1971, 1969, 1967, 1966, 1964, 1964, 1961, 1960, 1958,
1958, 1957, 1957, 1956, 1956, 1955, 1955, 1954, 1954, 1953,
1953, 1952, 1952, 1951, 1946, 1525),
y = c(1044, 1043, 1043, 1042, 1042, 1041, 1041, 1040, 1040, 1039,
1039, 1038, 1038, 1037, 1037, 1036, 1036, 1035, 1035, 1036,
1036, 1037, 1037, 1038, 1038, 1036, 1036, 1035, 1033, 1032,
1031, 1031, 1030, 1030, 1029, 1029, 1028, 1028, 1027, 1027,
1026, 1026, 1025, 1025, 1023, 1021, 1020, 1019, 1018, 1016,
1015, 1012, 1011, 1009, 1008, 1007, 1005, 1004, 1004, 1005,
1005, 1006, 1006, 1005, 1005, 1004, 1004, 1003, 1003, 1001,
1001, 1000, 999, 994, 994, 993, 990, 990, 991, 992, 993, 993,
995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1003, 1004,
1007, 1007, 1009, 1010, 1014, 1014, 1015, 1016, 1016, 1017,
1017, 1018, 1018, 1017, 1017, 1016, 1016, 1015, 1015, 1016,
1016, 1018, 1018, 1020, 1020, 1021, 1020, 1020, 1019, 1019,
1018, 1018, 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022,
1023, 1024, 1024, 1025, 1025, 1024, 1024, 1023, 1022, 1022,
1021, 1019, 1019, 1018, 1018, 1017, 1017, 1016, 1016, 1014,
1014, 1013, 1013, 1012, 1012, 1011, 1011, 1009, 1009, 1008,
1008, 1007, 1007, 1005, 1005, 1004, 1003, 1002, 1002, 1001,
1000, 999, 999)),
list(x = c( 1525, 1525), y = c(999, 733)),
list(x = c(1980, 1895, 1891, 1891, 1890, 1890, 1889, 1889, 1888, 1888,
1887, 1887, 1886, 1884, 1883, 1882, 1880, 1880, 1879, 1877,
1873, 1872, 1869, 1867, 1865, 1863, 1859, 1857, 1856, 1854,
1844, 1844, 1843, 1843, 1842, 1842, 1840, 1836, 1835, 1833,
1833, 1829, 1828, 1827, 1825, 1824, 1823, 1821, 1821, 1818,
1818, 1816, 1816, 1814, 1813, 1811, 1810, 1808, 1807, 1806,
1805, 1804, 1803, 1798, 1797, 1793, 1791, 1785, 1784, 1782,
1781, 1780, 1778, 1773, 1771, 1769, 1768, 1766, 1765, 1765,
1763, 1761, 1760, 1759, 1758, 1757, 1756, 1754, 1751, 1750,
1744, 1743, 1741, 1741, 1734, 1734, 1733, 1730, 1730, 1729,
1729, 1728, 1727, 1727, 1726, 1725, 1719, 1718, 1715, 1711,
1710, 1709, 1709, 1708, 1707, 1707, 1706, 1706, 1705, 1705,
1704, 1704, 1701, 1700, 1699, 1698, 1697, 1696, 1695, 1695,
1693, 1693, 1691, 1691, 1690, 1688, 1687, 1687, 1686, 1684,
1683, 1682, 1679, 1679, 1677, 1675, 1674, 1673, 1672, 1671,
1669, 1669, 1667, 1666, 1665, 1664, 1663, 1663, 1662, 1658,
1657, 1656, 1655, 1654, 1654, 1652, 1652, 1651, 1651, 1652,
1652, 1653, 1653, 1652, 1652, 1651, 1650, 1650, 1649, 1649,
1648, 1648, 1647, 1647, 1646, 1646, 1640, 1639, 1636, 1635,
1628, 1628, 1627, 1626, 1626, 1623, 1623, 1621, 1621, 1620,
1619, 1619, 1618, 1618, 1617, 1617, 1616, 1614, 1614, 1613,
1612, 1611, 1611, 1610, 1610, 1609, 1609, 1608, 1606, 1606,
1605, 1605, 1601, 1601, 1600, 1600, 1601, 1601, 1602, 1602,
1601, 1600, 1599, 1597, 1596, 1595, 1594, 1594, 1593, 1593,
1592, 1590, 1587, 1586, 1585, 1585, 1584, 1584, 1583, 1583,
1582, 1581, 1580, 1579, 1577, 1577, 1576, 1572, 1571, 1566,
1565, 1564, 1557, 1553, 1552, 1551, 1550, 1549, 1549, 1548,
1543, 1542, 1539, 1539, 1537, 1536, 1534, 1534, 1530, 1528,
1526, 1525),
y = c(556, 603, 607, 608, 608, 612, 612, 623, 623, 625, 626, 627,
627, 629, 629, 630, 630, 631, 631, 633, 633, 634, 634, 633,
633, 634, 634, 632, 632, 630, 630, 629, 629, 628, 628, 627,
625, 625, 626, 626, 627, 627, 628, 628, 629, 629, 630, 630,
631, 631, 632, 632, 633, 633, 634, 634, 635, 635, 634, 634,
633, 633, 632, 632, 631, 631, 632, 632, 633, 633, 634, 634,
636, 636, 637, 639, 639, 640, 640, 641, 641, 643, 643, 644,
644, 645, 645, 644, 644, 643, 643, 644, 644, 645, 645, 644,
644, 641, 640, 639, 634, 632, 631, 630, 630, 629, 629, 630,
630, 634, 634, 635, 636, 636, 637, 638, 638, 639, 639, 641,
642, 644, 647, 647, 648, 648, 649, 649, 650, 651, 651, 652,
654, 655, 655, 657, 657, 658, 658, 659, 659, 660, 660, 661,
661, 663, 663, 664, 664, 665, 665, 666, 666, 667, 667, 668,
668, 675, 676, 676, 677, 677, 678, 678, 679, 681, 684, 685,
689, 690, 692, 693, 694, 695, 696, 697, 697, 698, 699, 700,
700, 701, 701, 702, 702, 703, 703, 704, 704, 705, 705, 706,
707, 707, 709, 709, 711, 711, 712, 711, 711, 710, 710, 703,
702, 701, 701, 699, 698, 698, 699, 699, 701, 701, 703, 703,
704, 704, 706, 708, 709, 711, 711, 713, 713, 717, 718, 719,
720, 721, 722, 722, 723, 723, 724, 724, 725, 729, 730, 731,
731, 732, 732, 731, 731, 732, 733, 735, 735, 736, 736, 737,
736, 736, 735, 736, 735, 735, 736, 736, 737, 737, 730, 730,
731, 731, 732, 732, 733, 734, 734, 735, 735, 734, 734, 735,
736, 738, 738, 740, 740, 733)),
list(x = c(1525, 1522, 1522), y = c(733, 729, 529 ))) |
tidy_cauchy <- function(.n = 50, .location = 0, .scale = 1, .num_sims = 1){
n <- as.integer(.n)
num_sims <- as.integer(.num_sims)
location <- as.numeric(.location)
scale <- as.numeric(.scale)
if(!is.integer(n) | n < 0){
rlang::abort(
"The parameters '.n' must be of class integer. Please pass a whole
number like 50 or 100. It must be greater than 0."
)
}
if(!is.integer(num_sims) | num_sims < 0){
rlang::abort(
"The parameter `.num_sims' must be of class integer. Please pass a
whole number like 50 or 100. It must be greater than 0."
)
}
if(!is.numeric(location) | !is.numeric(scale)){
rlang::abort(
"The parameters of .location and .scale must be of class numeric and greater than 0."
)
}
if(scale < 0){
rlang::abort("The parameter of .scale must be greater than or equal to 0.")
}
x <- seq(1, num_sims, 1)
ps <- seq(-n, n-1, 2)
qs <- seq(0, 1, (1/(n-1)))
df <- dplyr::tibble(sim_number = as.factor(x)) %>%
dplyr::group_by(sim_number) %>%
dplyr::mutate(x = list(1:n)) %>%
dplyr::mutate(y = list(stats::rcauchy(n = n, location = location, scale = scale))) %>%
dplyr::mutate(d = list(density(unlist(y), n = n)[c("x","y")] %>%
purrr::set_names("dx","dy") %>%
dplyr::as_tibble())) %>%
dplyr::mutate(p = list(stats::pcauchy(ps, location = location, scale = scale))) %>%
dplyr::mutate(q = list(stats::qcauchy(qs, location = location, scale = scale))) %>%
tidyr::unnest(cols = c(x, y, d, p, q)) %>%
dplyr::ungroup()
attr(df, ".location") <- .location
attr(df, ".scale") <- .scale
attr(df, ".n") <- .n
attr(df, ".num_sims") <- .num_sims
attr(df, "tibble_type") <- "tidy_cauchy"
attr(df, "ps") <- ps
attr(df, "qs") <- qs
return(df)
} |
knitr::opts_chunk$set(
collapse = TRUE,
comment = "
)
lightenColor <- function(x,
amount = .4) {
x <- 255 - col2rgb(x);
x <- amount * x;
x <- 255 - x;
x <- rgb(t(x), maxColorValue=255);
return(x);
}
Okabe_Ito <- c("
"
"
orange <- Okabe_Ito[1];
lightBlue <- Okabe_Ito[2];
green <- Okabe_Ito[3]
yellow <- Okabe_Ito[4]
darkBlue <- Okabe_Ito[5];
red <- Okabe_Ito[6];
pink <- Okabe_Ito[7];
orange_l <- lightenColor(orange);
lightBlue_l <- lightenColor(lightBlue);
green_l <- lightenColor(green);
yellow_l <- lightenColor(yellow);
darkBlue_l <- lightenColor(darkBlue);
red_l <- lightenColor(red);
pink_l <- lightenColor(pink);
orangeBg <- lightenColor(orange, amount=.05);
greenBg <- lightenColor(green, amount=.05);
oldKableViewOption <- getOption("kableExtra_view_html", NULL);
options(kableExtra_view_html = FALSE);
oldSilentOption <- preregr::opts$get("silent");
preregr::opts$set(silent = TRUE);
knitr::opts_chunk$set(echo = FALSE, comment="");
if (!exists('headingLevel') || !is.numeric(headingLevel) || (length(headingLevel) != 1)) {
headingLevel <- 0;
}
validSectionIds <-
x$sections$section_id;
validSectionIds <- validSectionIds[
!is.na(validSectionIds) &
nchar(validSectionIds) > 0
];
if (is.null(section)) {
sectionsToShow <- validSectionIds;
} else {
sectionsToShow <-
intersect(
validSectionIds,
section
);
}
preregr::heading(
x$metadata$content[x$metadata$field == "title"],
idSlug("preregr-form"),
headingLevel=headingLevel
);
if (nrow(x$instructions) > 0) {
preregr::heading("Instructions", headingLevel=headingLevel + 1);
for (i in 1:nrow(x$instructions)) {
preregr::heading(
x$instructions[i, "heading"],
idSlug("preregr-form"),
headingLevel=headingLevel + 2
);
cat0("\n\n",
x$instructions[i, "description"],
"\n\n");
}
}
preregr::heading("Sections and items", headingLevel=headingLevel + 1);
for (section in sectionsToShow) {
preregr::heading(
"Section: ",
x$sections[
x$sections$section_id==section,
"section_label"
],
idSlug("preregr-form"),
headingLevel=headingLevel + 2
);
item_ids <- x$items$item_id[x$items$section_id == section];
item_labels <- x$items$item_label[x$items$section_id == section];
item_descriptions <- x$items$item_description[x$items$section_id == section];
names(item_labels) <- item_ids;
names(item_descriptions) <- item_ids;
for (currentItemId in item_ids) {
cat0("<div class=\"preregr preregr-form-item-spec ");
cat0("preregr-form-item\">\n");
cat0("<div class=\"preregr-item-heading\">\n");
cat0("<div class=\"preregr-item-label\">",
item_labels[currentItemId],
"</div>\n");
cat0("<div class=\"preregr-item-id\">",
currentItemId,
"</div>\n");
cat0("</div>\n");
cat0("<div class=\"preregr-item-spec-text\">",
item_descriptions[currentItemId],
"</div>\n");
cat0("</div>\n");
}
}
preregr::opts$set(silent = oldSilentOption);
if (!is.null(oldKableViewOption)) {
options(kableExtra_view_html = oldKableViewOption);
}
preregrJSON <-
preregr::form_to_json(x);
preregrJSON <-
gsub("'",
"&
preregrJSON
);
slug <- paste0("preregr-data-", preregr::randomSlug());
preregr::form_knit(
"prpQuant_v1"
); |
decisionDST <- function (mass, criterion, r = 0.5, sDec = 1:nrow(mass), D = Dcalculus(nrow(mass))){
if (is.vector(mass) || (is.matrix(mass) && nrow(mass) == 1)) {
mass = matrix(mass,, 1)
}
lm=nrow(mass);
nbvec_test=ncol(mass);
nbclasses=round(log2(lm));
class_fusion=c();
for(k in 1:nbvec_test){
masstmp=mass[,k];
if(criterion==1){
plau=mtopl(masstmp);
ii=1:nbclasses;
plau_singl=plau[1+2^(ii-1)];
indice=which.max(plau_singl);
class_fusion=c(class_fusion,indice);
}else if(criterion==2||criterion==3){
croy=mtobel(masstmp);
ii=1:nbclasses;
croy_singl=croy[1+2^(ii-1)];
valuemax=max(croy_singl);
indice=which.max(croy_singl);
if(criterion==3){
indice_complementaire=0;
for (i in seq(nbclasses,indice,by=-1)){
indice_complementaire=indice_complementaire+2^(nbclasses-(nbclasses-i+1));
}
if (valuemax>=croy[indice_complementaire]){
class_fusion=c(class_fusion,indice);
}else{
class_fusion=c(class_fusion,0);
}
}else{
class_fusion=c(class_fusion,indice);
}
}else if(criterion==4){
pign=mtobetp(t(masstmp));
indice=which.max(pign);
class_fusion=c(class_fusion,indice);
}else if(criterion==5){
plau=mtopl(t(masstmp));
lambda=1;
md=BayesianMass(lambda,r,nbclasses);
indice=which.max(plau*md);
class_fusion=c(class_fusion,indice);
}else if(criterion==6){
sizeSD <- length(sDec)
distJ <- c()
for (i in 1:sizeSD){
mSD <- matrix(0,lm,1)
mSD[sDec[i]] <- 1
distJ <- c(distJ, JousselmeDistance(masstmp, mSD, D))
}
indice=which.min(distJ)
class_fusion=c(class_fusion,sDec[indice])
}else{
stop('ACCIDENT: The critertion given is not right\n')
}
}
return(class_fusion)
}
Dcalculus <- function(lm) {
natoms = round(log2(lm))
ind = list()
if (2^natoms == lm) {
ind[[1]] = c(1)
ind[[2]] = c(2)
step = 3
while (step < 2^natoms) {
ind[step] = step
step = step + 1
indatom = step
for (step2 in 2: (indatom - 2)) {
ind[[step]] = sort(union(ind[[indatom - 1]], ind[[step2]]));
step = step + 1
}
}
out = matrix(0, 2^natoms, 2^natoms)
for (i in 1:2^natoms) {
for (j in 1:2^natoms) {
out[i, j] = length(intersect(ind[[i]], ind[[j]]))/length(union(ind[[i]], ind[[j]]))
}
}
} else{
stop("ACCIDENT in Dcalculus: length of input vector not OK: should be a power of 2")
}
return(out)
}
JousselmeDistance <- function(m1, m2, Tjaccard) {
if (length(m1) == length(m2)) {
if(missing(Tjaccard)){
Tjaccard = Dcalculus(length(m1))
}
m_diff = matrix(m1 - m2, length(m1) ,1)
out = sqrt(t(m_diff) %*% Tjaccard %*% m_diff/2)
} else {
stop("ACCIDENT in JousselmeDistance: the size of the both masses m1 and m2 is different\n")
}
return(out)
} |
context("Mahalanobis distance with missing values")
library(modi)
test_that("MDmiss without missings outputs the same result as mahalanobis (stats)", {
A <- matrix(c(2, 4, 3, 13, 5, 8), nrow = 3, ncol = 2, byrow = TRUE)
expect_equal(MDmiss(A, apply(A, 2, mean), var(A)), mahalanobis(A, apply(A, 2, mean), var(A)))
}) |
prep_MCMC <- function(object, start = NULL, end = NULL, thin = NULL,
subset = NULL, exclude_chains = NULL, warn = TRUE,
mess = TRUE, ...) {
if (is.null(start)) {
start <- start(object$MCMC)
} else {
start <- max(start, start(object$MCMC))
}
if (is.null(end)) {
end <- end(object$MCMC)
} else {
end <- min(end, end(object$MCMC))
}
if (is.null(thin))
thin <- coda::thin(object$MCMC)
MCMC <- get_subset(object, subset, warn = warn, mess = mess)
chains <- seq_along(MCMC)
if (!is.null(exclude_chains)) {
chains <- chains[-exclude_chains]
}
MCMC <- do.call(rbind,
window(MCMC[chains],
start = start,
end = end,
thin = thin))
return(MCMC)
}
get_D_names <- function(params, varname, lvls) {
nams <- nlapply(lvls, function(lvl) {
params$coef[
lvapply(params$outcome, function(x) varname %in% x) &
grepl(paste0("^D[[:digit:]]*_[", varname, "_]*", lvl, "\\["),
params$coef)
]
})
Filter(length, nams)
}
rd_vcov <- function(object, outcome = NULL, start = NULL, end = NULL,
thin = NULL,
exclude_chains = NULL, mess = TRUE, warn = TRUE) {
vars <- if (is.null(outcome)) {
names(object$coef_list)
} else {
names(object$coef_list)[outcome]
}
rd_vcov_list <- nlapply(vars, function(varname) {
get_Dmat(object, varname, start = start, end = end, thin = thin,
exclude_chains = exclude_chains, mess = mess, warn = warn)
})
if (length(rd_vcov_list) == 1L) {
rd_vcov_list[[1]]
} else {
rd_vcov_list
}
}
get_Dmat <- function(object, varname, start = NULL, end = NULL, thin = NULL,
exclude_chains = NULL, mess = TRUE, warn = TRUE,
lvls = "all") {
if (lvls == "all") {
lvls <- object$Mlist$idvar
}
MCMC <- prep_MCMC(object, start = start, end = end, thin = thin,
subset = NULL, exclude_chains = exclude_chains,
warn = warn, mess = mess)
Ds <- get_D_names(parameters(object), varname = varname, lvls = lvls)
Dpos <- lapply(Ds, function(d) {
t(sapply(strsplit(gsub("[[:print:]]+\\[|\\]", "", d), ","),
as.numeric))
})
Dmat <- nlapply(names(Dpos), function(lvl) {
nam <- get_rdvcov_names(object, varname, lvl)
m <- matrix(nrow = max(Dpos[[lvl]][, 1]),
ncol = max(Dpos[[lvl]][, 2]),
dimnames = list(nam$nam, nam$nam))
structure(m,
class = "Dmat",
structure = nam
)
})
for (lvl in names(Dmat)) {
for (k in seq_along(Ds[[lvl]])) {
Dmat[[lvl]][Dpos[[lvl]][k, 1],
Dpos[[lvl]][k, 2]] <- mean(MCMC[, Ds[[lvl]][k]])
}
Dmat[[lvl]][is.na(Dmat[[lvl]])] <- t(Dmat[[lvl]])[is.na(Dmat[[lvl]])]
}
Dmat
}
print.Dmat <- function(x, digits = getOption("digits"),
scientific = getOption("scipen"), ...) {
r <- rbind(c(rep("", 2), attr(x, "structure")$variable),
c(rep("", 2), colnames(x)),
cbind(attr(x, "structure")$variable,
rownames(x),
unname(format(x, digits = digits,
scientific = scientific, ...))
)
)
cat(format_Dmat(r), sep = c(rep(" ", ncol(r) - 1), "\n"))
}
format_Dmat <- function(r) {
spaces <- sapply(max(nchar(r)) - nchar(r), function(k) {
if (k > 0L) {
paste0(rep(" ", k), collapse = "")
} else {
""
}
})
matrix(nrow = nrow(r), ncol = ncol(r), data = paste0(spaces, r) )
}
get_rdvcov_names <- function(object, varname, lvl) {
pos <- nlapply(attr(object$info_list[[varname]]$rd_vcov[[lvl]], "ranef_index"),
function(nr) eval(parse(text = nr)))
if (length(pos) > 0L) {
nam <- nlapply(names(pos), function(v) {
attr(object$info_list[[v]]$hc_list$hcvars[[lvl]], "z_names")
})
melt_list(
Map(function(pos, nam) {
cbind(pos, nam)
}, pos = pos, nam = nam), varname = "variable"
)
} else {
nam <- attr(object$info_list[[varname]]$hc_list$hcvars[[lvl]], "z_names")
if (!is.null(nam)) {
data.frame(pos = seq_along(nam),
nam = nam,
variable = varname)
}
}
}
print_type <- function(type, family = NULL, upper = FALSE) {
a <- switch(type,
glm = switch(family,
gaussian = 'linear model',
binomial = 'binomial model',
Gamma = 'Gamma model',
poisson = 'poisson model',
lognorm = 'log-normal model',
beta = 'beta model'
),
glmm = switch(family,
gaussian = 'linear mixed model',
binomial = 'binomial mixed model',
Gamma = 'Gamma mixed model',
poisson = 'poisson mixed model',
lognorm = 'log-normal mixed model',
beta = 'beta mixed model'
),
coxph = 'proportional hazards model',
survreg = 'weibull survival model',
clm = 'cumulative logit model',
clmm = 'cumulative logit mixed model',
mlogit = "multinomial logit model",
mlogitmm = "multinomial logit mixed model",
JM = "joint survival and longitudinal model"
)
if (upper)
substr(a, 1, 1) <- toupper(substr(a, 1, 1))
a
}
get_intercepts <- function(stats, varname, lvls, rev = FALSE) {
interc <- stats[grep(paste0("gamma_", varname), rownames(stats)), ,
drop = FALSE]
attr(interc, "rownames_orig") <- rownames(interc)
if (isTRUE(rev)) {
rownames(interc) <- paste(varname, "\u2264", lvls[-length(lvls)])
} else {
rownames(interc) <- paste(varname, ">", lvls[-length(lvls)])
}
interc
}
computeP <- function(x) {
above <- mean(x > 0)
below <- mean(x < 0)
2 * min(above, below)
} |
expected <- eval(parse(text="\"NaN\""));
test(id=0, code={
argv <- eval(parse(text="list(NaN)"));
do.call(`as.character`, argv);
}, o=expected); |
orglm.fit <- function (x, y, weights = rep(1, nobs), start = NULL, etastart = NULL, mustart = NULL, offset = rep(0, nobs), family = gaussian(), control = list(), intercept = TRUE, constr, rhs, nec){
orr <- function(x, y, constr, rhs, nec){
unc <- lm.fit(x, y)
tBeta <- as.vector(coefficients(unc))
invW <- t(x) %*% x
orsolve <- function(tBeta, invW, Constr, RHS, NEC) {
Dmat <- 2 * invW
dvec <- 2 * tBeta %*% invW
Amat <- t(Constr)
solve.QP(Dmat, dvec, Amat, bvec = RHS, meq = NEC)
}
orBeta <- tBeta
val <- 0
for (i in 1:control$maxit) {
sqp <- orsolve(orBeta, invW, constr, rhs, nec)
orBeta <- sqp$solution
if (abs(sqp$value - val) <= control$epsilon)
break
else val <- sqp$value
}
return(list(coefficients=orBeta))
}
control <- do.call("glm.control", control)
x <- as.matrix(x)
if (is.vector(constr)) constr <- matrix(constr, nrow=1)
if (ncol(constr) != ncol(x)) stop(paste("constr has not correct dimensions.\nNumber of columns (",ncol(constr),") should equal the number of parameters: ", ncol(x), sep=""))
if (length(rhs) != nrow(constr)) stop(paste("rhs has a different number of elements than there are numbers of rows in constr (",length(rhs), " != ", nrow(constr), ")", sep=""))
if (nec < 0) stop("nec needs to be positive")
if (nec > length(rhs)) stop(paste("nec is larger than the number of constraints. (",nec," > ",length(rhs),")", sep=""))
xnames <- dimnames(x)[[2L]]
ynames <- if (is.matrix(y)) rownames(y) else names(y)
conv <- FALSE
nobs <- NROW(y)
nvars <- ncol(x)
EMPTY <- nvars == 0
if (is.null(weights)) weights <- rep.int(1, nobs)
if (is.null(offset)) offset <- rep.int(0, nobs)
variance <- family$variance
linkinv <- family$linkinv
if (!is.function(variance) || !is.function(linkinv)) stop("'family' argument seems not to be a valid family object", call. = FALSE)
dev.resids <- family$dev.resids
aic <- family$aic
mu.eta <- family$mu.eta
unless.null <- function(x, if.null) if (is.null(x)) if.null else x
valideta <- unless.null(family$valideta, function(eta) TRUE)
validmu <- unless.null(family$validmu, function(mu) TRUE)
if (is.null(mustart)) {
eval(family$initialize)
} else {
mukeep <- mustart
eval(family$initialize)
mustart <- mukeep
}
if (EMPTY) {
eta <- rep.int(0, nobs) + offset
if (!valideta(eta)) stop("invalid linear predictor values in empty model", call. = FALSE)
mu <- linkinv(eta)
if (!validmu(mu)) stop("invalid fitted means in empty model", call. = FALSE)
dev <- sum(dev.resids(y, mu, weights))
w <- ((weights * mu.eta(eta)^2)/variance(mu))^0.5
residuals <- (y - mu)/mu.eta(eta)
good <- rep(TRUE, length(residuals))
boundary <- conv <- TRUE
coef <- numeric()
iter <- 0L
} else {
coefold <- NULL
eta <- if (!is.null(etastart)) etastart else if (!is.null(start)) if (length(start) != nvars) stop(gettextf("length of 'start' should equal %d and correspond to initial coefs for %s", nvars, paste(deparse(xnames), collapse = ", ")), domain = NA) else {
coefold <- start
offset + as.vector(if (NCOL(x) == 1L) x * start else x %*% start)
} else family$linkfun(mustart)
mu <- linkinv(eta)
if (!(validmu(mu) && valideta(eta))) stop("cannot find valid starting values: please specify some", call. = FALSE)
devold <- sum(dev.resids(y, mu, weights))
boundary <- conv <- FALSE
for (iter in 1L:control$maxit) {
good <- weights > 0
varmu <- variance(mu)[good]
if (any(is.na(varmu))) stop("NAs in V(mu)")
if (any(varmu == 0)) stop("0s in V(mu)")
mu.eta.val <- mu.eta(eta)
if (any(is.na(mu.eta.val[good]))) stop("NAs in d(mu)/d(eta)")
good <- (weights > 0) & (mu.eta.val != 0)
if (all(!good)) {
conv <- FALSE
warning("no observations informative at iteration ", iter)
break
}
z <- (eta - offset)[good] + (y - mu)[good]/mu.eta.val[good]
w <- sqrt((weights[good] * mu.eta.val[good]^2)/variance(mu)[good])
ngoodobs <- as.integer(nobs - sum(!good))
fit <- orr(x[good, , drop = FALSE] * w, z * w, constr, rhs, nec)
if (any(!is.finite(fit$coefficients))) {
conv <- FALSE
warning(gettextf("non-finite coefficients at iteration %d", iter), domain = NA)
break
}
start <- fit$coefficients
eta <- drop(x %*% start)
mu <- linkinv(eta <- eta + offset)
dev <- sum(dev.resids(y, mu, weights))
if (control$trace) cat("Deviance =", dev, "Iterations -", iter, "\n")
boundary <- FALSE
if (!is.finite(dev)) {
if (is.null(coefold)) stop("no valid set of coefficients has been found: please supply starting values", call. = FALSE)
warning("step size truncated due to divergence", call. = FALSE)
ii <- 1
while (!is.finite(dev)) {
if (ii > control$maxit) stop("inner loop 1; cannot correct step size", call. = FALSE)
ii <- ii + 1
start <- (start + coefold)/2
eta <- drop(x %*% start)
mu <- linkinv(eta <- eta + offset)
dev <- sum(dev.resids(y, mu, weights))
}
boundary <- TRUE
if (control$trace) cat("Step halved: new deviance =", dev, "\n")
}
if (!(valideta(eta) && validmu(mu))) {
if (is.null(coefold)) stop("no valid set of coefficients has been found: please supply starting values", call. = FALSE)
warning("step size truncated: out of bounds", call. = FALSE)
ii <- 1
while (!(valideta(eta) && validmu(mu))){
if (ii > control$maxit) stop("inner loop 2; cannot correct step size", call. = FALSE)
ii <- ii + 1
start <- (start + coefold)/2
eta <- drop(x %*% start)
mu <- linkinv(eta <- eta + offset)
}
boundary <- TRUE
dev <- sum(dev.resids(y, mu, weights))
if (control$trace) cat("Step halved: new deviance =", dev, "\n")
}
if (abs(dev - devold)/(0.1 + abs(dev)) < control$epsilon) {
conv <- TRUE
coef <- start
break
} else {
devold <- dev
coef <- coefold <- start
}
}
if (!conv) warning("orglm.fit: algorithm did not converge", call. = FALSE)
if (boundary) warning("orglm.fit: algorithm stopped at boundary value", call. = FALSE)
eps <- 10 * .Machine$double.eps
if (family$family == "binomial") {
if (any(mu > 1 - eps) || any(mu < eps)) warning("orglm.fit: fitted probabilities numerically 0 or 1 occurred", call. = FALSE)
}
if (family$family == "poisson") {
if (any(mu < eps)) warning("orglm.fit: fitted rates numerically 0 occurred", call. = FALSE)
}
xxnames <- xnames
residuals <- (y - mu)/mu.eta(eta)
nr <- min(sum(good), nvars)
names(coef) <- xnames
}
names(residuals) <- ynames
names(mu) <- ynames
names(eta) <- ynames
wt <- rep.int(0, nobs)
wt[good] <- w^2
names(wt) <- ynames
names(weights) <- ynames
names(y) <- ynames
wtdmu <- if (intercept) sum(weights * y)/sum(weights) else linkinv(offset)
nulldev <- sum(dev.resids(y, wtdmu, weights))
n.ok <- nobs - sum(weights == 0)
nulldf <- n.ok - as.integer(intercept)
fit$rank <- rank <- if (EMPTY) 0 else qr(x)$rank
resdf <- n.ok - rank
fit <- list(coefficients = coef, residuals = residuals, fitted.values = mu, rank=rank, family = family, linear.predictors = eta, deviance = dev, null.deviance = nulldev, iter = iter, weights = wt, prior.weights = weights, df.residual = resdf, df.null = nulldf, y = y, X=x, converged = conv, boundary = boundary, aic=NA, constr=constr, rhs=rhs, nec=nec)
class(fit) <- c("glm", "lm")
return(fit)
} |
`_renv_aliases` <- list(
bioconductor = "Bioconductor",
bitbucket = "Bitbucket",
cellar = "Cellar",
cran = "CRAN",
git2r = "Git",
github = "GitHub",
gitlab = "GitLab",
local = "Local",
repository = "Repository",
standard = "CRAN",
url = "URL",
xgit = "Git"
)
renv_alias <- function(text) {
`_renv_aliases`[[text]] %||% text
} |
hill_taxa_parti_pairwise <- function(comm, q = 0, rel_then_pool = TRUE,
output = c("data.frame", "matrix"),
pairs = c("unique", "full"),
.progress = TRUE,
show_warning = TRUE, ...) {
if (any(comm < 0))
stop("Negative value in comm data")
if (any(colSums(comm) == 0) & show_warning)
warning("Some species in comm data were not observed in any site,\n delete them...")
output <- match.arg(output)
pairs <- match.arg(pairs)
nsite <- nrow(comm)
temp <- matrix(1, nsite, nsite)
dimnames(temp) <- list(row.names(comm), row.names(comm))
gamma_pair <- alpha_pair <- beta_pair <- local_simi <- region_simi <- temp
if(.progress)
progbar = utils::txtProgressBar(min = 0, max = nsite - 1, initial = 0, style = 3)
for (i in 1:(nsite - 1)) {
if(.progress) utils::setTxtProgressBar(progbar, i)
for (j in (i + 1):nsite) {
o <- hill_taxa_parti(comm[c(i, j), ], q = q, check_data = FALSE, ...)
gamma_pair[i, j] <- o$TD_gamma
gamma_pair[j, i] <- o$TD_gamma
alpha_pair[i, j] <- o$TD_alpha
alpha_pair[j, i] <- o$TD_alpha
beta_pair[i, j] <- o$TD_beta
beta_pair[j, i] <- o$TD_beta
local_simi[i, j] <- o$local_similarity
local_simi[j, i] <- o$local_similarity
region_simi[i, j] <- o$region_similarity
region_simi[j, i] <- o$region_similarity
}
}
if(.progress) close(progbar)
if (pairs == "full") {
if (output == "matrix") {
out <- list(q = q, TD_gamma = gamma_pair, TD_alpha = alpha_pair, TD_beta = beta_pair,
local_similarity = local_simi, region_similarity = region_simi)
}
if (output == "data.frame") {
site.comp <- as.matrix(expand.grid(row.names(comm), row.names(comm)))
out <- plyr::adply(site.comp, 1, function(x) {
data.frame(q = q, site1 = x[1], site2 = x[2],
TD_gamma = gamma_pair[x[1], x[2]],
TD_alpha = alpha_pair[x[1], x[2]],
TD_beta = beta_pair[x[1], x[2]],
local_similarity = local_simi[x[1], x[2]],
region_similarity = region_simi[x[1], x[2]])
})[, -1]
out <- tibble::as_tibble(out)
}
}
if (pairs == "unique") {
gamma_pair[lower.tri(gamma_pair, diag = TRUE)] <- NA
alpha_pair[lower.tri(alpha_pair, diag = TRUE)] <- NA
beta_pair[lower.tri(beta_pair, diag = TRUE)] <- NA
local_simi[lower.tri(local_simi, diag = TRUE)] <- NA
region_simi[lower.tri(region_simi, diag = TRUE)] <- NA
if (output == "matrix") {
out <- list(q = q, TD_gamma = gamma_pair, TD_alpha = alpha_pair, TD_beta = beta_pair,
local_similarity = local_simi, region_similarity = region_simi)
}
if (output == "data.frame") {
site.comp <- as.matrix(expand.grid(row.names(comm), row.names(comm)))
out <- plyr::adply(site.comp, 1, function(x) {
data.frame(q = q, site1 = x[1], site2 = x[2],
TD_gamma = gamma_pair[x[1], x[2]],
TD_alpha = alpha_pair[x[1], x[2]],
TD_beta = beta_pair[x[1], x[2]],
local_similarity = local_simi[x[1], x[2]],
region_similarity = region_simi[x[1], x[2]])
})
out <- na.omit(out)[, -1]
row.names(out) <- NULL
out <- tibble::as_tibble(out)
}
}
out
} |
test_that("mlr_tasks", {
expect_dictionary(mlr_tasks, min_items = 1L)
keys = mlr_tasks$keys()
for (key in keys) {
t = tsk(key)
expect_task_supervised(t)
}
})
test_that("load_x", {
ns = getNamespace("mlr3")
nn = names(ns)
nn = nn[startsWith(names(ns), "load_task")]
for (fun in nn) {
fun = get(fun, envir = ns, mode = "function")
expect_task_supervised(fun())
}
})
test_that("tasks are cloned", {
if (packageVersion("mlr3misc") >= "0.9.2") {
task = tsk("iris")
mlr_tasks$add("foo", task)
expect_different_address(task, tsk("foo"))
mlr_tasks$remove("foo")
}
}) |
chessdotcom_leaderboard <- function(game_type = "daily") {
df <- jsonlite::fromJSON("https://api.chess.com/pub/leaderboards")[game_type] %>% unname() %>% data.frame()
df$X.id <- NULL
return(df)
}
lichess_leaderboard <- function(top_n_players, speed_variant) {
top_leaders <- xml2::read_html(paste0("https://lichess.org/player/top/", top_n_players, "/", speed_variant)) %>%
rvest::html_table() %>%
data.frame()
player_status_codes <- gsub( "\\s.*", "", top_leaders$X2[grep("\\s", top_leaders$X2)]) %>% unique()
top_leaders$Usernames <- gsub(paste(player_status_codes, collapse="|"), "", top_leaders$X2) %>% gsub("\\s", "", .)
colnames(top_leaders) <- c("Rank", "TitleAndName", "Rating", "Progress", "Username")
extract_title <- function(x){
if(stringr::str_detect(x, "\\s+")){
x <- gsub( "\\s.*", "", x)
} else{
x <- NA
}
}
top_leaders$Title <- mapply(extract_title, top_leaders$TitleAndName)
top_leaders <- top_leaders %>% dplyr::select(.data$Rank, .data$Title, .data$Username, .data$Rating, .data$Progress)
top_leaders$SpeedVariant <- speed_variant
return(top_leaders)
} |
"samplesMonitors" <-
function(node)
{
if (is.R()){
command <- paste("SamplesEmbed.SetVariable(", sQuote(node),
");SamplesEmbed.StatsGuard;SamplesEmbed.Labels",sep="")
.CmdInterpreter(command)
buffer <- file.path(tempdir(), "buffer.txt")
rlb <- readLines(buffer)
len <- length(rlb)
if (len == 1 && rlb == "command is not allowed (greyed out)")
message(rlb)
else{
if(len == 0){
message("model has probably not yet been updated")
invisible("model has probably not yet been updated")
}
else {
scan(buffer, what = "character", quiet = TRUE, sep="\n")
}
}
} else {
sampsMonsSingle <- function(node){
command <- paste("SamplesEmbed.SetVariable(", sQuote(node),
");SamplesEmbed.StatsGuard;SamplesEmbed.Labels",sep="")
.CmdInterpreter(command)
buffer <- file.path(tempdir(), "buffer.txt")
rlb <- readLines(buffer)
len <- length(rlb)
if (len == 1 && rlb == "command is not allowed (greyed out)")
message(rlb)
else{
if(len == 0){
message("model has probably not yet been updated")
invisible("model has probably not yet been updated")
}
else {
scan(buffer, what = "character", sep="\n")
}
}
}
for(i in seq(along=node)){
mons <- lapply(node, sampsMonsSingle)
}
mons <- unlist(mons)
return(mons)
}
} |
dispatch_parser <- function(filename, decimal = ".", sep = NULL,
specnum = 1L) {
switch(
tolower(file_ext(filename)),
procspec = lr_parse_procspec(filename),
abs = lr_parse_abs(filename),
roh = lr_parse_roh(filename),
trm = lr_parse_trm(filename),
trt = lr_parse_trt(filename),
ttt = lr_parse_ttt(filename),
rfl8 = lr_parse_rfl8(filename, specnum),
raw8 = lr_parse_raw8(filename, specnum),
jdx = lr_parse_jdx(filename),
jaz = lr_parse_jaz(filename),
jazirrad = lr_parse_jazirrad(filename),
spc = lr_parse_spc(filename),
lr_parse_generic(filename, decimal = decimal, sep = sep)
)
} |
lmmlasso <- function(ggmix_object, ...) UseMethod("lmmlasso")
lmmlasso.default <- function(ggmix_object, ...) {
stop(strwrap("This function should be used with a ggmix object of class
lowrank or fullrank"))
}
lmmlasso.fullrank <- function(ggmix_object,
...,
penalty.factor,
lambda,
lambda_min_ratio,
nlambda,
n_design,
p_design,
eta_init,
maxit,
fdev,
standardize,
alpha,
thresh_glmnet,
epsilon,
dfmax,
verbose) {
if (is.null(lambda)) {
if (lambda_min_ratio >= 1) stop("lambda_min_ratio should be less than 1")
lamb <- lambdalasso(ggmix_object,
penalty.factor = penalty.factor,
nlambda = nlambda,
lambda_min_ratio = lambda_min_ratio,
eta_init = eta_init,
epsilon = epsilon
)
lambda_max <- lamb$sequence[[1]]
lamb$sequence[[1]] <- .Machine$double.xmax
tuning_params_mat <- matrix(lamb$sequence, nrow = 1, ncol = nlambda, byrow = TRUE)
dimnames(tuning_params_mat)[[1]] <- list("lambda")
dimnames(tuning_params_mat)[[2]] <- paste0("s", seq_len(nlambda))
lambda_names <- dimnames(tuning_params_mat)[[2]]
} else {
if (any(lambda < 0)) stop("lambdas should be non-negative")
nlambda <- length(lambda)
lambda <- as.double(rev(sort(lambda)))
lambda_max <- lambda[[1]]
tuning_params_mat <- matrix(lambda, nrow = 1, ncol = nlambda, byrow = TRUE)
dimnames(tuning_params_mat)[[1]] <- list("lambda")
dimnames(tuning_params_mat)[[2]] <- paste0("s", seq_len(nlambda))
lambda_names <- dimnames(tuning_params_mat)[[2]]
}
coefficient_mat <- matrix(
nrow = p_design + 3,
ncol = nlambda,
dimnames = list(
c(
colnames(ggmix_object[["x"]]),
"eta", "sigma2"
),
lambda_names
)
)
out_print <- matrix(NA,
nrow = nlambda, ncol = 4,
dimnames = list(
lambda_names,
c(
"Df",
"%Dev",
"Lambda",
"loglik"
)
)
)
beta_init <- matrix(0, nrow = p_design + 1, ncol = 1)
sigma2_init <- sigma2lasso(ggmix_object,
n = n_design,
eta = eta_init,
beta = beta_init
)
for (LAMBDA in lambda_names) {
lambda_index <- which(LAMBDA == lambda_names)
lambda <- tuning_params_mat["lambda", LAMBDA][[1]]
if (verbose >= 1) {
message(sprintf(
"Index: %g, lambda: %0.4f",
lambda_index, if (lambda_index == 1) lambda_max else lambda
))
}
k <- 0
converged <- FALSE
while (!converged && k < maxit) {
Theta_init <- c(as.vector(beta_init), eta_init, sigma2_init)
di <- 1 + eta_init * (ggmix_object[["D"]] - 1)
wi <- (1 / sigma2_init) * (1 / di)
beta_next_fit <- glmnet::glmnet(
x = ggmix_object[["x"]],
y = ggmix_object[["y"]],
family = "gaussian",
weights = wi,
alpha = alpha,
penalty.factor = c(0, penalty.factor),
standardize = FALSE,
intercept = FALSE,
lambda = c(.Machine$double.xmax, lambda),
thresh = thresh_glmnet
)
beta_next <- beta_next_fit$beta[, 2, drop = FALSE]
eta_next <- stats::optim(
par = eta_init,
fn = fn_eta_lasso_fullrank,
gr = gr_eta_lasso_fullrank,
method = "L-BFGS-B",
control = list(fnscale = 1),
lower = 0.01,
upper = 0.99,
sigma2 = sigma2_init,
beta = beta_next,
eigenvalues = ggmix_object[["D"]],
x = ggmix_object[["x"]],
y = ggmix_object[["y"]],
nt = n_design
)$par
sigma2_next <- sigma2lasso(ggmix_object,
n = n_design,
beta = beta_next,
eta = eta_next
)
Theta_next <- c(as.vector(beta_next), eta_next, sigma2_next)
criterion <- crossprod(Theta_next - Theta_init)
converged <- (criterion < epsilon)[1, 1]
if (verbose >= 2) {
message(sprintf(
"Iteration: %f, Criterion: %f", k, criterion
))
}
k <- k + 1
beta_init <- beta_next
eta_init <- eta_next
sigma2_init <- sigma2_next
}
if (!converged) {
message(sprintf(
"algorithm did not converge for lambda %s",
LAMBDA
))
}
saturated_loglik <- logliklasso(ggmix_object,
eta = eta_next,
sigma2 = sigma2_next,
beta = 1,
nt = n_design,
x = ggmix_object[["y"]]
)
intercept_loglik <- logliklasso(ggmix_object,
eta = eta_next,
sigma2 = sigma2_next,
beta = beta_next[1, , drop = FALSE],
nt = n_design,
x = ggmix_object[["x"]][, 1, drop = FALSE]
)
model_loglik <- logliklasso(ggmix_object,
eta = eta_next,
sigma2 = sigma2_next,
beta = beta_next,
nt = n_design
)
deviance <- 2 * (saturated_loglik - model_loglik)
nulldev <- 2 * (saturated_loglik - intercept_loglik)
devratio <- 1 - deviance / nulldev
df <- length(nonzeroCoef(beta_next)) - 1 + 2
out_print[LAMBDA, ] <- c(
if (df == 0) 0 else df,
devratio,
lambda,
model_loglik
)
coefficient_mat[, LAMBDA] <- Theta_next
deviance_change <- abs((out_print[lambda_index, "%Dev"] -
out_print[lambda_index - 1, "%Dev"]) /
out_print[lambda_index, "%Dev"])
if (length(deviance_change) > 0 & out_print[lambda_index, "%Dev"] > 0) {
if (deviance_change < fdev) break
}
if (df > dfmax) break
}
out_print <- out_print[stats::complete.cases(out_print), ]
lambdas_fit <- rownames(out_print)
out_print[1, "Lambda"] <- lambda_max
out <- list(
result = out_print,
ggmix_object = ggmix_object,
n_design = n_design,
p_design = p_design,
lambda = out_print[, "Lambda"],
coef = methods::as(coefficient_mat[, lambdas_fit, drop = FALSE], "dgCMatrix"),
b0 = coefficient_mat["(Intercept)", lambdas_fit],
beta = methods::as(coefficient_mat[colnames(ggmix_object[["x"]])[-1],
lambdas_fit,
drop = FALSE
], "dgCMatrix"),
df = out_print[lambdas_fit, "Df"],
eta = coefficient_mat["eta", lambdas_fit, drop = FALSE],
sigma2 = coefficient_mat["sigma2", lambdas_fit, drop = FALSE],
nlambda = length(lambdas_fit),
cov_names = colnames(ggmix_object[["x"]])
)
class(out) <- c(paste0("lasso", attr(ggmix_object, "class")), "ggmix_fit")
return(out)
} |
context("Test that citations are generated")
test_that("atlas_citation generates DOI for dataset with DOI", {
data <- data.frame()
attr(data, "doi") <- "test-doi"
expect_match(atlas_citation(data), "test-doi")
})
test_that("atlas_citation returns an error when no DOI or search url exists", {
data <- data.frame()
attr(data, "doi") <- NA
attr(data, "search_url") <- NA
expect_error(atlas_citation(data))
})
test_that("atlas_citation produces a citation using a search url", {
data <- data.frame()
attr(data, "doi") <- NA
attr(data, "search_url") <- "test_url"
expect_true(grepl("test_url", atlas_citation(data)))
}) |
suppressWarnings(RNGversion(vstr = "3.5.3"))
test_that("LSI works", {
set.seed(seed = 1)
mat <- matrix(data = rbinom(n = 25, size = 5, prob = 0.2), nrow = 5)
method1 <- RunTFIDF(object = mat, method = 1)
method2 <- RunTFIDF(object = mat, method = 2)
method3 <- RunTFIDF(object = mat, method = 3)
method4 <- RunTFIDF(object = mat, method = 4)
expect_equal(
object = method1[1, ],
expected = c(0.000000, 7.957927, 0.000000, 7.131699, 8.805025),
tolerance = 1 / 1000
)
expect_equal(
object = method2[1, ],
expected = c(0.0000000, 0.1980421, 0.0000000, 0.0866434, 0.4620981),
tolerance = 1 / 1000
)
expect_equal(
object = method3[1, ],
expected = c(0.000000, 5.516015, 0.000000, 4.943317, 6.103178),
tolerance = 1 / 1000
)
expect_equal(
object = method4[1, ],
expected = c(0, 2, 0, 1, 2)
)
lsi <- suppressWarnings(RunSVD(object = mat))
embeddings <- Seurat::Embeddings(object = lsi)
loadings <- Seurat::Loadings(object = lsi)
expect_equal(
object = as.vector(embeddings[1, ]),
expected = c(0.51255352, -0.08674426, 1.33604004, 1.18108240),
tolerance = 1 / 1000
)
expect_equal(
object = as.vector(loadings[1, ]),
expected = c(-0.4024075, -0.4292469, -0.6463644, 0.1740785),
tolerance = 1 / 1000
)
})
test_that("Jaccard works", {
set.seed(1)
mat <- matrix(data = sample(x = c(0, 1), size = 25, replace = TRUE), nrow = 5)
jm <- Jaccard(x = mat, y = mat)
expect_equal(object = jm[1, ], expected = c(1, 1 / 3, 2 / 5, 1 / 3, 0))
}) |
source("ESEUR_config.r")
library("plyr")
plot_layout(2, 1, max_height=12.5)
par(mar=MAR_default+c(-0.5, 0.9, -0.5, 0))
pal_col=rainbow(2)
added=read.csv(paste0(ESEUR_dir, "sourcecode/iwsc2011-kamiya.csv.xz"), as.is=TRUE)
reuse=subset(added, delta > 0)
x_bounds=1:100
delta_cnt=count(reuse$delta)
plot(delta_cnt, log="xy", col=pal_col[1],
cex=1.4, cex.lab=1.4, cex.axis=1.4,
xlim=c(2, 100), ylim=c(10, 1e3),
xlab="Revision difference", ylab="Reintroduced line sequences\n")
dc_mod=glm(log(freq) ~ log(x)+I(log(x)^2), data=delta_cnt, subset=x_bounds)
pred=predict(dc_mod)
lines(delta_cnt$x[x_bounds], exp(pred), col=pal_col[2])
add_cnt=count(reuse$added)
plot(add_cnt, log="xy", col=pal_col[1],
cex=1.4, cex.lab=1.4, cex.axis=1.4,
xlim=c(1, 100), ylim=c(10, 1e5),
xlab="Number of lines", ylab="Reintroduced line sequences\n\n")
ac_mod=glm(log(freq) ~ log(x), data=add_cnt, subset=x_bounds)
summary(ac_mod)
pred=predict(ac_mod)
lines(add_cnt$x[x_bounds], exp(pred), col=pal_col[2])
|
maketensor <- function(A, B){
x <- dim(A)[1]
y <- dim(A)[2]
z <- dim(B)[2]
C <- array(rep(1, x * y * z), c(x, y, z))
for (j in 1 : y){
for (k in 1 : z){
C[,j,k] <- A[,j] * B[,k]
}
}
C
} |
KFadvance <- function(obs,oldmean,oldvar,A,B,C,D,E,F,W,V,marglik=FALSE,log=TRUE,na.rm=FALSE){
if(na.rm){
if(any(is.na(obs))){
if(all(is.na(obs))){
if(log){
return(list(mean=A%*%oldmean + B,var=A%*%oldvar%*%t(A) + C%*%W%*%t(C),mlik=0))
}
else{
return(list(mean=A%*%oldmean + B,var=A%*%oldvar%*%t(A) + C%*%W%*%t(C),mlik=1))
}
}
else{
M <- diag(length(obs))
M <- M[-which(is.na(obs)),]
obs <- obs[which(!is.na(obs))]
D <- M%*%D
E <- M%*%E
F <- M%*%F
}
}
}
T <- A %*% oldmean + B
S <- A %*% oldvar %*% t(A) + C %*% W %*% t(C)
thing1 <- D %*% S
tD <- t(D)
K <- thing1 %*% tD + F %*% V %*% t(F)
margmean <- D %*% T + E
resid <- obs-margmean
if (marglik==TRUE){
if (all(dim(K)==1)){
thing2 <- S %*% tD
newmean <- T + as.numeric(1/K)* thing2 %*% resid
newvar <- S - as.numeric(1/K)*thing2 %*% thing1
marginal <- dnorm(obs,as.numeric(margmean),sqrt(as.numeric(K)),log=log)
}
else{
Kinv <- solve(K)
thing3 <- tD %*% Kinv
thing4 <- S %*% thing3
newmean <- T + thing4 %*% resid
newvar <- S - thing4 %*% thing1
if(log){
marginal <- (-1/2)*t(resid) %*% Kinv %*% resid
}
else{
marginal <- dmvnorm(as.vector(obs),as.vector(margmean),K,log=log)
}
}
return(list(mean=newmean,var=newvar,mlik=marginal))
}
else{
if (all(dim(K)==1)){
thing2 <- S %*% tD
newmean <- T + as.numeric(1/K) * thing2 %*% resid
newvar <- S - as.numeric(1/K) * thing2 %*% thing1
}
else{
Kinv <- solve(K)
thing3 <- tD %*% Kinv
thing4 <- S %*% thing3
newmean <- T + thing4 %*% resid
newvar <- S - thing4 %*% thing1
}
return(list(mean=newmean,var=newvar))
}
} |
test_that("model fitting", {
skip_if_not(TEST_MODEL_FITTING)
with_parallel({
model <- "LARSModel"
expect_error(test_model_binary(model))
expect_error(test_model_factor(model))
expect_output(test_model_numeric(model))
expect_error(test_model_ordered(model))
expect_error(test_model_Surv(model))
})
}) |
episode_group <- function(df, ..., episode_type = "fixed"){
args <- as.list(substitute(...()))
if (length(names(args)[names(args) == ""] > 0)){
err <- paste0("Every argument must be specified:\n",
"i- `episode_group()` has been retired!\n",
"i - Your values will be passed to `episodes()`.\n",
"i - Please specify any argument you've used.")
stop(err, call. = FALSE)
}
out <- bridge_episode_group(df = df, args = args, episode_type = episode_type)
if(out$err_cd == FALSE) stop(out$err_nm, call. = FALSE)
warning(paste0("`episode_group()` has been retired!:\n",
"i - Please use `episodes()` instead.\n",
"i - Your values were passed to `episodes()`."), call. = FALSE)
rm(list = ls()[ls() != "out"])
return(out$err_nm)
}
fixed_episodes <- function(date, case_length = Inf, episode_unit = "days",
to_s4 = TRUE, case_overlap_methods = 8, deduplicate = FALSE,
display = "none", bi_direction = FALSE,
recurrence_length = case_length,
recurrence_overlap_methods = case_overlap_methods,
include_index_period = TRUE, ...,
overlap_methods = 8, overlap_method = 8, x){
args <- as.list(substitute(...()))
if (length(names(args)[names(args) == ""] > 0)){
err <- paste0("Every argument must be specified:\n",
"i - Please specify any argument you've used.")
stop(err, call. = FALSE)
}
if(missing(case_overlap_methods) & !missing(overlap_methods)) {
case_overlap_methods <- overlap_methods
warning(paste0("`overlap_methods` is deprecated:\n",
"i - Please use `case_overlap_methods` instead.\n",
"i - Your values were passed to `case_overlap_methods`."), call. = FALSE)
}else if(missing(case_overlap_methods) & !missing(overlap_method)) {
overlap_methods <- paste0(overlap_method[!duplicated(overlap_method)], collapse = "|")
warning(paste0("`overlap_method` is deprecated:\n",
"i - Please use `case_overlap_methods` instead.\n",
"i - Your values were passed to `case_overlap_methods`."), call. = FALSE)
}
if(missing(date) & !missing(x)) {
date <- x
warning(paste0("`x` is deprecated and will be removed in the next release:\n",
"i - Please use `date` instead.\n",
"i - Your values were passed to `date`."), call. = FALSE)
}
if(class(display) == "logical"){
display <- ifelse(display == FALSE, "none", "stats")
}
err <- err_episodes_checks_1(date = date,
case_length = case_length,
recurrence_length = case_length,
episode_type = "fixed",
episode_unit = episode_unit,
case_overlap_methods = case_overlap_methods,
recurrence_overlap_methods = case_overlap_methods,
deduplicate = deduplicate,
display = display,
bi_direction = bi_direction,
include_index_period = include_index_period,
to_s4 = to_s4)
if(isTRUE(err)){
stop(err, call. = FALSE)
}
episode_unit <- tolower(episode_unit)
if(length(episode_unit) == 1){
episode_unit <- rep(episode_unit, length(date))
}
r <- prep_lengths(case_length, case_overlap_methods, as.number_line(date),
episode_unit, bi_direction)
case_length <- r$lengths
case_overlap_methods <- r$method
if(isTRUE(include_index_period)){
case_length <- c(case_length, list(index_window(date)))
case_overlap_methods <- c(case_overlap_methods, list(rep(8, length(date))))
}
epids <- episodes(date = date, episode_type = "fixed", case_overlap_methods = case_overlap_methods,
recurrence_overlap_methods = case_overlap_methods, display = display,
case_length = case_length, recurrence_length = case_length,
episode_unit = episode_unit, ...)
if(isTRUE(deduplicate)) {
epids <- epids[!epids@case_nm %in% c(2L, 3L)]
}
if(isFALSE(to_s4)){
epids <- to_df(epids)
}
rm(list = ls()[ls() != "epids"])
return(epids)
}
rolling_episodes <- function(date, case_length = Inf, recurrence_length = case_length,
episode_unit = "days", to_s4 = TRUE, case_overlap_methods = 8,
recurrence_overlap_methods = case_overlap_methods, deduplicate = FALSE,
display = "none", bi_direction = FALSE,
include_index_period = TRUE, ...,
overlap_methods = 8, overlap_method = 8, x) {
args <- as.list(substitute(...()))
if (length(names(args)[names(args) == ""] > 0)){
err <- paste0("Every argument must be specified:\n",
"i - Please specify any argument you've used.")
stop(err, call. = FALSE)
}
if(missing(case_overlap_methods) & !missing(overlap_methods)) {
case_overlap_methods <- overlap_methods
warning(paste0("`overlap_methods` is deprecated:\n",
"i - Please use `case_overlap_methods` instead.\n",
"i - Your values were passed to `case_overlap_methods`."), call. = FALSE)
}else if(missing(case_overlap_methods) & !missing(overlap_method)) {
case_overlap_methods <- paste0(overlap_method[!duplicated(overlap_method)], collapse = "|")
warning(paste0("`overlap_method` is deprecated:\n",
"i - Please use `case_overlap_methods` instead.\n",
"i - Your values were passed to `overlap_methods`."), call. = FALSE)
}
if(missing(recurrence_overlap_methods) & !missing(overlap_methods)) {
recurrence_overlap_methods <- overlap_methods
warning(paste0("`overlap_methods` is deprecated:\n",
"i - Please use `recurrence_overlap_methods` instead.\n",
"i - Your values were passed to `recurrence_overlap_methods`."), call. = FALSE)
}else if(missing(recurrence_overlap_methods) & !missing(overlap_method)) {
recurrence_overlap_methods <- paste0(overlap_method[!duplicated(overlap_method)], collapse = "|")
warning(paste0("`overlap_method` is deprecated:\n",
"i - Please use `recurrence_overlap_methods` instead.\n",
"i - Your values were passed to `recurrence_overlap_methods`."), call. = FALSE)
}
if(missing(date) & !missing(x)) {
date <- x
warning(paste0("`x` is deprecated and will be removed in the next release:\n",
"i - Please use `date` instead.\n",
"i - Your values were passed to `date`."), call. = FALSE)
}
if(class(display) == "logical"){
display <- ifelse(display == FALSE, "none", "stats")
}
err <- err_episodes_checks_1(date = date,
case_length = case_length,
recurrence_length = recurrence_length,
episode_type = "rolling",
episode_unit = episode_unit,
case_overlap_methods = case_overlap_methods,
recurrence_overlap_methods = recurrence_overlap_methods,
deduplicate = deduplicate,
display = display,
bi_direction = bi_direction,
include_index_period = include_index_period,
to_s4 = to_s4)
if(isTRUE(err)){
stop(err, call. = FALSE)
}
episode_unit <- tolower(episode_unit)
if(length(episode_unit) == 1){
episode_unit <- rep(episode_unit, length(date))
}
r <- prep_lengths(case_length, case_overlap_methods, as.number_line(date),
episode_unit, bi_direction)
case_length <- r$lengths
case_overlap_methods <- r$method
r <- prep_lengths(recurrence_length, recurrence_overlap_methods, as.number_line(date),
episode_unit, bi_direction)
recurrence_length <- r$lengths
recurrence_overlap_methods <- r$method
if(isTRUE(include_index_period)){
case_length <- c(case_length, list(index_window(date)))
recurrence_length <- c(recurrence_length, list(index_window(date)))
case_overlap_methods <- c(case_overlap_methods, list(rep(8, length(date))))
recurrence_overlap_methods <- c(recurrence_overlap_methods, list(rep(8, length(date))))
}
epids <- episodes(date = date, episode_type = "rolling",
case_overlap_methods = case_overlap_methods, recurrence_overlap_methods = recurrence_overlap_methods,
display = display, case_length = case_length, recurrence_length = recurrence_length,
episode_unit = episode_unit, ...)
if(isFALSE(to_s4)){
epids <- to_df(epids)
}
if(isTRUE(deduplicate)) {
epids <- epids[!epids@case_nm %in% c(2L, 3L)]
}
rm(list = ls()[ls() != "epids"])
return(epids)
} |
prob.max_sensitivity <- function(preds, labels, thresh = 0.5) {
positives <- as.logical(labels)
counter <- sum(positives)
tp <- as.numeric(sum(preds[positives] >= thresh))
fn <- as.numeric(counter - tp)
sens <- tp / (tp + fn)
sens <- ifelse(!is.finite(sens), -1, sens)
return(sens)
} |
DGzx<-function(xs, zs, xv, zv, den)
{
twopi = 2*pi
con=13.3464E-03
nvert = length(xv)
if(xv[1]!=xv[nvert] & zv[1]!=zv[nvert])
{
xv = c(xv, xv[1])
zv = c(zv, zv[1])
}
nvert = length(xv)
gravz = rep(NA, length(xs))
gravx = rep(NA, length(xs))
for(i in 1:length(xs))
{
xst = xs[i]
zst = zs[i]
x1 = xv[1:(nvert-1)]-xst;
z1 = zv[1:(nvert-1)]-zst;
x2 = xv[2:(nvert)]-xst;
z2 = zv[2:(nvert)]-zst;
theta1 = atan2(z1, x1);
theta2 = atan2(z2, x2);
dsign = sign(z1) != sign(z2)
if(any(dsign))
{
theta1[ dsign & (x1*z2<x2*z1) & z2>=0] = theta1[ dsign & (x1*z2<x2*z1) & z2>=0]+twopi
theta2[ dsign & (x1*z2>x2*z1) & z1>=0] = theta2[ dsign & (x1*z2>x2*z1) & z1>=0 ]+twopi
}
dx = x2-x1;
dz = z2-z1;
r1 = sqrt(x1*x1 + z1*z1);
r2 = sqrt(x2*x2 + z2*z2);
dxz2 = (dx*dx + dz*dz)
A = dx*( x1*z2 - x2*z1 )/(dx*dx + dz*dz);
B = dz/dx;
ZEE = A*( (theta1 - theta2) + B*log(r2/r1))
EX = A*(-((theta1 - theta2) )*B + log(r2/r1))
ZEE[x1*z2 == x2*z1] = 0
EX[x1*z2 == x2*z1] = 0
ZEE[ (x1==0 & z1==0) | (x2==0 & z2==0) ] = 0
EX[ (x1==0 & z1==0) | (x2==0 & z2==0) ] = 0
ZEE[x1==x2] = x1[x1==x2] * log(r2[x1==x2]/r1[x1==x2])
EX[x1==x2] = -1*x1[x1==x2] *(theta1[x1==x2] - theta2[x1==x2])
Z = sum( ZEE );
X = sum( EX );
gravz[i] = con*den*Z
gravx[i] = con*den*X
}
invisible(list(Gz=gravz, Gx=gravx))
} |
context("Interpolation and extrapolation of concentration")
test_that("extrapolate.conc", {
expect_error(
extrapolate.conc(
conc=1,
time=1,
time.out=2,
extrap.method="wrong"
),
regexp="extrap.method must be one of 'AUCinf', 'AUClast', or 'AUCall'"
)
expect_error(
extrapolate.conc(
conc=1,
time=1,
time.out=c(2, 3),
extrap.method="AUCinf"
),
regexp="Only one time.out value may be estimated at once."
)
expect_warning(
v1 <-
extrapolate.conc(
conc=NA,
time=1,
time.out=2,
extrap.method="AUCinf"
)
)
expect_equal(v1, NA)
expect_error(
extrapolate.conc(
conc=1,
time=1,
time.out=0.5,
extrap.method="AUCinf"
),
regexp="extrapolate.conc can only work beyond Tlast, please use interp.extrap.conc to combine both interpolation and extrapolation."
)
expect_error(
extrapolate.conc(
conc=1,
time=1,
time.out=1,
extrap.method="AUCinf"
),
regexp="extrapolate.conc can only work beyond Tlast, please use interp.extrap.conc to combine both interpolation and extrapolation."
)
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0),
time=1:3,
time.out=4,
extrap.method="AUClast"
),
0
)
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0),
time=1:3,
time.out=2.5,
extrap.method="AUClast"
),
0
)
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0),
time=1:3,
time.out=4,
extrap.method="AUCall"
),
0
)
expect_equal(
extrapolate.conc(
conc=c(0, 1, 1),
time=1:3,
time.out=4,
lambda.z=2,
extrap.method="AUCall"
),
0
)
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0),
time=1:3,
time.out=2.5,
extrap.method="AUCall"
),
0.5
)
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0),
time=1:3,
time.out=2.5,
lambda.z=1,
extrap.method="AUCinf"
),
1*exp(-1*0.5)
)
expect_equal(
extrapolate.conc(
conc=c(0, 5, 0),
time=1:3,
time.out=2.5,
lambda.z=3,
extrap.method="AUCinf"
),
5*exp(-3*0.5)
)
expect_equal(
extrapolate.conc(
conc=c(0, 5, 0),
time=1:3,
time.out=2.5,
lambda.z=NA,
extrap.method="AUCinf"
),
as.numeric(NA)
)
expect_equal(
expect_warning(
extrapolate.conc(
conc=rep(NA, 3),
time=1:3,
time.out=2.5,
lambda.z=NA,
extrap.method="AUCinf"
)
),
NA
)
extrapolations <-
list(
AUCinf=exp(-2),
AUCall=0,
AUClast=0
)
for (n in names(extrapolations)) {
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4, 5,
lambda.z=1,
extrap.method=n
),
extrapolations[[n]],
info=n
)
}
extrapolations <-
list(
AUCinf=exp(-1),
AUCall=0,
AUClast=0
)
for (n in names(extrapolations)) {
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4, 4,
lambda.z=1,
extrap.method=n
),
extrapolations[[n]],
info=n
)
}
extrapolations <-
list(
AUCinf=exp(-0.5),
AUCall=0.5,
AUClast=0
)
for (n in names(extrapolations)) {
expect_equal(
extrapolate.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4, 3.5,
lambda.z=1,
extrap.method=n
),
extrapolations[[n]],
info=n
)
}
})
test_that("interpolate.conc", {
interpolations <-
list(
linear=0,
"lin up/log down"=0
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1),
time=0:1,
time.out=0,
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=1,
"lin up/log down"=1
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1),
time=0:1,
time.out=1,
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=1,
"lin up/log down"=1
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1, NA, 1),
time=0:3,
time.out=2,
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=0.5,
"lin up/log down"=0.5
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1, 0),
time=0:2,
time.out=0.5,
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=1.75,
"lin up/log down"=2^0.75
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 2, 1),
time=0:2,
time.out=1.25,
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=1.75,
"lin up/log down"=2^0.75
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 2, 1),
time=seq(-10, -8, by=1),
time.out=-8.75,
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=0.25,
"lin up/log down"=0.25
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1, 0, 1, 0),
time=0:4,
time.out=2.25,
conc.blq="keep",
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=0.5,
"lin up/log down"=0.5
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1, 0, 1, 0),
time=0:4,
time.out=1.5,
conc.blq="keep",
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=0.5,
"lin up/log down"=0.5
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1, 0, 1, 0),
time=0:4,
time.out=2.5,
conc.blq="keep",
interp.method=n
),
interpolations[[n]],
info=n
)
}
interpolations <-
list(
linear=1,
"lin up/log down"=1
)
for (n in names(interpolations)) {
expect_equal(
interpolate.conc(
conc=c(0, 1, 0, 1, 0),
time=0:4,
time.out=2.25,
conc.blq="drop",
interp.method=n
),
interpolations[[n]],
info=n
)
}
expect_equal(
interpolate.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4,
time.out=1.5,
interp.method="lin up/log down"),
exp(mean(log(c(1, 0.5))))
)
expect_error(
interpolate.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4,
time.out=5,
interp.method="lin up/log down"
),
regexp="`interpolate.conc()` can only works through Tlast, please use `interp.extrap.conc()` to combine both interpolation and extrapolation.",
fixed=TRUE
)
expect_equal(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=-1),
0,
info="conc.origin defaults to zero"
)
expect_equal(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=-1,
conc.origin=NA),
NA,
info="conc.origin is honored as NA"
)
expect_equal(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=-1,
conc.origin=5
),
5,
info="conc.origin is honored as a number"
)
expect_equal(
interpolate.conc(
conc=c(NA, 1),
time=c(0, 1),
time.out=0.5,
check=FALSE
),
NA_real_,
info="Skipping the checks with an NA bounding the interpolation gives NA"
)
expect_equal(
interpolate.conc(
conc=c(NA, 1, 2),
time=c(0, 1, 2),
time.out=1.5,
check=FALSE
),
1.5,
info="Skipping the checks with an NA, but not bounding the interpolation gives the expected value."
)
expect_error(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=0:1
),
regexp="Can only interpolate for one time point per function call",
info="Confirm that more than one time.out requested is an error"
)
expect_error(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=0.5,
interp.method="this doesn't work"
),
regexp=tryCatch(expr={
match.arg("foo", choices=c("lin up/log down", "linear"))
},
error=function(e) e)$message,
fixed=TRUE,
info="Confirm that invalid interpolation methods are an error."
)
expect_error(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=0.5,
conc.origin=1:2
),
regexp="conc.origin must be a scalar",
info="conc.origin must be a scalar"
)
expect_error(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=0.5,
conc.origin="A"
),
regexp="conc.origin must be NA or a number \\(and not a factor\\)",
info="conc.origin must be a number and not a factor (character)"
)
expect_error(
interpolate.conc(
conc=0:1,
time=0:1,
time.out=0.5,
conc.origin=factor("A")
),
regexp="conc.origin must be NA or a number \\(and not a factor\\)",
info="conc.origin must be a number and not a factor (factor)"
)
})
test_that("interp.extrap.conc", {
expect_equal(
interp.extrap.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4,
time.out=1.5,
interp.method="lin up/log down"
),
exp(mean(log(c(1, 0.5))))
)
expect_equal(
expect_warning(
interp.extrap.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4,
time.out=c(1.5, NA),
interp.method="lin up/log down"
)
),
c(exp(mean(log(c(1, 0.5)))), NA)
)
expect_warning(
interp.extrap.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4,
time.out=c(1.5, NA),
interp.method="lin up/log down"
),
regexp="An interpolation/extrapolation time is NA"
)
expect_error(
interp.extrap.conc(
conc=c(0, 1, 0.5, 1, 0),
time=0:4,
time.out=c(),
interp.method="lin up/log down"
),
regexp="time.out must be a vector with at least one element"
)
})
test_that("interp.extrap.conc.dose handles all eventualities", {
event_choices <- unlist(event_choices_interp.extrap.conc.dose, use.names=FALSE)
eventualities <-
expand.grid(
event_before=setdiff(event_choices, "output_only"),
event=setdiff(event_choices, "none"),
event_after=setdiff(event_choices, "output_only")
)
eventualities$method <- NA_character_
for (nm in names(interp.extrap.conc.dose.select)) {
mask_selected <-
do.call(
interp.extrap.conc.dose.select[[nm]]$select,
list(x=eventualities)
)
expect_true(
any(mask_selected),
info=sprintf("interp.extrap.conc.dose.select[[%s]] matched at least one eventuality", nm)
)
expect_true(
!any(mask_selected & !is.na(eventualities$method)),
info=sprintf("interp.extrap.conc.dose.select[[%s]] overlapped with another method.", nm)
)
eventualities$method[mask_selected] <- nm
}
expect_false(
any(is.na(eventualities$method)),
info="interp.extrap.conc.dose.select matched all eventualities"
)
})
test_that("interp.extrap.conc.dose", {
expect_error(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
route.dose="foo",
duration.dose=NA,
time.out=c(-1, -0.1, 0, 0.1, 7),
out.after=FALSE
),
regexp="route.dose must be either 'extravascular' or 'intravascular'",
info="Route must be valid"
)
expect_error(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
route.dose=c("extravascular", "extravascular"),
duration.dose=NA,
time.out=c(-1, -0.1, 0, 0.1, 7),
out.after=FALSE
),
regexp="route.dose must either be a scalar or the same length as time.dose",
info="Route must have the correct length"
)
expect_error(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
route.dose="extravascular",
duration.dose="A",
time.out=c(-1, -0.1, 0, 0.1, 7),
out.after=FALSE
),
regexp="duration.dose must be NA or a number.",
info="duration.dose must be NA or a number (character)."
)
expect_error(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
route.dose="extravascular",
duration.dose=factor("A"),
time.out=c(-1, -0.1, 0, 0.1, 7),
out.after=FALSE
),
regexp="duration.dose must be NA or a number.",
info="duration.dose must be NA or a number (factor)."
)
expect_error(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
route.dose="extravascular",
duration.dose=c(1, NA),
time.out=c(-1, -0.1, 0, 0.1, 7),
out.after=FALSE
),
regexp="duration.dose must either be a scalar or the same length as time.dose",
info="duration.dose must match the length of time.dose or be a scalar."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=-2,
check=FALSE
),
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=-2
),
info="Check is respected"
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=-2
),
structure(0, Method="Before all events"),
info="Interpolation before all events yields conc.origin which defaults to zero."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
conc.origin=NA,
time.out=-2),
structure(NA_real_, Method="Before all events"),
info="Interpolation before all events yields conc.origin respecting its input."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=-1
),
structure(0, Method="Observed concentration"),
info="When there is a concentration measurement at a time point, it is returned."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=-0.1
),
structure(0, Method="Extrapolation"),
info="When the previous measurement is zero and there is no dose between, it is returned."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=0),
structure(0, Method="Extrapolation"),
info="When the previous measurement is zero it is at the time of the dose, zero is returned."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=0.1
),
structure(0.1, Method="Dose before, concentration after without a dose"),
info="Extrapolation to a dose then interpolation between the dose and the next time works."
)
expect_equal(
expect_warning(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=c(0, 0.1),
time.out=0.2
),
regexp="Cannot interpolate between two doses or after a dose without a concentration after the first dose.",
fixed=TRUE,
info="Two doses in a row generates a warning"
),
structure(NA_real_, Method="Dose before, concentration after without a dose"),
info="Extrapolation to a dose then interpolation between the dose and the next time gives NA when the dose is NA."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=5
),
structure(0.25, Method="Observed concentration"),
info="Copy from after the dose."
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=7
),
structure(NA_real_, Method="Extrapolation"),
info="Extrapolation without lambda.z gives NA result"
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=7,
lambda.z=log(2)
),
structure(0.0625, Method="Extrapolation"),
info="Extrapolation with lambda.z gives result"
)
expect_equal(
interp.extrap.conc.dose(
conc=0:2,
time=0:2,
time.dose=0,
time.out=0.5
),
structure(0.5, Method="Interpolation"),
info="Interpolation works"
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0:2, 1),
time=0:3,
time.dose=0,
time.out=2.5,
method="linear"
),
structure(sqrt(2), Method="Interpolation"),
info="Interpolation respects method"
)
expect_equal(
interp.extrap.conc.dose(
conc=0:2,
time=0:2,
time.dose=0,
route.dose="intravascular",
time.out=0,
duration.dose=0,
out.after=FALSE
),
structure(0, Method="Observed concentration"),
info="Observed before IV bolus"
)
expect_equal(
interp.extrap.conc.dose(
conc=0:2,
time=0:2,
time.dose=0,
route.dose="intravascular",
time.out=0,
duration.dose=0,
out.after=TRUE
),
structure(1, Method="Immediately after an IV bolus with a concentration next"),
info="Observed after IV bolus, one concentration"
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 2, 1),
time=0:2,
time.dose=0,
route.dose="intravascular",
time.out=0,
duration.dose=0,
out.after=TRUE
),
structure(4, Method="Immediately after an IV bolus with a concentration next"),
info="Observed after IV bolus, two concentrations"
)
expect_equal(
interp.extrap.conc.dose(
conc=c(2, 1),
time=1:2,
time.dose=0,
route.dose="intravascular",
time.out=0.5,
duration.dose=0
),
structure(2*sqrt(2), Method="After an IV bolus with a concentration next"),
info="After IV bolus, two concentrations"
)
expect_equal(
interp.extrap.conc.dose(
conc=2,
time=1,
time.dose=0,
route.dose="intravascular",
time.out=0.5,
duration.dose=0
),
structure(2, Method="After an IV bolus with a concentration next"),
info="After IV bolus, one concentration"
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=c(-2, 2)
),
structure(
c(0, 2),
Method=c("Before all events", "Observed concentration")
),
info="Outputs are in the same order as inputs (initially sorted)"
)
expect_equal(
interp.extrap.conc.dose(
conc=c(0, 1, 2, 1, 0.5, 0.25),
time=c(-1, 1:5),
time.dose=0,
time.out=c(2, -2)
),
structure(
c(2, 0),
Method=c("Observed concentration", "Before all events")
),
info="Outputs are in the same order as inputs (reverse sorted time.out)"
)
}) |
tiny_width = 5.5
tiny_height = 3 + 2/3
small_width = med_width = 6.75
small_height = med_height = 4.5
large_width = 8
large_height = 5.25
knitr::opts_chunk$set(
fig.width = small_width,
fig.height = small_height
)
if (capabilities("cairo") && Sys.info()[['sysname']] != "Darwin") {
knitr::opts_chunk$set(
dev = "png",
dev.args = list(type = "cairo")
)
}
library(dplyr)
library(tidyr)
library(purrr)
library(ggdist)
library(ggplot2)
library(distributional)
library(cowplot)
theme_set(theme_ggdist())
.old_options = options(width = 120)
set.seed(1234)
n = 5000
df = tibble(
.draw = 1:n,
intercept = rnorm(n, 3, 1),
slope = rnorm(n, 1, 0.25),
x = list(-4:5),
y = map2(intercept, slope, ~ .x + .y * -4:5)
) %>%
unnest(c(x, y))
df %>%
filter(.draw %in% 1:100) %>%
ggplot(aes(x = x, y = y, group = .draw)) +
geom_line(alpha = 0.25)
df %>%
group_by(x) %>%
median_qi(y)
df %>%
group_by(x) %>%
median_qi(y) %>%
ggplot(aes(x = x, y = y, ymin = .lower, ymax = .upper)) +
geom_lineribbon(fill = "gray65")
df %>%
group_by(x) %>%
median_qi(y, .width = c(.50, .80, .95)) %>%
ggplot(aes(x = x, y = y, ymin = .lower, ymax = .upper)) +
geom_lineribbon() +
scale_fill_brewer()
df %>%
ggplot(aes(x = x, y = y)) +
stat_lineribbon() +
scale_fill_brewer()
df %>%
ggplot(aes(x = x, y = y)) +
stat_lineribbon(.width = c(.66, .95)) +
scale_fill_brewer()
df %>%
ggplot(aes(x = x, y = y)) +
stat_lineribbon(aes(fill = stat(.width)), .width = ppoints(50)) +
scale_fill_distiller()
df %>%
ggplot(aes(x = x, y = y)) +
stat_lineribbon(aes(fill_ramp = stat(.width)), .width = ppoints(50), fill = "
scale_fill_ramp_continuous(range = c(1, 0))
df_2groups = rbind(
mutate(df, g = "a"),
mutate(df, g = "b", y = (y - 2) * 0.5)
)
df_2groups %>%
ggplot(aes(x = x, y = y, color = g)) +
stat_lineribbon() +
scale_fill_brewer()
df_2groups %>%
ggplot(aes(x = x, y = y, fill = g)) +
stat_lineribbon(alpha = 1/4)
df_2groups %>%
ggplot(aes(x = x, y = y, fill = g)) +
stat_lineribbon(aes(fill_ramp = stat(level)))
analytical_df = tibble(
x = -4:5,
y_mean = 3 + x,
y_sd = sqrt(x^2/10 + 1),
)
analytical_df
analytical_df %>%
ggplot(aes(x = x, dist = dist_normal(y_mean, y_sd))) +
stat_dist_lineribbon() +
scale_fill_brewer()
k = 11
n = 501
df = tibble(
.draw = 1:k,
mean = seq(-5,5, length.out = k),
x = list(seq(-15,15,length.out = n)),
) %>%
unnest(x) %>%
mutate(y = dnorm(x, mean, 3)/max(dnorm(x, mean, 3)))
df %>%
ggplot(aes(x = x, y = y)) +
geom_line(aes(group = .draw), alpha=0.2)
df %>%
group_by(x) %>%
median_qi(y, .width = .5) %>%
ggplot(aes(x = x, y = y)) +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
geom_line(aes(group = .draw), alpha=0.15, data = df) +
scale_fill_brewer() +
ggtitle("50% pointwise intervals with point_interval()")
df %>%
group_by(x) %>%
curve_interval(y, .width = .5) %>%
ggplot(aes(x = x, y = y)) +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
geom_line(aes(group = .draw), alpha=0.15, data = df) +
scale_fill_brewer() +
ggtitle("50% curvewise intervals with curve_interval()")
k = 1000
large_df = tibble(
.draw = 1:k,
mean = seq(-5,5, length.out = k),
x = list(seq(-15,15,length.out = n)),
) %>%
unnest(x) %>%
mutate(y = dnorm(x, mean, 3)/max(dnorm(x, mean, 3)))
pointwise_plot = large_df %>%
group_by(x) %>%
median_qi(y, .width = c(.5, .8, .95)) %>%
ggplot(aes(x = x, y = y)) +
geom_hline(yintercept = 1, color = "gray75", linetype = "dashed") +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
scale_fill_brewer() +
ggtitle("point_interval()")
curvewise_plot = large_df %>%
group_by(x) %>%
curve_interval(y, .width = c(.5, .8, .95)) %>%
ggplot(aes(x = x, y = y)) +
geom_hline(yintercept = 1, color = "gray75", linetype = "dashed") +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
scale_fill_brewer() +
ggtitle("curve_interval()")
plot_grid(nrow = 2,
pointwise_plot, curvewise_plot
)
set.seed(1234)
n = 4000
mpg = seq(min(mtcars$mpg), max(mtcars$mpg), length.out = 100)
mtcars_boot = tibble(
.draw = 1:n,
m = map(.draw, ~ loess(
hp ~ mpg,
span = 0.9,
control = loess.control(surface = "direct"),
data = slice_sample(mtcars, prop = 1, replace = TRUE)
)),
hp = map(m, predict, newdata = tibble(mpg)),
mpg = list(mpg)
) %>%
select(-m) %>%
unnest(c(hp, mpg))
mtcars_boot %>%
filter(.draw < 400) %>%
ggplot(aes(x = mpg, y = hp)) +
geom_line(aes(group = .draw), alpha = 1/10) +
geom_point(data = mtcars) +
coord_cartesian(ylim = c(0, 400))
mtcars_boot %>%
ggplot(aes(x = mpg, y = hp)) +
stat_lineribbon(.width = c(.5, .7, .9)) +
geom_point(data = mtcars) +
scale_fill_brewer() +
coord_cartesian(ylim = c(0, 400))
mtcars_boot %>%
group_by(mpg) %>%
curve_interval(hp, .width = c(.5, .7, .9)) %>%
ggplot(aes(x = mpg, y = hp)) +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
geom_point(data = mtcars) +
scale_fill_brewer() +
coord_cartesian(ylim = c(0, 400))
mtcars_boot %>%
group_by(mpg) %>%
curve_interval(hp, .width = c(.5, .7, .9), .interval = "bd-mbd") %>%
ggplot(aes(x = mpg, y = hp)) +
geom_lineribbon(aes(ymin = .lower, ymax = .upper)) +
geom_point(data = mtcars) +
scale_fill_brewer() +
coord_cartesian(ylim = c(0, 400))
options(.old_options) |
expected <- eval(parse(text="structure(list(c0 = logical(0)), .Names = \"c0\", row.names = integer(0), class = \"data.frame\")"));
test(id=0, code={
argv <- eval(parse(text="list(structure(list(c0 = structure(integer(0), .Label = character(0), class = \"factor\")), .Names = \"c0\", row.names = character(0), class = \"data.frame\"), structure(list(c0 = structure(integer(0), .Label = character(0), class = \"factor\")), .Names = \"c0\", row.names = character(0), class = \"data.frame\"))"));
do.call(`%%`, argv);
}, o=expected); |
densityVoronoi.tpp <- function(X, f = 1, nrep = 1,
at=c("points","pixels"),
dimt=128,...){
if(!inherits(X, "tpp")) stop("X should an object of class tpp")
if(missing(at)) at <- "pixels"
n <- npoints(X)
if(f<0 | f>1) stop("f should be between 0 and 1")
Xt <- lpp(X=cbind(X$data$t,rep(0,n)),
L=linnet_interval(startp=X$time[1], endp=X$time[2]))
out <- densityVoronoi.lpp(Xt,f=f,nrep=nrep,dimyx=dimt,...)
if(at=="pixels"){
out1 <- out$v[!is.na(out$v)]
class(out1) <- c("tppint")
attr(out1,"time") <- X$data$t
attr(out1,"tgrid") <- out$xcol
attr(out1,"tpp") <- X
return(out1)
}
else{
Tint <- out$v[!is.na(out$v)]
ID <- findInterval(X$data$t, out$xcol)
ID[which(ID==0)] <- 1
Tintout <- Tint[ID]
class(Tintout) <- c("numeric")
attr(out,"time") <- X$data$t
return(Tintout)
}
} |
if (!interactive()) options(prompt = " ", continue = " ", width = 70)
library(jsonlite)
library(OmicNavigator)
.tmplib <- tempfile()
local({
dir.create(.tmplib)
.libPaths(c(.tmplib, .libPaths()))
abc <- OmicNavigator:::testStudy(name = "ABC")
plots <- OmicNavigator:::testPlots()
abc <- addPlots(abc, plots)
tmpReport <- tempfile(fileext = ".html")
writeLines("<p>example</p>", tmpReport)
abc <- addReports(abc, list(model_02 = tmpReport))
OmicNavigator::installStudy(abc)
})
studies <- listStudies(libraries = .tmplib)
toJSON(studies, auto_unbox = TRUE, pretty = TRUE)
resultsTable <- getResultsTable(
study = "ABC",
modelID = "model_01",
testID = "test_01"
)
toJSON(resultsTable[1:2, ], pretty = TRUE)
enrichmentsTable <- getEnrichmentsTable(
study = "ABC",
modelID = "model_01",
annotationID = "annotation_01"
)
toJSON(enrichmentsTable[1:2, ], pretty = TRUE)
enrichmentsTable <- getEnrichmentsTable(
study = "ABC",
modelID = "model_01",
annotationID = "annotation_01",
type = "adjusted"
)
toJSON(enrichmentsTable[1:2, ], pretty = TRUE)
enrichmentsNetwork <- getEnrichmentsNetwork(
study = "ABC",
modelID = "model_01",
annotationID = "annotation_01"
)
enrichmentsNetworkMinimal <- list(
tests = enrichmentsNetwork[["tests"]],
nodes = enrichmentsNetwork[["nodes"]][1:3, ],
links = enrichmentsNetwork[["links"]][1:3, ]
)
toJSON(enrichmentsNetworkMinimal, auto_unbox = TRUE, pretty = TRUE)
nodeFeatures <- getNodeFeatures(
study = "ABC",
annotationID = "annotation_01",
termID = "term_01"
)
toJSON(nodeFeatures[1:4], pretty = TRUE)
linkFeatures <- getLinkFeatures(
study = "ABC",
annotationID = "annotation_01",
termID1 = "term_01",
termID2 = "term_03"
)
toJSON(linkFeatures[1:4], pretty = TRUE)
plotStudy(
study = "ABC",
modelID = "model_01",
featureID = "feature_0001",
plotID = "plotBase",
testID = "test_01"
)
plotStudy(
study = "ABC",
modelID = "model_03",
featureID = "feature_0001",
plotID = "plotGg",
testID = "test_01"
)
plotStudy(
study = "ABC",
modelID = "model_01",
featureID = c("feature_0001", "feature_0002"),
plotID = "plotMultiFeature",
testID = "test_01"
)
plotStudy(
study = "ABC",
modelID = "model_01",
featureID = c("feature_0001", "feature_0002"),
plotID = "plotMultiTestMf",
testID = c("test_01", "test_02")
)
modelID <- c("model_01", "model_02")
testID <- c("test_01", "test_02")
names(testID) <- modelID
plotStudy(
study = "ABC",
modelID = modelID,
featureID = c("feature_0002", "feature_0003", "feature_0004"),
plotID = "multiModel_scatterplot",
testID = testID
)
resultsIntersection <- getResultsIntersection(
study = "ABC",
modelID = "model_01",
anchor = "test_01",
mustTests = c("test_01", "test_02"),
notTests = c(),
sigValue = .5,
operator = "<",
column = "p_val"
)
toJSON(resultsIntersection[1:2, ], pretty = TRUE)
enrichmentsIntersection <- getEnrichmentsIntersection(
study = "ABC",
modelID = "model_01",
annotationID = "annotation_01",
mustTests = c("test_01", "test_02"),
notTests = c(),
sigValue = .5,
operator = "<",
type = "nominal"
)
toJSON(enrichmentsIntersection[1:2, ], pretty = TRUE)
resultsUpset <- getResultsUpset(
study = "ABC",
modelID = "model_01",
sigValue = .5,
operator = "<",
column = "p_val"
)
enrichmentsUpset <- getEnrichmentsUpset(
study = "ABC",
modelID = "model_01",
annotationID = "annotation_02",
sigValue = .05,
operator = "<",
type = "nominal"
)
upsetCols <- getUpsetCols(
study = "ABC",
modelID = "model_01"
)
toJSON(upsetCols, auto_unbox = TRUE, pretty = TRUE)
metaFeaturesTable <- getMetaFeaturesTable(
study = "ABC",
modelID = "model_01",
featureID = "feature_0001"
)
toJSON(metaFeaturesTable[1:2, ], pretty = TRUE)
barcodeData <- getBarcodeData(
study = "ABC",
modelID = "model_01",
testID = "test_01",
annotationID = "annotation_02",
termID = "term_05"
)
toJSON(barcodeData, auto_unbox = TRUE, pretty = TRUE)
reportLink <- getReportLink(
study = "ABC",
modelID = "model_01"
)
toJSON(reportLink, auto_unbox = TRUE, pretty = TRUE)
reportLink <- getReportLink(
study = "ABC",
modelID = "model_02"
)
toJSON(reportLink, auto_unbox = TRUE, pretty = TRUE)
resultsLinkouts <- getResultsLinkouts(
study = "ABC",
modelID = "model_01"
)
toJSON(resultsLinkouts, auto_unbox = TRUE, pretty = 2)
enrichmentsLinkouts <- getEnrichmentsLinkouts(
study = "ABC",
annotationID = "annotation_01"
)
toJSON(enrichmentsLinkouts, auto_unbox = TRUE, pretty = 2)
enrichmentsLinkouts <- getEnrichmentsLinkouts(
study = "ABC",
annotationID = "annotation_03"
)
toJSON(enrichmentsLinkouts, auto_unbox = TRUE, pretty = TRUE)
metaFeaturesLinkouts <- getMetaFeaturesLinkouts(
study = "ABC",
modelID = "model_01"
)
toJSON(metaFeaturesLinkouts, auto_unbox = TRUE, pretty = 2)
resultsFavicons <- getFavicons(linkouts = resultsLinkouts)
toJSON(resultsFavicons, auto_unbox = TRUE, pretty = 2)
enrichmentsFavicons <- getFavicons(linkouts = enrichmentsLinkouts)
toJSON(enrichmentsFavicons, auto_unbox = TRUE, pretty = 2)
toJSON(getResultsTable(study = "ABC", modelID = "?", testID = "?"))
toJSON(getEnrichmentsTable(study = "ABC", modelID = "?", annotationID = "?"))
toJSON(getEnrichmentsNetwork(study = "ABC", modelID = "?", annotationID = "?"))
toJSON(getNodeFeatures(study = "ABC", annotationID = "?", termID = "?"))
toJSON(getLinkFeatures(study = "ABC", annotationID = "?", termID1 = "?",
termID2 = "?"))
toJSON(getUpsetCols(study = "ABC", modelID = "?"))
toJSON(getMetaFeaturesTable(study = "ABC", modelID = "?", featureID = "?"))
toJSON(getBarcodeData(study = "ABC", modelID = "?", testID = "?",
annotationID = "?", termID = "?"))
toJSON(getReportLink(study = "ABC", modelID = "?"),
auto_unbox = TRUE, pretty = TRUE)
toJSON(getResultsLinkouts(study = "ABC", modelID = "?"),
auto_unbox = TRUE, pretty = 2)
toJSON(getEnrichmentsLinkouts(study = "ABC", annotationID = "?"))
toJSON(getPackageVersion(), auto_unbox = TRUE) |
get_time <- function(object) {
pluck(object, "final_signature", "when", "time")
}
get_info <- function(path, repo = ".") {
in_repository <- path %in%
(git2r::ls_tree(repo = repo, recursive = TRUE) %>%
mutate(filepath = paste0(path, name)) %>%
pull(filepath))
if (in_repository) {
blame_object <- blame(repo = repo, path = path)
file <- path
first_last <- blame_object %>%
pluck("hunks") %>%
map(get_time) %>%
flatten_dbl() %>%
range() %>%
as.POSIXct.numeric(origin = "1970-01-01") %>%
set_names(nm = c("first", "last"))
} else {
file <- path
first_last <- c(as.POSIXct.numeric(NA_real_, origin = "1970-01-01"),
file.info(file.path(repo, path))$mtime) %>%
set_names(nm = c("first", "last"))
}
list(
file = file,
in_repository = in_repository,
first_modif = first_last[1],
last_modif = first_last[2]
)
}
get_last_modif <- function(repo = ".", path = "R",
recursive = TRUE, untracked = TRUE) {
folder <- normalizePath(file.path(repo, path), mustWork = FALSE)
if (dir.exists(folder)) {
if (path != "") {
files <- git2r::ls_tree(repo = repo, recursive = recursive) %>%
filter(path == paste0(!!path, "/")) %>%
mutate(filepath = paste0(path, name)) %>%
pull(filepath)
if (isTRUE(untracked)) {
not_in_git <- git2r::status(repo, all_untracked = TRUE) %>% unlist()
files <- c(files, not_in_git[grepl(paste0(path, "/"), not_in_git)])
}
} else {
files <- git2r::ls_tree(repo = repo, recursive = recursive) %>%
mutate(filepath = paste0(path, name)) %>%
pull(filepath)
if (isTRUE(untracked)) {
not_in_git <- git2r::status(repo, all_untracked = TRUE) %>% unlist()
files <- c(files, not_in_git[grepl(paste0(path, "/"), not_in_git)])
}
}
} else {
stop(path, "/ folder was not found")
}
if (length(files) == 0) {
stop("There are no files to show. ",
"Check the path, recursive and untracked parameters.")
}
map(files, ~ get_info(.x, repo = repo))
}
present_files <- function(repo = ".", path = "R",
recursive = TRUE, untracked = TRUE) {
get_last_modif(repo, path, recursive, untracked) %>%
purrr::map_dfr(as_tibble) %>%
transmute(
File = file,
`Tracked in git` = ifelse(in_repository, "Yes", "No"),
`Date of creation` = first_modif,
`Last modification` = last_modif
) %>%
knitr::kable(., format = "markdown") %>%
paste(., collapse = " \n")
}
create_vignette_last_modif <- function(repo = ".", path = "R",
recursive = TRUE, untracked = TRUE) {
vig <- file.path(repo, "vignettes")
if (!dir.exists(vig)) {
stop("vignettes folder doesn't exist, please create vignettes folder")
} else {
update_vignette_last_modif(repo, path, recursive, untracked)
}
}
update_vignette_last_modif <- function(repo = ".", path = "R",
recursive = TRUE, untracked = TRUE) {
vig <- file.path(repo, "vignettes")
file <- file.path(vig, "modification_files.Rmd")
if (file.exists(file)) {
unlink(file)
}
path_to_copy <- system.file("template/modification_files.Rmd", package = "gitdown")
file.copy(path_to_copy, to = vig)
if (file.exists(file)) {
md <- c(
paste0("Created on: ", Sys.time()),
"\n\n",
present_files(repo, path, recursive, untracked), "\n\n")
write(md, file = file, append = TRUE)
} else {
stop("Copying the file didn't work!")
}
} |
MvnormalCreate <- function(priorParameters) {
mdObj <- MixingDistribution("mvnormal", priorParameters, "conjugate")
return(mdObj)
}
Likelihood.mvnormal <- function(mdObj, x, theta) {
y <- sapply(seq_len(dim(theta[[1]])[3]),
function(i) mvtnorm::dmvnorm(x, theta[[1]][,, i], theta[[2]][, , i]))
return(y)
}
PriorDraw.mvnormal <- function(mdObj, n = 1) {
priorParameters <- mdObj$priorParameters
sig <- rWishart(n, priorParameters$nu, priorParameters$Lambda)
mu <- simplify2array(
lapply(seq_len(n),
function(x)
mvtnorm::rmvnorm(1,
priorParameters$mu0,
solve(sig[, , x] * priorParameters$kappa0))
)
)
theta <- list(mu = mu, sig = sig)
return(theta)
}
PosteriorDraw.mvnormal <- function(mdObj, x, n = 1, ...) {
post_parameters <- PosteriorParameters(mdObj, x)
sig <- rWishart(n, post_parameters$nu_n, post_parameters$t_n)
mu <- simplify2array(
lapply(seq_len(n),
function(x) mvtnorm::rmvnorm(1,
post_parameters$mu_n,
solve(post_parameters$kappa_n * sig[, , x]))
)
)
return(list(mu = mu, sig = sig/post_parameters$kappa_n^2))
}
PosteriorParameters.mvnormal <- function(mdObj, x) {
if (!is.matrix(x)) {
x <- matrix(x, ncol = length(x))
}
kappa0 <- mdObj$priorParameters$kappa0
mu0 <- mdObj$priorParameters$mu0
kappa_n <- kappa0 + nrow(x)
nu_n <- mdObj$priorParameters$nu + nrow(x)
mu_n <- (kappa0 * mu0 + nrow(x) * colMeans(x))/(nrow(x) + kappa0)
sum_squares <- (nrow(x) - 1) * var(x)
sum_squares[is.na(sum_squares)] <- 0
t_n <- mdObj$priorParameters$Lambda +
sum_squares +
((kappa0 * nrow(x))/(kappa0 + nrow(x))) * ((mu0 - colMeans(x)) %*% t(mu0 - colMeans(x)))
return(list(mu_n = mu_n, t_n = t_n, kappa_n = kappa_n, nu_n = nu_n))
}
Predictive.mvnormal <- function(mdObj, x) {
priorParameters <- mdObj$priorParameters
pred <- numeric(nrow(x))
d <- ncol(x)
for (i in seq_along(pred)) {
post_params <- PosteriorParameters(mdObj, x[i, ,drop=FALSE])
pred[i] <- (pi^(-nrow(x[i,,drop=FALSE]) * d/2))
pred[i] <- pred[i] * (priorParameters$kappa0/post_params$kappa_n)^(d/2)
pred[i] <- pred[i] * (det(priorParameters$Lambda)^(priorParameters$nu/2))/(det(post_params$t_n)^(post_params$nu_n/2))
if (pred[i] > 0) {
gamma_contrib <- prod(sapply(seq_along(d),
function(j) gamma(priorParameters$nu/2 + nrow(x[i,,drop=FALSE])/2 + (1 - j)/2)))/prod(sapply(seq_along(d),
function(j) gamma(priorParameters$nu/2 + (1 - j)/2)))
pred[i] <- pred[i] * gamma_contrib
}
}
return(pred)
} |
options(prompt = " ", continue = " ", digits = 4, show.signif.stars = FALSE) |
TSGS <- function(x, filter=c("UBF-DDC","UBF","DDC","UF"),
partial.impute=FALSE, tol=1e-4, maxiter=150,
method=c("bisquare","rocke"),
init=c("emve","qc","huber","imputed","emve_c"), mu0, S0){
xcall <- match.call()
filter <- match.arg(filter)
method <- match.arg(method)
init <- match.arg(init)
if(is.data.frame(x) | is.matrix(x))
x <- data.matrix(x)
else stop("Data matrix must be of class matrix or data.frame.")
if(any(is.na(x))) warning("Data matrix contains missing values.")
n <- nrow(x)
p <- ncol(x)
if( p >200 | p < 2 ) stop("Column dimension of 'x' must be in between 2 and 200.")
if(filter == "UF"){
xf <- gy.filt(x, alpha = c(0.95, 0))
}
else if(filter == "UBF"){
xf <- gy.filt(x)
}
else if(filter == "DDC"){
tmp <- capture.output({res.DDC <- cellWise::DDC(x)})
xf <- x
xf[res.DDC$indcells] <- NA
}
else if(filter == "UBF-DDC"){
xf.ubf <- gy.filt(x)
v.ubf <- 1*is.na(xf.ubf)
tmp <- capture.output({res.DDC <- cellWise::DDC(x)})
xf.ddc <- x
xf.ddc[res.DDC$indcells] <- NA
v.ddc <- 1*is.na(xf.ddc)
xf <- x
xf[v.ubf == 1 & v.ddc == 1] <- NA
}
xf_pi <- xf
if( partial.impute ){
ximp <- .impute.coord.med(xf_pi)
aid <- which(rowSums(!is.na(xf_pi)) == p)
uid <- which(rowSums(!is.na(xf_pi)) < p)
n0 <- n/2 + (p+1)
if( n0 > length(aid) ){
fid <- sample( uid, n0 - length(aid))
xf_pi[fid,] <- ximp[fid,]
}
}
res <- GSE(xf_pi, tol=tol, maxiter=maxiter, method=method, init=init, mu0, S0)
res <- new("TSGS",
call = xcall,
S = res@S,
mu = res@mu,
xf = xf,
sc = res@sc,
mu0 = res@mu0,
S0 = res@S0,
iter = res@iter,
eps = res@eps,
estimator = "2SGS",
x = x,
ximp = res@ximp,
weights = res@weights,
weightsp = res@weightsp,
pmd = res@pmd,
pmd.adj = [email protected],
p = res@p,
pu = res@pu)
res
} |
context("moon")
test_that( "1900/01/01 is new moon", {
expect_equal(
attr( moon( day = 0 ), "data")$name,
"new moon"
)
expect_equal(
attr( moon( day = 0 ), "day") ,
attr( moon( date = lubridate::ymd("1900/01/01") ), "day" )
)
}) |
FCEPlot.Aggr.FCEs_obj <- reactive({
input$FCEPlot.Aggr.Refresh
dsList <- isolate(FCEPlot.Aggr.data())
if (is.null(dsList)) return(NULL)
aggr_on <- ifelse(input$FCEPlot.Aggr.Aggregator == 'Functions', 'funcId', 'DIM')
targets <- isolate(FCEPlot.Aggr.Targets_obj)
dt <- generate_data.Aggr(dsList, aggr_on = aggr_on, targets = targets,
which = 'by_FV')
dt
})
render_FCEPlot_aggr_plot <- reactive({
withProgress({
y_attr <- if (input$FCEPlot.Aggr.Ranking) 'rank' else 'value'
y_title <- if (input$FCEPlot.Aggr.Ranking) 'Rank' else 'Best-so-far f(x)'
reverse_scale <- input$FCEPlot.Aggr.Mode == 'radar'
dt <- FCEPlot.Aggr.FCEs_obj()
plot_general_data(dt, type = input$FCEPlot.Aggr.Mode, x_attr = 'funcId',
y_attr = y_attr, x_title = "FuncId", y_title = y_title, show.legend = T,
scale.ylog = input$FCEPlot.Aggr.Logy, scale.reverse = reverse_scale)
},
message = "Creating plot")
})
FCEPlot.Aggr.data <- function() {
data <- subset(DATA_RAW(), ID %in% isolate(input$FCEPlot.Aggr.Algs))
if (length(data) == 0) return(NULL)
if (input$FCEPlot.Aggr.Aggregator == 'Functions') {
data <- subset(data, DIM == input$Overall.Dim)
if (length(unique(get_funcId(data))) == 1) {
shinyjs::alert("This plot is only available when the dataset contains multiple functions for the selected dimension.")
return(NULL)
}
}
else{
data <- subset(data, funcId == input$Overall.Funcid)
if (length(unique(get_dim(data))) == 1) {
shinyjs::alert("This plot is only available when the dataset contains multiple dimensions for the selected function")
return(NULL)
}
}
if (length(unique(get_id(data))) == 1) {
shinyjs::alert("This plot is only available when the dataset contains multiple IDs for the selected dimension.")
return(NULL)
}
data
}
FCE_multi_function <- function() {
dt <- FCEPlot.Aggr.FCEs_obj()
if (input$FCEPlot.Aggr.Aggregator == 'Functions')
dt <- dcast(dt, funcId~ID, value.var = 'value')
else
dt <- dcast(dt, DIM~ID, value.var = 'value')
dt
}
default_runtimes_table <- reactive({
data <- FCEPlot.Aggr.data()
if (is.null(data)) return(NULL)
targets <- get_target_dt(data)
if (input$FCEPlot.Aggr.Aggregator == 'Functions')
targets <- targets[, c('funcId', 'target')]
else
targets <- targets[, c('DIM', 'target')]
})
FCEPlot.Aggr.Targets_obj <- NULL
proxy_FCEPlot.Aggr.Targets <- dataTableProxy('FCEPlot.Aggr.Targets')
output$FCEPlot.Aggr.Targets <- DT::renderDataTable({
req(length(DATA_RAW()) > 0)
FCEPlot.Aggr.Targets_obj <<- default_runtimes_table()
FCEPlot.Aggr.Targets_obj
}, editable = TRUE, rownames = FALSE,
options = list(pageLength = 5, lengthMenu = c(5, 10, 25, -1), scrollX = T, server = T))
observeEvent(input$FCEPlot.Aggr.Targets_cell_edit, {
info <- input$FCEPlot.Aggr.Targets_cell_edit
i <- info$row
req(i > 0)
j <- info$col + 1
v <- info$value
FCEPlot.Aggr.Targets_obj[i, j] <<-
DT::coerceValue(v, FCEPlot.Aggr.Targets_obj[['target']][[i]])
replaceData(proxy, FCEPlot.Aggr.Targets_obj, resetPaging = FALSE, rownames = FALSE)
})
output$FCEPlot.Aggr.FCETable <- DT::renderDataTable({
input$FCEPlot.Aggr.Refresh
req(length(DATA_RAW()) > 0)
withProgress({
dt <- FCE_multi_function()
},
message = "Creating table")
dt
}, editable = FALSE, rownames = TRUE,
options = list(pageLength = 5, lengthMenu = c(5, 10, 25, -1), scrollX = T, server = T))
output$FCEPlot.Aggr.Plot <- renderPlotly(
render_FCEPlot_aggr_plot()
)
output$FCEPlot.Aggr.DownloadTable <- downloadHandler(
filename = function() {
eval(FCE_multi_func_name)
},
content = function(file) {
df <- FCE_multi_function()
save_table(df, file)
}
)
output$FCEPlot.Aggr.Download <- downloadHandler(
filename = function() {
eval(FIG_NAME_FV_AGGR)
},
content = function(file) {
save_plotly(render_FCEPlot_aggr_plot(), file)
},
contentType = paste0('image/', input$FCEPlot.Aggr.Format)
) |
rmvnorm90ci_exact <- function(n, lower, upper, correlationMatrix){
correlationMatrix<-as.matrix(correlationMatrix)
lower<-data.matrix(lower)
upper<-data.matrix(upper)
colnames(lower)<-NULL
colnames(upper)<-NULL
c_0.95=qnorm(0.95)
if ( !is.numeric(lower) || !is.numeric(upper) )
stop("lower and upper value of the 90%-confidence interval must be given.")
if( !identical(length(lower), length(upper)) )
stop("lower and upper vectors must be of the same length.")
if( !identical( correlationMatrix, t(correlationMatrix) ) )
stop("correlationMatrix must be a symmetric matrix.")
if( !identical( as.vector(diag(correlationMatrix)), rep(1, nrow(correlationMatrix)) ) )
stop("All diagonal elements of correlationMatrix must be equal to 1.")
if( !identical(length(lower), nrow(correlationMatrix)) )
stop("confidence interval vectors and correlationMatrix must the same number of rows.")
mean<-rowMeans(cbind(lower,upper))
sd<-((mean - lower)/c_0.95)[,1]
sigma<-(t(sd*correlationMatrix))*sd
x<-mvtnorm::rmvnorm(n=n,
mean=mean,
sigma=sigma)
x
} |
estdweibull <-
function(x, method="ML", zero=FALSE, eps=0.0001, nmax=1000)
{
par<-numeric(2)
n<-length(x)
m1<-mean(x)
m2<-mean(x^2)
beta0<-1
q0<-ifelse(zero,m1/(m1+1),(m1-1)/m1)
if(method=="M")
{
if(sum(x<=as.numeric(!zero)+1)==n)
{
message("Method of moments not applicable on this sample!")
par<-c(NA,NA)
}
else
{
par<-solnp(pars<-c(q0,beta0),fun=lossdw,x=x,zero=zero,eps=eps,nmax=nmax,LB=c(0,0),UB=c(1,100))$pars
}
}
else if (method=="ML")
{
if(sum(x<=as.numeric(!zero)+1)==n)
{
message("Method of maximum likelihood not applicable on this sample!")
par<-c(NA,NA)
}
else
{
par<-nlm(f=loglikedw,x=x,zero=zero,p=c(q0,beta0))$estimate
}
}
else if (method=="P")
{
y<-sum(x==as.numeric(!zero))
if(y==0)
{
message("Method of proportion not applicable for estimating q!")
par<-c(NA,NA)
}
else
{
par[1]<-1-y/n
z<-sum(x==(as.numeric(!zero)+1))
if(z+y==round(n) | z/n==0)
{
message("Method of proportion not applicable for estimating beta!")
par[2]<-NA
}
else
par[2]<-log(log(par[1]-z/n)/log(par[1]))/log(2)
}
}
par
} |
estimDev <- function(psi,y ){
alpha1 <- mean(y)-mean(psi)
y <- y - alpha1
psi <- sort(psi,decreasing = TRUE )
y <- sort(y,decreasing = TRUE )
g <-matrix(0,1, length(psi))
n_p <- length(psi)
length(psi)
g_0 <- g
i_t = 0
i_max = n_p
t=1
for(t in 2:i_max){
res <- NULL
for(j in 1:n_p ){
res <- c( res, c_fun(j, i_t, y ,psi) )
}
abs1 <- which.min2(res[(i_t+1):n_p], na.rm=TRUE) +i_t
if(abs(abs1)!=Inf){
for(j in (i_t+1):abs1 ){
g[1,j] <- psi[j] + c_fun(abs1, i_t, y ,psi)
}
i_t <- abs1
}else{break;
}
if( i_t==n_p){
break;
}
if(t%%1000==0){
delta <- sum(sum(abs(g-g_0)))
g_0 <- g
}
}
t<- seq(-5,5, length.out=300)
g <- as.vector(g)
start <- sort(g)
for (i in 1:length(g)){
start[i] <-max(start[1:i])
}
start[is.na(start)]<-max(start, rm.na=T)
g <- sort(start,decreasing = T)
mean(g) - mean(psi)
g_star <- approxfun(psi, g,method = "linear")
return(g_star)
} |
xgx_minor_breaks_log10 <- function(data_range) {
r1 <- range(log10(data_range))
r <- r1
r[1] <- floor(r[1])
r[2] <- ceiling(r[2]) + 1
minor_breaks <- c()
for (i in seq(r[1], r[2])) {
minor_breaks <- c(minor_breaks, seq(2 * 10^(i - 1), 10^i - 10^(i - 1),
by = 10^(i - 1)))
}
minor_breaks <- minor_breaks[minor_breaks <= 10^r1[2]]
minor_breaks <- minor_breaks[minor_breaks >= 10^r1[1]]
return(minor_breaks)
} |
"grisons" |
dmudetagen <-
function(mu,B,Link,Dist){
if (Link=="Inverse") dmudeta<-mu^2
if (Link=="Log") dmudeta<-mu
if (Link=="Identity") dmudeta<-rep(1,length(mu))
if (Link=="Logit") dmudeta<-(B-mu)*(mu/B)
dmudeta
} |
nbcomp.bootplsR<-function(Y,X,R=500,sim="ordinary",ncpus=1,parallel="no",typeBCa=TRUE, verbose=TRUE){
indboot2=1
ncolBoot <- 5+2*typeBCa
if(verbose){print(indboot2)}
ressimYT<-plsRglm::PLS_lm(Y, X, nt = indboot2, modele = "pls", scaleX=TRUE, verbose=verbose)
compTsim=ressimYT$tt
databoot=cbind(ressimYT$RepY,compTsim)
if(sim!="permutation"){
sim.bootSim2<-boot::boot(data=databoot, parallel=parallel, ncpus=ncpus, statistic=coefs.plsR.CSim, sim=sim, stype="i", R=R)
confYT=t(as.matrix(plsRglm::confints.bootpls(sim.bootSim2,typeBCa = typeBCa)))
while (confYT[1,ncolBoot]>0){
indboot2=indboot2+1
if(verbose){print(indboot2)}
ressimYT<-plsRglm::PLS_lm(Y, X, nt = indboot2, modele = "pls", scaleX=TRUE, verbose=verbose)
if (ncol(ressimYT$tt)==ressimYT$nt){
compTsim=ressimYT$tt
databoot=cbind(ressimYT$RepY,compTsim)
sim.bootSim2<-boot::boot(data=databoot, parallel=parallel, ncpus=ncpus, statistic=coefs.plsR.CSim, sim=sim, stype="i", R=R)
confYT=t(as.matrix(plsRglm::confints.bootpls(sim.bootSim2,typeBCa = typeBCa)))
}
else{confYT=matrix(0,indboot2,ncolBoot+1)}
}
} else {
sim.bootSim2<-boot::boot(data=databoot, parallel=parallel, ncpus=ncpus, statistic=permcoefs.plsR.CSim, sim="permutation", stype="i", R=R)
confYT=t(as.matrix(plsRglm::confints.bootpls(sim.bootSim2,typeBCa = typeBCa)))
while (confYT[1,ncolBoot]>0){
indboot2=indboot2+1
if(verbose){print(indboot2)}
ressimYT<-plsRglm::PLS_lm(Y, X, nt = indboot2, modele = "pls", scaleX=TRUE, verbose=verbose)
if (ncol(ressimYT$tt)==ressimYT$nt){
compTsim=ressimYT$tt
databoot=cbind(ressimYT$RepY,compTsim)
sim.bootSim2<-boot::boot(data=databoot, parallel=parallel, ncpus=ncpus, statistic=permcoefs.plsR.CSim, sim="permutation", stype="i", R=R)
confYT=t(as.matrix(plsRglm::confints.bootpls(sim.bootSim2,typeBCa = typeBCa)))
}
else{confYT=matrix(0,indboot2,ncolBoot+1)}
}
}
if(verbose){print(paste("Optimal number of components: K = ", indboot2-1, sep = ""))}
return(indboot2-1)
} |
preWaveform <- function(freq, duration, from, xunit, samp.rate){
if (!is.numeric(duration) || duration <= 0 || length(duration) != 1)
stop("'duration' must be a positive numeric of length 1")
if (!is.numeric(from) || from < 0 || length(from) != 1)
stop("'from' must be a positive numeric of length 1")
if (!is.numeric(samp.rate) || samp.rate < 0 || length(samp.rate) != 1)
stop("'samp.rate' must be a positive numeric of length 1")
if(!is.numeric(freq) || freq <= 0 || length(freq) != 1)
stop("'freq' must be a positive numeric of length 1")
if(xunit == "time"){
duration <- duration * samp.rate
from <- from * samp.rate
}
return(c(duration = round(duration), from = round(from)))
}
postWaveform <- function(channel, samp.rate, bit, stereo, pcm = FALSE, ...){
if(!is.numeric(bit) || length(bit)!=1 || (!bit %in% c(0,1,8,16,24,32,64)))
stop("'bit' must be an integer of length 1 in {0,1,8,16,24,32,64}")
if(bit == 8)
channel <- channel + 127
if(stereo && !is.matrix(channel))
channel <- matrix(channel, ncol = 2, nrow = length(channel))
Wobj <- Wave(channel, samp.rate = samp.rate,
bit = if(bit %in% 0:1) 32 else bit, pcm = pcm, ...)
normalize(Wobj, unit = as.character(bit), center = FALSE)
}
silence <- function(duration = samp.rate, from = 0, samp.rate = 44100, bit = 1,
stereo = FALSE, xunit = c("samples", "time"), ...){
xunit <- match.arg(xunit)
durFrom <- preWaveform(freq = 1, duration = duration, from = from,
xunit = xunit, samp.rate = samp.rate)
channel <- rep(0, durFrom["duration"])
postWaveform(channel = channel, samp.rate = samp.rate,
bit = bit, stereo = stereo, ...)
}
sine <- function(freq, duration = samp.rate, from = 0, samp.rate = 44100, bit = 1,
stereo = FALSE, xunit = c("samples", "time"), ...){
xunit <- match.arg(xunit)
durFrom <- preWaveform(freq = freq, duration = duration, from = from,
xunit = xunit, samp.rate = samp.rate)
channel <- sin(2 * pi * freq * (durFrom["from"]:(sum(durFrom)-1)) / samp.rate)
postWaveform(channel = channel, samp.rate = samp.rate,
bit = bit, stereo = stereo, ...)
}
sawtooth <- function(freq, duration = samp.rate, from = 0, samp.rate = 44100, bit = 1,
stereo = FALSE, xunit = c("samples", "time"), reverse = FALSE, ...){
xunit <- match.arg(xunit)
durFrom <- preWaveform(freq = freq, duration = duration, from = from,
xunit = xunit, samp.rate = samp.rate)
channel <- seq(durFrom["from"], 2*freq*sum(durFrom),
length = durFrom["duration"]) %% 2 - 1
if(!is.logical(reverse) || length(reverse) != 1)
stop("'reverse' must be a logical value of length 1")
if(reverse) channel <- rev(channel)
postWaveform(channel = channel, samp.rate = samp.rate,
bit = bit, stereo = stereo, ...)
}
square <- function(freq, duration = samp.rate, from = 0, samp.rate = 44100, bit = 1,
stereo = FALSE, xunit = c("samples", "time"), up = 0.5, ...){
xunit <- match.arg(xunit)
durFrom <- preWaveform(freq = freq, duration = duration, from = from,
xunit = xunit, samp.rate = samp.rate)
if(!is.numeric(up) || length(up) != 1 || max(abs(up)) > .5)
stop("'up' must be a numeric in [-0.5, 0.5] of length 1")
channel <- sign(seq(durFrom["from"], freq*sum(durFrom),
length = durFrom["duration"])
%% 1 - 1 + up)
postWaveform(channel = channel, samp.rate = samp.rate,
bit = bit, stereo = stereo, ...)
}
noise <- function(kind = c("white", "pink", "power", "red"), duration = samp.rate,
samp.rate = 44100, bit = 1, stereo = FALSE,
xunit = c("samples", "time"), alpha = 1, ...){
xunit <- match.arg(xunit)
kind <- match.arg(kind)
if(kind != "power" && !missing(alpha))
warning("alpha ignored if noise kind is not 'power'")
durFrom <- preWaveform(freq = 1, duration = duration, from = 0,
xunit = xunit, samp.rate = samp.rate)
N <- durFrom["duration"] * (stereo + 1)
channel <-
switch(kind,
white = rnorm(N),
pink = TK95(N, alpha = 1),
power = TK95(N, alpha = alpha),
red = TK95(N, alpha = 1.5)
)
channel <- matrix(channel, ncol = (stereo + 1))
postWaveform(channel = channel, samp.rate = samp.rate,
bit = bit, stereo = stereo, ...)
}
TK95 <- function(N, alpha = 1){
f <- seq(from=0, to=pi, length.out=(N/2+1))[-c(1,(N/2+1))]
f_ <- 1 / f^alpha
RW <- sqrt(0.5*f_) * rnorm(N/2-1)
IW <- sqrt(0.5*f_) * rnorm(N/2-1)
fR <- complex(real = c(rnorm(1), RW, rnorm(1), RW[(N/2-1):1]),
imaginary = c(0, IW, 0, -IW[(N/2-1):1]), length.out=N)
reihe <- fft(fR, inverse=TRUE)
return(Re(reihe))
}
pulse <- function(freq, duration = samp.rate, from = 0, samp.rate = 44100, bit = 1,
stereo = FALSE, xunit = c("samples", "time"), width = 0.1,
plateau = 0.2, interval = 0.5, ...){
xunit <- match.arg(xunit)
if((width < 0) || (width > 1)) stop("Parameter 'width' must be between 0 and 1.")
if((interval < 0) || (interval > 1)) stop("Parameter 'interval' must be between 0 and 1.")
if((plateau < 0) || (plateau > 1)) stop("Parameter 'interval' must be between 0 and 1.")
durFrom <- preWaveform(freq = freq, duration = duration, from = from,
xunit = xunit, samp.rate = samp.rate)
x <- freq * (durFrom["from"]:(sum(durFrom)-1)) / samp.rate
channel <- .C(C_pulsewav, as.integer(length(x)),
as.double(width), as.double(interval), as.double(plateau),
as.double(x), y = double(length(x)))$y
postWaveform(channel = channel, samp.rate = samp.rate,
bit = bit, stereo = stereo, ...)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.