 |
cmd_linreg |
Function (ROM Call 0x35C) |
Executes TI-Basic 'LinReg' command.
cmd_linreg calculates a linear regression and updates all statistics
variables (see TI-Basic manual for more info). The RegData parameter
must point to a structure on the expression stack which describes where the
actual data is stored. This structure may have one of the following four
layouts (RegData should point to the last item):
x_list_name is the VAT symbol name (see
SYMSTR and
Tags for more info) of a TI-Basic list
variable which contains the x values. y_list_name is the VAT symbol
name of a TI-Basic list variable which contains the y values.
freqs_name (if present) is the VAT symbol name of a TI-Basic list
variable which contains the frequencies (all frequencies are assumed to be 1
if freqs_name is not present). categories_name (if present) is
the VAT symbol name of a TI-Basic list which contains the category code for
each item. categories_list represents a list of integer items which
determine which categories will be included (this makes sense only when
categories_name is used).
For example, assuming that two TI-Basic list variables "xdata" and "ydata"
contain the x and y values, you can calculate a simple regression using the
following code fragment:
push_quantum (NOTHING_TAG);
push_quantum (NOTHING_TAG);
push_quantum (NOTHING_TAG);
push_expression (SYMSTR ("ydata"));
push_expression (SYMSTR ("xdata"));
cmd_linreg (top_estack);
After this, you can retrieve the calculated regression data by accessing
TI-Basic system variables like "regCoef" directly (using
VarRecall, for example), or you can
display the calculated data using
cmd_showstat.
The symbol names x_list_name, y_list_name, freqs_name,
and categories_name may also be "c1".."c99". In this case, they
represent columns in the last data variable shown in the Data/Matrix editor.
In all cases, the lists represented by x_list_name,
y_list_name, freqs_name, and categories_name must have
the same dimension.
Uses: HeapAlloc, HeapDeref, HeapFree, HeapFreeIndir, HeapRealloc, HLock, ER_catch, ER_success, ER_throwVar, estack_to_ushort, next_expression_index, ST_helpMsg, XR_stringPtr, ceil, fabs, floor, sqrt, ck_valid_float, estack_to_float, is_cFloat_agg, OO_GetAppAttr, PlotInit, PlotPut, RM_Type, statFree, statStart, MakeWinRect, WinFill, WinFillTriangle, WinLine, WinRect, WinStrXY, _bcd_math, ROM Call 0x46B, ROM Call 0x4CB
See also: cmd_quadreg, cmd_cubicreg, cmd_quartreg, cmd_powerreg, cmd_expreg, cmd_lnreg, cmd_sinreg, cmd_onevar, cmd_twovar, cmd_medmed, cmd_logistic