Skip to content

Commit

Permalink
various CRAN check fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brandmaier committed Sep 11, 2021
1 parent 8bb3f0a commit 97cb334
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
^vignettes/Complex_shapes\.Rmd$
^vignettes/Runtime_comparison\.Rmd$
^\.travis\.yml$
^Makefile$
^CONTRIBUTORS\.md$
^README.Rmd$
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ Type: Package
Title: Permutation Distribution Clustering
Version: 1.0.4
Date: 2020-02-02
Author: Andreas M. Brandmaier [aut, cre]
Authors@R: c(person("Andreas M. Brandmaier",
email="[email protected]",
role=c("aut","cre"),
comment = c(ORCID = "0000-0001-8765-6982")))
Maintainer: Andreas M. Brandmaier <[email protected].de>
Maintainer: Andreas M. Brandmaier <andy@brandmaier.de>
Description: Permutation Distribution Clustering is a clustering method for time series. Dissimilarity of time series is formalized as the divergence between their permutation distributions. The permutation distribution was proposed as measure of the complexity of a time series.
License: GPL-3
Imports: stats,
Expand All @@ -21,4 +20,5 @@ Suggests:
knitr,
rmarkdown
VignetteBuilder: knitr
URL: http://brandmaier.github.io/pdc, https://github.com/brandmaier/pdc
URL: https://brandmaier.github.io/pdc/, https://github.com/brandmaier/pdc
RoxygenNote: 7.1.1
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export("convert.image")
#
# load shared object
#
useDynLib(pdc)
useDynLib(pdc, .registration = TRUE)

#
# imports from default (but not base) packages
Expand All @@ -53,4 +53,5 @@ importFrom("graphics", "abline", "contour", "image", "lines", "par",
"strwidth", "text")
importFrom("stats", "as.dendrogram", "as.dist", "cmdscale", "hclust",
"pchisq")
importFrom("stats", "qnorm")
importFrom("utils", "str")
4 changes: 2 additions & 2 deletions R/codebook.entropy.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
codebook.entropy <-
function(data, m, t)
function(data, m, t, normalize_by_observed=FALSE)
{

ent <- entropy(codebook(data,m, t))
ent <- entropy(codebook(data, m, t),normalize_by_observed=normalize_by_observed)

return( ent);
}
3 changes: 2 additions & 1 deletion R/entropy.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
entropy <-
function(dist)
function(dist, normalize_by_observed=FALSE)
{
n <- length(dist)
dist <- dist[dist!=0]
if (normalize_by_observed) n <- length(dist)
if (length(dist)==1) return (0);
return(-sum(dist*log(dist))/log(n));

Expand Down
4 changes: 2 additions & 2 deletions R/entropyHeuristic.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(X, m.min=3, m.max=7, t.min=1, t.max=1)
}

entropyHeuristic <-
function(X, m.min=3, m.max=7, t.min=1, t.max=1)
function(X, m.min=3, m.max=7, t.min=1, t.max=1, normalize_by_observed=FALSE)
{
X <- as.matrix(X)

Expand All @@ -22,7 +22,7 @@ function(X, m.min=3, m.max=7, t.min=1, t.max=1)
{
ent[k,1] <- j
ent[k,2] <- i
ent[k,3] <- mean(apply(FUN=codebook.entropy, MARGIN=2, X, m=i,t=j))
ent[k,3] <- mean(apply(FUN=codebook.entropy, MARGIN=2, X, m=i,t=j, normalize_by_observed=normalize_by_observed))
k <- k+1
}
best <- which.min(ent[,3]);
Expand Down
14 changes: 6 additions & 8 deletions R/pdclust.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
pdclust <-
function(X, m=NULL, t=NULL, divergence=symmetricAlphaDivergence, clustering.method="complete")
{
user.m <- !is.null(m);
user.t <- !is.null(t);
user.m <- !is.null(m)
user.t <- !is.null(t)

if ((is.null(m)) && (is.null(t))) {
m <- entropyHeuristic(X)$m;
m <- entropyHeuristic(X)$m
}

if (is.null(m)) {
m <- entropyHeuristic(X, t.min=t, t.max=t)$m;
m <- entropyHeuristic(X, t.min=t, t.max=t)$m
}

if (is.null(t)) {
t <- 1;
t <- 1
}



# calculate divergence matrix
D <- pdcDist(X,m,t,divergence);
D <- pdcDist(X,m,t,divergence)

# start hierarchical clustering
if (clustering.method == "complete") {
Expand Down
5 changes: 3 additions & 2 deletions R/udcDist.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ udConvert <- function(x) { ifelse(sign(diff(x))==1,1,0) }
udCodeword <- function(x, m) {sum( 2^(1:(m-1)-1) * udConvert(x) )+1}

udComplexity <- function(x, compression.type="zip") {
return(length(memCompress(paste0(udConvert(x),collapse = "")),
type=compression.type)/length(x))
return(length(
memCompress(paste0(udConvert(x),collapse = ""),type=compression.type)
)/length(x))
}

udcDist <- function(X, compression.type="zip") {
Expand Down
1 change: 1 addition & 0 deletions demo/00Index
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
paired.tseries Demonstrate clustering of pairs of time series
4 changes: 2 additions & 2 deletions man/codebook.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Codebook
A codebook contains the permutation distribution of a time series.
}
\usage{
codebook(x, m = 3, t = 1, use.fast=TRUE, normalized = TRUE, codeword_func = codeword)
codebook(x, m = 3, t = 1, use.fast=TRUE, normalized = TRUE, codeword_func = NULL)
}
\arguments{
\item{x}{
Expand All @@ -22,7 +22,7 @@ The embedding dimension.

\item{normalized}{Normalize codebook such that it is a probability distribution.}

\item{codeword_func}{Function to compute codewords.}
\item{codeword_func}{Function to compute codewords. If NULL, the default internal function codebook is used.}
}
\details{
The length of a codebook is the factorial of the embedding dimension. The elements of the
Expand Down
4 changes: 3 additions & 1 deletion man/entropy.heuristic.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Heuristic (MinE) automatically chooses an embedding dimension with an optimal
representational entropy as proxy for representational power.
}
\usage{
entropyHeuristic(X, m.min=3, m.max=7, t.min = 1, t.max = 1)
entropyHeuristic(X, m.min=3, m.max=7, t.min = 1, t.max = 1, normalize_by_observed = FALSE)

\method{print}{mine}(x, \dots)
\method{summary}{mine}(object, \dots)
Expand All @@ -32,6 +32,8 @@ entropyHeuristic(X, m.min=3, m.max=7, t.min = 1, t.max = 1)
\item{m.max}{Maximum embedding dimension}
\item{t.min}{Minimum time-delay}
\item{t.max}{Maximum time-delay}
\item{normalize_by_observed}{Boolean. If false, entropy is normalized by dividing by the logarithm of the number of all possible patterns. If true,
it is divided by the logarithm of the number of observed patterns.}
\item{\dots}{Further arguments for the generic print, summary, and plot method.}

\item{normalize}{Normalize values to range [0;1].}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/Getting_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: "Andreas Brandmaier"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteIndexEntry{Getting started}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down

0 comments on commit 97cb334

Please sign in to comment.