[R] mle
Hello, I am going to estimate the parameter of the count model: pr(N=n)= integration{B(x, alpha)-C(x,alpha)} by maximum likelihood estimation. n-c(0,1,2,3) and F- (0,3,4,5) are the vectors of values and observed frequency respectively. The function C(x,alpha) is not defined for n=0, but suppose C(x,alpha)=1 when n=0. When I want to insert this exception in the following loop, I don't receive reasonable estimate. pari (alpha){ nloglik- function(alpha){ B-function(x,k){} C-function(x,k){} A-function(x){ s-rep(0,length(x)) s-s+ C(x,k) s- s+B(x,k) } s } d-0 for (n in seq(along=F)){ lik-integrate(A,0,1)$value d- d - F[n]*log(lik)}} d } F- (0,3,4,5) n-length(F) mle (nloglik, start=list(alpha=alpha) } This program gives the answer when n= 1,2,3. But for n=0 I get error, I have to consider the exception : C(x,alpha)=1. Does anybody know where I need to put the exception in the program? ( For 'if' loops, I don't get reasonable results) I would appreciate any help Best Regards, __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Chi-square test
Hello, If the vector of observed frequencies is: f-c(0,0,0,2,3,6,17,15,21,21,14,10,5,1,5) and the vector of probability :p11-c(7.577864e-06, 1.999541e-04 ,1.833510e-03, 9.059845e-03, 2.886977e-02, 6.546229e-02 ,1.124083e-01, 1.525880e-01, 1.689712e-01, 1.563522e-01, 1.232031e-01, 8.395000e-02, 5.009534e-02, 2.645857e-02,0.0205403) The sum of the probabilities is equal to one. But when I want to do the the Chi-square test, I get this error: probabilities must sum to one. Does anybody know the reason? Best Regards, pari __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] package GPseq
Hello I am going to estimate the parameters of generalized Poisson model of Consul. I need to use the function: generalized -poisson-likelihood(y). can anybody make me sure what the vector y is? If the amounts of variable is: (0,1,2,3) , and the vector of observed values is: (1,4,7,3). Which one is vector (y)? Thank you __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] package GPseq
Hello I am going to estimate the parameters of generalized Poisson model of Consul. I need to use the function: generalized -poisson-likelihood(y). can anybody make me sure what the vector y is? If the amounts of variable is: (0,1,2,3) , and the vector of observed frequency for each level is: (1,4,7,3). Which one is vector (y)? Thank you __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] MLE
Dear Sir/Madam I am trying to get the Maximum Likelihood Estimation of a parameter in a probability mass function. The problem is my pmf which includes a summation and one integral. it is not similar to other known pdfs or pmfs such as normal, exponential, poisson, . Does anybody know whether I can use the current packages(like Maxlik) in R for getting the MLE of the parameter? Can anybody explains me with an example? I would appreciate any help. Best Regards, Pari __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] maximum likelihood estimation
Hello,As an example for Exponential distribution the MLE is got by this structure:t - rexp(100, 2)loglik - function(theta){ log(theta) - theta*t}a - maxLik(loglik, start=1)print(a)Exponential distribution has a simple loglikelihood function. But if a new pdf has a more complicated form like:pr(N(2)=n)= integral( ((2-x)^n)*(exp(ax-2))) - integral (((5-ax)^n)), both integrals are defined over the interval(0,2) with respect to x. I also need to use the loglike of the form : [F log(pr(n))]=lnL where F is the vector of observations and (n) is the vector of input for the defined pmf. Do you think how I can insert (define) the pr(n) in the loop below? loglik - function(a) sum(F*(log(pr(n)))? n - c(0,1,2,3,4,5,6,7,8) F-c(0,0,1,3,5,7,8,11,10) loglik - function(a) sum(F*(log(pr(n)))?? re - maxLik (loglik, start=.5) summary(re)I would be grateful if you let me know your idea.Best Regards,pari [[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] maximum likelihood estimation
HelloI am trying to estimate the parameter of a function by the Maximum Likelihood Estimation method.If the function is the difference between two integrals: C-function(n){integrand3-function(x) {((2-x)^n)*(exp(ax-2))}cc- integrate (integrand3,0,2)print(cc)} D-function(n){integrand4-function(x) {((5-ax)^n)}cc- integrate (integrand4,0,2)print(cc)} f(n) = C(n) - D(n) I need to estimate parameter (a). loglikelihood function is in the form of sum[F(k) log(f(k))]=lnL. I am wondering how to introduce my logliklihood function to the loop below. Can anybody help me for correcting the following loop? if there are some other packages better than this , please let me know.Thank you,Diba n - c(0,1,2,3,4,5,6,7,8) F-c(0,0,1,3,5,7,8,11,10) loglik - function(a) sum(F*log(C(n)-D(n))) re - maxLik (loglik, start=.5) summary(re) [[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] loop
Hello ,I am trying to write a loop for sum of integrals . the integral is:integrand4-function(x,a=1.5,n=3,k=0){(((a+1)*x)^k)*((2-x)^n)*(exp(-a*x-2))/(factorial(k)*factorial(n))} integrate(integrand4,0,2). I need a loop to give me the sum of integrals over k = 0,.n , for every positive integer input (n).can anybody check my program and tell me about it's problem?I am looking forward to your suggestions. B-function(n){Sum-1for (k in 0:n){BB-function(k){integrand2-function(x,a=1.5){(((a+1)*x)^k)*((2-x)^(n))*(exp(-a*x-2))/(factorial(k)*factorial(n))} integrate(integrand2,0,2)}r-print(BB(k))sum-sum+r}print(sum-1)} Best Regards,Diba [[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] C.D.F
Hello everybody, Can anybody help me to write a program for the CDF of sum of two independent gamma random variables ( covolution of two gamma distributions) with different amounts of parameters( the shape parameters are the same)? Thank you Diba [[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] MLE
Hello I know how to use R for estimating a parameter by using MLE if I have a simple function f(x,a). I am trying to design a program for a complicated function such as: g(.)=sum(integral(f(x,a,t,k))) where (a) is a parameter(needs to be estimated) , integral depends on (t) and sum is over (k). Does anybody have any idea? Thank you Diba [[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] Legendre quadrature
Hello everybody I need to approximate the amount of integral by using legendre quadrature. I have written a program which doesn't give me a logical answer; Can anybody help me and send the correct program? For example the approximated amount of integral of ( x ^2) on (-1,1) based on legendre quad rule. integrand-function(x){x^2} rules - legendre.quadrature.rules( 50 ) order.rule - rules[[50]] chebyshev.c.quadrature(integrand, order.rule, lower = -1, upper = 1) Thank you Diba [[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] legendre quadrature
Hello everybody I need to approximate the amount of integral by using legendre quadrature. I have written a program which doesn't give me a logical answer; Can anybody help me and send the correct program? For example the approximated amount of integral of ( x ^2) on (-1,1) based on legendre quad rule. integrand-function(x) {x^2} rules - legendre.quadrature.rules( 50 ) order.rule - rules[[50]] chebyshev.c.quadrature(integrand, order.rule, lower = -1, upper = 1) Thank you Diba [[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.