[R] typsize and fscale arguments to nlm
Martin Maechler
maechler at stat.math.ethz.ch
Mon Aug 5 09:56:14 CEST 2002
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 <><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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