2

I'm running a nonlinear lest squares using the minpack.lm package on Microsoft version or R. However, for each replication, with the same data, the output varies. In fact, my interest lies in the second parameter, however, even it suffers some variation. Base nlminb would return the same awkward output.

If I use the CRAN version of R, the results are reproducible.

Reproducible example:

library(minpack.lm)

df_ss <- read.csv("example.csv")

objective <- function(start, data_ss = df_ss) {

  beta_const <- start[1]
  beta_1 <- start[2:2]
  beta_poly <- start[-(1:2)]


  poly_df <- with(data_ss, cbind((var5 - var4 * beta_1)))
  poly_df <- poly(poly_df, degree = 2, raw = TRUE)


  poly_df <- poly_df %*% diag(beta_poly, nrow = length(beta_poly))


  lp2 <- qr(cbind(const = 1 * beta_const, poly_df))
  lp2 <- with(data_ss, qr.resid(lp2, y_ss - data_ss$var4 * beta_1))

  return(lp2)
}

start <- rep(0, 4)

ss_reg <- nls.lm(par = start, fn = objective)
print(ss_reg$par)
#2.227202e-06 -1.660069e-01  4.659955e-07  2.169863e-07

ss_reg <- nls.lm(par = start, fn = objective)
print(ss_reg$par)
#-1.022907e-06 -1.658407e-01  4.678488e-08  9.447334e-07    

ss_reg <- nls.lm(par = start, fn = objective)
print(ss_reg$par)
#1.911939e-06 -1.658408e-01  2.513519e-07 -2.140628e-07

ss_reg <- nls.lm(par = start, fn = objective)
print(ss_reg$par)
#-5.765922e-07 -1.658408e-01  3.606956e-07  5.372434e-07

The data used is here.

Am I doing something wrong?

Roland
  • 127,288
  • 10
  • 191
  • 288
Rodrigo Remedio
  • 640
  • 6
  • 20
  • I get the same output from multiple nls.lm runs, using MS R Server 9.1 (which is based on R 3.3.3). What version are you using? – Hong Ooi May 06 '17 at 17:03
  • I'm using Microsoft R Open 3.3.3. – Rodrigo Remedio May 06 '17 at 18:09
  • I can't reproduce the problem. See if rebooting fixes it, or otherwise, try reinstalling MRO. – Hong Ooi May 08 '17 at 00:57
  • 1
    Very interisting: I can only reproduce the problem using AMD processor (an A-10 7850k). When I try an Intel CPU (i5-2430M) the problem vanishes! That make me believe that the mkl doesn't run smoothly on AMD processors, or this is going too far? – Rodrigo Remedio May 14 '17 at 19:47
  • 1
    From Intel's literature on MKL and supported processors, it has not been validated to work on AMD processors ([ref][1]): "The Intel MKL 2017 release supports the IA-32 and Intel® 64 architectures." In this document they list Software/Processor architectures they have validated, and only Intel processors seem to have been tested. [1]: https://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-2017-system-requirements – Kirill Glushko - Microsoft May 15 '17 at 20:27

0 Answers0