Generate a simulated data set with 100 observations based on thefollowing model. Each data point is a vector Z= (X, Y) where Xdescribes the age of a machine New, FiveYearsOld, and TenYearsOldand Y describes whether the quality of output from the machineNormal or Abnormal. The probabilities of a machine being in thethree states are
P(X = New) = 1/4
P(X = FiveYearsOld) = 1/3
P(X = TenYearsOld) = 5/12
The probabilities of Normal output conditioned are machine ageare
P(Y = Normal | X= New) = 8/10
P(Y = Normal | X= FiveYearsOld) = 8/10
P(Y = Normal | X= TenYearsOld) = 4/10
Your data should consist of two vectors Y and Z both of whichare of class character. Convert these to factors using theas.factor function. Analyze your simulated data using thechisq.test function with inputs x=x, y=y. Perform the analysis withthe exact same function, but with simulated p-values using theinputs x=x, y=y, simulate.p.values=TRUE, B=10000. Would you trustthe p-values from the asymptotic distribution or the simulatedp-values more? What conclusions can you draw about your simulateddata from this analysis?