epcreg.save {EnsemblePCReg}R Documentation

Custom Functions for Disk I/O in EnsemblePCReg Package

Description

These functions can be used whether filemethod flag is set to TRUE or FALSE during the epcreg call. Note that epcreg.load ‘returns’ the estimation object (in contrast to the standard load method).

Usage

epcreg.save(obj, file)
epcreg.load(file)

Arguments

obj

Object of classes "epcreg" (and possibly "epcreg.file"), typically the output of call to function epcreg.

file

Filepath to where obj must be saved to / loaded from.

Value

Function epcreg.load returns the saved obj, with estimation files automatically copied to R temporary directory, and filepaths inside the obj fields updated to point to these new filepaths (if filemethod was set to TRUE in the call to epcreg).

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

See Also

epcreg

Examples

data(servo)
myformula <- class~motor+screw+pgain+vgain
perc.train <- 0.7
index.train <- sample(1:nrow(servo), size = round(perc.train*nrow(servo)))
data.train <- servo[index.train,]
data.predict <- servo[-index.train,]
est <- epcreg(myformula, data.train, ncores=2
  , baselearner.control=epcreg.baselearner.control(
    baselearners="knn"
    , baselearner.configs = make.configs("knn"
      , config.df = expand.grid(kernel = "rectangular"
        , k = c(5, 10)))), filemethod = TRUE)
epcreg.save(est, "somefile")
rm(est) # alternatively, exit and re-launch R session
est.loaded <- epcreg.load("somefile")
newpred <- predict(est.loaded, data.predict)
file.remove("somefile")

[Package EnsemblePCReg version 1.1.4 Index]