# Which plot results in the larger MSE?

# Settings to simulate data

  set.seed(8439)
  n <- 100
  x <- round(rnorm(n = n, mean = 3, sd = 0.5), digits = 1)
  beta0 <- -5
  beta1 <- 2

# Plot 1 data

  sigma1 <- 1
  epsilon1 <- rnorm(n = n, mean = 0, sd = sigma1)

  # Form y = beta0 + beta1*x1 + beta2*x2 + epsilon
  #   While rounding should not be done, it is here so that
  #   future displays of calculations are easier.
  y2 <- beta0 + beta1*x + epsilon1

  set1 <- data.frame(x, y)
  head(set1)

  # Estimate model
  mod.fit1 <- lm(formula = y ~ x, data = set1)
  summary(mod.fit1)


# Plot 2 data

  sigma2 <- 2
  epsilon2 <- rnorm(n = n, mean = 0, sd = sigma2)

  # Form y = beta0 + beta1*x1 + beta2*x2 + epsilon
  #   While rounding should not be done, it is here so that
  #   future displays of calculations are easier.
  y2 <- beta0 + beta1*x + epsilon2

  set2 <- data.frame(x, y2)
  head(set2)

  # Estimate model
  mod.fit2 <- lm(formula = y2 ~ x, data = set2)
  summary(mod.fit2)




################################################################################
# Plots

  par(mfrow = c(1,2))

  # I used the y-axis limits to make sure each plot was on the exact same scale
  plot(x = set1$x, y = set1$y, xlab = "x", ylab = "y", main = "Plot 1",
     xlim = , ylim = c(min(set1$y1, set2$y2), max(set1$y1, set2$y2)), col = "red", pch = 1, cex = 1.0,
     panel.first = grid(col = "gray", lty = "dotted"))
  curve(expr = mod.fit1$coefficients[1] + mod.fit1$coefficients[2]*x, xlim = c(min(set1$x),
    max(set1$x)), col = "blue", add = TRUE, n = 1000, lwd = 2)

  plot(x = set2$x, y = set2$y, xlab = "x", ylab = "y", main = "Plot 2",
     xlim = , ylim = c(min(set1$y1, set2$y2), max(set1$y1, set2$y2)), col = "red", pch = 1, cex = 1.0,
     panel.first = grid(col = "gray", lty = "dotted"))
  curve(expr = mod.fit2$coefficients[1] + mod.fit2$coefficients[2]*x, xlim = c(min(set2$x),
    max(set2$x)), col = "blue", add = TRUE, n = 1000, lwd = 2)


#