[R] Thanks and further question
Muhammad Kashif
mkashif at uaf.edu.pk
Sun Jan 3 22:19:56 CET 2016
Thank you Professor and sorry for question on personal email.
________________________________________
From: peter dalgaard <pdalgd at gmail.com>
Sent: Monday, January 4, 2016 2:15 AM
To: Muhammad Kashif
Cc: Group R-help
Subject: Re: Thanks and further question
Please keep on-list (cc'ed), for various good reasons. Comments inline.
-pd
> On 03 Jan 2016, at 22:02 , Muhammad Kashif <mkashif at uaf.edu.pk> wrote:
>
> Dear Peter dalgarrd
>
> Thanks and i really appreciate your answer. Actually i am new in r programming. using your answer i run the following code which generate the results
>
> gama=1.0
> beta=1.3
> x<-rgbs(n,gama,beta)
> ll.wd<-function(theta,x){
> n<-length(x)
> gama<-theta[1]
> beta<-theta[2]
> sum(-dgbs(x, gama, beta,log = TRUE))}
> out.wd<-optim(theta<-c(gama,beta),ll.wd,x=x,method = "Nelder-Mead",hessian=FALSE)
> gamhat<-out.wd$par[1]
> betahat<-out.wd$par[2]
> gamhat
> betahat
>
> Can you help me to solve the issue. if i am correct
>
> this code minimized the loglikelihood function of gbs using Nelder-Mead method.
the negative log likelihood, yes (i.e. maximizes the likelihood). Assuming that it converged, of course.
>
> if yes then further if i wanted to simulate this (say 2000) time and for every simulation i wanted the value of estimated parameter (gamhat and betahat). then what i do
My standard idiom for that sort of thing is
res <- replicate(2000, {
x<-rgbs(n,gama,beta)
optim(c(gama,beta), ll.wd, x=x,
method = "Nelder-Mead",hessian=FALSE)$par
})
which should give you a 2x2000 matrix with each column containing the parameter estimates for a simulation.
>
> Please help me in this regard i am very thankful to you.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list