The normal-error log-likelihood, for fixed variance, is a constant minus . Differentiating the squared residual gives the normal equations . Since has full column rank, is positive definite and the squared residual is strictly convex in . Hence the unique minimizer, and thus the maximum-likelihood estimator, is
Profiling over the unknown positive variance does not change the residual-minimizing value of .
Assume and a current state with , . The unnormalized posterior density is
Thus the log-posterior, up to an additive constant, is the log-likelihood plus the beta distribution and exponential distribution log prior densities. The exponential distribution rate is , since is its mean. [ref] [ref]
Choose a symmetric joint random-walk Metropolis algorithm proposal: and , for independent standard normal distribution draws. Its scale depends only on fixed hyperparameters, so forward and reverse proposal probability density functions agree. Reject immediately outside ; otherwise accept with Metropolis–Hastings acceptance probability
The following function makes exactly one proposal, with rejection retaining both old parameters:
MHstep <- function(x, p, beta, a, b, mu) {
  p_new <- rnorm(1, mean = p, sd = 0.1)
  beta_new <- rnorm(1, mean = beta, sd = mu / 2)
  if (p_new <= 0 || p_new >= 1 || beta_new <= 0)
    return(list(p = p, theta = beta))
  logpost <- function(pp, bb) {
    ll_f(pp, bb, x) + dbeta(pp, a, b, log = TRUE) +
      dexp(bb, rate = 1 / mu, log = TRUE)
  }
  logA <- logpost(p_new, beta_new) - logpost(p, beta)
  if (log(runif(1)) <= min(0, logA)) {
    p <- p_new
    beta <- beta_new
  }
  list(p = p, theta = beta)
}
The returned field theta contains the updated value of beta. The original PDF really asks for p and theta, although no parameter is defined in this question. This choice preserves its literal interface while making the intended second parameter explicit. A caller therefore advances with state <- MHstep(x, p, beta, a, b, mu), p <- state$p, and beta <- state$theta.
The proposal is an unrestricted symmetric normal distribution followed by rejection outside the support. Repeatedly drawing until a valid proposal appears would instead truncate and renormalize the proposal, requiring a proposal-density correction. The code uses immediate rejection and needs no such correction. The displayed scales are valid fixed choices; practical efficiency can be improved using a separate tuning phase.
Taking the logarithm of the normalized probability density function, then summing over the independent observations, gives the log-likelihood
Both and are parameters being inferred, so their contributions to the normalizing constant must be retained. The following R implementation validates the arguments and returns one number:
ll_f <- function(p, beta, x) {
  scalar <- function(v) {
    is.numeric(v) && !is.complex(v) && length(v) == 1L &&
      is.finite(v)
  }
  if (!scalar(p) || p <= 0 || p >= 1)
    stop("p must lie strictly between 0 and 1")
  if (!scalar(beta) || beta <= 0)
    stop("beta must be positive")
  if (!is.numeric(x) || is.complex(x) || !is.null(dim(x)) ||
      any(!is.finite(x)) || any(x <= 0))
    stop("x must be a vector of finite positive numbers")
  if (length(x) == 0L) return(0)
  t <- log1p(-p) - beta * x
  length(x) * (log(beta) - log(-log(p))) +
    sum(t - log(-expm1(t)))
}
Here and -expm1(t) computes accurately near zero. The empty-data likelihood function is one, so its log-likelihood is zero. Invalid parameter values produce errors in this evaluator; the next algorithm rejects candidates outside the parameter support before calling it.
Here the exponential distribution is parametrized by its mean, so for and . Its log-likelihood and maximum-likelihood estimate are
For one observation, . Since , its Fisher information is . Consequently the estimated standard error is , giving
This is a large-sample confidence interval, not an exact one. If its lower endpoint is negative, intersecting with the parameter space removes impossible values without excluding any possible true statistical parameter.
Let be the likelihood function, with full parameter space and null hypothesis . The generalized likelihood-ratio test compares the best null fit to the best unrestricted fit:
The likelihood ratio lies between zero and one, and small values count against the null hypothesis; equivalently, large values of the likelihood-ratio test statistic count against it.
Compute restricted and unrestricted maximum-likelihood estimates, evaluate their log-likelihoods, and form . Under the regular conditions of Wilks theorem, the null limit is
These statistical degrees of freedom count independent parameter restrictions. The regularity includes a locally identifiable smooth model, nonsingular Fisher information, and an interior null value; parameter-dependent support can invalidate the result.
For a chosen significance level , obtain the quantile of the chi-squared distribution and use
Equivalently, compare the asymptotic p-value to . This is a large-sample calibration; part (c) requires direct treatment because its support depends on a parameter.
The count vector has a multinomial distribution, with likelihood function
Maximize its log-likelihood using a Lagrange multiplier for the sum constraint. The equations and give and . Since all counts are positive and the log-likelihood is strictly concave on the interior of the probability simplex, this is the global maximum-likelihood estimate.
Under the uniform null hypothesis, each category has expected count
The common multinomial coefficient cancels from the likelihood ratio:
Taking minus twice its logarithm gives exactly
There are free category probabilities, because their sum is one, and the null fixes all of them. Thus its regular asymptotic chi-squared distribution has statistical degrees of freedom.
Write , and . For nondegenerate data from the shifted exponential distribution, the likelihood function is
For fixed feasible , differentiating its log-likelihood with respect to gives
The derivative changes from positive to negative there. Substituting gives the profile likelihood , which increases with . Therefore the unrestricted maximum-likelihood estimates are
while under the null hypothesis the estimate is . Their likelihood ratio is
Since the likelihood-ratio test rejects for small , the requested form is obtained with
The formulas assume , which holds almost surely for a continuous sample with ; coincident observations give an unbounded unrestricted likelihood and can be treated by its supremum.
An exact calibration is available and also explains why Wilks theorem should not be applied here. Under the null, the memoryless property makes and independent gamma distributions with common scale and shapes and . By beta sampling by gamma ratios,
Consequently, for ,
This yields an exact test size , independent of the unknown scale. The support endpoint and boundary null make this a likelihood-ratio test for an exponential support endpoint, with a different calibration from a regular one-parameter test.
TODO: Complete the data-specific numerical results and diagnostics when the original Iris_data.csv is available.
The identity
shows that the likelihood function is a bell-shaped curve in , maximized at the sample mean, with width . Its actual vertical scale also depends on the within-sample sum of squares.
Continue the R script with:
sse <- sum((x - xbar)^2)
loglik <- function(mu) {
  -n/2 * log(2*pi) - 0.5 * (sse + n * (mu - xbar)^2)
}
grid <- seq(3, 6, length.out = 2001L)
ell <- loglik(grid)
png("q2-likelihood.png", width = 900, height = 600)
par(mar = c(4.5, 4.5, 4, 1))
if (max(ell) > log(.Machine$double.xmin)) {
  plot(grid, exp(ell), type = "l", xlab = expression(mu),
       ylab = expression(L(mu)), main = "Likelihood on [3,6]")
} else {
  # Explicitly label a proportional likelihood if the true scale underflows.
  plot(grid, exp(ell - max(ell)), type = "l", xlab = expression(mu),
       ylab = "Likelihood relative to maximum on plotted grid",
       main = "Likelihood on [3,6] (rescaled)")
}
abline(v = xbar, col = "steelblue", lty = 2)
dev.off()
Working first with the log-likelihood avoids premature numerical underflow. The fallback preserves the shape on the requested interval and labels the altered scale. A data-specific plot requires the missing CSV file; no fabricated observation set is used here.
Poisson observation 2026-10-07
A Poisson observation is an integer-valued count modeled by a Poisson distribution of specified intensity, possibly conditionally on a latent field. Independent Poisson observations motivate Poisson data fidelity through their log-likelihood.
For independent Poisson distributions with log means , where is a known offset, differentiation of the log-likelihood gives the score function . An interior maximum-likelihood estimator therefore satisfies the displayed equations. An intercept and categorical indicator columns make fitted count totals equal observed count totals in each represented factor level. These equations match counts, rather than unweighted averages of rates when exposures differ.
Independent Poisson distributions with a separate nuisance intercept in every stratum become multinomial distributions after conditioning on their totals. Profiling the intercept gives . Substitution produces the same parameter-dependent log-likelihood as the conditional multinomial model. Both approaches fit . This exact equivalence differs from approximating a single binomial event count by a rare-event Poisson distribution.
Split the units into visible units , whose patterns occur in the training data, and hidden units . Let be the empirical probability distribution and maximize the average log-likelihood , where . The positive phase clamps to data and averages over ; the negative phase releases all units and averages over . The displayed difference uses these two expectations. When both units are visible, the positive pair product is supplied directly by the data.
For a proof, write . Differentiating each finite sum gives, respectively, and . Since , subtraction proves the rule. Similarly . A small positive step along these gradients increases log-likelihood. The negative term suppresses associations overproduced by the model; strengthening observed pairs alone misses this correction. The identity requires equilibrium expectations; estimates from insufficiently mixed sampling can give a biased update.
Profile log-likelihood 2026-10-14
The logarithm of the profile likelihood is the full log-likelihood evaluated at the nuisance fit constrained to the specified parameter of interest. It preserves likelihood ratios and maximizers, but is not generally a normalized sampling log-density. Conditioning and integrating out nuisance parameters are different operations.
For independent samples of size from exponential distributions with rates and , the maximum-likelihood estimators are and , where and are the respective sample sums. Their normalized P-star approximation is exact:
Indeed, and have independent gamma distributions with shapes and respective rates . The Jacobian determinant of their inverse transformation is , giving the displayed density. Alternatively the square root of the determinant of the fitted observed information is ; multiplying by the exponential of the fitted log-likelihood difference gives the same shape. Its normalizing constant in the P-star approximation is . Integrating over gives
so has the F-distribution with degrees of freedom .
Quasi-complete separation 2026-10-14
In a binary logistic regression, write the signed directional margin of observation as . Quasi-complete separation occurs when a nonzero direction makes all these margins nonnegative, with some zero and some strictly positive. Along coefficients , , each observation's log-likelihood contribution is nondecreasing, and those with positive margins strictly increase toward their limiting value. Hence the unpenalized fit cannot have a finite maximum in that direction. A group containing only outcome zeros is a simple example: sending its indicator coefficient to improves that group's likelihood while leaving all other observations unchanged. Zero fitted risk is then a boundary limit, and ordinary finite-coefficient Wald confidence intervals are unavailable.
Residual deviance 2026-10-06
The unscaled residual deviance of an exponential dispersion family compares its fitted mean with the saturated statistical model at a common dispersion parameter. Its normalization removes the factor in the log-likelihood. In Poisson regression and binomial regression, , so it is twice the saturated-minus-fitted log-likelihood. Under suitable regularity, has approximately a chi-squared distribution with the residual degrees of freedom; this is not an automatic accurate approximation for sparse responses. Nested deviance reductions with estimated dispersion lead to approximate F-tests after scaling by the dispersion estimate.
Saturated statistical model Created 2026-10-05 Updated 2026-10-14
A saturated model has enough independently varying mean parameters to match every observed response or response cell. In individual Bernoulli distribution data its fitted probabilities are , and its maximum log-likelihood is zero under . It defines the reference in a binomial deviance.
Score equation Created 2026-09-28 Updated 2026-10-14
A score equation sets the score function equal to zero. Its solutions are stationary points of the log-likelihood, and a negative-definite likelihood Hessian identifies an interior local maximum.
In a regular common-support statistical model with probability density function , the score function in is . Its zero expectation gives for . The mixed log-likelihood derivative is , so the cross Fisher information matrix block vanishes. At zero the same conclusion follows by continuity when the regular derivatives extend there. This proves parameter orthogonality; it does not establish exact independence of fitted parameters.
Complete separation means that a predictor direction strictly separates the binary outcomes as displayed. In logistic regression, replacing by increases each observed-outcome probability as increases, so the log-likelihood has no finite maximizer. Weak inequalities with some equalities can similarly produce quasi-complete separation. Finite coefficient estimates and ordinary information-matrix inference therefore require an existence check rather than relying only on the formal score equations.