By using standard error formula
Here we will use the standard error formula for getting the observations.
Syntax: sqrt(sum((a-mean(a))^2/(length(a)-1)))/sqrt(length(a))
where
- data is the input data
- sqrt function is to find the square root
- sum is used to find the sum of elements in the data
- mean is the function used to find the mean of the data
- length is the function used to return the length of the data
Example: R program to calculate the standard error using formula
R
# consider a vector with 10 elements a <- c (179, 160, 136, 227, 123, 23, 45, 67, 1, 234) # calculate standard error print ( sqrt ( sum ((a - mean (a)) ^ 2/( length (a) - 1))) / sqrt ( length (a))) |
Output:
[1] 26.20274
Calculate Standard Error in R
In this article, we are going to see how to calculate standard error in R Programming Language.
Mathematically we can calculate standard error by using the formula:
standard deviation/squareroot(n)
In R Language, we can calculate in these ways:
- Using sd() function with length function
- By using the standard error formula.
- Using plotrix package.