Running examples in ‘GCPM-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: analyze-methods
> ### Title: Analyze a Credit Portfolio
> ### Aliases: analyze-methods analyze,GCPM-method
> ###   analyze,GCPM,data.frame,missing,missing-method
> ###   analyze,GCPM,data.frame,numeric,missing-method
> ###   analyze,GCPM,data.frame,missing,numeric-method
> ###   analyze,GCPM,data.frame,numeric,numeric-method analyze
> ### Keywords: methods GCPM
> 
> ### ** Examples
> 
> #create a random portfolio with NC counterparties
> NC=100
> #assign business lines and countries randomly
> business.lines=c("A","B","C")
> CP.business=business.lines[ceiling(runif(NC,0,length(business.lines)))]
> countries=c("A","B","C","D","E")
> CP.country=countries[ceiling(runif(NC,0,length(countries)))]
> 
> #create matrix with sector weights (CreditRisk+ setting)
> #according to business lines
> NS=length(business.lines)
> W=matrix(0,nrow = NC,ncol = length(business.lines),
+ dimnames = list(1:NC,business.lines))
> for(i in 1:NC){W[i,CP.business[i]]=1}
> 
> #create portfolio data frame
> portfolio=data.frame(Number=1:NC,Name=paste("Name ",1:NC),Business=CP.business,
+                      Country=CP.country,EAD=runif(NC,1e3,1e6),LGD=runif(NC),
+                      PD=runif(NC,0,0.3),Default=rep("Bernoulli",NC),W)
> 
> #draw sector variances randomly
> sec.var=runif(NS,0.5,1.5)
> names(sec.var)=business.lines
> 
> #draw N sector realizations (independent gamma distributed sectors)
> N=5e4
> random.numbers=matrix(NA,ncol=NS,nrow=N,dimnames=list(1:N,business.lines))
> for(i in 1:NS){
+ random.numbers[,i]=rgamma(N,shape = 1/sec.var[i],scale=sec.var[i])}
> 
> #create a portfolio model and analyze the portfolio
> TestModel=init(model.type = "simulative",link.function = "CRP",N = N,
+ loss.unit = 1e3, random.numbers = random.numbers,LHR=rep(1,N),loss.thr=5e6,
+ max.entries=2e4)
    Generalized Credit Portfolio Model 
    Copyright (C) 2015 Kevin Jakob & Dr. Matthias Fischer

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    version 2 as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA  02110-1301, USA.

> TestModel=analyze(TestModel,portfolio)
Importing portfolio data....
3 sectors ...
100 counterparties (0 removed due to EAD=0 (0), lgd=0 (0), pd<=0 (0) pd>=1 (0))

Portfolio statistics....
Loss unit: 1 K
Portfolio EAD:43.56 M
Portfolio potential loss:22.74 M
Portfolio expected loss:3.42 M(analytical)
Starting simulation (50000simulations )
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Simulation finished

Calculating loss distribution...
Calculating risk measures from loss distribution....
Expected loss from loss distribution: 3.34 M (deviation from EL calculated from portfolio data: -2.21%)
Exceedance Probability of the expected loss:0.41164
Portfolio mean expected loss exceedance: 5.53 M
Portfolio loss standard deviation:2.26 M

> 
> #plot of pdf of portfolio loss (in million) with indicators for EL, VaR and ES
> alpha=c(0.995,0.999)
> plot(TestModel,1e6,alpha=alpha)
> 
> #calculate portfolio VaR and ES
> VaR=VaR(TestModel,alpha)
> ES=ES(TestModel,alpha)
> 
> #Calculate risk contributions to VaR and ES
> risk.cont=cbind(VaR.cont(TestModel,alpha = alpha),
+ ES.cont(TestModel,alpha = alpha))
Killed