<- 43; sigma <- 5.97 # parameters
mu <- 300
n
<- rnorm(n, mu, sigma)
x
hist(x, probability = TRUE)
Fitting Models
Fitting Models
R andom sample from the normal distribution, estimate the parameters
simulated sample
Estimate the parameters with x.bar and sd
<- mean(x); mu.hat mu.hat
[1] 42.54465
<- sd(x); sigma.hat sigma.hat
[1] 6.137992
Plot the fitted model on the histogram
hist(x, probability = TRUE)
curve(dnorm(x, mu.hat, sigma.hat), add=T)
Random sample from the exponential distribution, estimate the parameters
simulated sample
<- 11.34 # parameter
lambda <- 30
n
<- rexp(n, rate = lambda)
x
hist(x, probability = TRUE)
Estimate the parameters with x.bar
= 1/mean(x); lambda.hat lambda.hat
[1] 9.726872
Plot the fitted model on the histogram
hist(x, probability = TRUE)
curve(dexp(x, rate = lambda.hat), add=T)
Now suppose we want to fit the gamma distribution to a random sample how can we do this?
Can we use x.bar and the sd?
The big question is, how do we estimate parameters in models in general?