ae_by_state: Average Error by State

Description Usage Arguments Value Examples

View source: R/errorcalculation.R

Description

This function calculates the root mean square error for each state over a single or multiple years and checks that the idenifiers match. This function can only be used for proportions.

Usage

1
ae_by_state(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

a data frame with the state and the average error for that state

Examples

1
2
3
4
5
6
predict1 = data.frame(state = c("TX", "GA", "OR"), dem1 = c(.45, .49, .63), dem2 = c(.55, .51, .37))
actual1 = data.frame(state = c("TX", "GA", "OR"), dem1 = c(.42, .48, .62), dem2 = c(.56, .49, .35))
ae_by_state(predict1, actual1)
predict2 = data.frame(state = c("OK", "MS", "WY"), dem1 = c(.42, .44, .3))
actual2 = data.frame(state = c("OK", "MS", "WY"), dem1 = c(.41, .38, .3))
ae_by_state(predict2, actual2)

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