Re: [R] Finding starting values for the parameters using nls() or nls2()

2016-10-27 Thread dave fournier
> >> On Oct 25, 2016, at 9:29 AM, dave fournier wrote: >> >> >> >> Unfortunately this problem does not appear to be well posed. >> >>Retention = (b0*Area^(th+1))^b >> >> If b0, th, and b are the parameter only the product (th+1)*b

Re: [R] Finding starting values for the parameters using nls() or nls2()

2016-10-25 Thread dave fournier
Unfortunately this problem does not appear to be well posed. Retention = (b0*Area^(th+1))^b If b0, th, and b are the parameter only the product (th+1)*b is determined. This comes from noting that powers satisfy (a^b)^c = a^(b*c) So your model can be written as

Re: [R] Finding starting values for the parameters using nls() or nls2()

2016-10-24 Thread dave fournier
I've spent quite a bit of time trying to convince people on various lists that the solution to these kinds of problems lies in the stable parameterization of the model. I write the solutions in AD Model Builder because it is easy. But R people are generally stuck in R (or mired) so the

Re: [R] Finding starting values for the parameters using nls() or nls2()

2016-10-19 Thread dave fournier
Actually this converges very nicely if you use these starting values that I obtained with AD Model Builder th 9.1180e-01 b05.2104e+00 b1 -4.6725e-04 The R result looks like nls.m2 Nonlinear regression model model: Retention ~ expFct(Area, b0, b1, th) data:

Re: [R] nls in r

2015-08-12 Thread dave fournier
I believe that if your try these starting values the sum of squares is considerably smaller a=1.0851e-06 b=1.4596e-01 delta=9.1375e-01 something like SS= 0.005236471 vs SS= 0.01597071 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and

Re: [R] Hessian Matrix Issue

2011-09-03 Thread dave fournier
I wonder if your code is correct? I ran your script until an error was reported. the data set of 30 obs was [1] 0 0 1 3 3 3 4 4 4 4 5 5 5 5 5 7 7 7 7 7 7 8 9 10 11 [26] 12 12 12 15 16 I created a tiny AD Model Builder program to do MLE on it. DATA_SECTION init_int

Re: [R] Complicated nls formula giving singular gradient message

2010-12-22 Thread dave fournier
I don't Think that viewing lack of convergence by some R routine as a uuseful tool for diagnosing model or data inadequacy is a very useful approach. It is far better to fit the model. Then standard techniques can be employed to investigate these matters. For the model considered here there are

Re: [R] Solution to differential equation

2010-12-17 Thread dave fournier
It is not very difficult to integrate this DE numerically. For parameter estimation it is a good idea for stability to use a semi-implicit formulation. The idea is described here. http://otter-rsch.com/admodel/cc4.html __ R-help@r-project.org

Re: [R] Solution to differential equation

2010-12-17 Thread dave fournier
. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of dave fournier Sent: Friday

Re: [R] Complicated nls formula giving singular gradient message

2010-12-13 Thread dave fournier
I always enjoy these direct comparisons between different software packages. I coded this up in AD Model Builder which is freely available at http://admb-project.org ADMB calculates exact derivatives via automatic differentiation so it tends to be more stable for these difficult problems. The

Re: [R] autocorrelation in count data

2010-11-23 Thread dave fournier
You can fit this model with AD Model Builder's random effects module. there is an example fitting a Poisson and negative binomial to the venerable polio data set with ar(1) random effects at http://admb-project.org/examples/count-data/negative-binomial-serially-correlated-counts A

Re: [R] Mixed-effects model for overdispersed count data?

2010-10-25 Thread dave fournier
According to the documentation for glmmADMB if you fit your model with a statment like fit =glmm.admb(y~Base*trt+Age+Visit, ... data=epil2,family=nbinom) and that the parameter estimates are in fit$b while their estimated standard deviations are in fit$stdbeta so presumably p

Re: [R] Help: Maximum likelihood estimation

2010-10-22 Thread dave fournier
Actually it is not that difficult to parameterize the covariance matrix so that the optimization is unconstrained. first parameterize the correlation matrix and the standard deviations separately. the std devs can be parameterized as sigma_i=exp(x_i) 1=i=n For the correlation matrix

Re: [R] Using NLS with a Kappa function

2010-10-13 Thread dave fournier
Actually it just the parameterization that is causing trouble near k=0 let u = (x-z)/a then the problematic part of your function is (1- k*u)^(1/k) take the log to get log(1-k*u)/k = -(k*u +k^2*u^2/2 + ...)/k = -(u +k u^2/2 + ..) so your function is exp(-u - ku^2/2 - ...) and

Re: [R] optim() not finding optimal values

2010-06-28 Thread dave fournier
If you are going to make this program available for general use you want to take every precaution to make it bulletproof. This is a fairly informative data set. The model will undoubtedly be used on far less informative data. While the model looks pretty simple it is very challenging

Re: [R] Robust estimation of variance components for a nested design

2010-03-13 Thread dave fournier
If you mean using random effects which have a fat-tailed distribution this has been available in AD Model Builder's random effects package for some time now. The general idea is to start with a random effect assumed to be standard normal and then to transform it by the cumulative dist function

Re: [R] Starting estimates for nls Exponential Fit

2009-12-07 Thread dave fournier
I thought maybe my suggestion for reparameterizing this simple problem was ignored because I didn't supply R code for the problem. Here it is using optim for the optimization. It converges trivially with an initial value for E of 1000. As I stated before, there is nothing at all difficult about

Re: [R] Starting estimates for nls Exponential Fit

2009-12-07 Thread dave fournier
Thanks to Dennis Murphy who pointed out that ExponCycles is undefined. It is an R gotcha. I had shortened the name but R still remembered it so the script worked but only on my computer. This should fix that. ExponValues=c(2018.34,2012.54,2018.85,2023.52,2054.58,2132.61,2247.17,2468.32,27 78.47)

Re: [R] Starting estimates for nls Exponential Fit

2009-12-02 Thread dave fournier
Figuring out the best parameterization for this kind of model is a bit tricky until you get the hang of it. Let the function be y_t = y_0 + alpha * E^t where uppercase Y_t denotes an observed value and lower case y_t is a predicted value. Index the times by t_1 t_n WLOG assume that

Re: [R] Maximum likelihood estimation of parameters make no biological sense

2009-09-24 Thread dave fournier
Hi, Your results are do to using an unstable parameterization of the Von Bertalanffy growth curve, combined with the unreliable optimization methods supplied with R. I coded up your model in AD Model Builder which supplies exact derivatives through AD. I used your starting values and ran the

Re: [R] Entire Organization Switching from SAS to R - Any experience?

2009-07-25 Thread dave fournier
It is true that R does not offer support for custom likelihood functions in nonlinear mixed models. However you can switch to R and use AD Model Builder's random effects module http://admb-project.org This is freely available software and it is more flexible than proc nlmixed. I'm sure there are

Re: [R] nlme: problem with fitting logistic function

2009-03-11 Thread dave fournier
I think you can do this very efficiently with AD Model Builder's random effects module. The software is now freely available at http://admb-project.org If you want, you can contact me directly to discuss the model. Dave -- David A. Fournier P.O. Box 2040, Sidney, B.C. V8l 3S3 Canada

Re: [R] generalized linear mixed models with a beta distribution

2009-02-26 Thread dave fournier
You can fit this kind of model (and negative binomial) and more difficult mixed models with AD Model Builder's random effects module which is now freely available at http://admb-project.org/ -- David A. Fournier P.O. Box 2040, Sidney, B.C. V8l 3S3 Canada Phone/FAX 250-655-3364

[R] AD Model Builder now freely available

2008-11-25 Thread dave fournier
Hi All, Following Mike Praeger's posting on this list, I'm happy to pass on that AD Model Builder is now freely available from the ADMB Foundation. http://admb-foundation.org/ Two areas where AD Model builder would be especially useful to R users are multi-parmater smooth optimization as

[R] lmer function :method=AGQ glmmADMB

2008-04-02 Thread dave fournier
The freely available R package glmmADMB can do Adaptive Gaussian Quadrature for this type of model, since it is built using AD Model Builder's random effects module which incorporates this feature. There is now a beta version of the software for people using R on the Mac intel platform.

[R] lmer function :method=AGQ and glmmADMB

2008-04-02 Thread dave fournier
The freely available R package glmmADMB can do Adaptive Gaussian Quadrature for this type of model, since it is built using AD Model Builder's random effects module which incorporates this feature. There is now a beta version of the software for people using R on the Mac intel platform.

[R] coxme frailty model standard errors?

2007-12-07 Thread dave fournier
While it may be true that for coxme models the standard errors are not very good approximations, it is always useful to have them to compare with other diagnostics such as likelihood ratios and profile likelihoods. It is interesting to hear that with the currently used methodology Computation