[R] Assessing the fit of a nonlinear model to a new dataset

Prof J C Nash (U30A) nashjc at uottawa.ca
Fri Apr 5 22:41:34 CEST 2013


Given nls has a lot of C code (and is pretty complicated), I doubt 
you'll find much joy doing that.

nlxb from my nlmrt package is all in R, but you'll need to do quite a 
bit of work at each stage. I don't form the J' J matrix, and do a 
Marquardt approximation by adding appropriate rows to the J matrix then 
do a qr decomposition on that.

In any event, the Hessian (which  J' J is only a rather poor 
appriximation to) is what you want, and it may not be positive definite 
at the iterates, so you have infinite standard errors. Well, if the 
curvature was 0, they'd be infinite. Since the curvature is negative, 
maybe the SEs are more than infinite, if that has any meaning.

I have one problem for which I generated 1000 starting points and >75% 
had the Hessian indefinite. That is a simple logistic nonlinear 
regression, albeit with nasty data.

JN


> Message: 90 Date: Fri, 5 Apr 2013 05:06:57 +0000 From: Rebecca Lester <rebecca.lester at deakin.edu.au> To: "r-help at r-project.org" <r-help at r-project.org> Subject: [R] Assessing the fit of a nonlinear model to a new dataset Message-ID: <5A72FAA65583BC45A816A698A960E92788612C8A at mbox-f-3.du.deakin.edu.au> Content-Type: text/plain Hi all, I am attempting to apply a nonlinear model developed using nls to a new dataset and assess the fit of that model. At the moment, I am using the fitted model from my fit dataset as the starting point for an nls fit for my test dataset (see below). I would like to be able to view the t-statistic and p-values for each of the iterations using the trace function, but have not yet worked out how to do this. Any other suggestions are also welcome. Many thanks, Rebecca
>> model.wa <- nls(y ~ A*(x^B), start=list(A=107614,B=-0.415)) # create nls() power model for WA data
>> summary(model.wa) # model summary
>
> Formula: y ~ A * (x^B)
>
> Parameters:
>     Estimate Std. Error t value Pr(>|t|)
> A  7.644e+04  1.240e+04   6.165 4.08e-06 ***
> B -3.111e-01  4.618e-02  -6.736 1.15e-06 ***
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> Residual standard error: 5605 on 21 degrees of freedom
>
> Number of iterations to convergence: 6
> Achieved convergence tolerance: 7.184e-06
>   (6 observations deleted due to missingness)
>
>
>> model.vic <- nls(y.vic ~ A*(x.vic^B), start = list(A = 7.644e+04, B = -3.111e-01), trace = T)
> 3430193778 :  76440.0000    -0.3111
> 2634092902 :  48251.9235397    -0.2552481
> 2614516166 :  27912.1921354    -0.1772322
> 2521588892 :  32718.3764594    -0.1862611
> 2521233646 :  32476.4536126    -0.1836836
> 2521230904 :  32553.0767231    -0.1841362
> 2521230824 :  32540.063480    -0.184059
> 2521230822 :  32542.2970040    -0.1840721
>
>
>
>
> Important Notice: The contents of this email are intended solely for the named addressee and are confidential; any unauthorised use, reproduction or storage of the contents is expressly prohibited. If you have received this email in error, please delete it and any attachments immediately and advise the sender by return email or telephone.
>
> Deakin University does not warrant that this email and any attachments are error or virus free.
>
> 	[[alternative HTML version deleted]]
>
>
>
> ------------------------------



More information about the R-help mailing list