[R] Ben Bolker's '‘emdbook’ Package , rbetabinom

2012-11-19 Thread arun4
Hello, 
I am using rbetabinom ( to generate beta binomial random variables) function
available in the "emdbook"package written by Professor. Ben Bolker for my
research study.
I have no questions with this function. However, I am looking for the
theoretical method/algorithm  of the function "rbetabinom " . 
Morris (1997), American Naturalist 150:299-327 is given as the reference in
the package, But I couldn't fund any theoretical methods to generate beta
binomial random variables in this article.

I would like to kind request you to suggest me any journal paper or document
to study the methods of generating  beta binomial random variables used to
write the function "rbetabinom".

Thank you very much. 

Sincerely,
Arun.





--
View this message in context: 
http://r.789695.n4.nabble.com/Ben-Bolker-s-emdbook-Package-rbetabinom-tp4650047.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.


[R] Creating a frequency table for binomial varaible

2012-11-21 Thread arun4
Hello, 
I have simulated 30  observations from a binomial(5,0.1) distribution. 
Now I need to make frequency table( that means I need to tally how many 0's
, 1's  2's... 5's)
I know that the simple  R function table() will do this, but I am afraid
that some times I may get zero frequency for some particular values (for
example in the above there are 5-0's 10-1's , 14-2's, 10-3's , 11-4's but no
any 5's )

So I want to make by frequecy table ( as a date frame) as
value   freq
0   5
1  10
2  14
3  10
4   11
5   0


How can I create such a table?
Forgive me if this is a very basic question. I am new to R.

Thank you very much. 





--
View this message in context: 
http://r.789695.n4.nabble.com/Creating-a-frequency-table-for-binomial-varaible-tp4650286.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.


Re: [R] Ben Bolker's '‘emdbook’ Package , rbetabinom

2012-11-21 Thread arun4
I understood that from the source code. Currently I am referring the
suggested articles. 
Thank you very much for the off-list answer and this reply. 




--
View this message in context: 
http://r.789695.n4.nabble.com/Ben-Bolker-s-emdbook-Package-rbetabinom-tp4650056p4650287.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.


Re: [R] Creating a frequency table for binomial varaible

2012-11-21 Thread arun4
As I have to to this in a simulation study for 1000 such binomial variables,
I have created a R function as below..
Am I doing in the correct way? or is there any other simplest ways?

#using a user defined function to create a frequency distribution
create.freq.table<- function(x){
  values<-seq(0,5,by=1)
  level<-seq(0,6,by=1)
  freq.cut<-cut(x,breaks=level,right=FALSE)
  int.freq.table<-table(freq.cut)
  int.dataframe<-data.frame(int.freq.table)
  final.freq.table<-data.frame(cbind(values, Freq=int.dataframe[,2]))
  return(final.freq.table)
}




--
View this message in context: 
http://r.789695.n4.nabble.com/Creating-a-frequency-table-for-binomial-varaible-tp4650286p4650295.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.


Re: [R] Creating a frequency table for binomial varaible

2012-11-21 Thread arun4
Thank you A.K
Btw in which package count() is available? 



--
View this message in context: 
http://r.789695.n4.nabble.com/Creating-a-frequency-table-for-binomial-varaible-tp4650286p4650305.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.


Re: [R] Creating a frequency table for binomial varaible

2012-11-21 Thread arun4
Thank you Bill Dunlap . This seems very simple. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Creating-a-frequency-table-for-binomial-varaible-tp4650286p4650312.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.


[R] bbmle "Warning: optimization did not converge"

2012-11-25 Thread arun4
I am using the Ben bolker's R package "bbmle" to estimate the parameters of a
binomial mixture distribution via Maximum Likelihood Method. For some data
sets, I got the following warning messages:
*Warning: optimization did not converge (code 1: )
There were 50 or more warnings (use warnings() to see the first 50)*
Also, warnings() results the following: 
*In 0:(n - x) : numerical expression has 8 elements: only the first used
47: In beta(a, b) : NaNs produced*

I would like to know whether this is a serious issue? if so.. how can I
avoid it?

thank you.



--
View this message in context: 
http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730.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.


Re: [R] bbmle "Warning: optimization did not converge"

2012-11-25 Thread arun4
Thank you  Michael Weylandt.
Let me to describe my problem fully,
I have developed a new discrete probability distribution which has the
following Probability mas function( as an alternative to binomial
distribution)
 

Where n= number of trials
x are the binomial values
a and b are the two parameters to be estimated (I use MLE method by calling
mle2 from bbmle package)
As you can see, there is an inner summation which runs from zero to (n-x)

The below is the R functions I have written to define Negative Loglikelihood
and estimate parameters:

library(bbmle)

* ###Define Negative LL
Dist.NLL<-function(x,a,b,fre,n) { 
  term<-0 
  for (j in 0:(n-x)) { 
term=term+(((-1)**j)*(choose(n-x,j))*(beta(((x/a)+1+(j/a)),b)))
  }
  density=b*choose(n,x)*term 
  LL<-sum(fre*log(density))
  return(-LL) 
}

##an example dataset
x.values<-0:7  ##x values (here 7 trials)
frequency<-c(47,54,43,40,40,41,39,95)   ##Observed frequencies of x values
##Now use mle2 to estimate parameters.

mle2(Dist.NLL, start=list(a=22,b=22), data=list(x=values ,fre=frequency,
n=7))
*

This is what I have done, bow I am getting "In 0:(n - x) : numerical
expression has 8 elements: only the first used" error messages, which I
afraid serious errors. 

Thanks again.



--
View this message in context: 
http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730p4650759.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.


Re: [R] bbmle "Warning: optimization did not converge"

2012-11-25 Thread arun4
Sorry,
x values are created as
*values<- 0:7*



--
View this message in context: 
http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730p4650761.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.


Re: [R] bbmle "Warning: optimization did not converge"

2012-11-26 Thread arun4
Thank you Uwe Ligges-3



--
View this message in context: 
http://r.789695.n4.nabble.com/bbmle-Warning-optimization-did-not-converge-tp4650730p4650812.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.