From Data to Predictions: Linear Regression and Residual Plots
Loading the math board and drawing, please wait…
① This example demonstrates how to start with a set of scattered data points, fit a straight line using linear regression, and use a residual plot to evaluate the fit, ultimately moving from raw data to predictions. ② Core mathematical concepts include linear regression, least squares, residual analysis, statistical characteristics (mean, variance), and the relationship between line equations and function graphs. ③ Construction highlights: The GeoGebra command ResidualPlot is used to generate the residual plot, involving multiple data point objects (such as A1 to B16), with line fitting and residual visualization showing deviations between observed and predicted values. ④ Suitable for high school or college statistics and data analysis courses, this example provides an intuitive understanding of regression model construction and diagnostics, and is ideal for math labs or project-based learning to help students master data modeling fundamentals.
GeoGebra Commands & Parameters
ResidualPlot({(1880, -0.24), (1881, -0.3), (1882, -0.24), (1883, -0.23), (1884, -0.28), (1885, -0.2), (1886, -0.32), (1887, -0.33), (1888, 0.02), (1889, -0.27), (1890, -0.36), (1891, -0.3), (1892, -0.29), (1893, -0.25), (1894, -0.3), (1895, -0.12), (1896, 0), (1897, -0.17), (1898, -0.37), (1899, -0.1), (1900, 0.07), (1901, -0.34), (1902, -0.3), (1903, -0.52), (1904, -0.44), (1905, -0.27), (1906, -0.29), (1907, -0.3), (1908, -0.5), (1909, -0.37), (1910, -0.44), (1911, -0.32), (1912, -0.54), (1913, -0.31), (1914, -0.11), (1915, -0.24), (1916, -0.28), (1917, -0.33), (1918, -0.12), (1919, -0.24), (1920, -0.23), (1921, -0.06), (1922, -0.28), (1923, -0.19), (1924, -0.31), (1925, -0.17), (1926, -0.07), (1927, 0.01), (1928, -0.16), (1929, -0.14), (1930, -0.02), (1931, 0.03), (1932, -0.1), (1933, -0.2), (1934, -0.04), (1935, -0.03), (1936, -0.02), (1937, 0.1), (1938, 0.08), (1939, 0), (1940, 0.16), (1941, 0.43), (1942, 0.07), (1943, 0.26), (1944, 0.32), (1945, 0.27), (1946, 0), (1947, 0.05), (1948, -0.06), (1949, -0.06), (1950, -0.16), (1951, 0.13), (1952, 0.01), (1953, 0.12), (1954, -0.05), (1955, -0.12), (1956, -0.19), (1957, 0.03), (1958, 0.08), (1959, 0), (1960, 0.06), (1961, -0.02), (1962, 0.12), (1963, 0.23), (1964, -0.25), (1965, 0.02), (1966, -0.07), (1967, 0.15), (1968, 0.06), (1969, 0.09), (1970, -0.02), (1971, -0.08), (1972, 0.1), (1973, 0.07), (1974, -0.06), (1975, -0.12), (1976, -0.19), (1977, 0.12), (1978, 0.08), (1979, 0.3), (1980, 0.19), (1981, 0.18), (1982, 0.18), (1983, 0.24), (1984, 0.15), (1985, 0.15), (1986, 0.22), (1987, 0.35), (1988, 0.31), (1989, 0.29), (1990, 0.43), (1991, 0.29), (1992, 0.05), (1993, 0.23), (1994, 0.43), (1995, 0.44), (1996, 0.22), (1997, 0.64), (1998, 0.49), (1999, 0.35), (2000, 0.32), (2001, 0.52), (2002, 0.49), (2003, 0.74), (2004, 0.6), (2005, 0.68), (2006, 0.68), (2007, 0.56), (2008, 0.67), (2009, 0.64), (2010, 0.63), (2011, 0.61), (2012, 0.7), (2013, 0.67), (2014, 0.76), (2015, 1.03), (2016, 0.79), (2017, 0.81), (2018, 0.93), (2019, 0.95), (2020, 0.85)}, FitPoly[{(1880, -0.24), (1881, -0.3), (1882, -0.24), (1883, -0.23), (1884, -0.28), (1885, -0.2), (1886, -0.32), (1887, -0.33), (1888, 0.02), (1889, -0.27), (1890, -0.36), (1891, -0.3), (1892, -0.29), (1893, -0.25), (1894, -0.3), (1895, -0.12), (1896, 0), (1897, -0.17), (1898, -0.37), (1899, -0.1), (1900, 0.07), (1901, -0.34), (1902, -0.3), (1903, -0.52), (1904, -0.44), (1905, -0.27), (1906, -0.29), (1907, -0.3), (1908, -0.5), (1909, -0.37), (1910, -0.44), (1911, -0.32), (1912, -0.54), (1913, -0.31), (1914, -0.11), (1915, -0.24), (1916, -0.28), (1917, -0.33), (1918, -0.12), (1919, -0.24), (1920, -0.23), (1921, -0.06), (1922, -0.28), (1923, -0.19), (1924, -0.31), (1925, -0.17), (1926, -0.07), (1927, 0.01), (1928, -0.16), (1929, -0.14), (1930, -0.02), (1931, 0.03), (1932, -0.1), (1933, -0.2), (1934, -0.04), (1935, -0.03), (1936, -0.02), (1937, 0.1), (1938, 0.08), (1939, 0), (1940, 0.16), (1941, 0.43), (1942, 0.07), (1943, 0.26), (1944, 0.32), (1945, 0.27), (1946, 0), (1947, 0.05), (1948, -0.06), (1949, -0.06), (1950, -0.16), (1951, 0.13), (1952, 0.01), (1953, 0.12), (1954, -0.05), (1955, -0.12), (1956, -0.19), (1957, 0.03), (1958, 0.08), (1959, 0), (1960, 0.06), (1961, -0.02), (1962, 0.12), (1963, 0.23), (1964, -0.25), (1965, 0.02), (1966, -0.07), (1967, 0.15), (1968, 0.06), (1969, 0.09), (1970, -0.02), (1971, -0.08), (1972, 0.1), (1973, 0.07), (1974, -0.06), (1975, -0.12), (1976, -0.19), (1977, 0.12), (1978, 0.08), (1979, 0.3), (1980, 0.19), (1981, 0.18), (1982, 0.18), (1983, 0.24), (1984, 0.15), (1985, 0.15), (1986, 0.22), (1987, 0.35), (1988, 0.31), (1989, 0.29), (1990, 0.43), (1991, 0.29), (1992, 0.05), (1993, 0.23), (1994, 0.43), (1995, 0.44), (1996, 0.22), (1997, 0.64), (1998, 0.49), (1999, 0.35), (2000, 0.32), (2001, 0.52), (2002, 0.49), (2003, 0.74), (2004, 0.6), (2005, 0.68), (2006, 0.68), (2007, 0.56), (2008, 0.67), (2009, 0.64), (2010, 0.63), (2011, 0.61), (2012, 0.7), (2013, 0.67), (2014, 0.76), (2015, 1.03), (2016, 0.79), (2017, 0.81), (2018, 0.93), (2019, 0.95), (2020, 0.85)}, 1]) →ResidualPlot({(1880, -0.24), (1881, -0.3), (1882, -0.24), (1883, -0.23), (1884, -0.28), (1885, -0.2), (1886, -0.32), (1887, -0.33), (1888, 0.02), (1889, -0.27), (1890, -0.36), (1891, -0.3), (1892, -0.29), (1893, -0.25), (1894, -0.3), (1895, -0.12), (1896, 0), (1897, -0.17), (1898, -0.37), (1899, -0.1), (1900, 0.07), (1901, -0.34), (1902, -0.3), (1903, -0.52), (1904, -0.44), (1905, -0.27), (1906, -0.29), (1907, -0.3), (1908, -0.5), (1909, -0.37), (1910, -0.44), (1911, -0.32), (1912, -0.54), (1913, -0.31), (1914, -0.11), (1915, -0.24), (1916, -0.28), (1917, -0.33), (1918, -0.12), (1919, -0.24), (1920, -0.23), (1921, -0.06), (1922, -0.28), (1923, -0.19), (1924, -0.31), (1925, -0.17), (1926, -0.07), (1927, 0.01), (1928, -0.16), (1929, -0.14), (1930, -0.02), (1931, 0.03), (1932, -0.1), (1933, -0.2), (1934, -0.04), (1935, -0.03), (1936, -0.02), (1937, 0.1), (1938, 0.08), (1939, 0), (1940, 0.16), (1941, 0.43), (1942, 0.07), (1943, 0.26), (1944, 0.32), (1945, 0.27), (1946, 0), (1947, 0.05), (1948, -0.06), (1949, -0.06), (1950, -0.16), (1951, 0.13), (1952, 0.01), (1953, 0.12), (1954, -0.05), (1955, -0.12), (1956, -0.19), (1957, 0.03), (1958, 0.08), (1959, 0), (1960, 0.06), (1961, -0.02), (1962, 0.12), (1963, 0.23), (1964, -0.25), (1965, 0.02), (1966, -0.07), (1967, 0.15), (1968, 0.06), (1969, 0.09), (1970, -0.02), (1971, -0.08), (1972, 0.1), (1973, 0.07), (1974, -0.06), (1975, -0.12), (1976, -0.19), (1977, 0.12), (1978, 0.08), (1979, 0.3), (1980, 0.19), (1981, 0.18), (1982, 0.18), (1983, 0.24), (1984, 0.15), (1985, 0.15), (1986, 0.22), (1987, 0.35), (1988, 0.31), (1989, 0.29), (1990, 0.43), (1991, 0.29), (1992, 0.05), (1993, 0.23), (1994, 0.43), (1995, 0.44), (1996, 0.22), (1997, 0.64), (1998, 0.49), (1999, 0.35), (2000, 0.32), (2001, 0.52), (2002, 0.49), (2003, 0.74), (2004, 0.6), (2005, 0.68), (2006, 0.68), (2007, 0.56), (2008, 0.67), (2009, 0.64), (2010, 0.63), (2011, 0.61), (2012, 0.7), (2013, 0.67), (2014, 0.76), (2015, 1.03), (2016, 0.79), (2017, 0.81), (2018, 0.93), (2019, 0.95), (2020, 0.85)}, FitPoly[{(1880, -0.24), (1881, -0.3), (1882, -0.24), (1883, -0.23), (1884, -0.28), (1885, -0.2), (1886, -0.32), (1887, -0.33), (1888, 0.02), (1889, -0.27), (1890, -0.36), (1891, -0.3), (1892, -0.29), (1893, -0.25), (1894, -0.3), (1895, -0.12), (1896, 0), (1897, -0.17), (1898, -0.37), (1899, -0.1), (1900, 0.07), (1901, -0.34), (1902, -0.3), (1903, -0.52), (1904, -0.44), (1905, -0.27), (1906, -0.29), (1907, -0.3), (1908, -0.5), (1909, -0.37), (1910, -0.44), (1911, -0.32), (1912, -0.54), (1913, -0.31), (1914, -0.11), (1915, -0.24), (1916, -0.28), (1917, -0.33), (1918, -0.12), (1919, -0.24), (1920, -0.23), (1921, -0.06), (1922, -0.28), (1923, -0.19), (1924, -0.31), (1925, -0.17), (1926, -0.07), (1927, 0.01), (1928, -0.16), (1929, -0.14), (1930, -0.02), (1931, 0.03), (1932, -0.1), (1933, -0.2), (1934, -0.04), (1935, -0.03), (1936, -0.02), (1937, 0.1), (1938, 0.08), (1939, 0), (1940, 0.16), (1941, 0.43), (1942, 0.07), (1943, 0.26), (1944, 0.32), (1945, 0.27), (1946, 0), (1947, 0.05), (1948, -0.06), (1949, -0.06), (1950, -0.16), (1951, 0.13), (1952, 0.01), (1953, 0.12), (1954, -0.05), (1955, -0.12), (1956, -0.19), (1957, 0.03), (1958, 0.08), (1959, 0), (1960, 0.06), (1961, -0.02), (1962, 0.12), (1963, 0.23), (1964, -0.25), (1965, 0.02), (1966, -0.07), (1967, 0.15), (1968, 0.06), (1969, 0.09), (1970, -0.02), (1971, -0.08), (1972, 0.1), (1973, 0.07), (1974, -0.06), (1975, -0.12), (1976, -0.19), (1977, 0.12), (1978, 0.08), (1979, 0.3), (1980, 0.19), (1981, 0.18), (1982, 0.18), (1983, 0.24), (1984, 0.15), (1985, 0.15), (1986, 0.22), (1987, 0.35), (1988, 0.31), (1989, 0.29), (1990, 0.43), (1991, 0.29), (1992, 0.05), (1993, 0.23), (1994, 0.43), (1995, 0.44), (1996, 0.22), (1997, 0.64), (1998, 0.49), (1999, 0.35), (2000, 0.32), (2001, 0.52), (2002, 0.49), (2003, 0.74), (2004, 0.6), (2005, 0.68), (2006, 0.68), (2007, 0.56), (2008, 0.67), (2009, 0.64), (2010, 0.63), (2011, 0.61), (2012, 0.7), (2013, 0.67), (2014, 0.76), (2015, 1.03), (2016, 0.79), (2017, 0.81), (2018, 0.93), (2019, 0.95), (2020, 0.85)}, 1]) →
AI Drawing Prompt Reference
Create a scatter plot of data points from 1880 to 2020, with years on the x-axis and values on the y-axis. Fit a linear regression line through these points. Additionally, generate a residual plot showing the vertical deviations between each data point and the fitted line. Display the scatter plot and residual plot side by side or stacked to compare the fit quality.
The prompt above was compiled from the original drawing commands and is for reference only.