[R] How to find the index
Dear R experts, i have a vector z , i have to do something after z is sorted. how can i find the original index, i.e., before sorting, of a certain element in the sorted vector . thanks in advance regards --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] Non R Subject
Hi, all. This mail has nothing to do with R . But as a Chinese, I feel responsible to send this mail. :) The 2008 Beijing Olympics is beginning , welcome to Beijing ! best regards ! --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] Sum(Random Numbers)=100
Hi, I am afraid there is no other way except using brute force, that is , loop until their sum reaches your expectation. it is easy to figure out this probability by letting their sum to be a new random variable Z and Z = X_1 + \ldots + X_n where X_i ~ Poisson({\lambda}_i) . By calculating their moment generate function we can find the pmf of Z which is a new Poisson random variable with the parameter \sum_{i}{{\lambda}_i}. and Moshe Olshansky's method is also correct except it is based on the conditioning. On 2008-7-8, at 下午1:58, Shubha Vishwanath Karanth wrote: On 2008-7-8, at 下午2:39, Moshe Olshansky wrote: If they are really random you can not expect their sum to be 100. However, it is not difficult to get that given that the sum of n independent Poisson random variables equals N, any individual one has the conditional binomial distribution with size = N and p = 1/n, i.e. P(Xi=k/Sn=N) = (N over k)*(1/n)^k*((n-1)/n)^(N-k). So you can generate X1 binomial with size = 100 and p = 1/50; if X1 = k1 then the sum of the rest 49 must equal 100 - k1, so now you generate X2 binomial with size = 100-k1 and p = 1/49; if X2 = k2 then generate X3 binomial with size = 100 -(k1+k2) and p = 1/48, etc. Why do you need this? --- On Tue, 8/7/08, Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote: From: Shubha Vishwanath Karanth [EMAIL PROTECTED] Subject: [R] Sum(Random Numbers)=100 To: [EMAIL PROTECTED] Received: Tuesday, 8 July, 2008, 3:58 PM Hi R, I need to generate 50 random numbers (preferably poisson), such that their sum is equal to 100. How do I do this? Thank you, Shubha This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ 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. __ 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. --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] what does this warning mean ?
Hi , dear R experts . I use the package mclust to do some cluster analysis . doing the example that the document provides faithfulModel - Mclust( faithful ) plot( faithfulModel ) I remember in R 2.7.0 I can get several figures using the plot command, but after I update R, using the same statements, after I get the first figure and I press enter as R tells and I get Warning message:In plot.Mclust(faithfulMclust) : data not supplied. I tried other data set , the warning message still exists . what does it mean? how can i do to avoid it ? is there any resource that I can find solution to specific warning like some IDE(like Xcodes in mac or Eclipse , etc.) does??? thanks in advance. best regards. --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] about EM algorithm
Hi, dear R experts . is there any package contain an universal EM procedure, that is , for arbitrary d.f. , not just the one in mclust . thanks in advance best regards --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] help about random generation of a Normal distribution of several variables
Hi, Arnau, mvrnorm() in MASS library is what you need. ? mvrnorm to see the detail but first you need to load the MASS library, i.e,library(MASS) regards/ On 2008-7-6, at 上午12:21, Arnau Mir wrote: Hello. Somebody knows how can I generate a set of n random vectors of a normal distribution of several variables? For example, I want to generate n=100 random vectors of two dimensions for a normal with mean c(0,1) and variance matrix: matrix(c(2,1,1,3), 2,2). Thanks in advance, Arnau. __ 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. --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] help about random generation of a Normal distribution of several variables
Hi , Arnau Did you ever check your mailbox? your question was answered last night Beijing time. :) Just read the following . - There is no need to load the MASS library, since the code for mvrnorm therein is compact and self-contained: mvrnorm - function (n=1, mu, Sigma, tol=1e-06, empirical=FALSE) { p - length(mu) if(!all(dim(Sigma) == c(p, p))) stop(incompatible arguments) eS - eigen(Sigma, symmetric = TRUE, EISPACK = TRUE) ev - eS$values if(!all(ev = -tol * abs(ev[1]))) stop('Sigma' is not positive definite) X - matrix(rnorm(p * n), n) if(empirical) { X - scale(X, TRUE, FALSE) X - X %*% svd(X, nu = 0)$v X - scale(X, FALSE, TRUE) } X - drop(mu) + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) nm - names(mu) if(is.null(nm) !is.null(dn - dimnames(Sigma))) nm - dn[[1]] dimnames(X) - list(nm, NULL) if(n == 1) drop(X) else t(X) } Define that function as above, then proceed along the lines suggested by Gavin Simpson below. Ted. On 05-Jul-08 16:43:46, Gavin Simpson wrote: On Sat, 2008-07-05 at 18:21 +0200, Arnau Mir wrote: Hello. Somebody knows how can I generate a set of n random vectors of a normal distribution of several variables? For example, I want to generate n=100 random vectors of two dimensions for a normal with mean c(0,1) and variance matrix: matrix(c(2,1,1,3),2,2). One is mvrnorm() in the MASS package, part of the VR bundle that comes with R. require(MASS) mu - c(0,1) Sigma - matrix(c(2,1,1,3),2,2) res - mvrnorm(100, mu = mu, Sigma = Sigma) head(res) [,1][,2] [1,] 2.7582876 1.04208798 [2,] 0.6364184 -0.08043244 [3,] -1.8897731 0.04051395 [4,] 2.6699881 0.83163661 [5,] -1.1942385 -1.17503716 [6,] -0.4303459 -0.80880649 HTH G E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 05-Jul-08 Time: 18:09:23 -- XFMail -- __ 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. On 2008-7-6, at ä¸å12:13, Arnau Mir Torres wrote: Hello. Somebody knows how can I generate a set of n random vectors of a normal distribution of several variables? For example, I want to generate n=100 random vectors of two dimensions for a normal with mean c(0,1) and variance matrix: matrix(c(2,1,1,3),2,2). Thanks in advance, Arnau. __ 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]] __ 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.
[R] what can we do when R gives no response
Hi, dear R experts , I am new. I met this problem when I am trying to learn how to use the nlminb() function. I tried the example which the document provides ( as the following code ) and R gives no response . I don't know whether it is running or not and it takes a very long time but still output nothing so I just close the session window. my question is is there any method that I can see the running status of a R program or what can I do if R gives no response??? thank you in advance. here is my sessionInfo i386-apple-darwin8.10.1 locale: zh_CN.UTF-8/zh_CN.UTF-8/C/C/zh_CN.UTF-8/zh_CN.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] mclust_3.1-5 x - rnbinom(100, mu = 10, size = 10) hdev - function(par) { -sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE)) } nlminb(c(9, 12), hdev) --- Peng Jiang æ±é¹ ,Ph.D. Candidate Antai College of Economics Management å®æ³°ç»æµç®¡çå¦é¢ Department of Mathematics æ°å¦ç³» Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China [[alternative HTML version deleted]] __ 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.
Re: [R] what can we do when R gives no response
Hi, Jim thanks for your reply, I tried the scripts it still does not give any response on my mac. I have to stop in manually. what is your sessionInfo ? Thanks again. On 2008-7-3, at 上午10:10, jim holtman wrote: I ran you script and it came back in less than 1 second: x - rnbinom(100, mu = 10, size = 10) hdev - function(par) { + -sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE)) + } nlminb(c(9, 12), hdev) $par [1] 9.760001 13.802305 $objective [1] 278.9434 $convergence [1] 0 $message [1] relative convergence (4) $iterations [1] 11 $evaluations function gradient 12 31 On Wed, Jul 2, 2008 at 8:41 PM, Peng Jiang [EMAIL PROTECTED] wrote: Hi, dear R experts , I am new. I met this problem when I am trying to learn how to use the nlminb() function. I tried the example which the document provides ( as the following code ) and R gives no response . I don't know whether it is running or not and it takes a very long time but still output nothing so I just close the session window. my question is is there any method that I can see the running status of a R program or what can I do if R gives no response??? thank you in advance. here is my sessionInfo i386-apple-darwin8.10.1 locale: zh_CN.UTF-8/zh_CN.UTF-8/C/C/zh_CN.UTF-8/zh_CN.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] mclust_3.1-5 x - rnbinom(100, mu = 10, size = 10) hdev - function(par) { -sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE)) } nlminb(c(9, 12), hdev) --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China [[alternative HTML version deleted]] __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] if one of 4 conditions is not satisfied
use c() to make your condition a vector, try to use all() to return a logical value for the entire condition vector . On 2008-7-1, at 下午8:40, mysimbaa wrote: I'm trying to do realize the following: I have 4 condtions. If all conditions are satisfied I will paste(PASS) If any of these is not satisfied I will paste(FAIL). But I have to paste the corresponding failure. ifelse is a good solution but for a 2 conditions. Maybe switch or something like this. Does anyone have an idea how to do? Thanks in advance. Adel -- View this message in context: http://www.nabble.com/if-one-of-4-conditions-is-not-satisfied-tp18214194p18214194.html Sent from the R help mailing list archive at Nabble.com. __ 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. --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] Estimating parameters of log-normal distribution
Hi, Gunther, maybe fitdistr() in MASS library can do the job , the code should be library(MASS) fitdistr( x, densfun = log-normal) by using your data we can obtain the parameters , meanlog sdlog 2.5808007 1.2999517 (0.3752637) (0.2653515) is that what you want? On 2008-6-30, at 下午5:26, Gunther Höning wrote: Dear list, I have to vectors: x - rep(c(2,4,8,24,48,72),2) y - c (82543,169105,207615,96633,31988,7005,82687,172931,205541,101842,31898,69 50) that follows a log-normal function as f(x)= SO/(sqrt(2*pi)*sigma *x) * exp(-(ln x - mu)^2/(2*sigma^2)) that is a log-normal distribution multiplied with SO. How can I estimate SO, mu and sigma in R ? Wishes Gunther __ 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. --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] Which distribution best fits the data?
I agree with Ben . without providing any information of the data, we cannot make inference on the distribution itself. actually density estimation is a tough problem( and classical ). Of course, there are methods like GMM or some other method based on statistical learning, however, they make assumptions and only do the approximation. I hope anyone can explain more on this topic using more R specific language. On 2008-6-30, at 下午7:50, Ben Bolker wrote: Jenny Barnes jmb at mssl.ucl.ac.uk writes: Dear R-help community, Does anybody know of a stats function in R that tells you which distribution best fits your data? I have tried look through the archives but have only found functions that tell you if it's normal or log etc. specifically - I am looking for a function that tells you (given a timeseries) what the distribution is. Any help/advice will be greatly appreciated, All the best, Jenny Barnes jmb at mssl.ucl.ac.uk The problem is that it's not generally a good idea to data-dredge in this way. Your best bet is to think about the characteristics of the data (discrete or continuous, non-negative or real, symmetric or skewed) and try to narrow it down to a few distributions -- then you can use fitdistr() (from the MASS package) or something similar to compare among them. If you say a little bit more about what you're trying to do with the data you might get some more specific advice. Ben Bolker __ 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. --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] Mclust ???
Hi ,Ping . There ARE two components using the iris[,-5] data. The Mclust method is using the BIC value to obtain the optimal number of components of the model, and the result is two. Try to use Mc$parameters to see the parameters for each component. I suggest u to read the help document seriously. best regards. On 2008-6-30, at 下午8:40, 王春萍 wrote: hello everyone I have used the function Mclust, and i found the result(the component $z) is just two class, why? Mc - Mclust(iris[,-5]) Mc$z thanks wangchunping __ 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. --- Peng Jiang 江鹏 ,Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] Fwd: cannot install the package RMySQL
Hi, I first report the installing error to the r-sig-mac mailing list but it seems nobody ever encounter this annoying problem and I got no replies. so I am trying to forward it to this list, hope it never bothers. Anyone had the same problem, or what does the warning message mean ? Thank you in advance ! Begin forwarded message: From: Peng Jiang [EMAIL PROTECTED] Date: 2008å¹´6æ29æ¥ ä¸å11æ¶06å22ç§ To: [EMAIL PROTECTED] Subject: cannot install the package RMySQL Hi, I am writing to report the error when installed the package RMySQL. I tried installing for like 5 times and it gives the following error every time. gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now is it because all the downloading error or something else ? I am running Mac OS X 10.5.3 with R 2.7.1. thanks in advance. best regards --- Peng Jiang (æ±é¹), Ph.D. Candidate Antai College of Economics Management å®æ³°ç»æµç®¡çå¦é¢ Department of Mathematics æ°å¦ç³» Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China --- Peng Jiang æ±é¹ ,Ph.D. Candidate Antai College of Economics Management å®æ³°ç»æµç®¡çå¦é¢ Department of Mathematics æ°å¦ç³» Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China [[alternative HTML version deleted]] __ 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.
Re: [R] String concatenation
Hi, Andy I am a little confused, why don't you just use paste() directly? paste(12,3,45,sep=) produce the same result with your concat. regards . On 2008-6-28, at 下午7:44, Andy Fugard wrote: Hi, Is the following function built in somewhere? concat = function(v) { res = for (i in 1:length(v)) res = paste(res,v[i],sep=) res } e.g. concat(c(12,3,45)) [1] 12345 Cheers, Andy -- Andy Fugard, Postgraduate Research Student Psychology (Room F3), The University of Edinburgh, 7 George Square, Edinburgh EH8 9JZ, UK Mobile: +44 (0)78 123 87190 http://www.possibly.me.uk The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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. --- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] (no subject)
Hi , Ping, First you should report more detail about your problem and make sure it is a R specific one. To find out more on using hclust, I suggest you try help(hclust). I am not sure about what result you want to obtain since the result of hclust seems straight forward. By the way, to perform cluster analysis there is another package called mclust which is easier and stronger. regards. On 2008-6-27, at 下午3:57, 王春萍 wrote: Dear everyone: I am now doing one exercise with hclust and i do not know how to deal with the reslut as produced by it! My aim is to find out the number of clusters and what are the members for each cluster? So I am writing to here to get your help thanks in advance! chunping wang __ 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. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] binomial distribution
Hi, xiechao i don't think that is a R specific problem. you mean u got two random variables X,Y and both of them binomial distributed and you want to find the distribution of a new variable Z = X/Y. That is a basic transformation problem. u can start with introducing a new r.v. namely W, by letting it equal to X you obtain W=X,Z=X/Y from which u have X = W and Y = W / Z. It is easy to find the Jacobian of this transformation, and the left is routinely. regards. On 2008-6-27, at 下午8:29, Xie Chao wrote: Hi all, I am a biological student and need your help in statistics. I have two sets of binomial distributed numbers: {a1, a2, ..., an} and {b1, b2, ..., bn}. How can I get the distribution of the ratios of the two sets of numbers {a1/b1, a2/b2, ..., an/bn}? Is there a formula to transform the distributions? Or where I can start if I want to learn necessary techniques? Thank you a lot! xiechao [[alternative HTML version deleted]] __ 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. --- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] Average of Two Matrices
Hi, Gundala pretty much u can do is adding them directly , that is , treat them like two numbers instead of matrix. z - (x+y)/2 . Is that what u want ? or u have another meaning. regards On 2008-6-25, at 上午10:19, Gundala Viswanath wrote: Hi, I have two matrices x and y (same dimensions). How can I compute the average of x and y for each coordinate to form a new average matrix z ? - Gundala Viswanath Jakarta - Indonesia __ 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. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] tiff()-bug (was re:Preparing high quality figures with tiff as end result)
Hi , Gustaf i don't know why but it works pretty well on a mac. regards . On 2008-6-25, at 下午4:16, Uwe Ligges wrote: Gustaf Rydevik wrote: Hi all, A while back I sent a message concerning working with tiff-files, and mentioned that I encountered a bug in 2.7.0. This bug still occurs in 2.7.1, and is reproducable on a separate computer (both running WinXP professional): tiff() plot(1:1000) dev.off() This causes R to show the window R GUI has encountered a problem and needs to close. Can anyone else out there reproduce this, so I can file a bug report? Yes. Confirmed. Uwe Ligges Best, Gustaf Rydevik --- sessionInfo() R version 2.7.1 (2008-06-23) i386-pc-mingw32 locale: LC_COLLATE=Swedish_Sweden.1252;LC_CTYPE=Swedish_Sweden. 1252;LC_MONETARY=Swedish_Sweden. 1252;LC_NUMERIC=C;LC_TIME=Swedish_Sweden.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RWinEdt_1.8-0 loaded via a namespace (and not attached): [1] tools_2.7.1 __ 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. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] How to solve empty cells in the contingency table?
Hi , yan I don't think that is a R specific problem. Treating missing value is not that trivial, it depends too much on your raw data and your essential problem. regards. On 2008-6-25, at 上午2:14, 程燕 wrote: Hi,Dear all R experts, I am trying to do the 2-way contingency table analysis by fitting the loglinear models. However, I found my table has several empty cells which are theoretically missing values.I have no idea of how to solve them coz we cannot compute the simulated p-value with zero marginals.Does someone have some suggestions? Please help me out, thanks a lot! Cheers, Yan _ ÐÂÄê»»ÐÂÑÕ£¬¿ìÀ´×± °ç×Ô¼ºµÄMSN¸øÐÄÒǵÄTAÒ»¸ö¾ªÏ²£¡ http://im.live.cn/emoticons/?ID=18 [[alternative HTML version deleted]] __ 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. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] Simulating Gaussian Mixture Models
Hi, Is there any package that I can use to simulate the Gaussian Mixture Model , which is a mixture modeling method that is widely used in statistical learning theory. I know there is a mclust, however, I think it is a little bit different from my problem. Thanks very much.. regards. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] Cluster on both categorical and numerical data
hi, Chua Siang I think the mclust package is what you need. regards. On 2008-6-18, at 下午5:46, Chua Siang Li wrote: Hello there. Is there any function in R that can do cluster on a set of data that has both categorical and numerical variables? thanks. siangli __ 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. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
Re: [R] combining two data frames
Hi, haibing . you should try rbind or cbind. Type help(rbind) or ? rbind in the command line . regards. On 2008-6-18, at 上午6:33, calundergrad wrote: i know this is a very simple question but i have two data frames (one of which is a continuation of the first data frame) and i was just wondering how do you combine those? any simple solution would be helpful. thank you very much -- View this message in context: http://www.nabble.com/combining-two-data-frames-tp17956137p17956137.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] why does these warning mean?
Hi , I don't know whether it is a Mac specific problem. I hope it does not bother you. When I start R each time I got the following warning , I reinstall for many times the problem still exists. R(4053,0xa0619fa0) malloc: *** error for object 0x15630350: double free *** set a breakpoint in malloc_error_break to debug R(4053,0xa0619fa0) malloc: *** error for object 0x15630f10: double free *** set a breakpoint in malloc_error_break to debug R(4053,0xa0619fa0) malloc: *** error for object 0x15630350: double free *** set a breakpoint in malloc_error_break to debug R(4053,0xa0619fa0) malloc: *** error for object 0x15630f60: double free *** set a breakpoint in malloc_error_break to debug My sessionInfo() is sessionInfo() R version 2.7.0 (2008-04-22) i386-apple-darwin8.10.1 locale: zh_CN.UTF-8/zh_CN.UTF-8/C/C/zh_CN.UTF-8/zh_CN.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] simulating Gaussian Mixture Method
Hi, I have a mixture pdf which has three components, each satisfies the 6 dimension normal distribution. I use mvrnorm() from the MASS library to generate 1000 samples for each component and I add them to get the random samples which satisfies with the mixture distribution. I use Mclust() from the mclust library to get the model of the samples and strange things happened. First it gave a warning samplesMclust - Mclust( samples ) Warning messages: 1: In summary.mclustBIC(Bic, data, G = G, modelNames = modelNames) : best model occurs at the min or max # of components considered 2: In Mclust(samples) : optimal number of clusters occurs at min choice Then I input samplesMclust best model: XXI with 1 components it says the best model is with 1 component ! I am confused ... Is it because the way that I generate samples is wrong??? thanks so much ! -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.
[R] Generate Random Samples
Hi, I am a newbie to R and I am working with a Mac. Is there any package that I can use to generate random samples from a user defined distribution ? That is , I define a distribution function ( maybe multi dimension ) and I want some random samples generated from my this distribution. Or, there is a more specific problem . If I have a three component mixture with each of them being normal distribution( say 3 dimension ) , is there any package that I can use to generate random samples from this mixture . I know I can generate random samples from each individual component. However, can I just add them directly Thanks. -- Peng Jiang 江鹏 Ph.D. Candidate Antai College of Economics Management 安泰经济管理学院 Department of Mathematics 数学系 Shanghai Jiaotong University (Minhang Campus) 800 Dongchuan Road 200240 Shanghai P. R. China __ 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.