# [R] creating a grid of function values

Douglas Bates bates at stat.wisc.edu
Thu Feb 10 21:28:49 CET 2000

```I want to create a grid of function values for use in `contour' or
`persp'.  The function is the log-likelihood for the gamma.  The
sample is stored as vector of length 20 called `Survival'.

A single evaluation of the log-likelihood at, say, scale = 9 and shape
= 10 would be obtained by
sum(dgamma(Survival, scale = 9, shape = 10, log = TRUE))
(This may work only 0.99.0, I'm not sure.)

I would like to evaluate such a function on a grid of scale and shape
values.  I don't think I can use `outer' because of the way the
evaluation of the dgamma function would vectorize.  Although I could
write the calculation for the grid in `for' loops, I have a nagging
suspicion that there is a cleaner way that I have forgotten.

Can anyone remind me of a slick way of generating the grid?

--
Douglas Bates                            bates at stat.wisc.edu
Statistics Department                    608/262-2598
University of Wisconsin - Madison        http://www.stat.wisc.edu/~bates/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```