outer(b1,b2,FUN=bpllkd,x=x,y=y,n=n)
I don't think "outer" quite knows what to do with "x, y, n)". However, "x=x1, y=y1, n=n1") clearly tells outer to pass the object x1 to the argument x of function bpllkd, etc.
hope this helps. spencer graves p.s. I was just bitten by that snake last week.
Ravi Varadhan wrote:
Hi:
I am using R 1.7.0 on Windows. I am having trouble getting "outer" to work on one of my functions. Here is a simple example illustrating my problem:
b1 <- c(1.2,2.3) b2 <- c(0.5,0.6) x <- c(3e+01, 1e+02, 3e+02, 5e+02, 1e+03, 1e+04, 1e+05, 1e+06) y <- c(2,4,2,5,2,3,1,1) n <- c(5,8,3,6,2,3,1,1)
outer(b1,b2,FUN=bpllkd,x,y,n)
[,1] [,2] [1,] 17.78031 17.78031 [2,] 17.78031 17.78031
These values should all be different. What is the problem here? The function "bpllkd" is given below:
thanks for any help, Ravi.
bpllkd
function(t1,t2,x,y,n){ p <- 1 - (1+x/10^t1)^(-t2) keep <- !((p==0 & y==0) | (p==1 & n==y)) llk <- sum(y[keep]*log(p[keep])+(n-y)[keep]* log(1-p[keep])) return(-llk) }
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help