average_error: Average Error by State This function calculates the average...

Description Usage Arguments Value Examples

View source: R/errorcalculation.R

Description

Average Error by State This function calculates the average error and checks that the idenifiers match.

Usage

1
average_error(predicted, actual)

Arguments

predicted

the predictions including the first column with a character vector with idenifiers to check that the rows of predicted and actual match

actual

the real result including the first column with a character vector

Value

This function returns the average error for each state.

Examples

1
2
3
4
5
6
predict1 = data.frame(state = c("TX", "GA", "OR"), dem = c(.45, .49, .63), rep = c(.55, .51, .37))
actual1 = data.frame(state = c("TX", "GA", "OR"), dem = c(.42, .48, .62), rep = c(.58, .52, .38))
average_error(predict1, actual1)
predict2 = data.frame(state = c("OK", "MS", "WY"), dem = c(.42, .44, .3), rep = c(.56, .55, .7), other = c(0.02, 0.01, 0))
actual2 = data.frame(state = c("OK", "MS", "WY"), dem = c(.41, .38, .3), rep = c(.55, .58, .69), other = c(0.04, 0.04, 0.01))
average_error(predict2, actual2)

balexanderstats/bayesurvey documentation built on Sept. 20, 2020, 11:40 a.m.