Learn R Programming

scR (version 0.4.0)

getpac: Recalculate achieved sample complexity bounds given different parameter inputs

Description

Recalculate achieved sample complexity bounds given different parameter inputs

Usage

getpac(table, epsilon = 0.05, delta = 0.05)

Value

A list containing two named elements. Raw gives the exact output of the simulations, while Summary gives a table of accuracy metrics, including the achieved levels of \(\epsilon\) and \(\delta\) given the specified values. Alternative values can be calculated using getpac() again.

Arguments

table

A list containing an element named Raw. Should always be used with the output of estimate_accuracy()

epsilon

A real number between 0 and 1 giving the targeted maximum out-of-sample (OOS) error rate

delta

A real number between 0 and 1 giving the targeted maximum probability of observing an OOS error rate higher than epsilon

See Also

plot_accuracy(), to represent simulations visually, getpac(), to calculate summaries for alternate values of \(\epsilon\) and \(\delta\) without conducting a new simulation, and gendata(), to generated synthetic datasets.

Examples

Run this code
mylogit <- function(formula, data){
m <- structure(
  glm(formula=formula,data=data,family=binomial(link="logit")),
  class=c("svrclass","glm")  #IMPORTANT - must use the class svrclass to work correctly
)
return(m)
}
mypred <- function(m,newdata){
out <- predict.glm(m,newdata,type="response")
out <- factor(ifelse(out>0.5,1,0),levels=c("0","1"))
#Important - must specify levels to account for possibility of all
#observations being classified into the same class in smaller samples
return(out)
}
# \donttest{
library(parallel)
results <- estimate_accuracy(two_year_recid ~ race +
    sex + age + juv_fel_count + juv_misd_count + priors_count +
    charge_degree..misd.fel.,mylogit,br,predictfn = mypred,
    nsample=10,
    steps=1000,
    coreoffset = (detectCores() -2))
resultsalt <- getpac(results,epsilon=0.5,delta=0.3)
print(resultsalt$Summary)
# }

Run the code above in your browser using DataLab