[R] convert an S plus file to R?

Steven McKinney smckinney at bccrc.ca
Thu Nov 29 04:26:36 CET 2007



Hi,

The function you show below performs
relatively simple S language stuff, and
looks as if it will run as is in R.

Looks like you'll need an output object
"Hill.2oQV" (I'm guessing from a function
of the same name).  That Hill.2oQV() function
may need some work, but the Hill.AMSE.kopt()
function below should work as is.

Best

Steve McKinney




-----Original Message-----
From: r-help-bounces at r-project.org on behalf of filame uyaco
Sent: Wed 11/28/2007 6:51 PM
To: r-help at stat.math.ethz.ch
Subject: [R] convert an S plus file to R?
 

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