From: Nadeem Shafique <nadeemshafique_at_gmail.com>

Date: Thu, 03 Jul 2008 10:25:07 +0100

x <- rmvnorm(n=n, mean=m, sigma=s)

pi <- x[,2]/sum(x[,2])

P <- pi*((1-2*pi)/(1-pi)+sum(pi/(1-pi))) Pi<-t(combn(pi,2))

y<-t(combn(x[,1],2))

PI<-t(combn(P,2))

yht <- y[,1]/PI[,1]+ y[,2]/PI[,2]

R-help_at_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. Received on Thu 03 Jul 2008 - 09:41:51 GMT

Date: Thu, 03 Jul 2008 10:25:07 +0100

library(mvtnorm)

library(combinat)

yg <- function(n,m,s) {

n<-10 m<-c(1,2) s<- matrix(c(4,.2,.2,3), ncol=2)

x <- rmvnorm(n=n, mean=m, sigma=s)

pi <- x[,2]/sum(x[,2])

P <- pi*((1-2*pi)/(1-pi)+sum(pi/(1-pi))) Pi<-t(combn(pi,2))

y<-t(combn(x[,1],2))

PI<-t(combn(P,2))

yht <- y[,1]/PI[,1]+ y[,2]/PI[,2]

*PIJ <- (Pi[,1]*Pi[,2]*(2-Pi[,1]-Pi[,2]))/((1-Pi[,1])*(1-Pi[,2]))*

Eyht <- sum(yht*PIJ)

E2yht <- sum(yht^2*PIJ)

var1 <- E2yht - Eyht^2

var1

}

I want to impose the condition on PIJ(which is a vector). If any value in
the PIJ is negative then go back and take another sample until a sample is
selected which produces the PIJ positive(all values in PIJ).

I hope now you can understand.

Best Regards,

Nadeem Shafique Butt

[[alternative HTML version deleted]]

R-help_at_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. Received on Thu 03 Jul 2008 - 09:41:51 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Thu 03 Jul 2008 - 12:31:52 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*