Assessment of Homework 4

This page summarises the results for homework 4. The questions can be found on the corresponding homework sheet.

Overview

The following counts were obtained by inspecting the uploaded files, but without trying to run R yet.

Loading The Answers into R

I tried to load all solutions which are possibly R scripts into R.

The following list shows some of the errors which prevented files from being loaded:

Marking

Exercise ex19

As an example, here is a (randomly chosen) student solution which got full marks:

ex19 <- function() { x <- read.csv("ex04-1.csv")
}
[source]

I called your function and checked whether the correct data set is returned.

Exercise ex20

As an example, here is a (randomly chosen) student solution which got full marks:

ex20 <- function(x) {read.csv("ex04-2.csv", sep=";")
}
[source]

I called your function and checked whether the correct data is returned. This data set has columns separated by semicolons, so the option sep=";" is required here.

Exercise ex21

As an example, here is a (randomly chosen) student solution which got full marks:

ex21 <- function() {
	c <- read.csv("ex04-3.csv", header=F)
}
[source]

I called your function and checked whether the correct data set is returned. This data set has no column headers, so the option header=FALSE is required when importing these data.

Exercise ex22

As an example, here is a (randomly chosen) student solution which got full marks:

ex22 <- function(z) {z <- read.csv("ex04-3.csv", header=FALSE)
a=z[,1]
b=z[,5]
c=z[,1]-mean(a)
d=z[,5]-mean(b)
(sum(c*d))/(sqrt((sum(c^2))*(sum(d^2))))
}
[source]

I called your function and checked whether the correct correlation is returned.

Exercise ex23

As an example, here is a (randomly chosen) student solution which got full marks:

ex23 <- function(x, y) {
lm(y~x)$coefficients[[2]]
}
[source]

For testing, I called your function twice, using two different sets of paired data. For each call I compared the output of your function to the output of my own function.

Exercise ex24

As an example, here is a (randomly chosen) student solution which got full marks:

ex24 <- function(x, y) {m<- lm(y~x)
predict(m, newdata=data.frame(x=7))
}
[source]

For testing, I called your function twice, using two different sets of paired data. For each call I compared the output of your function to the output of my own function.

Exercise ex25

As an example, here is a (randomly chosen) student solution which got full marks:

ex25 <- function(m) {
rss <-sum(residuals(m)^2)
rss
}
[source]

For testing, I called your function twice, using two different linear models fitted using the lm() command. For each call I compared the output of your function to the output of my own function.

Results