Dear R helpers,

Last week Mr. Ista Zahn has taken lots of efforts and helped me with the
following code generating basel_asset_wise (e.g. bank, corporate, sovereign)
graphs. The code works excellently and assetwise grahs are aslo genereated.
I have tried to customize the code as per my need.

However, there is only one small problem with the graphs. The graph doesn't
give me the asset names. I.e. in the graph which is meant for bank doesn't
show me the name bank. Under the X - label i.e. Rating, it gives me number
1, Similarly for corporate and sovereign it gives the numbers 2 and 3
respectively.

I understand it is like a spoon feeding, but I have really taken the efforts
to find the solution and invested myself on whole of Saturday and Sunday and
tried different options but just couldn't find the way.

I will be grateful if someone guides me. I understand the
default_probability should be between 0 and 1. However, just for disply
checking purpose I have taken different figures.

Regards

Akshata


# Here is the part of my code which generates the graphs -

library(plyr)

internal_scale = c("AAA","AA","A","BBB","BB","B","CCC")
# internal_scale_id <- c(1:length(internal_scale))

# basel_asset_class <- c("Bank", "Corporate", "Sovereign")
# basel_asset_class_id <- c(1:length(basel_asset_class))


output = data.frame(basel_asset_class_id =
c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3),
            internal_scale_id =
c(1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7),
            default_probability =
c(10,28,32,44,57,62,78,14,23,38,47,56,65,74,1,9,16,25,36,49,64))

#


# Generation of Graphs

DP_graphs <- function(Data = output, class.var="basel_asset_class_id",
ratings="internal_scale_id", IPD="default_probability")

{
   class <- unique(as.character(Data[[class.var]]))[1]
   png(filename=sprintf("%s%s%s%s%s", "Curve ", "( ", class," )",".png"),
       width=480,height=480)
   par('bg'= "#FFFFCC")
   par(xaxt="n")
   plot(as.numeric(factor(Data[[ratings]])), Data[[IPD]], "b",
ylab="PD", xlab="Rating",
        fg="#804000", font.main=2,cex.main=1,col="Red",
        col.main="black",col.axis="black" ,col.lab = "black")
   title("Exponential Curve", sub = paste("(", class,")"), cex.main=1.2,
         font.main= 2, col.main= "black", cex.sub = 1, font.sub = 2,
         col.sub ="black")
   par(xaxt="s")
   axis(1,at=1:length(unique(output$internal_scale_id)), labels =
internal_scale)
   box(which="outer",bty = "o", col = "#804000")
   dev.off()
}

d_ply(output, .(basel_asset_class_id), DP_graphs)

	[[alternative HTML version deleted]]

