Re: [R] Matlab's lsqnonlin
I'm wondering about experiences: Do you know of cases where minpack.lm's nls.lm() solved a (real) problem that nls() would have a problem with ? In short, no. However, I looked at this question in the limited context of fitting the parameters of a linear superposition of 2 exponentials with Gaussian noise. A simulation study showed nearly identical performance for the range of parameter values/noise levels that are of practical interest to us. Are there problems for which steepest descent gets you in the neighborhood of a solution whereas GN does not? If such problems exist then there would be reason to apply LM instead of GN, but I don't know of any. Beware however -- one of the main things I learned about this field from Doug Bates, co-author of Bates_and_Watts and prinicipal author of S's and R's nls() : It's a *feature* that nls() does not converge sometimes when other methods do falsely claim convergence! Martin Maechler, ETH Zurich KateM KateM Katharine Mullen KateM mail: Department of Physics and Astronomy, Faculty of Sciences KateM Vrije Universiteit Amsterdam, de Boelelaan 1081 KateM 1081 HV Amsterdam, The Netherlands KateM room: T.1.06 KateM tel: +31 205987870 KateM fax: +31 205987992 KateM e-mail: [EMAIL PROTECTED] KateM homepage: http://www.nat.vu.nl/~kate/ KateM On Fri, 7 Sep 2007, Jose Luis Aznarte M. wrote: Hi! I'm translating some code from Matlab to R and I found a problem. I need to translate Matlab's function 'lsqnonlin' (http://www-ccs.ucsd.edu/matlab/toolbox/optim/lsqnonlin.html) into R, and at the beginning I thought it would be the same as R's 'optim'. But then I looked at the definition of 'lsqnonlin' and I don't quite see how to make 'optim' to do the same thing. Does anyone have an idea? This is apart from the fact that I would like to use the Levenberg Marquardt algorithm which is not implemented in R (some discussion about this: http://tolstoy.newcastle.edu.au/R/help/00b/2492.html). Thank you! All the best, -- -- Jose Luis Aznarte M. http://decsai.ugr.es/~jlaznarte Department of Computer Science and Artificial Intelligence Universidad de Granada Tel. +34 - 958 - 24 04 67 GRANADA (Spain) Fax: +34 - 958 - 24 00 79 __ R-help@stat.math.ethz.ch 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. KateM __ KateM R-help@stat.math.ethz.ch mailing list KateM https://stat.ethz.ch/mailman/listinfo/r-help KateM PLEASE do read the posting guide http://www.R-project.org/posting-guide.html KateM and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch 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.
Re: [R] Matlab's lsqnonlin
The thread you linked to regarding Levenberg-Marquardt's supposed lack of availability is from 2001; it has been possible to get to the MINPACK implementation of Levenberg-Marquardt within R via the package minpack.lm (http://cran.r-project.org/src/contrib/Descriptions/minpack.lm.html) since 2005. Katharine Mullen mail: Department of Physics and Astronomy, Faculty of Sciences Vrije Universiteit Amsterdam, de Boelelaan 1081 1081 HV Amsterdam, The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] homepage: http://www.nat.vu.nl/~kate/ On Fri, 7 Sep 2007, Jose Luis Aznarte M. wrote: Hi! I'm translating some code from Matlab to R and I found a problem. I need to translate Matlab's function 'lsqnonlin' (http://www-ccs.ucsd.edu/matlab/toolbox/optim/lsqnonlin.html) into R, and at the beginning I thought it would be the same as R's 'optim'. But then I looked at the definition of 'lsqnonlin' and I don't quite see how to make 'optim' to do the same thing. Does anyone have an idea? This is apart from the fact that I would like to use the Levenberg Marquardt algorithm which is not implemented in R (some discussion about this: http://tolstoy.newcastle.edu.au/R/help/00b/2492.html). Thank you! All the best, -- -- Jose Luis Aznarte M. http://decsai.ugr.es/~jlaznarte Department of Computer Science and Artificial Intelligence Universidad de Granada Tel. +34 - 958 - 24 04 67 GRANADA (Spain) Fax: +34 - 958 - 24 00 79 __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] Estimate Fisher Information by Hessian from OPTIM
ChenYen wrote: Dear All, I am trying to find MLE by using OPTIM function. Difficult in differentiating some parameter in my objective function, I would like to use the returned hessian matrix to yield an estimate of Fisher's Information matrix. My question: Since the hessian is calculated by numerical differentiate, is it a reliable estimate? Otherwise I would have to do a lot of work to write a second derivative on my own. Thank you very much in advance [[alternative HTML version deleted]] When the objective function is based on a smooth function (in particular, a mix of exponentials) then in my experience the Fisher information matrix is the same as estimated via the finite difference approximation in numericDeriv or via analytical derivatives -- e.g., for the results discussed in Katharine M. Mullen, Mikas Vengris, and Ivo H. M. van Stokkum. Algorithms for separable nonlinear least squares with application to modelling time-resolved spectra. /Journal of Global Optimization/, vol 38, n 2, 201-213, 2007 (at http://www.nat.vu.nl/~kate/jgo2005.ps) __ R-help@stat.math.ethz.ch 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.
Re: [R] Write a summary or a longer text to a graphical device
one option is to display your information in a tcltk window - load tcltk and say demo(tkfaq) for an example of loading a txt file into a window with a scrollbar (to apply this example directly you would first write what you wanted to file) From: Torsten Mathies [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Write a summary or a longer text to a graphical device Date: Thu, 13 Jul 2006 22:39:37 +0200 How can I write a text, such as a result of a function or an explanation to a graphic device? When I try plot, I'm unable to reduce the axes. Greetings torsten __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Katharine Mullen Department of Physics and Astronomy Faculty of Sciences Vrije Universiteit Amsterdam de Boelelaan 1081 1081 HV Amsterdam The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] http://www.nat.vu.nl/~kate/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] click on graph and select data points?
if you are interested in a solution using the tcltk package, then an idea is to base a solution on the code for the demo tkcanvas. after installing the tcltk package, then require(tcltk) demo(tkcanvas) Katharine Mullen Department of Physics and Astronomy Faculty of Sciences Vrije Universiteit Amsterdam de Boelelaan 1081 1081 HV Amsterdam The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] http://www.nat.vu.nl/~kate/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Using R to process spectroscopic data
In the biophysics group of Vrije Universiteit Amsterdam we are working on an R package implementing a problem solving environment for multi-way spectroscopic modeling. We do not have a public version yet, but one will be made available in the future. We plan to describe the package at useR2006. If you are interested in the sort of (parametric model-based) analysis we are doing, you can see some project documentation at http://www.nat.vu.nl/comp/proj4.html. To reply to one of your questions, for determination of the optimal number of spectrally distinct components, you could simply take the SVD of your measurements and plot the singular values. The number of values that stand out may be used as an estimate of the number of components. Feel free to contact me for more information. We look forward to providing a complete and powerful package soon! Katharine Mullen Department of Physics and Astronomy Faculty of Sciences Vrije Universiteit Amsterdam de Boelelaan 1081 1081 HV Amsterdam The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] http://www.nat.vu.nl/~kate/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] tcltk package problems (R 2.2.0, SuSE 10)
i also had a problem getting 2.2.0 to work with tcltk on SuSE 10.0... and with compiling R from source on SuSE 10.0. on getting tcltk to work: i ended up taking source for tcl and tk from http://www.tcl.tk/software/tcltk/ and recompiling; once you unpack the tar.gz the install instructions are in the directory /unix for both programs. after that then capabilities() shows tcltk is TRUE and it works fine. i'm not sure if this was the easiest solution, but it worked. on getting SuSE 10 to compile R from source: i was unable to use Yast to get a fortran compiler and ended up recompiling gcc to include gfortran from the source (at e.g. http://gcc.fyxm.net/releases/gcc-4.0.2/ ) if you want some more detailed instructions feel free to mail me. best regards and good luck. Katharine Mullen Department of Physics and Astronomy Faculty of Sciences Vrije Universiteit de Boelelaan 1081 1081 HV Amsterdam The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] http://www.nat.vu.nl/~kate/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] playing with R: make a animated GIF file...
you could first make the frames to put together in R, then outside of R glue the frames into a gif. eg: frames-10 for(i in 1:frames) { jpeg(paste(ani_, i, .jpg, sep = )) plot(1:10,1:10, col = i) dev.off() } then use an image editing program to glue the jpgs together -- eg free and crossplatform imagemagick (www.imagemagick.org). under linux and once imagemagick is installed, the command $ convert -delay 10 ani_*.jpg animation.gif makes a looping animated gif `animation.gif' with 10/100 sec. between frame flips. Katharine Mullen Department of Physics and Astronomy Faculty of Sciences Vrije Universiteit de Boelelaan 1081 1081 HV Amsterdam The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] http://www.nat.vu.nl/~kate/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] eliminate t() and %*% using crossprod() and solve(A,b)
you might want to see Douglas Bates. Least squares calculations in R. R News, 4(1):17-20, June 2004. http://CRAN.R-project.org/doc/Rnews/ he gives some rules of thumb, eg use solve(A,b) not solve(A) %*% b use crossprod(X) not t(X) %*% X use crossprod(X,y) not t(X) y Katharine Mullen Department of Physics and Astronomy Faculty of Sciences Vrije Universiteit de Boelelaan 1081 1081 HV Amsterdam The Netherlands room: T.1.06 tel: +31 205987870 fax: +31 205987992 e-mail: [EMAIL PROTECTED] http://www.nat.vu.nl/~kate/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html