Question 2.1

1)

To find the likelihood function β„’(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛), we need to multiply the probability functions of each observation in the sample. Given the exponential probability function, 𝒫(𝑦; πœ‡) = (1/πœ‡)*exp(-𝑦/πœ‡), we can write the likelihood function as:

β„’(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = 𝒫(𝑦_1; πœ‡) * 𝒫(𝑦_2; πœ‡) * … * 𝒫(𝑦_𝑛; πœ‡)

Now, substitute the exponential probability function into the likelihood function:

β„’(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = (1/πœ‡) * exp(-𝑦_1/πœ‡) * (1/πœ‡) * exp(-𝑦_2/πœ‡) * … * (1/πœ‡) * exp(-𝑦_𝑛/πœ‡)

Simplify the expression:

β„’(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = (1/πœ‡^n) * exp(-(𝑦_1 + 𝑦_2 + … + 𝑦_𝑛)/πœ‡)

Let 𝑆 = 𝑦_1 + 𝑦_2 + … + 𝑦_𝑛 be the sum of all the observations in the sample, and let 𝑦̅ = 𝑆/𝑛 be the sample mean. Then, the likelihood function becomes:

β„’(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = (1/πœ‡^n) * exp(-𝑛*𝑦̅/πœ‡)

Now, let’s find the log-likelihood function β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) by taking the natural logarithm of the likelihood function:

β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = ln(β„’(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛)) = ln((1/πœ‡^n) * exp(-𝑛*𝑦̅/πœ‡))

Use the properties of logarithms to simplify the expression:

β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = ln(1/πœ‡^n) + ln(exp(-𝑛𝑦̅/πœ‡)) = -𝑛 ln(πœ‡) - (𝑛*𝑦̅/πœ‡)

So, the log-likelihood function is:

β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = -𝑛 * ln(πœ‡) - (𝑛*𝑦̅/πœ‡)

2)

The score function π‘ˆ(πœ‡) is the first derivative of the log-likelihood function β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) with respect to the unknown parameter πœ‡. Given the log-likelihood function we derived earlier:

β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = -𝑛 * ln(πœ‡) - (𝑛*𝑦̅/πœ‡)

Let’s differentiate this with respect to πœ‡:

π‘ˆ(πœ‡) = dβ„“(πœ‡)/dπœ‡

First, differentiate the term -𝑛 * ln(πœ‡):

d(-𝑛 * ln(πœ‡))/dπœ‡ = -𝑛 * (1/πœ‡)

Next, differentiate the term -(𝑛*𝑦̅/πœ‡):

d(-(𝑛𝑦̅/πœ‡))/dπœ‡ = 𝑛𝑦̅/πœ‡^2

Now, add these two terms together to find the score function:

π‘ˆ(πœ‡) = -𝑛 * (1/πœ‡) + 𝑛*𝑦̅/πœ‡^2

So, the score function is:

π‘ˆ(πœ‡) = -𝑛 * (1/πœ‡) + 𝑛*𝑦̅/πœ‡^2

3)

To find the maximum likelihood estimate (MLE) of πœ‡, denoted as πœ‡Μ‚, we need to set the score function π‘ˆ(πœ‡) to zero and solve for πœ‡. From the score function we derived earlier:

π‘ˆ(πœ‡) = -𝑛 * (1/πœ‡) + 𝑛*𝑦̅/πœ‡^2

Set π‘ˆ(πœ‡) to zero:

0 = -𝑛 * (1/πœ‡) + 𝑛*𝑦̅/πœ‡^2

Now, we’ll solve for πœ‡:

𝑛 * (1/πœ‡) = 𝑛*𝑦̅/πœ‡^2

Cancel out the 𝑛 term:

1/πœ‡ = 𝑦̅/πœ‡^2

Now, cross-multiply to eliminate the fractions:

πœ‡^2 = 𝑦̅*πœ‡

Since πœ‡ > 0 (as given in the problem context), we can safely divide both sides by πœ‡:

πœ‡ = 𝑦̅

So, the maximum likelihood estimate (MLE) for πœ‡, denoted as πœ‡Μ‚, is equal to the sample mean:

πœ‡Μ‚ = 𝑦̅

4)

The observed information for πœ‡, denoted as 𝐼(πœ‡), is the negative of the second derivative of the log-likelihood function β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) with respect to the unknown parameter πœ‡. Given the log-likelihood function we derived earlier:

β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = -𝑛 * ln(πœ‡) - (𝑛*𝑦̅/πœ‡)

Let’s differentiate it twice with respect to πœ‡:

First, we already found the first derivative (the score function π‘ˆ(πœ‡)):

π‘ˆ(πœ‡) = -𝑛 * (1/πœ‡) + 𝑛*𝑦̅/πœ‡^2

Now, differentiate π‘ˆ(πœ‡) with respect to πœ‡:

dπ‘ˆ(πœ‡)/dπœ‡ = 𝑛/πœ‡^2 - 2𝑛*𝑦̅/πœ‡^3

The observed information 𝐼(πœ‡) is the negative of the second derivative of the log-likelihood function:

𝐼(πœ‡) = -dΒ²β„“(πœ‡)/dπœ‡Β² = -dπ‘ˆ(πœ‡)/dπœ‡

Now, plug in the second derivative:

𝐼(πœ‡) = - (𝑛/πœ‡^2 - 2𝑛*𝑦̅/πœ‡^3)

Simplify the expression:

𝐼(πœ‡) = -𝑛/πœ‡^2 + 2𝑛*𝑦̅/πœ‡^3

So, the observed information for πœ‡ is:

𝐼(πœ‡) = -𝑛/πœ‡^2 + 2𝑛*𝑦̅/πœ‡^3

5)

The expected information for πœ‡, also known as the Fisher information, is the expected value of the observed information 𝐼(πœ‡) with respect to the distribution of the data. In this case, we’re working with the exponential distribution.

Since the observed information 𝐼(πœ‡) is:

𝐼(πœ‡) = -𝑛/πœ‡^2 + 2𝑛*𝑦̅/πœ‡^3

Let’s compute the expected information for πœ‡, denoted as 𝐼_E(πœ‡):

𝐼_E(πœ‡) = E[𝐼(πœ‡)]

Now, recall that for the exponential distribution, the mean and variance are both equal to πœ‡:

E[𝑦] = πœ‡ Var(𝑦) = πœ‡^2

So, the expected value of 𝑦̅ (sample mean) is πœ‡:

E[𝑦̅] = πœ‡

Now, substitute the expected value of 𝑦̅ into the observed information 𝐼(πœ‡):

𝐼_E(πœ‡) = -𝑛/πœ‡^2 + 2𝑛*E[𝑦̅]/πœ‡^3

Plug in E[𝑦̅] = πœ‡:

𝐼_E(πœ‡) = -𝑛/πœ‡^2 + 2𝑛*πœ‡/πœ‡^3

Simplify the expression:

𝐼_E(πœ‡) = -𝑛/πœ‡^2 + 2𝑛/πœ‡^2

Now, combine the terms:

𝐼_E(πœ‡) = 𝑛/πœ‡^2

So, the expected information for πœ‡ is:

𝐼_E(πœ‡) = 𝑛/πœ‡^2

6)

To find the estimated standard error for πœ‡Μ‚, denoted as 𝑠𝑒(πœ‡Μ‚), we need to find the square root of the inverse of the expected information for πœ‡. We have previously found the expected information for πœ‡:

𝐼_E(πœ‡) = 𝑛/πœ‡^2

Now, let’s find the inverse of 𝐼_E(πœ‡):

𝐼_E(πœ‡)^(-1) = πœ‡^2/𝑛

The estimated variance of πœ‡Μ‚ is given by the inverse of the expected information for πœ‡:

Var(πœ‡Μ‚) = πœ‡^2/𝑛

Now, we’ll take the square root of the variance to find the estimated standard error:

𝑠𝑒(πœ‡Μ‚) = √(Var(πœ‡Μ‚)) = √(πœ‡^2/𝑛)

Recall that we have found the maximum likelihood estimate (MLE) for πœ‡:

πœ‡Μ‚ = 𝑦̅

Substitute πœ‡Μ‚ for πœ‡ in the standard error formula:

𝑠𝑒(πœ‡Μ‚) = √(πœ‡Μ‚^2/𝑛)

So, the estimated standard error for πœ‡Μ‚ is:

𝑠𝑒(πœ‡Μ‚) = πœ‡Μ‚/βˆšπ‘›

7)

The Wald test statistic is used to test a hypothesis about a parameter in a statistical model. In this case, we are testing the null hypothesis 𝐻_0: πœ‡ = 1.

The Wald test statistic is given by the following formula:

π‘Š = (πœƒΜ‚ - πœƒ_0) / 𝑠𝑒(πœƒΜ‚)

where πœƒΜ‚ is the maximum likelihood estimate (MLE) of the parameter (in this case, πœ‡Μ‚), πœƒ_0 is the hypothesized value of the parameter under the null hypothesis (in this case, 1), and 𝑠𝑒(πœƒΜ‚) is the estimated standard error of the MLE.

We have already found the MLE for πœ‡:

πœ‡Μ‚ = 𝑦̅

And the estimated standard error for πœ‡Μ‚:

𝑠𝑒(πœ‡Μ‚) = πœ‡Μ‚/βˆšπ‘›

Now, we’ll substitute these values into the Wald test statistic formula:

π‘Š = (πœ‡Μ‚ - 1) / (πœ‡Μ‚/βˆšπ‘›)

Now, multiply both numerator and denominator by βˆšπ‘› to eliminate the fraction in the denominator:

π‘Š = (βˆšπ‘› * (πœ‡Μ‚ - 1)) / πœ‡Μ‚

Now, simplify the expression:

π‘Š = (βˆšπ‘› * πœ‡Μ‚ - βˆšπ‘›) / πœ‡Μ‚

So, the Wald test statistic for testing 𝐻_0: πœ‡ = 1 is:

π‘Š = (πœ‡Μ‚ - 1) / (βˆšπœ‡Μ‚^2/𝑛)

8)

The likelihood ratio test statistic is used to test a hypothesis about a parameter in a statistical model. In this case, we are testing the null hypothesis 𝐻_0: πœ‡ = 1.

The likelihood ratio test statistic is given by the following formula:

𝐿 = 2 * (β„“(πœƒΜ‚) - β„“(πœƒ_0))

where πœƒΜ‚ is the maximum likelihood estimate (MLE) of the parameter (in this case, πœ‡Μ‚), πœƒ_0 is the hypothesized value of the parameter under the null hypothesis (in this case, 1), and β„“(πœƒ) is the log-likelihood function for the parameter πœƒ.

We have already found the MLE for πœ‡:

πœ‡Μ‚ = 𝑦̅

And the log-likelihood function:

β„“(πœ‡; 𝑦_1, β‹― , 𝑦_𝑛) = -𝑛 * ln(πœ‡) - (𝑛 * 𝑦̅/πœ‡)

Now, let’s evaluate the log-likelihood function at πœ‡Μ‚:

β„“(πœ‡Μ‚) = -𝑛 * ln(πœ‡Μ‚) - (𝑛 * 𝑦̅/πœ‡Μ‚)

Since πœ‡Μ‚ = 𝑦̅:

β„“(πœ‡Μ‚) = -𝑛 * ln(𝑦̅) - 𝑛

Next, evaluate the log-likelihood function at πœ‡_0 = 1:

β„“(1) = -𝑛 * ln(1) - (𝑛 * 𝑦̅/1)

Since ln(1) = 0:

β„“(1) = -𝑛 * 𝑦̅

Now, let’s substitute these values into the likelihood ratio test statistic formula:

𝐿 = 2 * (β„“(πœ‡Μ‚) - β„“(1)) = 2 * (-𝑛 * ln(𝑦̅) - 𝑛 - (-𝑛 * 𝑦̅))

Simplify the expression:

𝐿 = 2 * (𝑛 * 𝑦̅ - 𝑛 * ln(𝑦̅) - 𝑛)

Factor out 𝑛:

𝐿 = 2𝑛(𝑦̅ - ln(𝑦̅) - 1)

Since πœ‡Μ‚ = 𝑦̅:

𝐿 = 2𝑛(πœ‡Μ‚ - log(πœ‡Μ‚) - 1)

So, the likelihood ratio test statistic for testing 𝐻_0: πœ‡ = 1 is:

𝐿 = 2𝑛(πœ‡Μ‚ - log(πœ‡Μ‚) - 1)

9)

# Load required libraries
library(ggplot2)

# Define the sample size
n <- 10

# Generate a sequence of mu_hat values
mu_hat <- seq(0.5, 2.0, by = 0.1)

# Calculate W^2 and LRT
W_sq <- ((mu_hat - 1) / (sqrt(mu_hat^2 / n)))^2
LRT <- 2 * n * (mu_hat - log(mu_hat) - 1)

# Combine the data into a data frame
data <- data.frame(mu_hat = mu_hat, W_sq = W_sq, LRT = LRT)

# Create a ggplot object
p <- ggplot(data) +
  geom_line(aes(x = mu_hat, y = W_sq, color = "W^2")) +
  geom_line(aes(x = mu_hat, y = LRT, color = "LRT")) +
  labs(x = expression(hat(mu)), y = "Test Statistic Value", title = "W^2 and LRT vs. Mu_hat") +
  scale_color_manual(values = c("W^2" = "red", "LRT" = "blue"), name = "Test Statistic") +
  theme_minimal()

# Print the plot
print(p)

The resulting plot shows the relationship between π‘Š^2 and LRT as πœ‡Μ‚ varies. Both test statistics increase as the difference between the null hypothesis value (πœ‡ = 1) and πœ‡Μ‚ increases, indicating a stronger evidence against the null hypothesis.

10)

# Define the sample size
n <- 100

# Generate a sequence of mu_hat values
mu_hat <- seq(0.5, 2.0, by = 0.1)

# Calculate W^2 and LRT
W_sq <- ((mu_hat - 1) / (sqrt(mu_hat^2 / n)))^2
LRT <- 2 * n * (mu_hat - log(mu_hat) - 1)

# Combine the data into a data frame
data <- data.frame(mu_hat = mu_hat, W_sq = W_sq, LRT = LRT)

# Create a ggplot object
p <- ggplot(data) +
  geom_line(aes(x = mu_hat, y = W_sq, color = "W^2")) +
  geom_line(aes(x = mu_hat, y = LRT, color = "LRT")) +
  labs(x = expression(hat(mu)), y = "Test Statistic Value", title = "W^2 and LRT vs. Mu_hat") +
  scale_color_manual(values = c("W^2" = "red", "LRT" = "blue"), name = "Test Statistic") +
  theme_minimal()

# Print the plot
print(p)

The resulting plot shows the relationship between π‘Š^2 and LRT as πœ‡Μ‚ varies for 𝑛 = 100. As with the previous plot, both test statistics increase as the difference between the null hypothesis value (πœ‡ = 1) and πœ‡Μ‚ increases, indicating stronger evidence against the null hypothesis. However, for 𝑛 = 100, the test statistics increase more sharply compared to 𝑛 = 10, as a larger sample size provides more evidence against the null hypothesis when the true value of πœ‡ is different from the hypothesized value.

Question 2.2

1)

To calculate the variance-covariance matrix of 𝛽̂0, 𝛽̂1, and 𝛽̂2, we need to find the inverse of the information matrix 𝐼(πœ·Μ‚).

# Define the information matrix
information_matrix <- matrix(c(4823, 12334, 20871,
                               12334, 31798, 53423,
                               20871, 53423, 90348), nrow = 3, ncol = 3, byrow = TRUE)

# Calculate the variance-covariance matrix
var_cov_matrix <- solve(information_matrix)

# Print the variance-covariance matrix
print(var_cov_matrix)
##             [,1]         [,2]         [,3]
## [1,]  0.70524128  0.023890843 -0.177042229
## [2,]  0.02389084  0.005597557 -0.008828796
## [3,] -0.17704223 -0.008828796  0.046129512

The formula used to calculate the variance-covariance matrix is:

Var-Cov(πœ·Μ‚) = 𝐼(πœ·Μ‚)^(-1)

where 𝐼(πœ·Μ‚) is the information matrix and 𝐼(πœ·Μ‚)^(-1) is its inverse.

2)

To find the estimated standard error of 𝛽̂1, we need to take the square root of the corresponding diagonal element in the variance-covariance matrix.

# Calculate the standard error of beta_hat_1
se_beta_hat_1 <- sqrt(var_cov_matrix[2, 2])

# Print the standard error
print(se_beta_hat_1)
## [1] 0.07481683

3)

To find the 95% confidence interval of 𝛽̂1, we will use the estimated standard error we calculated previously, as well as the t-distribution critical value for a 95% confidence level.

The formula for the confidence interval is:

CI(𝛽̂1) = 𝛽̂1 Β± t_Ξ±/2 * SE(𝛽̂1)

The degrees of freedom for the t-distribution in a GLM are usually calculated as n - p, where n is the number of observations and p is the number of parameters. However, we don’t have the number of observations in this case, so we will use the normal distribution critical value (z-score) as an approximation, which is 1.96 for a 95% confidence interval.

# Define the MLE of beta_1
beta_hat_1 <- 2.0

# Define the critical value (z-score) for a 95% confidence interval
z_critical <- 1.96

# Calculate the confidence interval for beta_hat_1
lower_bound_1 <- beta_hat_1 - z_critical * se_beta_hat_1
upper_bound_1 <- beta_hat_1 + z_critical * se_beta_hat_1

# Print the confidence interval
cat("95% confidence interval for beta_hat_1: (", lower_bound_1, ", ", upper_bound_1, ")\n")
## 95% confidence interval for beta_hat_1: ( 1.853359 ,  2.146641 )

4)

To find the estimated standard error of 𝛽̂1 βˆ’ 𝛽̂2, we need to consider the covariance between 𝛽̂1 and 𝛽̂2 as well. The formula for the standard error of 𝛽̂1 βˆ’ 𝛽̂2 is:

SE(𝛽̂1 βˆ’ 𝛽̂2) = sqrt(Var(𝛽̂1) + Var(𝛽̂2) - 2 * Cov(𝛽̂1, 𝛽̂2))

where Var(𝛽̂1) and Var(𝛽̂2) are the variances of 𝛽̂1 and 𝛽̂2, and Cov(𝛽̂1, 𝛽̂2) is the covariance between 𝛽̂1 and 𝛽̂2. These values can be obtained from the variance-covariance matrix calculated earlier.

# Extract variances and covariance from the variance-covariance matrix
var_beta_hat_1 <- var_cov_matrix[2, 2]
var_beta_hat_2 <- var_cov_matrix[3, 3]
cov_beta_hat_1_2 <- var_cov_matrix[2, 3]

# Calculate the standard error of beta_hat_1 - beta_hat_2
se_beta_hat_1_2 <- sqrt(var_beta_hat_1 + var_beta_hat_2 - 2 * cov_beta_hat_1_2)

# Print the standard error
print(se_beta_hat_1_2)
## [1] 0.2634097

5)

To find the 95% confidence interval of 𝛽̂1 βˆ’ 𝛽̂2, we will use the estimated standard error we calculated previously, as well as the normal distribution critical value (z-score) for a 95% confidence level, which is 1.96.

The formula for the confidence interval is:

CI(𝛽̂1 - 𝛽̂2) = (𝛽̂1 - 𝛽̂2) Β± z_Ξ±/2 * SE(𝛽̂1 - 𝛽̂2)

where (𝛽̂1 - 𝛽̂2) is the difference between the MLEs of 𝛽1 and 𝛽2, z_Ξ±/2 is the critical value from the normal distribution for a 95% confidence level (Ξ± = 0.05), and SE(𝛽̂1 - 𝛽̂2) is the estimated standard error of 𝛽̂1 - 𝛽̂2.

# Define the MLEs of beta_1 and beta_2
beta_hat_1 <- 2.0
beta_hat_2 <- 1.0

# Define the critical value (z-score) for a 95% confidence interval
z_critical <- 1.96

# Calculate the difference between beta_hat_1 and beta_hat_2
beta_hat_diff <- beta_hat_1 - beta_hat_2

# Calculate the confidence interval for beta_hat_diff
lower_bound_2 <- beta_hat_diff - z_critical * se_beta_hat_1_2
upper_bound_2 <- beta_hat_diff + z_critical * se_beta_hat_1_2

# Print the confidence interval
cat("95% confidence interval for beta_hat_1 - beta_hat_2: (", lower_bound_2, ", ", upper_bound_2, ")\n")
## 95% confidence interval for beta_hat_1 - beta_hat_2: ( 0.483717 ,  1.516283 )

6)

Let’s summarize the 95% confidence intervals obtained in the previous two questions:

  1. For 𝛽̂1, the 95% CI was calculated to be (1.853359, 2.146641).
  2. For 𝛽̂1 - 𝛽̂2, the 95% CI was calculated to be (0.483717, 1.516283).

Now, we’ll comment on the two null hypotheses:

  1. 𝐻0: 𝛽̂1 = 1.5 To test this hypothesis at a significance level of 0.05, we need to check if the hypothesized value (1.5) is within the 95% confidence interval for 𝛽̂1. The value 1.5 is not within the interval (1.853359, 2.146641), we reject the null hypothesis.

  2. 𝐻0: 𝛽̂1 - 𝛽̂2 = 0 To test this hypothesis at a significance level of 0.05, we need to check if the hypothesized value (0) is within the 95% confidence interval for 𝛽̂1 - 𝛽̂2. The value 0 is not within the interval (0.483717, 1.516283), we reject the null hypothesis.

Question 2.3

1)

We are given that 𝒫(𝑦; 𝑝) = exp(𝑦 βˆ— 𝑓1(𝑝) - 𝑓2(𝑝)). Let’s rewrite the geometric distribution’s probability mass function in terms of exponential functions:

𝒫(𝑦; 𝑝) = 𝑝(1 βˆ’ 𝑝)^(𝑦-1)

Taking the natural logarithm of 𝑝 and (1 - 𝑝)^(𝑦-1):

log(𝑝) = log(exp(log(𝑝)))

(1 - 𝑝)^(𝑦-1) = exp((𝑦-1) * log(1-𝑝))

Now, let’s rewrite the geometric distribution in terms of exponentials:

𝒫(𝑦; 𝑝) = exp(log(𝑝) + (𝑦-1) * log(1-𝑝))

Now, we can see that 𝑓1(𝑝) = log(1-𝑝) and 𝑓2(𝑝) = -log(𝑝). So we have:

πœƒ = 𝑓1(𝑝) = log(1-𝑝) πœ…(πœƒ) = 𝑓2(𝑝) = -log(𝑝)

To rewrite πœ…(πœƒ) as a function of πœƒ, we need to express 𝑝 in terms of πœƒ:

πœƒ = log(1-𝑝) ⟹ exp(πœƒ) = 1-𝑝 ⟹ 𝑝 = 1 - exp(πœƒ)

Now, substitute 𝑝 in πœ…(πœƒ):

πœ…(πœƒ) = -log(1 - exp(πœƒ))

Since πœ™ = 1, we can find π‘Ž(𝑦,πœ™):

π‘Ž(𝑦,πœ™) = 𝑦 - 1

So, we have:

πœƒ = log(1-𝑝) πœ™ = 1 πœ…(πœƒ) = -log(1 - exp(πœƒ)) π‘Ž(𝑦,πœ™) = 𝑦 - 1

2)

We know that for the geometric distribution, πœ‡ = 𝐸[𝑦] = 1/𝑝. We also know that πœƒ = log(1-𝑝). Our goal is to find the canonical link function, 𝑔(πœ‡), such that πœƒ = 𝑔(πœ‡).

First, let’s express 𝑝 in terms of πœ‡:

1/𝑝 = πœ‡ ⟹ 𝑝 = 1/πœ‡

Now, substitute this expression for 𝑝 in the equation for πœƒ:

πœƒ = log(1 - (1/πœ‡))

Thus, the canonical link function for the geometric distribution is:

𝑔(πœ‡) = log(1 - (1/πœ‡))

3)

We know that for the geometric distribution, π‘£π‘Žπ‘Ÿ[𝑦] = (1βˆ’π‘)/𝑝^2. We also know that πœ‡ = 1/𝑝 and πœ™ = 1. Our goal is to find the variance function, 𝑉(πœ‡), such that π‘£π‘Žπ‘Ÿ[𝑦] = πœ™ βˆ— 𝑉(πœ‡).

First, let’s rewrite π‘£π‘Žπ‘Ÿ[𝑦] in terms of πœ‡:

π‘£π‘Žπ‘Ÿ[𝑦] = (1βˆ’(1/πœ‡))/(1/πœ‡)^2

Now, since πœ™ = 1, the variance function 𝑉(πœ‡) is equal to π‘£π‘Žπ‘Ÿ[𝑦]:

𝑉(πœ‡) = (1βˆ’(1/πœ‡))/(1/πœ‡)^2

Thus, the variance function for the geometric distribution is:

𝑉(πœ‡) = (1βˆ’(1/πœ‡))/(1/πœ‡)^2

4)

πœ…(πœƒ) = -log(1 - exp(πœƒ)) π‘‘πœ…(πœƒ)/π‘‘πœƒ = exp(πœƒ)/(1 - exp(πœƒ))

exp(πœƒ) = 1-𝑝

π‘‘πœ…(πœƒ)/π‘‘πœƒ = (1-𝑝)/𝑝

πœ‡ = (1-𝑝)/𝑝

𝑝 = 1/(1+πœ‡)

πœ‡ = 1/𝑝

5)

π‘‘πœ…(πœƒ)/π‘‘πœƒ = (1-𝑝)/𝑝

π‘‘Β²πœ…(πœƒ)/π‘‘πœƒΒ² = 𝑑((1-(1-exp(πœƒ)))/((1-exp(πœƒ))))/π‘‘πœƒ = 𝑑(exp(πœƒ)/(1-exp(πœƒ)))/π‘‘πœƒ

Let u = exp(πœƒ) and v = (1 - exp(πœƒ)):

π‘‘Β²πœ…(πœƒ)/π‘‘πœƒΒ² = (v(𝑑u/π‘‘πœƒ) - u(𝑑v/π‘‘πœƒ))/vΒ²

Since 𝑑u/π‘‘πœƒ = exp(πœƒ) and 𝑑v/π‘‘πœƒ = -exp(πœƒ):

π‘‘Β²πœ…(πœƒ)/π‘‘πœƒΒ² = ((1-exp(πœƒ))(exp(πœƒ)) - exp(πœƒ)(-exp(πœƒ)))/(1-exp(πœƒ))^2 = (exp(2πœƒ))/(1-exp(πœƒ))^2

Now, let’s find π‘£π‘Žπ‘Ÿ[𝑦] = πœ™((π‘‘Β²πœ…(πœƒ)/π‘‘πœƒΒ²)):

Since πœ™ = 1:

π‘£π‘Žπ‘Ÿ[𝑦] = (exp(2πœƒ))/(1-exp(πœƒ))^2

We know that πœƒ = log(1-𝑝), so exp(πœƒ) = 1-𝑝:

π‘£π‘Žπ‘Ÿ[𝑦] = (1-𝑝)2/(𝑝2) = (1-𝑝)/𝑝^2

6)

To find the MLE of 𝑝 for a single observation 𝑦1, we need to maximize the likelihood function.

L(𝑝; 𝑦1) = 𝑝(1-𝑝)^(𝑦1-1)

β„“(𝑝) = log(𝑝) + (𝑦1 - 1)log(1-𝑝)

Differentiating β„“(𝑝) with respect to 𝑝:

dβ„“(𝑝)/d𝑝 = 1/𝑝 - (𝑦1 - 1)/(1-𝑝)

Setting the derivative equal to zero:

1/𝑝 - (𝑦1 - 1)/(1-𝑝) = 0

Solving for 𝑝:

𝑝 = 1/𝑦1

The MLE of 𝑝 is 1/𝑦1.

Question 2.4

1)

# Load the data 
data(nambeware)
nambeware_data <- nambeware

# Create a scatter plot
plot(nambeware_data$Diam, nambeware_data$Price, xlab="Diam", ylab="Price", main="Price vs. Diam")

# Add a regression line
model <- lm(Price ~ Diam, data=nambeware_data)
abline(model, col="red")

  1. Trend: The price tends to increase as the diameter increases, there’s a positive correlation between the two variables.

  2. Dispersion: With lower diameters the price appears to be closely correlated with diameter, but as diameter increases we see an increase in the variance of dispersion of the points along our line.

2)

# Divide the data into age groups
groups <- cut(nambeware_data$Diam, breaks=c(-Inf, 8.25, 10.25, 12.25, 14.25, Inf), right = FALSE)

# Calculate group means, variances, and sample sizes
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
group_summary <- nambeware_data %>% 
  mutate(group = groups) %>% 
  group_by(group) %>% 
  summarise(
    mean_blocks = mean(Diam),
    var_blocks = var(Diam),
    sample_size = n()
  )

# Log-transform the group means and variances
group_summary$log_mean <- log(group_summary$mean_blocks)
group_summary$log_var <- log(group_summary$var_blocks)

# Plot log(group_variance) vs log(group_mean)
plot(group_summary$log_mean, group_summary$log_var, 
     xlab = "Log(Group Mean)", ylab = "Log(Group Variance)")

# Fit a linear model
lm_model <- lm(group_summary$log_var ~ group_summary$log_mean)

# Add the regression line to the plot
abline(lm_model, col="red")

# Convert the group_summary data.frame to a table
group_summary_table <- group_summary %>% 
  select(-log_mean, -log_var) %>% 
  rename(
    `Age Group` = group,
    `Sample Mean` = mean_blocks,
    `Sample Variance` = var_blocks,
    `Sample Size` = sample_size
  )

# Transpose the group_summary_table
group_summary_table_transposed <- as.data.frame(t(group_summary_table[,-1]))

# Set the column names as the Age Group values
colnames(group_summary_table_transposed) <- group_summary_table$`Age Group`

# Add row names for Sample Mean, Sample Variance, and Sample Size
rownames(group_summary_table_transposed) <- c("Sample Mean", "Sample Variance", "Sample Size")

# Print the transposed table
print(group_summary_table_transposed)
##                 [-Inf,8.25) [8.25,10.2) [10.2,12.2) [12.2,14.2) [14.2, Inf)
## Sample Mean        6.420000   9.2818182  11.1666667  13.1583333    17.15556
## Sample Variance    1.137429   0.3056364   0.2842424   0.5499242    11.09028
## Sample Size       15.000000  11.0000000  12.0000000  12.0000000     9.00000

3)

The table and plot of log(Group Variance) vs log(Group Mean) show a positive relationship between group mean and variance. A suitable Exponential Dispersion Model (EDM) for this is the Gamma distribution, with a variance function:

V(ΞΌ) = ΞΌ^2

This suggests that the variance increases quadratically with the mean, fitting the observed relationship in the data.