Hi Rui, how are you? That worked perfectly! Thank-you very much!
Irucka <-----Original Message-----> >From: Rui Barradas [[email protected]] >Sent: 12/19/2012 9:33:53 AM >To: [email protected] >Cc: [email protected] >Subject: Re: [R] probability of binary data > >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 > > _____________________________________________ >[email protected] 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. <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 – POP3 – Calendar – SMS – Translator – Much More!</font></font></span> [[alternative HTML version deleted]] ______________________________________________ [email protected] 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.

