title: How to estimate composite error terms for a linear model using the Maximum Likelihood Estimator?
body: <p>I'm trying to estimate parameters of a linear model with composite error terms in R using the stats4 and bbmle packages. </p>
  
  <p>for the model specifications click<br>
  <a href="https://i.stack.imgur.com/JBZja.png" rel="nofollow noreferrer">Linear model specification</a> and <a href="https://i.stack.imgur.com/poMva.png" rel="nofollow noreferrer">Log Likelihood function specification</a></p>
  
  <p><strong>My code so far:</strong> </p>
  
  <pre><code>N &lt;- 100
  x &lt;- runif(N)
  y &lt;- 5 * x + 3 + rnorm(N)
  
  library("stats4")
  LL &lt;- function(beta0, beta1, sigma1, sigma2){
  R = y - x*beta1 - beta0
  V = suppressWarnings(dnorm(R, 0, sigma1))
  U = suppressWarnings(dnorm(R, 0, sigma2))
  R = V + U
  std = sqrt(sigma1^2 + sigma2^2)
  lampda = sigma2/sigma1
  s = -1
  z = length(y)
  - z*log(std) + z*0.5*log(2/3.14159) + sum(dnorm((s*R*lampda/std), log = 
      TRUE) - (0.5*R^2/std^2))
  }
  library("bbmle")
  fit &lt;- mle2(LL, start = list(beta0 = 3, beta1 = 1, sigma1 = 0.1, sigma2 = 
             0.1))
  summary(fit).
  </code></pre>
  
  <p><strong>the output of the model:</strong></p>
  
  <pre><code>Maximum likelihood estimation
  
  Call:
  mle2(minuslogl = LL, start = list(beta0 = 3, beta1 = 1, sigma1 = 0.1, 
      sigma2 = 0.1))
  
  Coefficients:
            Estimate  Std. Error     z value     Pr(z)    
  beta0  -2.0313e+11          NA          NA        NA    
  beta1  -1.2108e+11  5.8350e-67 -2.0750e+77 &lt; 2.2e-16 ***
  sigma1 -2.1035e-09  4.4256e-51 -4.7531e+41 &lt; 2.2e-16 ***
  sigma2  5.0292e-08  4.4258e-51  1.1364e+43 &lt; 2.2e-16 ***
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
  -2 log L: -8.009115e+90 
  Warning message:
  In sqrt(diag(object@vcov)) : NaNs produced
  </code></pre>
  
  <p>I am getting insiginificant estimates (the estimates should be atleast closer to those produced using OLS estimater) and also i'm getting the warning message shown above. My head is now messed up. 
  Your help will be greatly appreciated.</p>
  
  <p>regards.</p>