With our necessary assumptions decided upon, the simplest way to predict the outcome of a particular scenario is to plug relevant numbers into a regression model and calculate the result. Suppose we want to estimate the rating of an ambush attack when we know only the number of Shu soldiers that we will engage.
> #set the R working directory > #replace the sample location with one that is relevant to you > setwd("/Users/johnmquick/rBeginnersGuide/")
> #load the chapter six workspace > load("rBeginnersGuide_Ch_06_ReadersCopy.RData")
> #what is the predicted rating of an ambush attack in which the Shu forces engage 5000 soldiers? >#ambush model: Rating = 56 + 44 * execution - 1.97 * duration + 0.0018 * Shu soldiers - 0.00082 * Wei soldiers > 56 + 44 * probabilitySuccessAmbush - 1.97 * meanDurationAmbush + 0.0018 * 5000 - 0.00082 * (5000 * ratioWeiShuSoldiersAmbush) [1] 52.746
Our calculated rating of 53 falls well below our threshold of 80 and suggests that the Shu army would have roughly an equal chance of winning or losing in this battle scenario.