Dear all, Given rr<-data.frame(r1<-rnorm(1000,10,5),r2<-rnorm(1000,220,5)) How can I add a column (rr$p) for the joint probability of each r1 & r2 pair? I know how to add the column.. I just dont know how to compute the p value for joint probabilities given the two samples. //M
On 2011-01-31 12:42, moleps wrote:> Dear all, > > Given > > rr<-data.frame(r1<-rnorm(1000,10,5),r2<-rnorm(1000,220,5)) > > > How can I add a column (rr$p) for the joint probability of each r1& r2 pair?If you take the values in each pair to be observations from two independent Normal distributions, it's easy: The "joint probability" of those values is zero. But I suspect you mean something else by "joint probability". Can you elaborate? Peter Ehlers> I know how to add the column.. I just dont know how to compute the p value for joint probabilities given the two samples. > > > //M > > ______________________________________________ > 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.
On Mon, Jan 31, 2011 at 09:42:27PM +0100, moleps wrote:> Dear all, > > Given > > rr<-data.frame(r1<-rnorm(1000,10,5),r2<-rnorm(1000,220,5)) >Hello. There is already an answer to your question. However, i think that the above command works in a different way than you expect. The embedded assignments create vectors r1, r2 and the names of columns are derived from the whole expressions "r1<-rnorm(1000,10,5)" and "r2<-rnorm(1000,220,5)". If there are no other variables, then you get rr<-data.frame(r1<-rnorm(1000,10,5),r2<-rnorm(1000,220,5)) ls() [1] "rr" "r1" "r2" rr[1:3, ] r1....rnorm.1000..10..5. r2....rnorm.1000..220..5. 1 8.639778 227.3891 2 17.477301 227.4780 3 5.640543 227.7373 If r1, r2 should be the names of the columns, then use named arguments in the call of the function data.frame() rr<-data.frame(r1=rnorm(1000,10,5),r2=rnorm(1000,220,5)) rr[1:3, ] r1 r2 1 12.3274362 224.7632 2 13.1347464 214.3805 3 0.7495177 219.6179 Petr Savicky.