Reputation: 313
I am trying to create numerous plots with varying parameter values. When I submit the code below:
for(i in mars){
for(j in 1:5){
negRets <- -table1.matrix[,j]
tauSigma <- gpd(negRets,threshold=i)
tau <- tauSigma$par.ests[1]
sigma <- tauSigma$par.ests[2]
#cat("For ", reitPort[j], "portfolio and MAR=", i, "the parameter estimats are:", "\n")
#cat("Tau= ", tau, "Sigma= ", sigma, "\n")
exceedence.vector <- sort(subset(negRets, negRets > i))
returns.sorted <- sort(negRets)
pdf(paste("C:\\Users\\John Broussard\\Dropbox\\evtHandbookProject\\figuresTables\\mar_",i,"_",reitPort[j],".pdf",sep=""))
plot(returns.sorted, dgpd(returns.sorted, xi = tau, beta = sigma), type ="l", col="blue", ylim=c(0,90))
title(main=cat("Tau= ", tau, " Sigma= ", sigma), ylab=" ")
dev.off()
#print(j)
#print(i)
}
}
The plots are written to the files, but no title, and the y-axis label contains "xi=tau," not the value for xi submited in the plot code.
How do I get a title and the values of the parameters being using for the plots to be incorporated into the individual files?
Upvotes: 1
Views: 8367
Reputation: 1928
You are looking for the paste()
function rather than the cat()
function. The cat()
function outputs an object while paste()
concatenates a vector after converting to a character.
plot(returns.sorted, dgpd(returns.sorted, xi = tau, beta = sigma),
type ="l", col="blue", ylim=c(0,90),
main = paste("Tau= ", tau, " Sigma= ", sigma), ylab=" ")
If you want greek letters see this question or this question.
Upvotes: 1