R version 4.4.0 RC (2024-04-16 r86441 ucrt) -- "Puppy Cup" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > require(lokern) Loading required package: lokern > data(xSim) > (n <- length(xSim)) [1] 75 > summary(xSim) Min. 1st Qu. Median Mean 3rd Qu. Max. -3.1323 -1.6148 0.7583 0.3969 1.7713 4.4505 > tt <- ((1:n) - 1/2)/n # equidistant x > > lk <- lokerns(tt, xSim, trace=1) lokerns (n=75,m=300; nue=0, isrand=1, inputp=0) -> kord=2 phase 2 phase 3 phase 4 40: itt=0, (il=1, iu=75) - (tl=1, tu=0) phase 5 phase 6 phase 7 phase 8 phase 9 phase 10 100: (il=6, iu=70) -> vi=0.115996 phase 11 kernel(n= 75, m= 76, ny=0 => global bandw.; b=0.01000531) -> (chg.pt,cut_b)=( 7.0, 0.09) => 'classic' phase 12 phase 18 phase 19 phase 20 kernel(n= 75, m=300, ny=1 => local bandw.; b=0.04845241) -> (chg.pt,cut_b)=( 7.0, 0.09) => 'classic' phase 21 kernel(n= 75, m=399, ny=0 => global bandw.; b= 0.0611626) -> (chg.pt,cut_b)=( 9.0, 0.12) => 'classic' kernp(n=399, m=300, ny=1 => local bandw.; b= 0.086814) -> (chg.pt,cut_b)=( 8.1, 0.02) => 'fast O(n)' kernfp(n=399, b= 0.086814, nue=0, kord=2, ny=1, m=300): phase 22 phase 23 kernel(n= 75, m=300, ny=1 => local bandw.; b=0.04845241) -> (chg.pt,cut_b)=( 7.0, 0.09) => 'classic' > head(x. <- seq(-3.5, 4.5, length=1001)) [1] -3.500 -3.492 -3.484 -3.476 -3.468 -3.460 > lk. <- lokerns(tt, xSim, x.out= x., trace=1) lokerns (n=75,m=1001; nue=0, isrand=1, inputp=0) -> kord=2 phase 2 phase 3 phase 4 40: itt=0, (il=1, iu=75) - (tl=1, tu=0) phase 5 phase 6 phase 7 phase 8 phase 9 phase 10 100: (il=6, iu=70) -> vi=0.115996 phase 11 kernel(n= 75, m= 76, ny=0 => global bandw.; b=0.01000531) -> (chg.pt,cut_b)=( 7.0, 0.09) => 'classic' phase 12 phase 18 phase 19 phase 20 kernel(n= 75, m=1001, ny=1 => local bandw.; b=0.04845241) -> (chg.pt,cut_b)=( 7.0, 0.09) => 'classic' phase 21 kernel(n= 75, m=399, ny=0 => global bandw.; b= 0.0611626) -> (chg.pt,cut_b)=( 9.0, 0.12) => 'classic' kernp(n=399, m=1001, ny=1 => local bandw.; b= 0.086814) -> (chg.pt,cut_b)=( 7.0, 0.14) => 'classic' phase 22 phase 23 kernel(n= 75, m=1001, ny=1 => local bandw.; b=0.04845241) -> (chg.pt,cut_b)=( 7.0, 0.09) => 'classic' > lkw <- tryCatch(lokerns(tt, xSim, x.out= x., x.inOut="aim"), + warning = function(.) .) > stopifnot(inherits(lkw, "simpleWarning"), + grepl("x.inOut", lkw[["message"]])) > > lkn. <- lokerns(tt, xSim, n.out= 1000, x.inOut=FALSE) > lknT <- lokerns(tt, xSim, n.out= 1000, x.inOut=TRUE) > lkn1 <- lokerns(tt, xSim, n.out= 1000, x.inOut="aim") > lkn2 <- lokerns(tt, xSim, n.out= 1000, x.inOut="simple") > lkn3 <- lokerns(tt, xSim, n.out= 1000, x.inOut="interpolate") > > iO <- which("call" != names(lkn.)) > stopifnot(all.equal(lknT[iO], + lkn1[iO], tol=1e-12), + inherits(try(residuals(lkn.), silent=TRUE), "try-error"), + length(residuals(lkn1)) == length(tt), + length(fitted (lkn2)) == length(tt), + TRUE) > pdf("lok-xout-ex.pdf") > > plot(tt, xSim, main = "data + 4 different lokerns(.., x.inOut = *)") > lines(est~x.out, data=lk. [c("x.out", "est")]) > lines(est~x.out, data=lkn1[c("x.out", "est")], col=2) > lines(est~x.out, data=lkn2[c("x.out", "est")], col=3) > lines(est~x.out, data=lkn3[c("x.out", "est")], col=4) > mtext("(you should not see different curves -- rather perfectly overlap") > > gkn. <- glkerns(tt, xSim, n.out= 1000, x.inOut=FALSE) > gknT <- glkerns(tt, xSim, n.out= 1000, x.inOut=TRUE) > gkn1 <- glkerns(tt, xSim, n.out= 1000, x.inOut="aim") > gkn2 <- glkerns(tt, xSim, n.out= 1000, x.inOut="simple") > gkn3 <- glkerns(tt, xSim, n.out= 1000, x.inOut="interpolate") > > plot(tt, xSim, main = "data + 4 different glkerns(.., x.inOut = *)") > lines(est~x.out, data=gkn.[c("x.out", "est")]) > lines(est~x.out, data=gkn1[c("x.out", "est")], col=2) > lines(est~x.out, data=gkn2[c("x.out", "est")], col=3) > lines(est~x.out, data=gkn3[c("x.out", "est")], col=4) > mtext("(you should not see different curves -- rather perfectly overlap") > > stopifnot(all(sapply(ls(patt="kn"), function(.)get(.)$sig) - + 0.145106481 < 5e-10)) > > cat('Time elapsed: ', proc.time(),'\n') # "stats" Time elapsed: 0.23 0.07 0.29 NA NA > > proc.time() user system elapsed 0.23 0.07 0.29