R version 4.2.3 (2023-03-15 ucrt) -- "Shortstop Beagle" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > ls() [1] "pontok" > pontok x y 1 -1.8128998 1.266693 2 -1.7800062 1.715194 3 -1.5376151 1.530396 4 -1.3854859 2.724910 5 -1.3637005 1.542313 6 -1.0637228 2.884884 7 -1.0034652 2.368573 8 -0.5760387 3.842141 9 -0.5117520 3.261627 10 -0.5016896 3.917820 11 -0.4181832 3.398032 12 -0.2633086 4.391169 13 -0.2026714 3.030846 14 -0.1716494 2.885382 15 -0.1361445 4.168821 16 -0.1220230 4.568679 17 0.1114579 4.560052 18 0.1870899 4.385610 19 0.2119255 3.720698 20 0.4965816 2.757011 21 0.6245640 3.280524 22 0.6773494 3.573479 23 0.6988148 4.350537 24 0.7129744 2.681535 25 0.7543323 3.098144 26 0.9234113 3.063429 27 1.0619507 2.809594 28 1.3010199 2.545490 29 1.4286769 2.060928 30 1.7552736 0.941456 > x Error: object 'x' not found > y Error: object 'y' not found > attach(pontok) > x [1] -1.8128998 -1.7800062 -1.5376151 -1.3854859 -1.3637005 -1.0637228 [7] -1.0034652 -0.5760387 -0.5117520 -0.5016896 -0.4181832 -0.2633086 [13] -0.2026714 -0.1716494 -0.1361445 -0.1220230 0.1114579 0.1870899 [19] 0.2119255 0.4965816 0.6245640 0.6773494 0.6988148 0.7129744 [25] 0.7543323 0.9234113 1.0619507 1.3010199 1.4286769 1.7552736 > plot(x,y) > plot(x,y,type="l") > reg1 <- lm(y ~ x) > abline(reg1$coef,col="blue") > reg2 <- lm(y ~ x + I(x^2)) > reg2 Call: lm(formula = y ~ x + I(x^2)) Coefficients: (Intercept) x I(x^2) 3.82095 -0.03571 -0.85048 > lines(x,reg2$fitted,col="red") > plot(x,reg2$resid) > summary(reg2) Call: lm(formula = y ~ x + I(x^2)) Residuals: Min 1Q Median 3Q Max -0.91664 -0.32332 -0.00554 0.34234 0.96987 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.82095 0.13260 28.816 < 2e-16 *** x -0.03571 0.10547 -0.339 0.738 I(x^2) -0.85048 0.09949 -8.549 3.66e-09 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.5348 on 27 degrees of freedom Multiple R-squared: 0.7388, Adjusted R-squared: 0.7195 F-statistic: 38.19 on 2 and 27 DF, p-value: 1.345e-08 > reg3 <- lm(y ~ I(x^2)) > reg3 Call: lm(formula = y ~ I(x^2)) Coefficients: (Intercept) I(x^2) 3.8156 -0.8422 > plot(x,y) > lines(x,reg3$fitted) > anova(reg1,reg2) Analysis of Variance Table Model 1: y ~ x Model 2: y ~ x + I(x^2) Res.Df RSS Df Sum of Sq F Pr(>F) 1 28 28.6218 2 27 7.7217 1 20.9 73.081 3.663e-09 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > anova(reg2,reg3) Analysis of Variance Table Model 1: y ~ x + I(x^2) Model 2: y ~ I(x^2) Res.Df RSS Df Sum of Sq F Pr(>F) 1 27 7.7217 2 28 7.7544 -1 -0.032792 0.1147 0.7375 >