Learn R Programming

modelObj (version 4.2)

fitObject: Retrieve Regression Object

Description

Retrieves the value object returned by the regression method used to obtain parameter estimates.

Usage

fitObject(object, ...)

# S4 method for ANY fitObject(object, ...)

# S4 method for modelObjFit fitObject(object, ...)

Arguments

object

An object of class modelObjFit.

...

ignored.

Value

The Value returned by the regression method specified in the governing modelObj. The exact structure of the value will depend on the regression method. For example, if nls() is the regression method, a list is returned.

Details

This function is useful for accessing methods that are defined by the regression method but are not directly accessible from the modelObjFit object. For example, for many regression methods, users can retrieve the fitted values by calling fitted.values(object). This method is not directly accessible from a modelObjFit. However, fitted.values() can be applied to the object returned by fitObject().

Examples

Run this code
# NOT RUN {
   # 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)

   obj <- fitObject(fit.obj)
   fobj <- fitted.values(obj)
   head(fobj)

# }

Run the code above in your browser using DataLab