Hello,,

Try the following.


f2 <- function(obs, dat){
     obs <- as.logical(obs)
     dat <- as.logical(dat)
     s1 <- sum(obs & dat)
     s2 <- sum(obs & !dat)
     s3 <- sum(!obs & dat)
     s1/(s1 + s2 + s3)
}

observed <- matrix(c(0, 1, 0, 0, 1, 1, 1, 0, 0),3,3,byrow=TRUE)
data <- matrix(c(1, 1, 0, 0, 1, 0, 0, 0, 1),3,3,byrow=TRUE)

f2(observed, data)


Hope this helps,

Rui Barradas
Em 19-12-2012 15:10, Irucka Embry escreveu:
> Hi, how are you?
>
> I am trying to replicate the binary data f(2) function in the attached
> document by starting with the simple example found below:
>
> observed <- matrix(c(0, 1, 0, 0, 1, 1, 1, 0, 0),3,3,byrow=TRUE)
> data <- matrix(c(1, 1, 0, 0, 1, 0, 0, 0, 1),3,3,byrow=TRUE)
>
> f2 = sum(probability of the matrix element where the matrix element is
> present in both the observed and the data)/[sum(probability of the
> matrix element where the matrix element is present in both the observed
> and the data) + sum(probability of the matrix element where the matrix
> element is present in the observed and absent in the model) +
> sum(probability of the matrix element where the matrix element is absent
> in the observed and present in the model)]
>
> What is the best way to create the f2 function in R?
>
> Thank-you.
>
> Irucka Embry
>
>
> <span id=m2wTl><p><font face="Arial, Helvetica, sans-serif" size="2" style="font-size:13.5px">_______________________________________________________________<BR>Get the Free email that has everyone talking at <a href=http://www.mail2world.com target=new>http://www.mail2world.com</a><br>  <font color=#999999>Unlimited Email Storage &#150; POP3 &#150; Calendar &#150; SMS &#150; Translator &#150; Much More!</font></font></span>
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


	[[alternative HTML version deleted]]


