@@ -467,144 +467,144 @@ fitted<- function(.Object)
467467 return (ts(getFittedvalues(.Object ), deltat = t [2 ]- t [1 ]))
468468}
469469
470- ycsummary <- function (.Object )
471- {
472- y <- list (obs = .Object @ observedvalues , matsin = .Object @ matsin ,
473- coeff = .Object @ coefficients , fitted = .Object @ fittedvalues ,
474- matsout = .Object @ matsout , resid = .Object @ residuals ,
475- typeres = .Object @ typeres )
476-
477- if (max(y $ obs ) < 0.2 && (y $ typeres != " rates" ))
478- {
479- y $ fitted <- euriborfromprice(0 , y $ matsout , y $ fitted )
480- }
481-
482- if (max(y $ obs ) > 0.2 && (y $ typeres != " prices" ))
483- {
484- y $ fitted <- pricefromeuribor(0 , y $ matsout , y $ fitted )
485- }
486-
487- n <- length(y $ obs )
488- if (.Object @ method == " SW" )
489- {p <- length(y $ coeff ) - 1 }
490- else {p <- length(y $ coeff )}
491-
492- cat(" Residuals:" , " \n " )
493- print(summary(y $ resid ))
494- cat(" \n " )
495-
496- cat(" Coefficients:" , " \n " )
497- cat(y $ coeff , " \n " )
498- cat(" \n " )
499-
500- # Total sum of squares
501- yobs <- y $ obs
502- ybar <- mean(y $ obs )
503- typeres <- y $ typeres
504- u <- y $ matsin
505- t <- y $ matsout
506- indicemat <- pmatch(u , t )
507-
508- ychapeau <- y $ fitted [indicemat ]
509-
510- resid <- y $ resid
511-
512- ESS <- crossprod(rep.int(ybar , n ) - ychapeau )[1 ,1 ]
513- SSR <- crossprod(yobs - ychapeau )[1 ,1 ]
514- SST <- ESS + SSR
515-
516- cat(" Total sum of squares:" , " \n " )
517- cat(SST , " \n " )
518- cat(" with" , n - 1 ," degrees of freedom" ," \n " )
519- cat(" \n " )
520-
521- cat(" Explained sum of squares:" , " \n " )
522- cat(ESS , " \n " )
523- cat(" with" , p - 1 ," degrees of freedom" ," \n " )
524- cat(" \n " )
525-
526- cat(" Residual sum of squares:" , " \n " )
527- cat(SSR , " \n " )
528- cat(" with" , n - p ," degrees of freedom" ," \n " )
529- cat(" \n " )
530-
531- Rsquared <- 1 - SSR / SST
532- cat(" Multiple R-squared " , " *" , " Adjusted R-squared" , " \n " )
533- cat(Rsquared , " *" , 1 - ((n - 1 )/ (n - p ))* (1 - Rsquared ), " \n " )
534- cat(" \n " )
535-
536- if (try(shapiro.test(y $ resid )$ p.value , TRUE ) > = 0.05 || n > = 30 )
537- {
538- Fstat <- ((n - p )/ (p - 1 ))* (Rsquared / (1 - Rsquared ))
539- suppressWarnings(cat(" F-statistic:" , Fstat , " on" ,
540- n - p ," and" , p - 1 , " degrees of freedom, p-value:" , pf(Fstat , n - p , p - 1 ), " \n " ))
541- }
542- }
543-
544- ycplot <- function (.Object ){
545-
546- indicatrice <- pmatch(.Object @ matsin , .Object @ matsout )
547-
548- par(mfrow = c(2 ,2 ))
549-
550- ord <- .Object @ fittedvalues
551- x <- .Object @ observedvalues
552-
553- if (.Object @ typeres == " rates" )
554- {
555- if (max(.Object @ observedvalues ) > 0.2 )
556- {x <- euriborfromprice(0 , .Object @ matsin , .Object @ observedvalues )}
557-
558- plot(x = .Object @ matsout , y = ord ,
559- main = " (Red) Observed values and (Black) Fitted values" , xlab = " Maturity" ,
560- ylab = " Yield to maturity" )
561- points(x = .Object @ matsin , y = x , col = " red" , pch = 3 )
562-
563- plot(x = x , y = ord [indicatrice ],
564- main = " Observed vs Fitted values" , xlab = " observed values" , ylab = " fitted values" )
565- abline(0 , 1 , col = " red" )
566- }
567- else
568- {
569- if (max(.Object @ observedvalues ) < 0.2 )
570- {x <- pricefromeuribor(0 , .Object @ matsin , .Object @ observedvalues )}
571-
572- plot(x = .Object @ matsout , y = ord ,
573- main = " (Red) Observed values and (Black) Fitted values" , xlab = " Maturity" ,
574- ylab = " Zero-coupon price" )
575- points(x = .Object @ matsin , y = x , col = " red" , pch = 3 )
576-
577- plot(x = x , y = ord [indicatrice ],
578- main = " Observed vs Fitted values" , xlab = " observed values" , ylab = " fitted values" )
579- abline(0 , 1 , col = " red" )
580- }
581-
582- hist(.Object @ residuals , main = paste(" Histogram and density" , " \n " ," of residuals" ),
583- xlab = " residuals" )
584- lines(density(.Object @ residuals ), col = " red" )
585-
586- if (max(.Object @ matsout ) < = max(.Object @ matsin ))
587- {
588- qqnorm(.Object @ residuals , main = " Residuals' Normal Q-Q plot" )
589- qqline(.Object @ residuals , col = " red" )
590- }
591- else
592- {
593- plot(forwardrates(.Object ), main = " Extrapolated forward rates" )
594- }
595- }
596-
470+ # ycsummary <- function(.Object)
471+ # {
472+ # y <- list(obs = .Object@observedvalues, matsin = .Object@matsin,
473+ # coeff = .Object@coefficients, fitted =.Object@fittedvalues,
474+ # matsout = .Object@matsout, resid = .Object@residuals,
475+ # typeres = .Object@typeres)
476+ #
477+ # if(max(y$obs) < 0.2 && (y$typeres != "rates"))
478+ # {
479+ # y$fitted <- euriborfromprice(0, y$matsout, y$fitted)
480+ # }
481+ #
482+ # if(max(y$obs) > 0.2 && (y$typeres != "prices"))
483+ # {
484+ # y$fitted <- pricefromeuribor(0, y$matsout, y$fitted)
485+ # }
486+ #
487+ # n <- length(y$obs)
488+ # if (.Object@method == "SW")
489+ # {p <- length(y$coeff) - 1}
490+ # else {p <- length(y$coeff)}
491+ #
492+ # cat("Residuals:", "\n")
493+ # print(summary(y$resid))
494+ # cat("\n")
495+ #
496+ # cat("Coefficients:", "\n")
497+ # cat(y$coeff, "\n")
498+ # cat("\n")
499+ #
500+ # # Total sum of squares
501+ # yobs <- y$obs
502+ # ybar <- mean(y$obs)
503+ # typeres <- y$typeres
504+ # u <- y$matsin
505+ # t <- y$matsout
506+ # indicemat <- pmatch(u, t)
507+ #
508+ # ychapeau <- y$fitted[indicemat]
509+ #
510+ # resid <- y$resid
511+ #
512+ # ESS <- crossprod(rep.int(ybar, n) - ychapeau)[1,1]
513+ # SSR <- crossprod(yobs - ychapeau)[1,1]
514+ # SST <- ESS + SSR
515+ #
516+ # cat("Total sum of squares:", "\n")
517+ # cat(SST, "\n")
518+ # cat("with", n - 1,"degrees of freedom","\n")
519+ # cat("\n")
520+ #
521+ # cat("Explained sum of squares:", "\n")
522+ # cat(ESS, "\n")
523+ # cat("with", p - 1,"degrees of freedom","\n")
524+ # cat("\n")
525+ #
526+ # cat("Residual sum of squares:", "\n")
527+ # cat(SSR, "\n")
528+ # cat("with", n - p,"degrees of freedom","\n")
529+ # cat("\n")
530+ #
531+ # Rsquared <- 1 - SSR/SST
532+ # cat("Multiple R-squared ", "*", "Adjusted R-squared", "\n")
533+ # cat(Rsquared, "*", 1 - ((n-1)/(n-p))*(1 - Rsquared), "\n")
534+ # cat("\n")
535+ #
536+ # if (try(shapiro.test(y$resid)$p.value, TRUE) >= 0.05 || n >= 30)
537+ # {
538+ # Fstat <- ((n-p)/(p-1))*(Rsquared/(1 - Rsquared))
539+ # suppressWarnings(cat("F-statistic:", Fstat, "on",
540+ # n - p,"and", p-1, "degrees of freedom, p-value:", pf(Fstat, n-p, p-1), "\n"))
541+ # }
542+ # }
543+
544+ # ycplot <- function(.Object){
545+ #
546+ # indicatrice <- pmatch(.Object@matsin, .Object@matsout)
547+ #
548+ # par(mfrow=c(2,2))
549+ #
550+ # ord <- .Object@fittedvalues
551+ # x <- .Object@observedvalues
552+ #
553+ # if(.Object@typeres == "rates")
554+ # {
555+ # if (max(.Object@observedvalues) > 0.2)
556+ # {x <- euriborfromprice(0, .Object@matsin, .Object@observedvalues)}
557+ #
558+ # plot(x = .Object@matsout, y = ord,
559+ # main = "(Red) Observed values and (Black) Fitted values", xlab = "Maturity",
560+ # ylab = "Yield to maturity")
561+ # points(x = .Object@matsin, y = x, col="red", pch=3)
562+ #
563+ # plot(x = x, y = ord[indicatrice],
564+ # main = "Observed vs Fitted values", xlab="observed values", ylab="fitted values")
565+ # abline(0, 1, col="red")
566+ # }
567+ # else
568+ # {
569+ # if (max(.Object@observedvalues) < 0.2)
570+ # {x <- pricefromeuribor(0, .Object@matsin, .Object@observedvalues)}
571+ #
572+ # plot(x = .Object@matsout, y = ord,
573+ # main = "(Red) Observed values and (Black) Fitted values", xlab = "Maturity",
574+ # ylab = "Zero-coupon price")
575+ # points(x = .Object@matsin, y = x, col="red", pch=3)
576+ #
577+ # plot(x = x, y = ord[indicatrice],
578+ # main = "Observed vs Fitted values", xlab="observed values", ylab="fitted values")
579+ # abline(0, 1, col="red")
580+ # }
581+ #
582+ # hist(.Object@residuals, main = paste("Histogram and density", "\n","of residuals"),
583+ # xlab = "residuals")
584+ # lines(density(.Object@residuals), col="red")
585+ #
586+ # if(max(.Object@matsout) <= max(.Object@matsin))
587+ # {
588+ # qqnorm(.Object@residuals, main = "Residuals' Normal Q-Q plot")
589+ # qqline(.Object@residuals, col="red")
590+ # }
591+ # else
592+ # {
593+ # plot(forwardrates(.Object), main = "Extrapolated forward rates")
594+ # }
595+ # }
596+ #
597597
598598forwardrates <- function (.Object )
599599{
600600 t <- .Object @ matsout
601601 return (ts(getFwdrates(.Object ), deltat = t [2 ]- t [1 ]))
602602}
603603
604- tolist <- function (.Object )
605- {
606- y <- list (matsin = .Object @ matsin , obs = .Object @ observedvalues , method = .Object @ method , typeres = .Object @ typeres ,
607- coeff = .Object @ coefficients , matsout = .Object @ matsout , fitted = .Object @ fittedvalues , fwdrates = .Object @ fwdrates ,
608- resid = .Object @ residuals , UFR = .Object @ UFR , T_UFR = .Object @ T_UFR , extra = .Object @ extrapvalues )
609- return (y )
610- }
604+ # tolist <- function(.Object)
605+ # {
606+ # y <- list(matsin = .Object@matsin, obs = .Object@observedvalues, method = .Object@method, typeres = .Object@typeres,
607+ # coeff = .Object@coefficients, matsout = .Object@matsout, fitted =.Object@fittedvalues, fwdrates = .Object@fwdrates,
608+ # resid = .Object@residuals, UFR = .Object@UFR, T_UFR = .Object@T_UFR, extra = .Object@extrapvalues)
609+ # return(y)
610+ # }
0 commit comments