Can some kind person point out my error here? I'm trying to set up a grid for a countour plot of a likelihood function.

> u <- rnorm(20,9.5,2.5)
> # sample of size 20 from N(9.5,2.5^2)
> loglik <- function(th1,th2) {
+ n <- length(u)
+ -(n/2)*log(2*pi*th2^2)-0.5*sum((u-th1)^2/th2^2)
+ }
> x <- seq(4.5,14.5,len=50)
> y <- seq(0.5,6,len=50)
> f <- outer(x, y, loglik(x,y))
Error in match.fun(FUN) : not function, character, or symbol: "loglik(x, y)"
In addition: Warning message:
longer object length
        is not a multiple of shorter object length in: u - th1
> loglik(9,2)
[1] -44.56294
> is.function(loglik)
[1] TRUE

Thanks,

Murray
--
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: [EMAIL PROTECTED]                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    +64 7 849 6486 home    Mobile 021 1395 862

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to