Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Root mean square function in R

A very brief question. After much searching I couldn't find a function to calculate the RMS of a set of integers. Does such a function exist in R?

like image 293
Jojo Avatar asked Jul 30 '12 10:07

Jojo


People also ask

What package is RMSE in R?

The rmse() function available in Metrics package in R is used to calculate root mean square error between actual values and predicted values.

What is MSE in R output?

One of the most common metrics used to measure the prediction accuracy of a model is MSE, which stands for mean squared error. It is calculated as: MSE = (1/n) * Σ(actual – prediction)2.

How do you do RMSE?

To compute RMSE, calculate the residual (difference between prediction and truth) for each data point, compute the norm of residual for each data point, compute the mean of residuals and take the square root of that mean.


2 Answers

I didn't search for a function but you can write it

x <- 1:10
sqrt(sum(x^2)/length(x))
6.204837

A better alternative is using mean function

> sqrt(mean(x^2))
[1] 6.204837
like image 160
Jilber Urbina Avatar answered Sep 21 '22 22:09

Jilber Urbina


The function rms(x) from the package {seewave} must produce the same value.

like image 45
varzik Avatar answered Sep 21 '22 22:09

varzik