extract_rmse: Extracts root mean square error (RMSE)

View source: R/utility_functions.R

extract_rmseR Documentation

Extracts root mean square error (RMSE)

Description

Given two vectors of loadings, computes the root mean square between them.

Usage

extract_rmse(vector1, vector2)

Arguments

vector1

First numerical vector of loadings for the calculation.

vector2

Second numerical vector of loadings for the calculation.

Details

RMSE has been also used as a metric for factor matching (see ref). It is calculated as:

RMSE_{x,y} = sqrt( sum((x_{i}-y_{i})^2) / n)

Where n is the number of variables in both components x and y. A RMSE of 0 corresponds to a perfect match. The smaller the RMSE is, the more equivalent two components are.

Value

Returns the root mean square (RMS) between vector1 and vector2.

Author(s)

Abel Torres Espin

References

Guadagnoli E, Velicer W. A Comparison of Pattern Matching Indices. Multivar Behav Res. 1991 Apr;26(2):323–43

Examples

data(mtcars)
pca_mtcars_1<-prcomp(mtcars, center = TRUE, scale = TRUE)

#Second pca with a subsetted mtcars as an example of comparing loading patterns
#from two proximal datasets
pca_mtcars_2<-prcomp(mtcars[1:20,], center = TRUE, scale = TRUE)

s.loadings_1<-stand_loadings(pca = pca_mtcars_1, pca_data = mtcars)
s.loadings_2<-stand_loadings(pca = pca_mtcars_2, pca_data = mtcars[1:20,])

extract_rmse(s.loadings_1[,1], s.loadings_2[,1])


ucsf-ferguson-lab/syndRomics documentation built on June 26, 2022, 5:36 p.m.