search for: get_mse

Displaying 1 result from an estimated 1 matches for "get_mse".

Did you mean: get_msr
2012 Feb 23
1
Improving performance of split-apply problem
...MSE's. Now, regardless of the size of the group, the regression needs to be run on exactly 40 observations. If the group has less than 40 observations, then I need to add rows to get to 40, populating all variables with 0's for those extra rows. Here's the function I wrote to do this: get_MSE = function(x) { rownames(x) = x$ID #'ID' can take on any value from 1 to 40. x = x[as.character(1:40), ] x[is.na(x)] = 0 regressionResult = lm(A ~ B + C + D + E, data=x) #A-E are some variables in the data frame. MSE = mean((regressionResult$fitted.values - A)^2) return(MSE) }...