HP Prime - Statistics 2Var App:  MAKELIST, L1 and Spreadsheets

Introduction, Help

The Statistics 2Var App is useful for performing regressions on sets of xy data both graphically and numerically  As usual, you should check out the online Help before using this feature.

In the examples below, we will generate and analyze 2 variable data using MAKELIST/L1 and Spreadsheet/User variable.  These will be referred to when using the Statistics 2 variable App.

Example 1 - Use MAKELIST command and list L1

If we open the Statistics 2Var App then click the Num view, we can enter numerical data directly as shown.  For this example, I just keyed into C1 ascending numbers 1-8


We could key in another column of data (C2), but instead, lets create some data using the MAKELIST command then store it in a list L1.[1] 

In Home view, create a list using MAKELIST:

  • Symb Catlg (scroll to) MAKELIST OK [2]
  • Fill in the MAKELIST() parameters (expression, X, start, end).  I used X2+5+RANDNORM() for X from 1 to 8
  • This generates an 8 element list of numbers shown.

Now store this new list into L1:

  • Sto Vars Home  List L1 OK  [3]

Next, in the Symb view, enter S1: C1 and L1 for the X and Y data.  For Type1: Linear then OK   Click Plot  to see the plot of L1 versus C1 along with the linear best fit line.  From here, I normally adjust the plot using Shift Plot (settings) for the graph shown.

  • X range from -1 to 10 and x ticks = 1
  • Y range from -10 to +100 and y ticks = 10
  • On page 2, I checked Labels

Although this graph may be interesting, the linear fit seems poor. Try other Type1: fits.  

Note that in this example (1) we generated data using a command MAKELIST() and (2) stored it in a predefined list location L1.  In general, you can create numerical lists in other ways - keying in, generating with other commands so you dont have to use MAKELIST().  Also, there is nothing magic about list L1.  Feel free to use L0-L9 or a custom name like mylist.  mylist can be referred to in the statistics app just like L1 can.  Note that mylist will also show up as a User Variable and at the bottom of the lists (Shift Lists).

Example 2 - Use Spreadsheet/User variables

In this example, we will generate both x data and y data in a spreadsheet app, save the data (xda, yda) then refer to them in the Statistics 2Var App.

Start by creating a new spreadsheet app to work in.

  • Apps highlight Spreadsheet Save enter new name[4] then OK 

Now, pick two columns for the x data and y data.  Enter (or generate) as many rows as you wish.  In example shown, I created 30 rows of data.

Now, as in Example 1, we can create saved lists that refer to the two columns of data in the spreadsheet.  To do this, I entered two cell formulas in cells D4 and D5 as shown[5].

  • D4:  =xda:=A1:A30        // defines xda as a user variable (list) referring to A1:A30
  • D5:  =yda:=B1:B30        // defines yda as a user variable (list) referring to B1:B30

If you want to check, leave the spreadsheet app and find the new xda, yda lists in user variables.

Now, return to the Statistics 2Var App, Symb view.  Enter S2: xda and yda.  Uncheck S1: plot and check the S2: plot as shown.

Now, Plot gives the following for my xda, yda data (after I messed around with the  Shift Plot (settings) )...

As in prior examples,pressing Menu then Defn   will give the fitted model and  Num then stats will give regression statistics.

Try the following on your own:

  • Try using different combinations of data sources for x, y data including manual C1 data, C2 data using MAKE, lists (L1, user variable) and lists generated by spreadsheets.
  • Setup different spreadsheet apps for different data sets or experiments you want to keep a record of.  Perhaps SS DATA1, SS DATA2 etc.?
  • In a spreadsheet, try generating y data (f(x) data) automatically based on x using spreadsheet formulas.  Can you add and control random noise?  See if the Statistics 2Var App can fit the model from the spreadsheet.
  • Try running regressions on the xda, yda user variables using the CAS command linear_regression() which should give you the linear coefficients.

[1] if you want to save a couple of keystrokes, you could enter MAKELIST(.....) Sto L1 all on one line

[2] Alternately, you could type in MAKELIST.  Or, when in Catlg, press M (+/- key) to take you to the beginning of M catalog items.

[3] Alternately, you could type in L1.

[4] I named mine SS STATS - try to be descriptive, short and all upper or lower case to ease retyping later.

[5] I added the special formatting (colors, alignment etc) to make it easier to use later. Select and Format are useful for this in the spreadsheet app.  I also “hid” rows 7-25 by setting their height to zero (temporarily).