SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: maximum likelihood [ Reply ]
By: faeze moradi on 2015-01-29 19:47
[forum:41853]
hi
Explain away the original data in the Newton-Raphson method?
I still could not tell you before I sent it to answer my query
I do not know what the original data
Help me

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2015-01-09 21:39
[forum:41781]
I am using Newton-Raphson estimation. I think the problem is the order of the original data.
after the initial data in Newton Raphson method to do?How Newton-Raphson procedure to give preliminary data? On what basis?

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2015-01-09 05:11
[forum:41779]
Well,
another way you can go is to run Monte-Carlo simulations. Create the correctly distributed random variables yourself and estimate the parameters. Do you get (almost) exactly the correct values? If not, something is wrong with your log-likelihood.

Cheers,
Ott

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2015-01-02 14:09
[forum:41769]
i check your wbXII likelihood is correct (noticed a term +(k-1)*log(D) there,
)
It is not a factor in the article I tried both of them and the answer came back,
I do not know what to do:(

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2015-01-01 07:06
[forum:41768]
Your log-likelihood was slightly incorrect (k+1 instead of k-1). However, the function below works.

As you see I calculated analytic derivatives, this substantially improves convergence and changes standard errors a lot while the estimates remain the same. But many warnings still persist. As you see, numeric precision matters here.

I would recommend you the following steps now:
* check your wbXII likelihood is correct (noticed a term +(k-1)*log(D) there, is this correct?)
* compute the analytic derivatives. See what happens.

Good luck,
Ott

fm1 <- function(...) {
x<-c( 70, 90, 96, 97 , 99, 100, 103 ,104 ,104 ,105 ,107 ,108, 108, 108, 109, 109, 112 ,112, 113, 114, 114, 114, 116, 119, 120, 120, 120, 121, 121, 123, 124, 124, 124, 124 ,124 ,128,
128, 129, 129 ,130 ,130, 130, 131, 131, 131, 131, 131, 132, 132 ,132 ,133 ,134, 134, 134,134, 134 ,136, 136 ,137 ,138 ,138, 138, 139, 139, 141 ,141 ,142 ,142 ,142, 142, 142, 142,
144, 144, 145, 146 ,148 ,148 ,149 ,151 ,151 ,152 ,155 ,156, 157, 157 ,157 ,157 ,158 ,159,162, 163 ,163, 164, 166, 166, 168, 170, 174 ,196, 212)
n<-length(x)
loglik<-function(param) {
s<-param[1]
k<-param[2]
c<-param[3]
D <- 1 + (x/s)^c
l <- log(c) +
log(k) -
c*log(s) +
(c-1)*(log(x)) -
(k+1)*log(D)
gs <- -c/s + (k+1)/D*c*x^c*s^(-c-1)
gk <- 1/k - log(D)
gc <- 1/c + log(x) - log(s) -
(k+1)*(log(x) - log(s))*(x/s)^c/D
cbind(gs,gk,gc)
attr(l, "gradient") <- cbind(gs,gk,gc)
l
}
start <- c(s=1,k=1,c=1)
## compareDerivatives(loglik, gradlik, t0=start)
## stop()
m <- maxLik(loglik, start=start, ...)
d <- density(x)
dx <- d$x
dy <- log(d$y)
x <- seq(from=min(x), to=max(x), length=100)
y <- loglik(coef(m))
plot(dx, dy, ylim=range(dy, y), type="l")
lines(x,y, col=2)
m
}

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-30 18:11
[forum:41767]

New Text Document (2).txt (27) downloads
hi.tankyou

The Newton-Raphson method, data was fitted with the distribution I.
attached

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2014-12-30 09:23
[forum:41766]
Dear Faeze,
please fit your data with a plain Burr distribution. See if you can get it to converge. Think further after that.

You should also program analytic derivatives. The fact that different optimization algorithms give you rather different results suggests there are aproximation problems.

Best,
Ott

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-28 09:23
[forum:41765]
hi.im sorry .
Run command output did not answer one essay.!!!!!
i dont converge!
x<-c( 70, 90, 96, 97 , 99, 100, 103 ,104 ,104 ,105 ,107 ,108, 108, 108, 109, 109, 112 ,112, 113, 114, 114, 114, 116, 119, 120, 120, 120, 121, 121, 123, 124, 124, 124, 124 ,124 ,128,
+ 128, 129, 129 ,130 ,130, 130, 131, 131, 131, 131, 131, 132, 132 ,132 ,133 ,134, 134, 134,134, 134 ,136, 136 ,137 ,138 ,138, 138, 139, 139, 141 ,141 ,142 ,142 ,142, 142, 142, 142,
+ 144, 144, 145, 146 ,148 ,148 ,149 ,151 ,151 ,152 ,155 ,156, 157, 157 ,157 ,157 ,158 ,159,162, 163 ,163, 164, 166, 166, 168, 170, 174 ,196, 212)
> faezeMoradi <- function(type="wbb", ...)
+ {
+ library(maxLik)
+ WbBurrXII <- function(param) {
+ alpha <- param[1]
+ beta <- param[2]
+ scale <- param[3]
+ k <- param[4]
+ WbShape <- param[5]
+ D <- 1 + (x/scale)^WbShape
+ A <- log(alpha) + log(beta) + log(WbShape) +
+ log(k) - WbShape*log(scale) +
+ (WbShape - 1)*log(x) + (k-1)*log(D)
+ B <- -alpha*(D^k - 1)^beta
+ C <- (D^k - 1)^(beta - 1)
+ A + B + C
+ }
+ start <- c(alpha=100.24, beta=0.6383, s=151.42, k=0.024,c=13.230)
+ s<-maxLik(WbBurrXII, start=start, ...)
+ s
+ }
> summary(s)
--------------------------------------------
Maximum Likelihood estimation
Newton-Raphson maximisation, 1 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 286.7901
5 free parameters
Estimates:
Estimate Std. error t value Pr(> t)
alpha 1.0024e+02 NA NA NA
beta 6.3830e-01 NA NA NA
s 1.5142e+02 7.3743e-04 205335 < 2.2e-16 ***
k 2.4000e-02 NA NA NA
c 1.3230e+01 NA NA NA
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
--------------------------------------------
Warning messages:
1: In sqrt(diag(vc)) : NaNs produced
2: In sqrt(diag(vc)) : NaNs produced
>

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2014-12-27 20:14
[forum:41764]
All right,
at least I could see what is the cdf. The pdf seems to wrong---the denominator should be (1 + (x/s)^c)^(1-k) I think. At least this seems to be the correct derivative, and this also gives you weibull distribution if alpha = beta = k = 1.

I am able to get weibull distribution to converge (by fixing the other parameters). However, the Burr part of the distribution does not behave well, either I have coded it wrong, or the data just does not work with the distribution. It converges to reasonable values using BHHH but the Hessian matrix is virtually singular. I suspect there is too little information for 5 parameters but who knows... I don't have time to dig further into that distribution, but you should try it---estimate it as a stand-alone weibull, and as a stand-alone burr. Can you get both of these to converge?

Cheers,
Ott

BTW,
maxLik is pretty much a wrapper for maxNR (and other optimization routines).

faezeMoradi <- function(type="wbb", ...)
{
library(maxLik)
WbBurrXII <- function(param) {
alpha <- param[1]
beta <- param[2]
scale <- param[3]
k <- param[4]
WbShape <- param[5]
D <- 1 + (x/scale)^WbShape
A <- log(alpha) + log(beta) + log(WbShape) +
log(k) - WbShape*log(scale) +
(WbShape - 1)*log(x) + (k-1)*log(D)
B <- -alpha*(D^k - 1)^beta
C <- (D^k - 1)^(beta - 1)
A + B + C
}
start <- c(alpha=100.24, beta=0.6383, s=151.42, k=0.024,c=13.230)
s<-maxLik(WbBurrXII, start=start, ...)
s
}

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-26 18:21
[forum:41763]
hi
i help me:(
i want table for wburrxii distribution at attached.
estimate parameters for newton raphson method

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-22 19:07
[forum:41760]

I want obtaine estimate following.pdf (28) downloads
hi

RE: maximum likelihood [ Reply ]
By: Arne Henningsen on 2014-12-21 22:09
[forum:41758]
No, I do not understand your question. Sorry!

RE: maximum likelihood [ Reply ]
By: Arne Henningsen on 2014-12-21 22:08
[forum:41757]
I cannot open the attachment. Please re-post it as plain text file or PDF file.

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-21 16:49
[forum:41756]
do you help me?

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-19 10:44
[forum:41755]
are you understand quastion?

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-18 09:17
[forum:41752]
This article is for thesis and I have attachments that are sent (the estimated parameters) to get the article written by the Newton-Raphson that these estimates are obtained
And I want to answer in this paper is the Newton method (which is sent as attachments) reach.
I wrote an article written instructions to answer, but the answer is not
help me

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2014-12-18 05:25
[forum:41751]
Hey,
I don't understand what do you want, but this function seems not to converge, at least not with NR optimization. You can get convergence with Nelder-Mead (maxNM) although the gradient does not look correct, or with BHHH (maxBHHH) but you have to modify the log-likelihood a bit. So I suspect either your log-likelihood is wrong, or you run into numerical problems.
* test your log-likelihood function
* Did you get the simpler version to work?
* calculate the analytic gradient and use BHHH method (or explain me why you cannot do that)
* use maxLik instead of maxNR, that adds a lot of flexibility

Cheers,
Ott

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-17 21:51
[forum:41749]

I want obtaine estimate following.docx (79) downloads
hi .
I want the following density function parameter estimation method, Newton-Raphson .but estimation Paramete with write order the following and I sent with attachments that one can not
What is the reason? Is the at vector parameters?

x<-c( 70, 90, 96, 97 , 99, 100, 103 ,104 ,104 ,105 ,107 ,108, 108, 108, 109, 109, 112 ,112,
113, 114, 114, 114, 116, 119, 120, 120, 120, 121, 121, 123, 124, 124, 124, 124 ,124 ,128,
128, 129, 129 ,130 ,130, 130, 131, 131, 131, 131, 131, 132, 132 ,132 ,133 ,134, 134, 134,
134, 134 ,136, 136 ,137 ,138 ,138, 138, 139, 139, 141 ,141 ,142 ,142 ,142, 142, 142, 142,
144, 144, 145, 146 ,148 ,148 ,149 ,151 ,151 ,152 ,155 ,156, 157, 157 ,157 ,157 ,158 ,159,
162, 163 ,163, 164, 166, 166, 168, 170, 174 ,196, 212)

n<-length(x)
loglik<-function(param){
alpha<-param[1]
beta<-param[2]
s<-param[3]
k<-param[4]
c<-param[5]
l=n*log(alpha)+n*log(beta)+n*log(c)+n*log(k)-n*c*log(s)+(c-1)*sum(log(x))-
sum(log(1+(x/s)^c))-
(alpha*sum(((1+(x/s)^c)^k)-1)^beta)+
(beta-1)*sum(log(((1+(x/s)^c)^k)-1))
;l
}
s<-maxNR(loglik,start=c(1,1,1,1,1))
summary(s)

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2014-12-09 15:09
[forum:41728]
Dear Faeze,
I don't understand what do you want to do. I don't know what is Weibull-exponential model. Weibull is an extension of exponential that involves 2 parameters, not 3.

* Your log-likelihood does not converge. In particular, the third component of the gradient is always 0. You may estimate it by setting 'fixed=3':
a <- faezeMoradi(method="bhhh", fixed=3)
> summary(a)
--------------------------------------------
Maximum Likelihood estimation
BHHH maximisation, 15 iterations
Return code 2: successive function values within tolerance limit
Log-Likelihood: -15.20684
2 free parameters
Estimates:
Estimate Std. error t value Pr(> t)
[1,] 5.78067 0.43826 13.190 < 2.2e-16 ***
[2,] 1.62811 0.03779 43.083 < 2.2e-16 ***
[3,] 1.00000 0.00000 NA NA
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
--------------------------------------------

(I set start values to c(1,1,1) here). So please make sure your loglik function is correct.

* Show me first that you are able to estimate (and understand) the exponential model.

* Consider using maxLik, not maxNR, and a less error-prone method, such as bhhh. maxNR is perfect in case your program the analytic gradient and Hessian. You don't do that and may easily run into numerical problems.

Best,
Ott

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-09 14:39
[forum:41727]

table estimate parameters.docx (77) downloads
hi.i'm sorry
density function is weibull-exponential that should estimate parameters with newton-raphson method ( in fact i estimate the following parameters in the file attachmant,in fact the write command to obtain estimate).density function in the following attachmant.
the program in modified as followes:(i dont know what vector parameters)
x<-c(0.55,0.74,0.77,0.81,0.84,0.93,1.04,1.11,1.13,1.24,1.25,1.27,1.28,1.29,1.30,1.36,1.39,1.42,1.48,1.48,1.49,1.49,1.50,1.50,1.51,1.52,1.53,1.54,1.55,1.55,1.58,1.59,1.6,1.61,1.61,1.61,1.61,1.62,1.62,1.63,1.64,1.66,1.66,1.66,1.67,1.68,1.68,1.69,1.7,1.7,1.73,1.76,1.76,1.77,1.78,1.81,1.82,1.84,1.84,1.89,2,2.01,2.24)
n<-length(x)
loglik<-function(param){
alpha<-param[1]
beta<-param[2]
lambda<-param[3]
n*log(alpha)+n*log(beta)+beta*n*log(lambda)+(beta-1)*sum(log(x))+beta*lambda*sum(x)+(alpha-1)*sum(log(1-exp((-1)*lambda*x)^beta))
}
s<-maxNR(loglik,start=c(؟),print.level=2)
summary(s)

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2014-12-09 04:48
[forum:41726]
Dear Faeze,
I cannot understand what you want to do. Do you want to estimate a weibull duration model? In that case you may want to use dweibull() instead of writing your function yourself. But if you want to do it yourself, please ensure that it is correct. The current version does not converge, I suspect the term n**log(1-exp(-(lambda*x)^beta)) in your log-likelihood. But as I don't know what you intend to do, I cannot really comment on that.

Second, in case of maximizing log-likelihood, it is better to use maxLik() instead of maxNR().

If you are inexperienced with estimating your own likelihood, Do first an exponential model instead of weibull. Get correct results out of that.

Finally, you specify parameters in a correct way (given they enter correctly into your log-likelihood).

Cheers,
Ott

This version below works.

faezeMoradi <- function(print.level=0,
...) {
library(maxLik)
x <- c(0.55,0.74,0.77,0.81,0.84,0.93,1.04,1.11,1.13,1.24,1.25,1.27,1.28,1.29,1.30,1.36,1.39,1.42,1.48,1.48,1.49,1.49,1.50,1.50,1.51,1.52,1.53,1.54,1.55,1.55,1.58,1.59,1.6,1.61,1.61,1.61,1.61,1.62,1.62,1.63,1.64,1.66,1.66,1.66,1.67,1.68,1.68,1.69,1.7,1.7,1.73,1.76,1.76,1.77,1.78,1.81,1.82,1.84,1.84,1.89,2,2.01,2.24)
n<-length(x)
loglik1 <- function(param) {
shape <- param[1]
scale <- param[2]
dweibull(x, shape, scale, log=TRUE)
}
lambda0 <- mean(1/x)
a<-maxLik(loglik1,
start=c(1, lambda0),
print.level=print.level, ...)
}

RE: maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-07 15:11
[forum:41713]
هi'm sorry
i not found.example for weibull-exponential function the following ,how specify vector parameters?

x<-c(0.55,0.74,0.77,0.81,0.84,0.93,1.04,1.11,1.13,1.24,1.25,1.27,1.28,1.29,1.30,1.36,1.39,1.42,1.48,1.48,1.49,1.49,1.50,1.50,1.51,1.52,1.53,1.54,1.55,1.55,1.58,1.59,1.6,1.61,1.61,1.61,1.61,1.62,1.62,1.63,1.64,1.66,1.66,1.66,1.67,1.68,1.68,1.69,1.7,1.7,1.73,1.76,1.76,1.77,1.78,1.81,1.82,1.84,1.84,1.89,2,2.01,2.24)
n<-length(x)
loglik<-function(param){
alpha<-param[1]
beta<-param[2]
lambda<-param[3]
n*log(alpha)+n*log(beta)+beta*n*log(lambda)+(beta-1)*sum(log(x))-beta*(-lambda*sum(x))+n*alpha*log(1-exp(-(lambda*x)^beta))-n**log(1-exp(-(lambda*x)^beta))
}
a<-maxNR(loglik,start=c(?),print.level=2)
summary(a)

RE: maximum likelihood [ Reply ]
By: Ott Toomet on 2014-12-07 14:30
[forum:41711]
Well,
this depends on what are those parameters. I did not dig into your likelihood function, it seems to be a sort of exponential duration model. If this is the case, you may set the duration parameter equal to the inverse of the average failure time, and individual-specific parameters to 0. But it really depends on how do you specify the model. In very simple cases you can always pick the easiy solution: set everything to 0 that can be 0 (like coefficients) and everything to 1 that cannot be 0 (like variance).

In more complex cases you should seriously consider how to find good start values.

Cheers,
Ott

maximum likelihood [ Reply ]
By: faeze moradi on 2014-12-07 13:40
[forum:41710]
i'm sorry , and tank you for reply
how do you specify the vector of start?and c=(1,1)
if we have 3 parameters ,what will be the start?

Thanks to:
Vienna University of Economics and Business Powered By FusionForge