hello, i'am is new in R software.i have try to make a function but it can't give what it should.i dunno what have to do next. Can somebody help me to solve it.i'll very appreciate...
##GEV simulation(Non-stationary) dsim<-function(n, alpha, beta,sca,sha){ t <- 1:n location <- alpha + beta*t inv.df<-function(x) location + -(sca/sha)+(sca/sha)*(-log(x))^(-sha) u<-runif(n) y<-inv.df(u) return(y) } xdat<-c(3.4,7.8,10.1,11.7,13.9,14.1,14.2,14.6,14.6,14.6,15,15,16.1,18) ##GEV function(Non-stationary) GEV.lik<-function(a,x)#a=(location,scale,shape) { alpha <- a[1] beta <- a[2] scale<-a[3] shape<-a[4] n <- length(x) t <- 1:n location<-100/(1+alpha*exp(beta*x)) if(scale<=0)return(1e+10) if(y1<=0)return(1e+10) { if(min(1+shape*(x-location)/scale)<=0)return(1e+10) n<- length(x) y0<- 1+(1/shape) y1<- (1+shape*(x-location)/scale) y2<- log(y1) y3<- y1^(-1/shape) l<- -n*log(scale)-y0*sum(y2)-sum(y3) } return(-l) } start<-c(50,-0.5,6.55,0.1) bl<-c(-Inf,-Inf,0,-0.5) bu<-c(Inf,Inf,Inf,Inf) y<-optim(start,GEV.lik,x=xdat,hessian=T) y y$par y$hessian -- View this message in context: http://n4.nabble.com/R-beginner-tp1576033p1576033.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.