[R] typsize and fscale arguments to nlm
John Fox
jfox at mcmaster.ca
Mon Aug 5 15:15:15 CEST 2002
Dear Martin,
Thank you for answering my question. I'm impressed that you would pay
attention to a two-week-old question. In the interim I obtained and read
the two references in the documentation, which clarified what typsize and
fscale are and how they are used in the algorithm (which is why I didn't
repost the question).
With respect to the documentation, my remark was probably unfair -- it's
not reasonable to ask for detailed documentation of such a complicated
function. I think, though, that I would replace the word "size" here with
"absolute value," which seems to me more precise in this context (or just
put "absolute value" within parentheses after size as a clarification), and
perhaps say briefly how these arguments are used in the algorithm.
It occurred to me that I could look at the source code, but I'm not a very
good C programmer. I'd have a better chance to figure out what the code is
doing if it were in FORTRAN -- which dates me, I guess. Even if the code
were in FORTRAN, I'm probably not sufficiently clever to understand it
without reading the references.
Thanks again,
John
At 09:56 AM 8/5/2002 +0200, you wrote:
>nobody seems to have answered this on R-help.
> >>>>> "John" == John Fox <jfox at mcmaster.ca> writes
>on July 22 :
>
> John> Dear R list members, I have a question about the
> John> proper use of the typsize and fscale arguments to nlm.
>
> John> I use nlm in my sem package to fit general
> John> structural-equation models, which entails maximizing a
> John> multinormal likelihood with respect to parameters that
> John> represent regression coefficients and covariances of
> John> variables. The magnitudes of these parameters can be
> John> very different.
>
> John> The documentation for typsize is rather terse: "an
> John> estimate of the size of each parameter at the
> John> minimum," with the default typsize=rep(1, length(p))
> John> [where length(p) gives the number of parameters]. Am I
> John> correct in interpreting the "size of each parameter"
> John> as its absolute values?
>
>yes ``typical absolute values''
>
> John> as its absolute values? If so, is it reasonable to
> John> specify typsize=abs(start), where start contains that
> John> start values of the parameters?
>Yes -- unless some `start[j]' is ``untypically'' close to zero ..
>
> John> I can compute start values that have generally
> John> reasonable magnitudes (certainly more generally
> John> reasonable than assuming that all parameters are of
> John> the same magnitude) and that will never be identically
> John> 0. A related question is whether typsize specifies the
> John> relative or absolute "sizes" of the parameters.
>
>absolute.
>
>Note that R is open source and (if you don't have the references
>that help(nlm) mentions) you can always read the source code.
>In this case, the really relevant things are in src/appl/uncmin.c
>whose optif9() is called from do_nlm() in src/main/optimimze.c}.
>Note that "typsize" is "typsiz" in the C code (since that is
>translated from Fortran which had a 6-letter limitation).
>
>Typical lines in uncmin.c are
>
> 1788: gs = fmax2(fabs(f), fscale) / fmax2(fabs(x[i]), typsiz[i]);
>
> 1858: hs = fmax2(fabs(g[j]), 1.0) / fmax2(fabs(x[j]), typsiz[j]);
>
>where the first tells you how `fscale' is used and both show you
>how the `typsize[]' vector is.
>
>
> John> Finally, there is another argument to nlm called
> John> fscale which specifies "an estimate of the size of f
> John> at the minimum" (where f is the function to be
> John> minimized -- in my case the negative
> John> log-likelihood). The default is fscale=1. In
> John> experimenting with nlm I've found that using
> John> typsize=abs(start) appears to make my sem function
> John> more robust (e.g., less sensitive to start values when
> John> the parameters are of very different magnitudes), but
> John> setting fscale to the log-likelihood at the start
> John> values for the parameters seems to create problems.
>
> John> Any help, advice, or additional information would be
> John> appreciated. (I plan to take a look at the Dennis and
> John> Schnabel text cited in the help file for nlm but have
> John> not yet done so.)
>
> John> Thanks, John
>
>You're welcome.
>Could you (`in return') propose improvements to the text
>in help(nlm) ?
>
>My answering above should really be an incentive for people
>to start reading source code....
>Martin
>
> John> John Fox Department of Sociology McMaster University
> John> Hamilton, Ontario, Canada L8S 4M4 email:
> John> jfox at mcmaster.ca phone: 905-525-9140x23604 web:
> John> www.socsci.mcmaster.ca/jfox
> John> -----------------------------------------------------
>
>Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
>Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
>ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
>phone: x-41-1-632-3408 fax: ...-1228 <><
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list