Properties of estimators — exam-style exercises with the scooter fleet, the best-guessing maximum, the speedometer and Cramér–Rao (and the “more efficient” one that wasn’t)
In the EC2 mock exam we did in class I was asked to decide which of two variance estimators was more efficient, and I compared their variances: I picked the unbiased one and got zero for the part. The question said “by the mean squared error criterion”, and the other one, the biased one, had a smaller MSE. I had read it, but in my head “efficient” meant “the one with less variance” and I did not look again. Two points for one word. This article is so that in the real one you read the criterion before comparing.
These are three chained exercises like those in the ME1 EC2 (one context per exercise and parts that build on the previous one), with the rental scooter fleet in Las Palmas as the thread, plus a bonus. Before you start, it helps to have the theory, the proofs and the practice of properties of estimators, and point estimation, because here you first have to derive the estimator.
Table of Contents
How to use this article
- Do the exercises with the exam in mind. In the ME1 EC2 you have 4 hours for 50 points, with RStudio and the data open. These three exercises add up to 40 points plus a 2.5-point bonus: give them about 3 hours.
- Paper for what is proved, R for what is computed. Unbiasedness, MSE, bound and consistency on paper; the estimates and the simulations that check them in R, with 2 decimals as the exam asks. Keep the code in a script: at the end you have to upload the
.Rfile with the code for each exercise. - Read the criterion. “More efficient” by variances (between unbiased estimators) or by MSE is not the same thing. And plain “efficient” means reaching the Cramér–Rao bound.
- Mark yourself with the criteria. Each solution comes with “How it is marked” and a split of the points. It is a guide, mine: not the official marking scheme.
- Finish with the cheat sheet and “For your script”. The cheat sheet only has results (that is what you can take in, handwritten: two sheets, both sides, in the EC2) and “For your script” is the topic’s code, ready for your
.Rfile. If a proof gets stuck, the proofs have the step by step.
Exercise 1: the time between two rentals (10 points)
The scooter company wants to know how long a scooter takes to be rented again once someone leaves it in the street. The time X, in minutes, between two rentals of the same scooter is modelled with the density
These are 15 times measured around campus:
gap <- c(10.1, 18.3, 8.3, 17.1, 29.5, 21.2, 12.3, 6.4, 19.9, 6.2, 24.1, 10.6, 11.5, 4.8, 22.2)
- (2 points) Compute E(X) and Var(X), identifying the distribution of X, and get the method of moments estimator of θ, .
- (3 points) Get the maximum likelihood estimator, , and check that it is a maximum.
- (2 points) Prove that is unbiased, compute its variance and prove that it is consistent.
- (2 points) Prove that is efficient.
- (1 point) Give the estimate of θ from the data and its standard error.
Exercise 2: the serial numbers at Las Canteras (15 points)
Another scooter company also spreads its fleet around the city. Its scooters are numbered from 1 to θ and, as in the theory, the number of any one of them is modelled as a uniform(0, θ). These are the numbers of 10 of that company’s scooters seen along the Las Canteras promenade:
canteras <- c(1715, 1479, 2351, 1621, 264, 1262, 2929, 991, 2677, 1254)
Recall (no need to prove it): for , and .
- (2 points) Compute from the data the estimates of θ with , with and with .
- (3 points) Among all estimators of the form , with c > 0, find the value of c that minimises the MSE and the value of that minimum MSE.
- (3 points) Compute the bias of the estimator from part 2, , and compare its MSE with that of . Which is more efficient by the MSE criterion?
- (3 points) Prove that T is consistent.
- (2 points) With R, simulate 10,000 samples of 10 scooters from a fleet of θ = 3000 and compute the MSE of the four estimators (the three from part 1 and T). Compare them with their formulas.
- (2 points) Give the estimate of θ with T and explain why a biased estimator can beat an unbiased one.
Exercise 3: the speedometer error (15 points)
The scooters have a speedometer that is not exact. The error X (speed shown minus real speed, in km/h) follows a normal : on average it is not wrong (μ = 0, known), but we do not know how much it strays. These are the errors of 12 scooters measured on a test bench:
error <- c(-1.18, 0.08, -1.76, -0.25, -2.80, -0.18, 1.24, 1.79, -1.64, -0.56, -1.40, 0.05)
We call the parameter .
- (3 points) Get the maximum likelihood estimator of v, , and check that it is a maximum.
- (3 points) Prove that is unbiased and compute its variance. (Hint: identify the distribution of .)
- (3 points) Prove that is efficient.
- (2 points) A classmate suggests using the sample variance , “which is unbiased”. Compare its MSE with that of . Which is more efficient? Why?
- (2 points) Compute from the data , and the maximum likelihood estimate of σ. Justify the last one.
- (2 points) With R, check with 10,000 simulations (σ = 1.5) the variances of and .
Bonus (2.5 points)
At night trips are longer. These are the durations, in minutes, of 25 night trips, assumed exponential(λ):
night <- c(17.3, 8.2, 7.0, 2.1, 24.8, 10.9, 1.1, 65.4, 9.7, 0.4, 6.4, 48.6, 14.9,
12.3, 19.5, 0.2, 50.7, 2.5, 34.3, 27.9, 12.8, 75.3, 13.5, 26.0, 48.2)
- (1 point) Compute the MLE of λ and its asymptotic variance, with the formula and with
optim. - (1 point) Give the standard error and interpret it.
- (0.5 points) Give the unbiased estimate of λ.
Solutions
Exercise 1
Part 1. The density is that of a gamma with shape 2 and scale θ (rate 1/θ). With the rule :
Setting equal to : .
Why spot the gamma instead of integrating by parts. The integral of can be done by parts, but it takes two rounds, and three more for : in the exam, a lot of time and a sign lost somewhere. If you see “a power of x times an exponential”, the gamma rule gives each expectation in one line. And the method of moments always goes in this order: as a function of θ, set it equal to , and solve.
Part 2. With :
Second derivative: . At , since :
It is a maximum. Here the MLE coincides with the moments estimator.
Why substitute instead of studying the sign of in general. The obvious path is to check whether is always negative. Here it isn’t: , negative only for . But the curve doesn’t need to be concave everywhere: it’s enough that it is at the only point where the derivative is 0. That’s why is replaced with , and the sign comes out with no numbers.
Part 3. : unbiased. By the variance rule:
Unbiased and with : by the consistency theorem, consistent.
Part 4. . Differentiating twice:
Unbiased and = bound: efficient.
Setting up efficiency. Efficient means “unbiased and with variance equal to the bound”. The first part is already done in part 3; only the bound is missing. For you use the second derivative and not the square of the first because is linear in x: its expectation only needs . With the square you would need and more algebra.
Check you’ve got it: why does the Cramér–Rao bound work here but not for the uniform in exercise 2?
Because here X lives on x > 0, and that range doesn’t depend on θ. In the uniform(0, θ) the upper end is θ itself: that’s exactly the mistake in snippet 2 of “What is wrong here?”.
Part 5. The standard error is :
n <- length(gap) theta_ml <- mean(gap) / 2 round(c(theta = theta_ml, std_err = theta_ml / sqrt(2 * n)), 2)
Output:
theta std_err 7.42 1.35
minutes, with a standard error of 1.35. The mean time between two rentals is minutes (the sample mean).
How it is marked. Part 1: identifying the gamma or integrating (1), estimator (1). Part 2: log-likelihood and derivative (2), second derivative (1). Part 3: unbiased (0.5), variance (1), consistency by the theorem (0.5). Part 4: information (1), comparing with the variance (1). Part 5: the two numbers (0.5 + 0.5).
Exercise 2
Part 1.
n <- length(canteras)
round(c(moments = 2 * mean(canteras),
maximum = max(canteras),
corrected = (n + 1) / n * max(canteras)), 2)
Output:
moments maximum corrected 3308.6 2929.0 3221.9
Here is larger than the maximum (2929), so it does not give an impossible fleet, but the three values are almost 400 scooters apart.
Before part 2: what the unknown is. contains both c and θ, but what you choose is c; θ is fixed and you don’t know it. That’s why you differentiate with respect to c. And factors out: the optimal c doesn’t depend on θ. If it did, you couldn’t use it. The shortcut also works, but it needs first; expanding the square uses the two expectations from the statement directly.
Part 2. With , expanding the square and using the two expectations given:
It is a parabola in c. Differentiating with respect to c and setting it to 0:
(the second derivative, , is positive: a minimum). Substituting:
because .
In the picture, the parabola of the MSE (divided by θ²) with n = 10. The plain maximum (c = 1) is far from the bottom; the corrected one (c = 11/10) almost on it; the minimum is at c = 12/11, a hair to the left of the corrected one.
Part 3. The bias of :
Biased, downwards, though only slightly (with n = 10, θ/121). Its MSE against the corrected one’s, (theory):
T is more efficient by the MSE criterion, though only just: with n = 10, 121/120 = 1.008.
Why a ratio and not a difference. Both MSEs carry , which you don’t know. When you divide, θ disappears and you’re left with a number that only depends on n: if it’s greater than 1, the one in the denominator wins for every θ. With a difference you’d have to discuss the sign of an expression with θ inside.
Check you’ve got it: with θ = 3000 and n = 10, what is the MSE of T, and where does it show up again?
. It’s the number in the mse_theo row, optimal column, of the output in part 5.
Part 4. (the ratio of degree-2 polynomials tends to 1): asymptotically unbiased. Its variance:
(degree 2 on top, degree 4 below). By the consistency theorem, T is consistent.
Why “unbiased and variance going to 0” isn’t enough. T is biased, so you need the version of the theorem where the expectation tends to θ. There’s a shortcut to double-check: the MSE from part 2, , already tends to 0, and with the Chebyshev bound from the theory that’s enough.
Part 5.
set.seed(55)
theta <- 3000; n <- 10
sims <- replicate(10000, {
x <- runif(n, 0, theta)
c(moments = 2 * mean(x), maximum = max(x), corrected = (n + 1) / n * max(x),
optimal = (n + 2) / (n + 1) * max(x))
})
mse_sim <- apply(sims, 1, function(v) mean((v - theta)^2)) # 1: by estimator
mse_theo <- theta^2 * c(1 / (3 * n), 2 / ((n + 1) * (n + 2)), 1 / (n * (n + 2)), 1 / (n + 1)^2)
round(rbind(mse_sim, mse_theo))
Output:
moments maximum corrected optimal mse_sim 298165 131962 71547 70831 mse_theo 300000 136364 75000 74380
The formulas are 300,000, 136,364, 75,000 and 74,380, and the simulation is within 5 % of each (the maximum and the last two come out a little short: that is the noise of 10,000 samples, which affects both the same way, because they come from the same maximum). The moments estimator has an MSE four times larger than the others; the corrected and optimal ones almost tie, as the ratio 1.008 said: with 10,000 simulations, that 0.8 % difference does not always show in the order.
Why the same samples and mean((v - theta)^2). Each sample gives the four estimators at once: they’re compared on the same data. And the MSE is the mean of the squared errors, not var(v), which measures the spread around the estimator’s own mean, not around θ. For the maximum, which is biased, var would give about 61,983 instead of 136,364: you’d lose the squared bias (74,380).
Part 6.
round((n + 2) / (n + 1) * max(canteras), 2)
Output:
[1] 3195.27
T estimates a fleet of 3195 scooters. A biased estimator can win because the MSE adds variance and squared bias: T falls a little short on average (bias ), but multiplying by a number slightly smaller than the corrected one’s also shrinks its variance, and what it gains in variance is more than what it loses to the squared bias.
How it is marked. Part 1: the three numbers (2). Part 2: MSE as a function of c (1), differentiate and solve (1), minimum value (1). Part 3: bias (1), ratio (1), conclusion (1). Part 4: limit of the expectation (1), variance (1), theorem (1). Part 5: simulation (1), comparison (1). Part 6: number (0.5) and explanation (1.5).
Exercise 3
Part 1. With μ = 0, , and
; at , with : . A maximum.
Part 2. Each , so , with and . Since :
Unbiased. Note that here the chi-squared has n degrees of freedom, not n − 1: there is no mean to estimate.
Why the chi-squared and not the variance rule. The obvious path is , but then you need , which you won’t always remember in the exam. Writing as a multiple of a chi-squared gives you the expectation and the variance at once, from two facts you do know: n and 2n. Both paths give the same: , and divided by n, .
Part 3. , so
Unbiased and with variance equal to the bound: efficient. (With μ = 0, .)
Part 4. is unbiased and, in the normal, . Ratio:
is more efficient. It is no coincidence: measures distances to because it does not know the mean is 0, and pays for that ignorance with a degree of freedom. uses the information that μ = 0. Besides, since is efficient, no unbiased estimator can beat it.
Part 5. By invariance, the MLE of is :
n <- length(error) round(c(v_ml = mean(error^2), S2 = var(error), sigma_ml = sqrt(mean(error^2))), 2)
Output:
v_ml S2 sigma_ml
1.84 1.68 1.36
(km/h)², and km/h: the speedometer is typically off by a little over 1 km/h.
Why comes out smaller than here. With these data , and measures distances to that −0.55, not to 0. Since , dividing by 11 gives 1.68, below . Neither is wrong: in this particular sample the mean came out somewhat negative.
Part 6.
set.seed(66)
sim <- replicate(10000, { x <- rnorm(12, 0, 1.5); c(v_ml = mean(x^2), S2 = var(x)) })
round(rbind(mean = apply(sim, 1, mean), variance = apply(sim, 1, var),
theo_var = c(2 * 1.5^4 / 12, 2 * 1.5^4 / 11)), 3)
Output:
v_ml S2 mean 2.241 2.244 variance 0.836 0.928 theo_var 0.844 0.920
Both means are around σ² = 2.25 (both are unbiased) and the variances sit on their formulas, and .
How it is marked. Part 1: log-likelihood (1), estimator (1), maximum (1). Part 2: chi-squared with n degrees (1), expectation (1), variance (1). Part 3: information (2), conclusion (1). Part 4: MSE of (1), ratio and conclusion (1). Part 5: the three numbers (1.5), invariance (0.5). Part 6: simulation (1), comparison (1).
Bonus
n <- length(night)
lambda_ml <- 1 / mean(night)
loglik <- function(l) n * log(l) - l * sum(night)
o <- optim(lambda_ml, loglik, method = "Brent", lower = 0.001, upper = 1,
control = list(fnscale = -1), hessian = TRUE)
data.frame(lambda = round(lambda_ml, 4),
var_formula = signif(lambda_ml^2 / n, 3),
var_optim = signif(-1 / o$hessian[1, 1], 3),
std_err = round(sqrt(lambda_ml^2 / n), 4),
unbiased = round((n - 1) / (n * mean(night)), 4))
Output:
lambda var_formula var_optim std_err unbiased 1 0.0463 8.57e-05 8.57e-05 0.0093 0.0444
1. trips ending per minute (a mean duration of 21.6 minutes), with asymptotic variance ; optim gives the same from the curvature. 2. The standard error is 0.0093: if we repeated the 25 trips, would move around λ with a standard deviation of about 0.009, 20 % of its value. 3. .
Why the unbiased one isn’t . The obvious reasoning is “ is unbiased for , so is unbiased for λ”. It fails: the expectation doesn’t pass through , and in the exponential . That’s why you multiply by : .
Check you’ve got it: if λ were 0.05, around what value would the MLE come out on average with 25 trips?
Around : 4 % above λ. With 100,000 simulations in R you get 0.052.
How it is marked. 1: estimate (0.5) and variance both ways (0.5). 2: number (0.5) and interpretation (0.5). 3: number (0.5).
What is wrong here?
Three solutions by other people with one slip each. Before reading the explanation, try to find it.
Snippet 1. A classmate computes in R the MSE of the fleet maximum from exercise 2:
set.seed(1) m <- replicate(10000, max(runif(10, 0, 3000))) c(variance = var(m), mse = var(m) + (mean(m) - 3000))
Output:
variance mse 59360.93 59093.94
What is wrong: they get an MSE smaller than the variance, which is impossible. They added the bias without squaring it, and since the maximum’s bias is negative (about −270 scooters), it subtracts. The real MSE is (the formula gives 136,364): the squared bias weighs more than the variance.
Adding the bias instead of its square. Quick check: the MSE is never smaller than the variance.
Snippet 2. Another solution, on paper, for the uniform(0, θ):
log f(x|θ) = −log θ → ∂/∂θ = −1/θ → i(θ) = E[(−1/θ)²] = 1/θ² Cramér-Rao bound = θ²/n. Var((n+1)/n · X(n)) = θ²/(n(n+2)) < θ²/n → the estimator breaks the bound! Conclusion: the variance formula for the maximum is wrong.
What is wrong: the variance formula is fine; what does not hold is the bound. The Cramér–Rao inequality requires the support of f not to depend on the parameter, and in the uniform(0, θ) the support is . With a moving support the bound does not apply, which is why the maximum can have a variance of order .
Before computing a Cramér–Rao bound, look at where X lives. If the end points carry the parameter, there is no bound.
Snippet 3. For exercise 2, someone suggests using only the first scooter seen:
T₁ = 2·X₁. E(T₁) = 2·θ/2 = θ → unbiased. Since it is unbiased, it is consistent.
What is wrong: unbiased does not imply consistent. , which does not depend on n: however many scooters you see, T₁ only looks at the first one and its variance does not fall. The consistency theorem asks for both conditions, and , and the second one fails.
When you are asked to prove consistency, always write both limits. If one fails, you cannot use the theorem (and almost always the estimator is not consistent).
In the picture, the three slips with their check at a glance: the MSE below the variance, the bound applied with a moving support and the variance that does not fall with n.
Practice quiz
Before moving on to the next topic, check you have got it. This quiz is here to consolidate what this article explains: the ME1 exam is not a multiple-choice test (you solve problems by hand and with R), so no mark here counts. There are 10 questions on the properties of estimators: key ideas, typical mistakes and many «what does this R code print?», with the outputs from really running it. In the short answers, a decimal point or a decimal comma both work. Answer without running anything, press Check and read the explanation for each option; you can repeat it as many times as you like.
A classmate computes the maximum’s MSE as var(m) + (mean(m) - 3000) and gets something smaller than the variance. What did they do wrong?
- They added the bias without squaring it; since the bias is negative, it subtracts
- They should subtract the bias
- They used the mean instead of the median
- Nothing: the MSE can be smaller than the variance
Solution
Answer: They added the bias without squaring it; since the bias is negative, it subtracts
Quick check: the MSE is never smaller than the variance.
In the uniform(0, θ), the estimator (n + 1)/n · X(n) has variance θ²/(n(n + 2)), smaller than the «Cramér–Rao bound» θ²/n. What is going on?
- The bound does not apply: Cramér–Rao requires the support not to depend on the parameter, and here the support is [0, θ]
- The variance formula is wrong
- The estimator is biased
- Fisher information is computed without the n
Solution
Answer: The bound does not apply: Cramér–Rao requires the support not to depend on the parameter, and here the support is [0, θ]
Before computing a Cramér–Rao bound, look at where X lives. If the endpoints contain the parameter, there is no bound.
T₁ = 2·X₁ (only the first scooter) is unbiased for θ in the uniform(0, θ). Is it consistent?
- No: its variance, θ²/3, does not go down as n grows
- Yes, because it is unbiased
- Yes, because the variance is finite
- No, because it is biased
Solution
Answer: No: its variance, θ²/3, does not go down as n grows
When asked to prove consistency, always write both limits.
An estimator has variance 4 and bias −3. What is its MSE?
Solution
Answer: 13
MSE = Var + b² = 4 + (−3)² = 4 + 9 = 13.
What does it print? (It is Var(2X₁) with X₁ ~ uniform(0, 3000), in millions.)
theta <- 3000 4 * theta^2 / 12 / 1e6
Solution
Answer: 3
Var(X₁) = θ²/12 and the constant comes out squared: Var(2X₁) = 4θ²/12 = θ²/3 = 3,000,000, that is, 3 million. It does not depend on n.
Match each property with its definition:
| Bias | |
| Mean squared error | |
| Unbiased | |
| Consistent | |
| Efficient |
Definitions:
- Variance larger than any other's
- Var(θ̂) + bias²
- E(θ̂) → θ and Var(θ̂) → 0 as n grows
- E(θ̂) − θ
- Unbiased with variance equal to the Cramér–Rao bound
- Bias 0 for every θ
Solution
- Bias → E(θ̂) − θ
- Mean squared error → Var(θ̂) + bias²
- Unbiased → Bias 0 for every θ
- Consistent → E(θ̂) → θ and Var(θ̂) → 0 as n grows
- Efficient → Unbiased with variance equal to the Cramér–Rao bound
To compare: among unbiased ones, smaller variance; in general, smaller MSE. Use the criterion the question asks for.
True or false?
- A biased estimator can have a smaller MSE than an unbiased one.
- The Cramér–Rao bound holds for any distribution.
- The Cramér–Rao bound is 1/(n·i(θ)), with i(θ) the information of one observation.
- To compare unbiased estimators it is enough to compare their variances.
Solution
- T — A biased estimator can have a smaller MSE than an unbiased one.
- F — The Cramér–Rao bound holds for any distribution.
- T — The Cramér–Rao bound is 1/(n·i(θ)), with i(θ) the information of one observation.
- T — To compare unbiased estimators it is enough to compare their variances.
That is the case of the fleet’s maximum: biased, but with a small MSE. The bound requires the support not to depend on θ.
In the uniform(0, θ), why is the maximum multiplied by (n + 1)/n?
- Because E(X(n)) = n/(n + 1) · θ: the maximum falls short and the factor corrects it so it is unbiased
- To reduce its variance
- Because that is the method-of-moments estimator
- To make it consistent
Solution
Answer: Because E(X(n)) = n/(n + 1) · θ: the maximum falls short and the factor corrects it so it is unbiased
With n = 10 and θ = 3000, E(maximum) = 10/11 · 3000 ≈ 2727: about 270 scooters below.
What does it print? (Expected maximum of 10 uniforms on (0, 3000), rounded.)
round(10 / 11 * 3000)
Solution
Answer: 2727
E(X(n)) = n/(n + 1) · θ = 10/11 · 3000 = 2727.27. The bias is −272.7, the «about −270» of snippet 1.
The Fisher information of one observation is i(θ) = 1/θ² and you have n data. What bound does Cramér–Rao give (if it can be applied)?
- θ²/n
- θ²
- 1/θ²
- n/θ²
Solution
Answer: θ²/n
The third question of «Before handing in»: Fisher information is for one observation and the bound has the n.
Try it in the R playground
Paste this script into the R playground: it draws the MSE parabola from part 2 of exercise 2 for any n, and marks the three values of c.
n <- 10
mse_c <- function(c) c^2 * n / (n + 2) - 2 * c * n / (n + 1) + 1 # MSE(c X(n)) / theta^2
curve(mse_c, from = 0.9, to = 1.25, lwd = 2, xlab = "c", ylab = "MSE / theta^2")
abline(v = c(1, (n + 1) / n, (n + 2) / (n + 1)), lty = 2, col = c("grey", "blue", "red"))
round(c(maximum = mse_c(1), corrected = mse_c((n + 1) / n), optimal = mse_c((n + 2) / (n + 1))), 5)
What to look at:
- In Plots, the parabola and the three lines: the red one (the optimum) is right at the bottom.
- The three numbers in the console: the corrected and the optimal ones are very close.
- Change n to 2: the gap between the corrected and the optimal ones is more noticeable.
- Change n to 100: the three lines come together near 1.
Cheat sheet: properties of estimators
The essentials in 30 seconds. Bias . . Unbiased: for every θ. More efficient: smaller variance (between unbiased ones) or smaller MSE (in general). Efficient: variance = bound , with . Consistent if and .
| I want… | Result |
|---|---|
| bias of | |
| MSE of and (normal) | and |
| maximum of the uniform(0, θ) | ; ; ; |
| MSE of , , | , , |
| best multiple of the maximum | , MSE |
| Fisher information | Poisson ; Bernoulli ; normal (μ) ; normal (v = σ², μ known) ; exponential |
| exponential | ; unbiased , variance |
| asymptotic variance of the MLE | ; standard error, its square root |
| MLE for large n |
| In R, I want… | Code |
|---|---|
| to simulate an estimator | replicate(B, { x <- …; estimator(x) }) |
| to summarise by estimator | apply(sims, 1, f) |
| the simulated MSE | mean((est - theta)^2) |
the asymptotic variance with optim | -1 / optim(…, control = list(fnscale = -1), hessian = TRUE)$hessian |
| Symptom | Likely cause |
|---|---|
| MSE smaller than the variance | bias not squared |
| the summary has B numbers | apply with margin 2 |
| estimator variance = 0 in the simulation | the sample was generated outside the replicate |
| an estimator “breaks” the bound | support that depends on θ, or a biased estimator |
NaN in the standard error | the minus sign of the Hessian is missing |
Before handing in, ask yourself:
- Have I used the criterion the question asks for (variance or MSE)?
- Have I written both limits for consistency?
- Is the Fisher information for one observation, and does the bound carry the n?
- Do the estimates have 2 decimals and their units?
For your script
The topic’s functions, tested, for your .R file. No exercise statements: each one says what it does.
## Properties of estimators (ME1, topic 10)
# Simulates one or several estimators: 'generate' returns a sample, 'estimators' a named vector.
simulate_est <- function(generate, estimators, B = 10000) replicate(B, estimators(generate()))
# Summary of a simulation matrix (one estimator per row): mean, bias, variance (over B) and MSE.
summarise_est <- function(sims, theta) {
mean_est <- apply(sims, 1, mean)
mse <- apply(sims, 1, function(v) mean((v - theta)^2))
round(data.frame(mean = mean_est, bias = mean_est - theta, variance = mse - (mean_est - theta)^2, mse), 4)
}
# Asymptotic variance and standard error of the MLE from the log-likelihood (one parameter).
mle_se <- function(loglik, start, lower, upper) {
o <- optim(start, loglik, method = "Brent", lower = lower, upper = upper,
control = list(fnscale = -1), hessian = TRUE)
c(mle = o$par, asym_var = -1 / o$hessian[1, 1], std_err = sqrt(-1 / o$hessian[1, 1]))
}
# Fisher information of one observation of a discrete variable, as E[(d log f / d theta)^2].
fisher_info_disc <- function(dlogf, dmass, support) sum(dlogf(support)^2 * dmass(support))
# MSE of c * maximum of a uniform(0, theta), divided by theta^2.
mse_c_max <- function(c, n) c^2 * n / (n + 2) - 2 * c * n / (n + 1) + 1
# Usage examples
set.seed(1)
s <- simulate_est(function() runif(12, 0, 2400),
function(x) c(mom = 2 * mean(x), cor = 13 / 12 * max(x)), B = 2000)
summarise_est(s, 2400)
mle_se(function(l) 20 * log(l) - l * 238.2, 0.08, 0.001, 1) # exponential, n = 20, sum 238.2
fisher_info_disc(function(x) -1 + x / 3, function(x) dpois(x, 3), 0:100) # Poisson(3): 1/3
optimize(mse_c_max, c(0.5, 2), n = 10)$minimum # (n + 2) / (n + 1)
What comes next?
With this topic you can now derive an estimator and say whether it is good: whether it is right on average, how wrong it is, whether it reaches the bound and whether it improves with more data. But in every exercise you have given one number (3195 scooters, 7.42 minutes) and, at most, its standard error. The next ME1 topic, confidence intervals, turns that number into a range: “between this and that, with 95 % confidence”. The asymptotic normality of the MLE and its standard error, which you computed in the bonus, are exactly the basis of those intervals.
If you want to go over things first, you have the theory, the proofs and the practice for this topic, and point estimation, where the estimators we have judged here come from.
Keep goingAll Statistics articlesDid this article help you? Here is how you can support SergioLearns →
Ready for the exam?ME1 EC2 mock exam — 4 hours with R beside you, from the normal to confidence intervals, four versions and a mark out of 50 (and why exercise 1 is worth double)


