WeBWorK Problems

stats and least squares linear regression

Re: stats and least squares linear regression

by Danny Glin -
Number of replies: 0

You can look at the code of the problems in the Regression section of the OPL to get some ideas.  Here are a few techniques that I am aware of:

  1. Use the R integration with WeBWorK.  This allows you to call any R functions to do statistical calculations.  Many of the UBC statistics problems in the OPL take advantage of this.
  2. There appears to be a function called linear_regression in PGstatisticsmacros.pl.  According to the documentation, the usage is:
    @xdata = (-1,2,3,4,5,6,7);
    @ydata = (6,5,6,7,8,9,11);
    ($slope,$intercept,$var,$SXX) = linear_regression(~~@xdata,~~@ydata);
    Though based on a quick look, this isn't used in any OPL problem, so I don't know how well tested it is.
  3. You can create a for loop within your problem to manually calculate the parameters.  This is inelegant but effective.