Commit c4c6c590 by Eric Coissac

Corrections to comply with devtools::check_rhub

parent 74443221
......@@ -4,7 +4,7 @@ Title: Informative Procrustean Matrix Correlation
Version: 1.0.0
Author: Eric Coissac, Christelle Gonindard-Melodelima
Maintainer: Eric Coissac <eric.coissac@metabarcoding.org>
Description: Estimates procruste corrected correlation between matrices for removing overfitting effect.
Description: Estimates corrected Procrustean correlation between matrices for removing overfitting effect.
License: CeCILL-2
Encoding: UTF-8
LazyData: true
......
......@@ -34,8 +34,8 @@ export(pca)
export(pcoa)
export(procmod_frame)
export(protate)
export(rmatrix)
export(simulate_correlation)
export(simulate_matrix)
export(varls)
import(MASS)
import(doParallel)
......
......@@ -21,8 +21,8 @@ NULL
#'
#' @examples
#' # Renerate a random matrix of size 10 x 15
#' m1 <- rmatrix(10, 15)
#' m2 <- rmatrix(10, 20)
#' m1 <- simulate_matrix(10, 15)
#' m2 <- simulate_matrix(10, 20)
#' mr <- protate(m1, m2)
#'
#' @author Christelle Gonindard-Melodelima
......
......@@ -17,14 +17,14 @@
#' @return a numeric matrix of \code{n} rows and \code{p} columns
#'
#' @examples
#' sim1 <- rmatrix(25,10)
#' sim1 <- simulate_matrix(25,10)
#' class(sim1)
#' dim(sim1)
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
rmatrix <- function(n, p, equal_var = TRUE) {
simulate_matrix <- function(n, p, equal_var = TRUE) {
new <- rnorm(n * p, mean = 0, sd = 1)
dim(new) <- c(n, p)
......@@ -33,12 +33,10 @@ rmatrix <- function(n, p, equal_var = TRUE) {
attributes(new)$`scaled:center` <- NULL
attributes(new)$`scaled:scale` <- NULL
new.sd <- sqrt(sum(new^2) / (n - 1))
new <- new / new.sd
return(new)
new / new.sd
}
#' Simulate n points of dimension p correlated with a reference matrix.
#' Simulate n points of dimension p correlated to a reference matrix.
#'
#' Simulates a set of point correlated to another set according to the
#' procrustean correlation definition.
......@@ -63,10 +61,10 @@ rmatrix <- function(n, p, equal_var = TRUE) {
#' @return a numeric matrix of \code{nrow(reference)} rows and \code{p} columns
#'
#' @examples
#' sim1 <- rmatrix(25,10)
#' sim1 <- simulate_matrix(15,5)
#' class(sim1)
#' dim(sim1)
#' sim2 <- simulate_correlation(sim1,20,0.8)
#' sim2 <- simulate_correlation(sim1,10,0.8)
#' corls(sim1, sim2)^2
#'
#' @author Eric Coissac
......@@ -77,7 +75,7 @@ simulate_correlation <- function(reference, p, r2, equal_var = TRUE) {
n <- nrow(reference)
maxdim <- max(ncol(reference), p)
noise <- rmatrix(n, p, equal_var = equal_var)
noise <- simulate_matrix(n, p, equal_var = equal_var)
if (maxdim == p && maxdim > ncol(reference)) {
# noise is the largest matrix
......@@ -103,9 +101,7 @@ simulate_correlation <- function(reference, p, r2, equal_var = TRUE) {
new <- scale(new, scale = FALSE)
attributes(new)$`scaled:center` <- NULL
new.sd <- sqrt(sum(new^2) / (n - 1))
new <- new / new.sd
return(new)
new / new.sd
}
#rmatrix_tree
#simulate_matrix_tree
......@@ -21,8 +21,8 @@ No scaling and no centrering are done, before computing the SVD.
}
\examples{
# Renerate a random matrix of size 10 x 15
m1 <- rmatrix(10, 15)
m2 <- rmatrix(10, 20)
m1 <- simulate_matrix(10, 15)
m2 <- simulate_matrix(10, 20)
mr <- protate(m1, m2)
}
......
......@@ -2,7 +2,7 @@
% Please edit documentation in R/simulate.R
\name{simulate_correlation}
\alias{simulate_correlation}
\title{Simulate n points of dimension p correlated with a reference matrix.}
\title{Simulate n points of dimension p correlated to a reference matrix.}
\usage{
simulate_correlation(reference, p, r2, equal_var = TRUE)
}
......@@ -35,10 +35,10 @@ The intensity of the correlation is determined by the \code{r2}
parameter.
}
\examples{
sim1 <- rmatrix(25,10)
sim1 <- simulate_matrix(15,5)
class(sim1)
dim(sim1)
sim2 <- simulate_correlation(sim1,20,0.8)
sim2 <- simulate_correlation(sim1,10,0.8)
corls(sim1, sim2)^2
}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
\name{rmatrix}
\alias{rmatrix}
\name{simulate_matrix}
\alias{simulate_matrix}
\title{Simulate n points of dimension p.}
\usage{
rmatrix(n, p, equal_var = TRUE)
simulate_matrix(n, p, equal_var = TRUE)
}
\arguments{
\item{n}{an \code{int} value indicating the number of observations.}
......@@ -28,7 +28,7 @@ Therefore they are expected to be equal to 0 and reflect only the
random distribution of the covariance between two random vectors.
}
\examples{
sim1 <- rmatrix(25,10)
sim1 <- simulate_matrix(25,10)
class(sim1)
dim(sim1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment