swirldev / swirl_courses

:mortar_board: A collection of interactive courses for the swirl R package.
http://swirlstats.com
Other
4.29k stars 7.25k forks source link

Regression Models link typo #35

Closed stephenfranklin closed 10 years ago

stephenfranklin commented 10 years ago

Lesson 2 'Residuals' of the Regression Models swirl course reads: This lesson corresponds to Regression_Models/01_02_linearRegression., refering to https://github.com/DataScienceSpecialization/courses/tree/master/07_RegressionModels/01_02_linearRegression, which is a page that doesn't exist.

Possibly it should be 01_02_notation or another section.

The lesson also refers to equations "in the slides" for the intercept and slope which are difficult to identify; they don't seem to be in 01_02_notation.

WilCrofter commented 10 years ago

Thanks @stephenfranklin.

I believe the reference should have been https://github.com/DataScienceSpecialization/courses/tree/master/07_RegressionModels/01_03_ols. I've made that change and pushed it to github.

The slides and swirl exercises are trying to convey a point which is difficult to make without calculus, namely that squared error is minimized precisely when the residual has sample mean zero and when the sample correlation of the residual with the predictor is also zero. These two equations can be solved for the two unknowns, slope and intercept. Using calculus, the equations would be derived by setting partial derivatives with respect to slope and intercept to zero. Perhaps we should say that.

A closely related topic (Gaussian elimination,) which is difficult to convey without linear algebra, is addressed in Introduction to Multivariate Analysis. We're hoping swirl's numerical treatment of both subjects will be useful, but we're aware of the weaknesses and welcome critique and suggestions.

stephenfranklin commented 10 years ago

Thank you! @WilCrofter,

Yeah I think primary difficulty with using the swirl lessons is that they don't display equations; instead they tend to refer approximately to a slide in a lecture. It's interruptive to have to try to figure out which equation is being referenced. The correct equation would seem pretty obvious if you already understand the concepts that are being taught, but in the middle of learning, it can be quite confusing.

I have a few ideas that might address that difficulty:

  1. At the very least, an equation can be referred to with the slide's title and/or number (and a link to the github repo just for convenience).
  2. The equation can be displayed as R code or pseudocode; not necessarily to be run, but just for the purpose of presenting the concept.
  3. Would it be possible to have knitr or sweave output a png of a LaTeX equation? If in Rstudio, could it be output to the "Plots" window?
WilCrofter commented 10 years ago

Again, thanks for your comments and interest. We are a small group of volunteer developers and genuinely appreciate the help. I can relate to your point about which equation we're talking about. I believe I've been there myself recently.

In addition to the options which you have mentioned, RStudio can display local html files and Shiny apps in its Viewer (internal web browser). Even without RStudio, locally served html could be displayed in the default system browser, (although it might be a bit annoying to have the browser pop up and hide the console.) Nick has even demo'd things along these lines. (See swirl_misc at github.)

We can detect if a lesson is running in RStudio and act accordingly. We do precisely that in Least Squares Estimation where we use an interactive plot in RStudio and a static plot otherwise. I imagine we could do something similar with equations, using html in the Viewer if it's present, or R code if it's not.

ncarchedi commented 10 years ago

Nick has even demo'd things along these lines.

Yup, displaying math notation is a feature I worked on in a special branch of our swirldev/swirl repository a while back. I just brought it up to date if you'd like to give it a try with a little demo course I wrote.

To install the special dev branch of swirl and the demo course, do the following. Note that this will erase any courses you currently have installed, but you can always reinstall those.

library(devtools)
install_github("swirldev/swirl@math_notation")
install_from_swirl("Exploring_Math_Notation", dev = TRUE)
library(swirl)
swirl()

Thoughts/comments/insults welcome!

ncarchedi commented 10 years ago

Sorry, there was a typo in my previous comment. You have to type library(swirl) before swirl(), but that's probably old news for you anyway.

stephenfranklin commented 10 years ago

Yeah! Exactly that should be in all the courses. Thanks!

ncarchedi commented 10 years ago

@stephenfranklin Cool, we'll consider including it (or something similar) in the next release of swirl. Thanks for your feedback.