########## #Practice 7 # ########## #HW1 from last week is prolonged #I suggested a solution based on simulating from the #joint (normal) distribution of the parameter estimators #(fbvevd in the evd package provides this) and then the #for the grid points it can be checked if they belong to #the region or not. But it is still far from obvious #HW2 library(POT) sizes = c(40,100,200,300) rep=100 res=array(0,dim=c(rep,length(sizes),3)) p = 0.95 set.seed=1234 for (j in 1:rep) { for (i in 1:length(sizes)) { ech = rgpd(sizes[i] ,shape=0.6,scale=1) q = quantile(ech,p) #mle estimation fit = fitgpd(ech, threshold=0, est="mle") # mle estimation of parameters pli = confint(fit, prob=p, parm = "quant", level=0.95,range=c(2,55), prof=TRUE) #prof. lik. int res[j,i,1] = pli[2]-pli[1] res[j,i,2] = pli[1] res[j,i,3] = pli[2] } } rownames(res)=as.character(sizes) colnames(res)=c("value","b_inf","b_sup") print(res[,1,]) theo=qgpd(0.95,shape=0.6,scale=1) cover=c(0,0,0,0) for (i in 1:length(sizes)) { for (j in 1:rep) {if (!is.na(res[j,i,2]) & !is.na(res[j,i,3])) {if (theo>res[j,i,2] & theores[j,i,2] & theo