How to use the method of moments to find the mean and variance on R?

582 Views Asked by At

I have a set of 50 independent observations and need to model these observations as a normal distribution. I'm assuming I need to use the method of moments but not entirely sure how to find the mean and variance?

1

There are 1 best solutions below

1
On BEST ANSWER

Here is a quick demonstration using simulated data. Maybe it will help you get oriented for working your exercise.

First, I use R statistical software to simulate 50 observations from the distribution $\mathsf{Norm}(\mu = 100,\, \sigma = 15).$ I find the sample mean $\bar X = 98.33$ and sample standard deviation $S = 15.54$; note that $\bar X$ and $S^2$ are the method-of-moments estimates of $\mu$ and $\sigma^2.$ (Look in your text or notes for details of finding $\bar X$ and $S.$)

set.seed(417)
x = rnorm(50, 100, 15)
a = mean(x);  s = sd(x)
a; s
## 98.3272
## 15.53877

Here is a list of the sample (rounded for compactness), the numbers in brackets show the index of the first observation in each row. There are ten observations per row.

round(x)
 [1] 126  87  80 103  73 121  83  68 124  74
[11]  85 101 105  89 101  71  93  96 102  97
[21] 111  67  93 110  84  98 110  86 113  86
[31] 123  99 105  93 106  93 111  96  86 110
[41]  78 113 114 109 111 104 123 121  99  84

Here is a histogram of the fifty observations. The tick marks along the horizontal axis show the positions of the individual observations.

enter image description here

The red curve is the density function of the 'best-fitting' normal distribution. It is obtained by using mean $\hat \mu = \bar X$ and $\hat \sigma = S$ (where 'hats' on parameters indicate they have been estimated).

This is not a bad fit for only $n = 50$ observations. $\hat \mu = \bar X$ is not far from $\mu = 100$ and $\hat \sigma = S$ is not far from $\sigma=15.$ But if you used a larger sample, you would get better results. Here is the same kind of figure as above, but for a sample of size $n = 500.$

enter image description here