ML estimation of linear regression with t distribution

I have tried to estimate a simple linear regression model with Student t errors. First I used maxLik and the results were very sensitive to the initial value of nu. Then I used stats4::mle but I got an error message (some named values are not arguments to the supplied log-likelihood).

I extracted the first 15 rows of the data set and generated the reproducible example below.

Could you please help me to find out what is wrong with the code?

Thanks,

Les

ys = c(0.1072, -0.0102, 0.07577, 0.0006, -0.0267, -0.0060, 0.0837, 0.0164, -0.0083, +
         0.1153, 0.0541, 0.0108, 0.0208, -0.0071, 0.0177)
xs = c(0.0816, -0.0154, -0.0116, -0.1053, -0.0587, -0.0127,  0.0523,  0.0189, +
         0.0355, 0.0602, 0.0170, -0.0044, 0.0333, -0.0537, 0.0392)

# ML estimation of a simple linear regression with t distribution

library(maxLik)
#> Warning: package 'maxLik' was built under R version 4.3.3
#> Loading required package: miscTools
#> Warning: package 'miscTools' was built under R version 4.3.3
#> 
#> Please cite the 'maxLik' package as:
#> Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.
#> 
#> If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
#> https://r-forge.r-project.org/projects/maxlik/
ll = function(param) {
  alpha = param[1]
  beta = param[2]
  nu = param[3]
  llf = sum(dt(x = ys - alpha - beta*xs, df = nu, log = TRUE))
}
m1 = maxLik(logLik = ll, start = c(alpha = 0.1, beta = 0.5, nu = 11))
summary(m1)
#> --------------------------------------------
#> Maximum Likelihood estimation
#> Newton-Raphson maximisation, 5 iterations
#> Return code 1: gradient close to zero (gradtol)
#> Log-Likelihood: -13.79246 
#> 3  free parameters
#> Estimates:
#>        Estimate Std. error  t value Pr(> t)    
#> alpha 2.652e-02  2.596e-01    0.102   0.919    
#> beta  6.066e-01  5.335e+00    0.114   0.909    
#> nu    2.701e+04  2.373e+01 1138.394  <2e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> --------------------------------------------
# For start = c(...nu < 11) the standard error is not available 

library(stats4)
lln = function(param){
  alpha = param[1]
  beta = param[2]
  nu = param[3]
  -sum(log(dt(x = ys - alpha - beta*xs, dt = nu), log = TRUE))
}
m2 = mle(lln, start = list(alpha = 0.1, beta = 0.5, nu = 13))
#> Error in l2v(start): some named values are not arguments to the supplied log-likelihood
summary(m2)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'summary': object 'm2' not found
# Error: some named values are not arguments to the supplied log-likelihood

Created on 2025-02-12 with reprex v2.1.1