0

I have to compute the MSE of the value "Td" without packaging. I used a function but I have always the same MSE (see MSE_mod1) for each row (it shouldn't be the same MSE between lines, right?). Do you know why?

Could you help me? :)

Here is my code:

fonction_MSE <- function(tdval, td) {
  
  n<- 8741
  diff<- tdval-td
  MSEmode1<- (1/n)*sum((diff)^2)
  print(round(MSEmode1, digits = 9))    
}

MSE_mod1 <- fonction_MSE(meteo_charleroi[, "Td"], meteo_charleroi[, "Td_mod1"])

MSE_mod2 <- fonction_MSE(meteo_charleroi[, "Td"], meteo_charleroi[, "Td_mod2"])

here is the head of my data frame:

head of data frame

  • 1
    the head of your data.frame is missing – DPH Nov 04 '20 at 14:13
  • Perhaps a better question is: are the results of your models different? Maybe calculate `mod_difference <- meteo_charleroi[, "Td_mod1"] - meteo_charleroi[, "Td_mod2"]` and look `summary(mod_difference)`. Perhaps you have a typo in assigning the model results to the data frame, or something like that. – Gregor Thomas Nov 04 '20 at 14:35
  • sorry, I juste edited now – Hugo Evrard Nov 04 '20 at 14:39

1 Answers1

1

Why not just using:

mean((tdval-td)^2)
holzben
  • 1,459
  • 16
  • 24