methods-fit: Execute Regression Step

Description Usage Arguments Details Value Author(s) Examples

Description

Executes the model fitting procedure for an object of class modelObj.

Usage

1
2
## S4 method for signature 'modelObj,data.frame,vector'
fit(object, data, response, ...)

Arguments

object

an object of class modelObj as returned by the ‘buildModelObj’ function.

data

an object of class data.frame containing the variables in the model.

response

an object of class vector containing the response variable.

...

ignored

Details

If defined by the modeling function, the following methods can be applied to a modelObjFit object to obtain standard fit results: coef, plot, predict, residuals, and summary.

Value

Returns an object of class "modelObjFit", which contains the object returned by the modeling function and the method to be used to obtain predictions.

Slots of the modelObjFit object can be retrieved using fitObject(object), predictor(object), and predictorArgs(object).

Author(s)

Shannon T. Holloway <sthollow@ncsu.edu>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    #----------------------------------------------------#
    # Generate data
    #----------------------------------------------------#
    X <- matrix(rnorm(1000,0,1),
                ncol=4,
                dimnames=list(NULL,c("X1","X2","X3","X4")))

    Y <- X %*% c(0.1, 0.2, 0.3, 0.4) + rnorm(250)

    X <- data.frame(X)

    #----------------------------------------------------#
    # Create modeling object using a formula
    #----------------------------------------------------#
    mo <- buildModelObj(model=Y ~ X1 + X2 + X3 + X4,
                   solver.method='lm')

    #----------------------------------------------------#
    # Fit model
    #----------------------------------------------------#
    fit.obj <- fit(object=mo, data=X, response=Y)

    coef(fit.obj)
    head(residuals(fit.obj))
    plot(fit.obj)
    head(predict(fit.obj,X))
    summary(fit.obj)

modelObj documentation built on May 2, 2019, 5:20 p.m.