Commit c4c6c590 by Eric Coissac

Corrections to comply with devtools::check_rhub

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