# R Analysis of experience, salary dataset ################################################# > x <- c(6,7,9,10,13,15) > y <- c(40,41,43,45,46,49) > mean(x) [1] 10 > sd(x) [1] 3.464102 > mean(y) [1] 44 > sd(y) [1] 3.34664 > cov(x,y) [1] 11.4 > cor(x,y) [1] 0.9833434 > salary.results <- lm(y~x) > summary(salary.results) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 34.5000 0.9208 37.47 3.03e-06 x 0.9500 0.0878 10.82 0.000414 Residual standard error: 0.6801 on 4 degrees of freedom Multiple R-squared: 0.967, Adjusted R-squared: 0.9587 F-statistic: 117.1 on 1 and 4 DF, p-value: 0.0004139 > anova(salary.results) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F value Pr(>F) x 1 54.15 54.150 117.08 0.0004139 Residuals 4 1.85 0.463 > predict(salary.results, list(x=c(6)), interval="confidence", se.fit=TRUE) $fit fit lwr upr 1 40.2 38.95704 41.44296 $se.fit [1] 0.448