Re: [R] Basic Vector and Matrix Operations

2008-07-07 Thread Xiaohui Chen
Eric Turkheimer 写道: I am wondering if it is possible to perform the following two basic functions with primitive R functions. I know I could write functions for either, but it seems as though they are probably built-in somewhere. 1) Fill out a vector to a desired length with missing values or

Re: [R] help

2008-06-29 Thread Xiaohui Chen
mclust is not doing the hierarchicial clustering, if I understand your question correctly. Presumably you define certain distance measure, hclust and cut funtions should do the job. On the other hand, if the purpose is to extract the classification labels from mclust package, it should be strai

Re: [R] Simulating Gaussian Mixture Models

2008-06-22 Thread Xiaohui Chen
First, simulate a uniform r.v on [0,1] and then cast it to binary label according to your underlying mixing probability; Second, simulate a Gaussian r.v. in above selected component. Of course, you can vecterize the two steps to simply your code. X Peng Jiang 写道: Hi, Is there any package

Re: [R] existing package (mmlcr) modification -- appropriate process?

2008-05-29 Thread Xiaohui Chen
Hi Jenny, A simple solution is to add your line to the function, re-load/source the modified function to the console (e.g. by copy and paste). Then the new function with the same name as the original one will be called next time. If you don't want to use modified function any longer, just use

Re: [R] How do you exit a function in R?

2008-05-29 Thread Xiaohui Chen
stop('Different number of assets! \n\n') X Bill Cunliffe 写道: For example, based on a certain condition, I may want to exit my code early: # Are there the same number of assets in "prices" and "positions"? if (nAssetPositions != nAssetPrices) {

Re: [R] Accessing Value of binom.test

2008-05-28 Thread Xiaohui Chen
binom.test(x=12, n=50, p=12/50, conf.level = 0.90)$estimate Gundala Viswanath 写道: With this line: binom.test(x=12, n=50, p=12/50, conf.level = 0.90) I get this output: Exact binomial test data: 12 and 50 number of successes = 12, number of trials = 50, p-value = 1 alte

Re: [R] can I do this with R?

2008-05-28 Thread Xiaohui Chen
Andrew Robinson 写道: On Wed, May 28, 2008 at 03:47:49PM -0700, Xiaohui Chen wrote: Frank E Harrell Jr ??: Xiaohui Chen wrote: step or stepAIC functions do the job. You can opt to use BIC by changing the mulplication of penalty. I think AIC and BIC are not only limited to

Re: [R] can I do this with R?

2008-05-28 Thread Xiaohui Chen
Frank E Harrell Jr 写道: Xiaohui Chen wrote: step or stepAIC functions do the job. You can opt to use BIC by changing the mulplication of penalty. I think AIC and BIC are not only limited to compare two pre-defined models, they can be used as model search criteria. You could enumerate the

Re: [R] can I do this with R?

2008-05-28 Thread Xiaohui Chen
step or stepAIC functions do the job. You can opt to use BIC by changing the mulplication of penalty. I think AIC and BIC are not only limited to compare two pre-defined models, they can be used as model search criteria. You could enumerate the information criteria for all possible models if t

Re: [R] Rotated text on a regression line

2008-05-27 Thread Xiaohui Chen
Note that the scale of x-axis and y-axis is different in your plot. One simple way to avoid this is to keep the data unit in the x direction is equal that in the y direction, by setting asp=1 in calling plot function. X Dr. Christoph Scherber 写道: Dear all, I stumbled over a problem recently

Re: [R] GMM estimation

2008-05-27 Thread Xiaohui Chen
were you meaning Gaussian mixture model? If so, try the mclust package. But you might want to try to learn how to search using R website resourse, try RSiteSearch('GMM') X Correia 写道: > Hello there!!! > > Sorry to bother you all with such question and difficulties that I have been > facing on.

Re: [R] maximizing the gamma likelihood

2008-05-24 Thread Xiaohui Chen
Hi Mark, As I said in earlier emails, you do NOT need to explicitly code the likelihood function for gamma distn. I just code you example as below: vsamples<- c(14.7, 18.8, 14, 15.9, 9.7, 12.8) gamma.nll <- function(par,data) -sum(dgamma(data,shape=par[1],scale=par[2],log=T)) optim(c(1,1),ga

Re: [R] Log likelihood of Gamma distributions

2008-05-20 Thread Xiaohui Chen
By the scale of log-likelihood, I did not mean the scale parameter of the gamma density... Generally, as you get more and more data, the log-likelihood will get more and more negative. Hence, what I mean by scale is how negative of the values of loglik. So the 10 values returned from your dgamma

Re: [R] Log likelihood of Gamma distributions

2008-05-20 Thread Xiaohui Chen
The scale of log-likelihood depends on the number of your data samples, you should sum over the log-densities from individual points: sum(llgm) Xiaohui Edward Wijaya 写道: Dear all, How can I compute the log likelihood of a gamma distributions of a vector. I tried the following. But it doesn'