Tag Archives: linear regression

fitbit data analysis


The fitbit is a wearable device for collecting various activity metrics including walking and sleeping. As expected, with a r statistics extremely close to 1 there is a direct relationship between steps and distance traveled.

Analysis with one more variable of “minutes active” provided by fitbit revealed similar relationship.fitbit3




Shipping option decision by linear regression on TI-84

An online store offered the following shipping options:

Monday – $142
Tuesday – $86
Friday – $63

Applying linear regression in TI-84, the following parameters are obtained.

Plotting the results in Stat Plot:

It therefore appears delivery on Tuesday is the most appealing choice.

Durbin-Watson statistic in TI-84

Unlike the more sophisticated TI-89 and Nspire, the Durbin-Watson statistic is not included in the TI-84. Yet, calculating it is fairly straight-forward using list functions.

This statistics of regression is given as


where e is the residual list of values. To obtain this list (using a previous multiple regression example), simply subtract the actual values from the regression formula (Y7 below):

durbinwatson1 durbinwatson2

Finally, run the formula below for answer.


Quick residual plot in TI Nspire

When working with regression analysis, residual plot is a handy tool to gain insights by visualization. The TI Nspire provided easy and convenient access to these plots in just a few clicks.

Using a simple linear regression as an example below:


Access the menu 4:Analyze > 7:Residuals will show the two options for residual plots, including Show Residual Squares and Residual Plots. The nice plotting output are show below.


Multiple linear regression by weighted least squares on the Nspire

When performing data analysis, it is sometimes desirable to assign weights to selected data according to their perceived values. For example, data that are more reliable are assigned a higher weight, or weight value that is inversely proportional to variance of that data value. This technique can be applied to multiple linear regression as well. In the more common regression method by ordinary least squares (OLS), all observed data are of the same weight. In weighted least squares (WLS), an arbitrary weight value is assigned to each of the observations. WLS is a special case of generalized least squares (GLS) method.

The regression analysis in Nspire supports only the OLS method. Programming is required to adopt the WLS. Fortunately, the built-in programming by the Nspire supports accessing data stored in the spreadsheet application in the form of  lists and matrices, which are heavily relied upon on the calculation of WLS statistics. Needless to say Nspire is good at performing matrix operations.

Similar to OLS, the WLS approach is based on the minimization of the sum of squares between sets of data, from which the parameters for the regression equation are obtained. In WLS, the equation is given by

β = (XT Λ-1 X)-1XTΛ-1Y

where  Λ is the covariance matrix used to determine the weights, and can be represented by the piece-wise equation


The total sum of squares in WLS is given by


and the sum of squares error by


For visualization, the response plane plot of the regression equations obtained from a sample data set by OLS with the Nspire built-in multiple linear regression and the WLS program respectively are generated using the 3D function plot.