Line Through the Data
Fit an ordinary least squares line to the points (x[i], y[i]) with statsmodels and return [intercept, slope].
Example 1
x [0,1,2]
y [1,3,5]
returns [1.0,2.0]
The points lie on y = 1 + 2x.
Constraints
3 <= len(x) <= 40- The xs are not all equal
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Reading Off the LineBeginner
- Room for the InterceptBeginner
- Slope From a TableBeginner
- What the Line MissesBeginner
- Echo of YesterdayEasy
- Fair R SquaredEasy
- Group GapsEasy
- Is the Share DifferentEasy