Thank you all for your useful suggestions.

Jean, I had already tried to use the maxiter command in that way, but it simply 
told me that the model had not converged.

Based on Profs Ripley and Nash's comments, I have opted to use an alternative 
approach, and am creating a distribution of plausible models, and comparing my 
sum of squared residuals to those arising from that distribution. This seems to 
work.

Thanks again.

Cheers,

Rebecca

-----
Rebecca Lester
Lecturer, Freshwater Ecology
School of Life & Environmental Sciences
Deakin University
PO Box 423, Warrnambool, 3280

Ph: +61 3 5563 3330
Fax: +61 3 5563 3462


-----Original Message-----
From: Prof J C Nash (U30A) [mailto:nas...@uottawa.ca] 
Sent: Saturday, 6 April 2013 7:42 AM
To: r-help@r-project.org; Rebecca Lester
Subject: Re: Assessing the fit of a nonlinear model to a new dataset

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.les...@deakin.edu.au> To: "r-help@r-project.org" 
> <r-help@r-project.org> Subject: [R] Assessing the fit of a nonlinear 
> model to a new dataset Message-ID: 
> <5a72faa65583bc45a816a698a960e92788612...@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]]
>
>
>
> ------------------------------


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.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to