QScript LinearRegression

From Q
Jump to navigation Jump to search

LinearRegression

A linear regression that is run from either Table JavaScript or QScript by specifying dependent and independent questions (as well as optional filters and weight variables, in the case of QScripts). Please see Driver (Importance) Analysis for more information on the regression outputs listed below.

betas

Gets an array of the independent variable Betas, also known as standardized coefficients.
Example:
log("Beta of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.betas[0]);

betasCorrectedPValues

Gets an array of the corrected p-values of the Beta estimates.
Example:
log("Corrected p-value of the Beta of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.betasCorrectedPValues[0]);

betasNormalized

Gets an array of the independent variable Betas that have been normalized such that their magnitudes sum to 1.
Example:
log("Normalized Beta of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.normalizedBetas[0]);

betasPValues

Gets an array of the p-values of the Beta estimates.
Example:
log("p-value of the Beta of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.betasPValues[0]);

betasStandardErrors

Gets an array containing the standard errors of the Beta estimates.
Example:
log("Standard error of the first Beta estimate: " + lin_reg.betasStandardErrors[0]);

betasTStatistics

Gets an array of the t-statistics of the Beta estimates.
Example:
log("t-statistic of the Beta of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.betasTStatistics[0]);

betasZStatistics

Gets an array of the z-statistics of the Beta estimates.
Example:
log("z-statistic of the Beta of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.betasZStatistics[0]);

coefficientLabels

Gets an array of labels for the linear regression coefficients constructed from the question names and variable labels.
Example:
log("First independent variable: " + lin_reg.coefficientLabels[1]);

coefficients

Gets an array of the linear regression coefficients with the intercept term in the first entry and the indepedent variable coefficients in the subsequent entries.
Example:
log("Intercept: " + lin_reg.coefficients[0]);

contributions

Gets an array of the (signed) independent variable contributions. See Importance and Contribution.
Example:
log("Contribution of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.contributions[0]);

contributionsRaw

Gets an array of the independent variable contributions that have not been normalized to sum to 1. See Importance and Contribution.
Example:
log("Raw contribution of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.contributionsRaw[0]);

contributionsRawCorrectedPValues

Gets an array of the corrected p-values of the raw contribution estimates.
Example:
log("Corrected p-value of the raw contribution of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.contributionsRawCorrectedPValues[0]);

contributionsRawPValues

Gets an array of the p-values of the raw contribution estimates.
Example:
log("p-value of the raw contribution of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.contributionsRawPValues[0]);

contributionsRawSigned

Same as contributionsRaw but with signs applied from the linear regression coefficients.
Example:
log("Signed raw contribution of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.contributionsRawSigned[0]);

contributionsRawStandardErrors

Gets an array containing the standard errors of the raw (not normalized to sum to 1) contribution estimates.
Example:
log("Standard error of the first raw contribution estimate: " + lin_reg.contributionsRawStandardErrors[0]);

contributionsRawTStatistics

Gets an array of the t-statistics of the raw contribution estimates.
Example:
log("t-statistic of the raw contribution of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.contributionsRawTStatistics[0]);

contributionsRawZStatistics

Gets an array of the z-statistics of the raw contribution estimates.
Example:
log("z-statistic of the raw contribution of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.contributionsRawZStatistics[0]);

degreesOfFreedom

Gets the degrees of freedom of the regression.
Example:
log("Degrees of freedom: " + lin_reg.degreesOfFreedom);

effectiveSampleSize

Gets the effective sample size of the regression.
Example:
log("Effective sample size: " + lin_reg.effectiveN);

elasticity

Gets an array containing elasticity estimates of each independent variable, which are the coefficients obtained from a regression in which both the dependent and independent variables have been transformed using the natural logarithm.
Example:
log("Elasticity of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.elasticity[0]);

elasticityCorrectedPValues

Gets an array of the corrected p-values of the elasticity estimates.
Example:
log("Corrected p-value of the elasticity of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.elasticityCorrectedPValues[0]);

elasticityPValues

Gets an array of the p-values of the elasticity estimates.
Example:
log("p-value of the elasticity of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.elasticityPValues[0]);

elasticityRSquared

Gets the R-squared of the elasticity regression.
Example:
log("Elasticity R-squared: " + lin_reg.elasticityRSquared);

elasticityStandardErrors

Gets the standard errors for the elasticity estimates.
Example:
log("Standard error of the first elasticity estimate: " + lin_reg.elasticityStandardErrors[0]);

elasticityTStatistics

Gets an array of the t-statistics of the elasticity estimates.
Example:
log("t-statistic of the elasticity of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.elasticityTStatistics[0]);

elasticityZStatistics

Gets an array of the z-statistics of the elasticity estimates.
Example:
log("z-statistic of the elasticity of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.elasticityZStatistics[0]);

equals(obj)

Whether two objects are the same.
objThe object to compare against.
Returns:true or false
Example:
data_file.getQuestionByName('Q2').equals(data_file.questions()[0])

failed

A read-only property that is true if the data in the input questions is not appropriate.

failureMessage

A read-only property that contains a string explaining why the data in the input questions is not appropriate if failed is true.

importances

Gets an array of the (signed) independent variable importances. See Importance and Contribution
Example:
log("Importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.importances[0]);

independentVarCoefs

Same as coefficients except that the intercept coefficient is omitted.
Example:
log("Coefficient of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.independentVarCoefs[0]);

independentVarCoefsCorrectedPValues

Gets an array of the corrected p-values of the independent variable coefficient estimates.
Example:
log("Corrected p-value of the coefficient of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.independentVarCoefsCorrectedPValues[0]);

independentVarCoefsPValues

Gets an array of the p-values of the independent variable coefficient estimates.
Example:
log("p-value of the coefficient of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.independentVarCoefsPValues[0]);

independentVarCoefsStandardErrors

Gets an array containing the standard errors of the independent variable coefficient estimates.
Example:
log("Standard error of the coefficient of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.independentVarCoefsStandardErrors[0]);

independentVarCoefsTStatistics

Gets an array of the t-statistics of the independent variable coefficient estimates.
Example:
log("t-statistic of the coefficient of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.independentVarCoefsTStatistics[0]);

independentVarCoefsZStatistics

Gets an array of the z-statistics of the independent variable coefficient estimates.
Example:
log("z-statistic of the coefficient of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.independentVarCoefsZStatistics[0]);

kruskalImportance

Gets an array containing Kruskal importance estimates of each independent variable.
Example:
log("Kruskal importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.kruskalImportance[0]);

kruskalImportanceCorrectedPValues

Gets an array of the corrected p-values of the Kruskal importance estimates.
Example:
log("Corrected p-value of the Kruskal importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.kruskalImportanceCorrectedPValues[0]);

kruskalImportanceNormalized

Gets an array containing Kruskal importance estimates of each independent variable that have been normalized such that their magnitudes sum to 1.
Example:
log("Normalized Kruskal importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.kruskalImportanceNormalized[0]);

kruskalImportancePValues

Gets an array of the p-values of the Kruskal importance estimates.
Example:
log("p-value of the Kruskal importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.kruskalImportancePValues[0]);

kruskalImportanceSigned

Same as kruskalImportance but with signs applied from the linear regression coefficients.
Example:
log("Signed Kruskal importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.kruskalImportanceSigned[0]);

kruskalImportanceStandardErrors

Gets the standard errors for the Kruskal importance estimates.
Example:
log("Standard error of the first Kruskal importance estimate: " + lin_reg.kruskalImportanceStandardErrors[0]);

kruskalImportanceTStatistics

Gets an array of the t-statistics of the Kruskal importance estimates.
Example:
log("t-statistic of the Kruskal importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.kruskalImportanceTStatistics[0]);

kruskalImportanceZStatistics

Gets an array of the z-statistics of the Kruskal importance estimates.
Example:
log("z-statistic of the Kruskal importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.kruskalImportanceZStatistics[0]);

relativeImportance

Gets an array containing relative importance estimates of each independent variable.
Example:
log("Relative importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.relativeImportance[0]);

relativeImportanceCorrectedPValues

Gets an array of the corrected p-values of the relative importance estimates.
Example:
log("Corrected p-value of the relative importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.relativeImportanceCorrectedPValues[0]);

relativeImportanceNormalized

Gets an array containing relative importance estimates of each independent variable that have been normalized such that their magnitudes sum to 1.
Example:
log("Normalized relative importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.relativeImportanceNormalized[0]);

relativeImportancePValues

Gets an array of the p-values of the relative importance estimates.
Example:
log("p-value of the relative importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.relativeImportancePValues[0]);

relativeImportanceSigned

Same as relativeImportance but with signs applied from the linear regression coefficients.
Example:
log("Signed relative importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.relativeImportanceSigned[0]);

relativeImportanceStandardErrors

Gets the standard errors for the relative importance estimates.
Example:
log("Standard error of the first relative importance estimate: " + lin_reg.relativeImportanceStandardErrors[0]);

relativeImportanceTStatistics

Gets an array of the t-statistics of the relative importance estimates.
Example:
log("t-statistic of the relative importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.relativeImportanceTStatistics[0]);

relativeImportanceZStatistics

Gets an array of the z-statistics of the relative importance estimates.
Example:
log("z-statistic of the relative importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.relativeImportanceZStatistics[0]);

rSquared

Gets the R-squared of the regression.
Example:
log("R-squared: " + lin_reg.rSquared);

shapleyImportance

Gets an array containing Shapley importance estimates of each independent variable.
Example:
log("Shapley importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.shapleyImportance[0]);

shapleyImportanceCorrectedPValues

Gets an array of the corrected p-values of the Shapley importance estimates.
Example:
log("Corrected p-value of the Shapley importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.shapleyImportanceCorrectedPValues[0]);

shapleyImportanceNormalized

Gets an array containing Shapley importance estimates of each independent variable that have been normalized such that their magnitudes sum to 1.
Example:
log("Normalized Shapley importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.shapleyImportanceNormalized[0]);

shapleyImportancePValues

Gets an array of the p-values of the Shapley importance estimates.
Example:
log("p-value of the Shapley importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.shapleyImportancePValues[0]);

shapleyImportanceSigned

Same as shapleyImportance but with signs applied from the linear regression coefficients.
Example:
log("Signed Shapley importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.shapleyImportanceSigned[0]);

shapleyImportanceStandardErrors

Gets the standard errors for the Shapley importance estimates.
Example:
log("Standard error of the first Shapley importance estimate: " + lin_reg.shapleyImportanceStandardErrors[0]);

shapleyImportanceTStatistics

Gets an array of the t-statistics of the Shapley importance estimates.
Example:
log("t-statistic of the Shapley importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.shapleyImportanceTStatistics[0]);

shapleyImportanceZStatistics

Gets an array of the z-statistics of the Shapley importance estimates.
Example:
log("z-statistic of the Shapley importance of " + lin_reg.coefficientLabels[1] + ": " + lin_reg.shapleyImportanceZStatistics[0]);

type

Returns 'LinearRegression'.

See also

Further reading: Key Driver Analysis Software