Hi, I am writing a function to plot a pdf of a distribution, GNL.pdf.fn = function(x,mu,sigma,alpha,beta,rho) { y = x-rho*mu cf.fn = function(s){ cplex = complex(1,0,1) temp1 = alpha*beta*exp(-sigma*s^2/2) temp2 = (alpha-cplex*s)*(beta+cplex*s) out = (temp1/temp2)^rho out } temp.fn = function(s){ (Mod(cf.fn(s)))*cos(Arg(cf.fn(s))-s*y) }
int.fn = function(t){sapply(t,FUN=temp.fn)} te = integrate(int.fn,lower=0,upper=Inf,rel.tol=1e-10,subdivisions=1000000) temp3 = ifelse(te$message == "OK",te$value/pi,NA) temp3 } GNL.pdf.fn(x[100],mu,sigma,alpha,beta,rho) L = rep(0,length(x)) pdf = function(x,mu,sigma,alpha,beta,rho) { for(i in 1:length(x)) { L[i] = GNL.pdf.fn(x,mu,sigma,alpha,beta,rho) } L } when i call the function pdf this an error occurs in the console Error in rho * mu : 'rho' is missing Can anyone help me please ? -- View this message in context: http://r.789695.n4.nabble.com/Error-Variable-is-Missing-tp4515410p4515410.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.