GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — R/Module-3-Example-3.R at main · Eggy115/R Expand file tree/ Copy pathModule-3-Example-3.RMore file actions 75 lines (42 loc) · 1.49 KB / Copy pathModule-3-Example-3.RFile metadata and controls75 lines (42 loc) · 1.49 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 # setwd("SET THE Working Director to THE PATH TO THIS DIRECTORY") student <- read.csv("Datasets/students.csv") student attach(student) study.hours<-hours plot(hours, score, main="Scatterplot of exam score vs. hours of study", xlab="Hours of study", ylab="Score", xlim=c(0,10), ylim=c(40,100), pch=1, col="red", cex.lab=1.5) #calculate sample correlation cor(study.hours, score) cor(score, study.hours) a <- cor(score, study.hours) print(a) my.model <- lm(student$score~student$hours) # print the linearValues print(my.model) # or and use the intercept and score to draw a line # abline(51.515, 5.012) # OR # or just pass the result values of the lm function to draw a line abline(my.model) # Calculate Confidence Intervals for Model Parameters confint(my.model) ?confint # default level is .90 confint(my.model, level = .90) # report a summary of my model summary(my.model) # create Analysis of Variance Table anova(my.model) # fitted values of my model fitted(my.model) # residuals of my model resid(my.model) # plot fitted values plot(fitted(my.model), residuals(my.model), axes = T, frame.plot = T, xlab = "fitted values", ylab="residue") plot(score, residuals(my.model), axes = T, frame.plot = T) # histogram of the residuals hist(residuals(my.model)) # Something more - not required for the class # As an extra task describe what these plots are layout(matrix(c(1,2,3,4), 2, 2 )) plot(my.model) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |