The standard error of the mean can be calculated with standard functions in the native stats package. The describe function in the psych package includes the standard error of the mean along with other descriptive statistics. This function is useful to summarize multiple variables in a data frame.
Introduction
Similar statistics
See the Handbook for information on these topics.
Example
Standard error example
### --------------------------------------------------------------
### Standard error example, p. 115
### --------------------------------------------------------------
Input =("
Stream Fish
Mill_Creek_1 76
Mill_Creek_2 102
North_Branch_Rock_Creek_1 12
North_Branch_Rock_Creek_2 39
Rock_Creek_1 55
Rock_Creek_2 93
Rock_Creek_3 98
Rock_Creek_4 53
Turkey_Branch 102
")
Data = read.table(textConnection(Input),header=TRUE)
### Calculate standard error manually
sd(Data$ Fish, na.rm=TRUE) /
sqrt(length(Data$Fish[!is.na(Data$ Fish)])) #
Standard error
[1] 10.69527
### Use describe function from psych
package for standard error
### Also works on whole data frames
library(psych)
describe(Data$ Fish,
type=2) # Type of skew and
kurtosis
vars n mean sd median trimmed mad min max range skew kurtosis se
1 1 9 70 32.09 76 70 34.1 12 102 90 -0.65 -0.69 10.7
# # #
How to calculate the standard error
Methods are described in the “Example” section above.