Question: R studio help. I am trying to create a predictive model using markov chains and R Studio. I am using a dataset called veteranbenefits which
R studio help. I am trying to create a predictive model using markov chains and R Studio. I am using a dataset called "veteranbenefits" which has State.Name, Percent.ofVeterans.who.used.GIBill.Education.Benefits, Number.ofEducation.Benefit.Recipients, Veteran.population, and Year over the course of years I am having a hard time writing out the code to have it predict which state will most likely have a higher probability of veterans using their GI Bill benefits compared to others. I had previously received help but I am now getting this repeated error "Error in dimnamesx dn :
length of 'dimnames' not equal to array extent." This is the code and a preview of the dataset. Could my dataset be the issue? Thank you again for any help.
librarydplyr
librarymarkovchain
veteranbenefits read.csvveteranbenefitscsv
veteranbenefits naomitveteranbenefits
transitionmatrix veteranbenefits
groupbyStateName, Year
summarisetransitionprob sumPercentofVeterans.who.used.GIBill.Education.Benefits
sumPercentofVeterans.who.used.GIBill.Education.Benefits
transitionmatrix pivotwidertransitionmatrix, namesfrom "Year", valuesfrom "transitionprob"
transitionmatrixisnatransitionmatrix
markovmodel newmarkovchain states uniqueveteranbenefits$State.Name
transitionMatrix asmatrixtransitionmatrix
predictedprobabilities steadyStatesmarkovmodel
higheststate namespredictedprobabilitieswhichmaxpredictedprobabilities
printhigheststate
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
