linearRegFit
Fit a Linear Model from Spotfire

### Description

Fits a linear model from Spotfire using the formula, data, and (optionally) the weights. Summary statistics, the model coefficients and data for visualizations of the fit are returned. This function is not intended to be called by the user.

### Usage

    linearRegFit(formula, data, weights, modelName = NULL)

### Arguments

formula | a formula object. The response variable, specified as either a single numeric variable must be on the left of a tilde (~) operator and the terms, separated by plus sign (+) operators, must be on the right.
data | data frame to contain the variables named in the formula.
weights | a character string containing the name of the observation weights column in data.
modelName | a character string containing the name of the model in Spotfire.

### Details

This function gets invoked when a linear regression model is fit in Spotfire from the Tools menu.
Value
a list with components:

modelObj | the object created by calling lm using the formula and data. The object is converted to a "raw" binary object with the function SObjectToBlob from the SpotfireUtils package. This is to allow storing the object in Spotfire. To convert to the original lm object, use the BlobToSObject function, also in the SpotfireUtils package.
coefTable | a data frame containing the model coefficients, standard errors, t-statistics and p-values.
fitSummaryTable | a single column data frame containing a summary of the linear model. The first row of the data frame contains the name of the response column in data. The second row contains the names of the predictor columns from data in a single string, comma separated.
fitPlotData | a data frame containing the residuals, fitted values, standardized residuals, Normal quantiles of the standardized residuals, square root of the absolute value of the standardized residuals, and Cooks distance values.
fitPlotDesc | a character matrix containing a description of the visualizations that can be created in Spotfire using the data in fitPlotData. The columns of the matrix are: MenuName the text to appear in the Spotfire menu. PlotType the type of visualization to create Xdatatable the name of the data table for the x-axis variable. If the data table is generated by this function (i.e. fitPlotData) the name will have the prefix modelName_. Xcolumn the name of the x-axis column in Xdatatable. Ydatatable the name of the data table for the y-axis variable. If the data table is generated by this function (i.e. fitPlotData) the name will have the prefix modelName_. Ycolumn the name of the y-axis column in Ydatatable. Title the title for the visualization.
varImpTable | a two column data frame with columns Variable and VarImportance. The value of VarImportance is the absolute value of the t-statistic from the coefficients table from the model summary.

See Also
linearRegEvaluate, linearRegPredict, lm
Examples

    zlm <- linearRegFit(ozone ~ wind + temperature, data=Sdatasets::air,
        modelName="lmExample")
    names(zlm)
    zlm[[2]]

Package SpotfireStats version 6.1.5-18
Package Index