Closed josherrickson closed 7 years ago
The mean
does not propagate the error as a simple sum, but it takes the standard error of the mean.
The standard error of the mean (SEM) is the standard deviation of the sample-mean's estimate of a population mean. (It can also be viewed as the standard deviation of the error in the sample mean with respect to the true mean, since the sample mean is an unbiased estimator.) SEM is usually estimated by the sample estimate of the population standard deviation (sample standard deviation) divided by the square root of the sample size (assuming statistical independence of the values in the sample).
In this case,
sd(x)/sqrt(length(x))
#> [1] 0.5773503
So the propagation is ok.
Is that what the goal of the function should be though? In a package dedicated to error propagation, I'd anticipate any arithmetic function to propagate errors using the basic rules. Returning the SEM in another function (e.g. sem(x)
) is fine, but the fact that errors(mean(x)) != errors(sum(x)/length(x))
seems likely to lead to confusion.
Thanks for the report, but I don't see any reason for an additional function.
sum(x)/length(x)
.?mean.errors
is pretty clear, so there is no possible confusion:Details
The mean and weighted.mean methods set the error as the maximum of the standard error of the mean and the (weighted) mean of the errors.
Using the 0.0.2 package from CRAN: