Hi all,
I'm trying to make a little script to determine an "unknown" rate for a
number of known exponential trials.
My Code:
#Set Trials and generate number
trials=100
rand<-runif(1,0,1)
vector=0
#Generate vector of 100 random exponentials and sum them
for (i in 1:100) {
vector<-rexp(trials,rate=rand)
}
sumvect=sum(vector)
#Create the log likelihood function
LL<-function(x) {(trials*log(x))-(x*sumvect)}
optim(1,LL,method="BFGS")
The "rand" variable should be between 0 and 1 and is what I am trying to
approximate. However, as it is I generally get a value in the tens of
thousands. I'm sure it's something simple but I can't find my error.
Jon
______________________________________________
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.