What is the proper way to format a categorical predictor to use in STAN? I cannot seem to input a categorical predictor as a normal factor variable, so what is the quickest way to transform a normal categorical variable such that Stan can accept it?
For example, say I had a a continue predictor and a categorical predictor
your_dataset = data.frame(income = c(62085.59, 60806.33, 60527.27, 67112.64, 57675.92, 58128.44, 60822.47, 55805.80, 63982.99, 64555.45),
country = c("England", "England", "England", "USA", "USA", "USA", "South Africa", "South Africa", "South Africa", "Belgium"))
Which looks like this:
income country
1 62085.59 England
2 60806.33 England
3 60527.27 England
4 67112.64 USA
5 57675.92 USA
6 58128.44 USA
7 60822.47 South Africa
8 55805.80 South Africa
9 63982.99 South Africa
10 64555.45 Belgium
How would I prepare this to be entered in rstan
?