idaGlm: Generalized Linear Models (GLM)

View source: R/glm.R

idaGlmR Documentation

Generalized Linear Models (GLM)

Description

This function computes generalized linear models on the contents of an ida.data.frame.

Usage


idaGlm(	form, data, id = "id", intercept = T, family = "bernoulli", family_param = -1, 
          link = "logit", link_param = 1, maxit = 20, eps = 1e-3, tol = 1e-7, 
          method = "irls", trials = NULL, incolumn = "", interaction = "", 
          modelname = NULL, format = "glm", raw.resid = F, dropAfter = F, ...)
          
## S3 method for class 'idaGlm'
print(x, ...)
## S3 method for class 'idaGlm'
predict(object, newdata, id, outtable = NULL, ...)

Arguments

form

A formula object that describes the GLM to build.

data

An ida.data.frame object that stores the data to be used for GLM building.

id

The ID column name.

intercept

The intercept.

family

The type of error distribution. It can have one of the follwing values: "bernoulli", "gaussian", "poisson", "binomial", "negativebinomial", "wald", "gamma"

family_param

A family-specific parameter.

link

Type of the link function. It can have one of the follwoing values:

"clog", "cloglog", "gaussit", "identity", "log", "logit", "oddspower", "power", "probit", and "sqrt". For Db2 for z/OS it can have the following values as well: "canbinom", "cangeom", "cannegbinom", "cauchit", "inverse", "invnegative", "invsquare", "loglog" .

link_param

Link parameter, 1 by default.

maxit

Maximum number of iterations. 20 by default.

eps

Maximum (relative) error used as a stopping criterion. This should be sufficiently small for the algorithm to work.

tol

The tolerance for the linear equation solver to consider a value equal to be zero. This should be sufficiently small for the algorithm to work.

method

Computing algorithm: either "irls" ("iteratively reweighted least square") or "psgd" ("parallel stochastic gradient descent").

trials

The input table column containing the number of trials for the binominal distribution. Ignored unless family is 'binomial'.

incolumn

Overwrite automatic creation of incolumn parameter and specify your own incolumn here.

interaction

Overwrite automatic creation of interaction parameter and specify your own interaction here.

modelname

Name of the model that will be created in the database. Will be created automatically if not specified.

format

Specify output format. Either "glm" for output looking like stats::glm or raw for downloading all results as data.frames.

raw.resid

If format equals "raw", whether to download the residuals or return NULL instead.

dropAfter

Whether to drop the results after downloading them as specified in format.

x

An idaGlm object.

object

An idaGlm object.

newdata

New data used for prediction as ida.data.frame.

outtable

The name of the table the results will be written in.

...

Additional parameters.

Details

For more details on the GLM algorithm and requirements to the data, please refer to the documentation of the nza..GLM stored procedure in the Netezza In-Database Analytics Reference Guide or Netezza In-Database Analytics Developers Guide.

Value

  • The function idaGlm returns the generalized linear regression model of classes glm and idaGlm if format equals "glm" or a list of data.frames if format equals "raw".

  • The functions print and summary have no return values.

  • The function predict returns an ida.data.frame that contains the predicted values.

Examples

## Not run: 
#Add isSetosa column to iris data frame
iris2 <- iris
iris2$isSetosa <- ifelse(iris2$Species=="setosa", 1, 0)

#Store the iris2 data frame in the IRIS2 table
idf <-as.ida.data.frame(iris2, table="IRIS2", clear.existing=T, rownames="ID")

#Calculate GLM model in-db
glm <- idaGlm(isSetosa~PetalLength+SepalLength*SepalWidth+PetalWidth, idf, id="ID")

#Print the model
print(glm)

#Apply the model to data
idf2 <- predict(glm, idf, "ID")

#Inspect the results
head(idf2)


## End(Not run)

ibmdbR documentation built on Nov. 24, 2023, 5:09 p.m.