[R] convert an S plus file to R?

filame uyaco filams0704 at yahoo.com
Thu Nov 29 03:51:05 CET 2007


hi!

i send again my question because there was a problem earlier that 
someone did not see my attached file.   If you really can't download it,
this is the attached file.


Please help me how to convert this S plus file to R.  
Is there a quick method to do it?  I don't have an S plus
installer here.


---------------------------------------------------

# Computes a possible choice for the optimal k value
# of the Hill estimator by minimizing estimates of 
# the asumptotic mean squared error (Section 4.7ii)
#
# Estimates can be based on the estimates of the second
# order parameters gamma, b and beta obtained with the
# function Hill.2oQV
#
# If addtoHill=TRUE then the optimal k value is added to
# the plot of the Hill estimates (given the plot is available)
#
# If plot=TRUE then the estimates of the AMSE are plotted
# as a function of k and the optimal k value is added to it


"Hill.AMSE.kopt" <- function(Hill.2oQV, addtoHill=FALSE, plot=FALSE, ...) {
 
 K <- Hill.2oQV$k
 gamma <- Hill.2oQV$gamma
 b <- Hill.2oQV$b
 beta <- Hill.2oQV$beta
 
 AMSE.Hill <- (gamma^2)/K + (b/(1+beta))^2
 AMSE.Hill.min <- min(AMSE.Hill, na.rm = T)
 kopt <- K[AMSE.Hill==AMSE.Hill.min]
 
### plots if TRUE

if ( addtoHill ) {  ### add optimal k value to Hill-plot
 abline(v=kopt,lty=3,col=4)
}

if ( plot ){   ### plot estimates of AMSE as function of k
 plot(K, AMSE.Hill, type="l", ylab="AMSE gamma", xlab="k", main="AMSE estimates of extreme value index", ...)
 abline(v=kopt,lty=3,col=4)
}

### output list with values of k, corresponding
### estimates of AMSE Hill and optimal k value kopt

list(K=K, AMSE.Hill=AMSE.Hill, kopt=kopt)

}
--------------------------------------------------------

Thanks for the help.


Filame

       
---------------------------------


More information about the R-help mailing list