linearRegEvaluate
Evaluate a Linear Model from Spotfire

Description

Evaluates a linear model from Spotfire by computing predictions and residuals from the supplied newdata. Summary statistics and data for visualizations of the predictions are returned. This function is not intended to be called by the user.

Usage

linearRegEvaluate(modelObj, newdata, origRespName, newRespName, origPredNames,
    newPredNames, modelName)

Arguments

modelObj an object of class "lm".
newdata a data frame to use for the evaluations. It must contain columns with names newRespName and newPredNames.
origRespName a character string naming the response variable used in modelObj.
newRespName a character string naming the response variable in newdata. This is often the same as origRespName.
origPredNames a single character string containing the predictor variables used in modelObj. The values must be tab delimited.
newPredNames a single character string naming the predictor variable in newdata. This is often the same as origPredNames. The values must be tab delimited.
modelName a character string containing the name of the model in Spotfire. This is used to construct the names of the components in the return list.

Details

This function gets invoked when a linear regression model is evaluated in Spotfire.
Value
a list with components:
evalSummaryTable a single column data frame containing summary information for the model evaluation. This includes R^2 and the mean square error.
evalPlotData a data frame containing the predictions, residuals and Normal quantiles of the residuals, all computed from newdata.
evalPlotDesc a character matrix containing a description of the visualizations that can be created in Spotfire using the data in evalPlotData. 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.
See Also
linearRegFit, linearRegPredict, lm
Examples
zlm <- linearRegFit(ozone ~ wind + temperature, data=Sdatasets::air,
    modelName="lmExample")
respName <- zlm$fitSummaryTable[1,1]
predNamesString <- zlm$fitSummaryTable[2, 1]
predNames <- strsplit(predNamesString, "\t", fixed=TRUE)[[1]]
ap <- Sdatasets::air[1:20, c(respName, predNames)]
zEval <-  linearRegEvaluate(zlm$modelObj, newdata=ap,
    respName, respName, predNamesString, predNamesString, modelName="lmExample")
Package SpotfireStats version 6.1.4-13
Package Index