[R] bigglm connected to a database

Glenn Schultz glennmschultz at me.com
Tue Mar 3 21:02:29 CET 2015


I can get bigglm working with the following code.

ModelFit <- bigglm(SMM ~ 
                    I(1-.88 * exp(-.192 * LoanAge))+ 
                    ns(Incentive, df = 5)+ 
                    Purpose +
                    Occupancy +
                    TPO +
                    Servicer,
                    data = sqlQuery(Train.Data, ModelData),
                    family = binomial(link = "logit"),
                    chuncksize = 10000,
                    maxit = 100)

However, I would like to order the factors so I wrote the following code to make data.  However, it is not working.  I have read through the manual as well as some examples provided and I am not having much success with the revised code below.  I think I need to make data and provide ordering of the factors in the make data but so far this scheme has not worked.  I think I am missing somethin any insights are appreciated.

Best Regards,
Glenn

make.data <- function(connection, query, chunksize,...){
 
    function(reset = FALSE) {
      if (reset) {
        if (got > 0) {
            dbClearResult(result)
            result <<- dbSendQuery(Train.Data, ModelData)
            got <<- 0
        }
        return(TRUE)
    }
    rval <- fetch(result, n = chunksize)
    got <<- got + nrow(rval)
    if (nrow(rval) == 0)
        return(NULL)
    return(rval)
}
}

data <- make.data(connection = Train.Data, query = ModelData, chunksize = 10000)

ModelFit <- bigglm(SMM ~ 
                    I(1-.88 * exp(-.192 * LoanAge))+ 
                    ns(Incentive, df = 5)+ 
                    Purpose +
                    Occupancy +
                    TPO +
                    Servicer,
                    data = data,
                    family = binomial(link = "logit"),
                    maxit = 100)



 


More information about the R-help mailing list