getpac {scR} | R Documentation |
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)
Arguments
table |
A list containing an element named |
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 |
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.
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
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)
}
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=10,
coreoffset = (detectCores() -2))
resultsalt <- getpac(results,epsilon=0.5,delta=0.3)
print(resultsalt$Summary)