From Carsten.Urbach at physik.fu-berlin.de  Fri Sep  9 11:32:02 2005
From: Carsten.Urbach at physik.fu-berlin.de (Carsten.Urbach@physik.fu-berlin.de)
Date: Fri,  9 Sep 2005 11:32:02 +0200 (CEST)
Subject: [Rd] nls fails to return correlation matrix (PR#8127)
Message-ID: <20050909093202.40C241C519@slim.kubism.ku.dk>

Full_Name: Carsten Urbach
Version: 2.1.1  (2005-06-20)
OS: Linux
Submission from: (NULL) (141.34.5.241)


I observed one case where nls failed to return the correlation matrix, while the
parameter estimates were computed correctly. In the follwing I include all the
commands leading to this problem. R was started with 'R --vanilla':

> version
         _
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
status
major    2
minor    1.1
year     2005
month    06
day      20
language R
> data <- read.table(file="zp.dat", header=F)
> data
  V1     V2      V3      V4
1  4 5.6791 0.80709 0.00094
2  6 5.8636 0.71202 0.00083
3  8 6.0219 0.67844 0.00139
4 10 6.1628 0.65797 0.00130
5 12 6.2885 0.64604 0.00119
6 16 6.4956 0.63047 0.00112
> df <- data.frame(x=data$V2-6, y=data$V3)
> df
        x       y
1 -0.3209 0.80709
2 -0.1364 0.71202
3  0.0219 0.67844
4  0.1628 0.65797
5  0.2885 0.64604
6  0.4956 0.63047
> fit4 <- nls(y ~ a+b*x+c*x^2+d*x^3+e*x^4, data = df, start = list(a = 1., b =
-1., c = 1., d=-1., e=1.))
> summary(fit4)
Formula: y ~ a + b * x + c * x^2 + d * x^3 + e * x^4

Parameters:
   Estimate Std. Error t value Pr(>|t|)
a  0.680936   0.001327 513.002  0.00124 **
b -0.168167   0.010660 -15.775  0.04030 *
c  0.325593   0.047433   6.864  0.09210 .
d -0.860767   0.117710  -7.313  0.08652 .
e  0.957177   0.319101   3.000  0.20486
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1

Residual standard error: 0.001722 on 1 degrees of freedom

Correlation of Parameter Estimates:
  a b c d
b   1
c , , 1
d   * , 1 
e . , * *
attr(,"legend")
[1] 0 ? ? 0.3 ?.? 0.6 ?,? 0.8 ?+? 0.9 ?*? 0.95 ?B? 1

> fit4
Nonlinear regression model
  model:  y ~ a + b * x + c * x^2 + d * x^3 + e * x^4
   data:  df
         a          b          c          d          e
 0.6809363 -0.1681674  0.3255929 -0.8607670  0.9571768
 residual sum-of-squares:  2.966569e-06



[Rd] nls fails to return correlation matrix (PR#8127)
Carsten.Urbach@physik.fu-berlin.de