Appropriate model for path choice data

I have data from a path choice experiment in which shopping mall visitors chose among different path alternatives at several intersections. Additionally, I have measures of spatial syntax for the different path alternatives at all the intersections (these measures are of numeric type and indicate, for example, how connected a path is to other paths).

My goal is to test whether the measures of spatial syntax can predict pedestrians' path choice.

As an initial inspection, I thought of running a Chi-squared test of the number of times a path was chosen across the different path alternatives for each intersection. However, this simply treats the path alternatives as categorical variables and doesn't consider their numeric measures of spatial syntax. Moreover, I am looking for a way to incorporate all intersections into one prediction model.

What would be a suitable model for the prediction I am trying to make?

Edit:

Here is an example intersection: Pedestrians who enter the intersection from 1.a can choose between 1.b, 1.c, and 1.d. Pedestrians who enter from 1.b can choose between 1.a, 1.c, and 1.d, etc.

For 100 pedestrians, the data might look like this:

library(tidyverse)

set.seed(27)

int_1_pathchoice <- tibble(
ID = 1:100,
1.a = sample(c("1.b", "1.c", "1.d"), size = 100, prob = c(2/7, 4/7, 1/7), replace = TRUE),
1.b = sample(c("1.a", "1.c", "1.d"), size = 100, prob = c(1/7, 5/7, 1/7), replace = TRUE),
1.c = sample(c("1.a", "1.b", "1.d"), size = 100, prob = c(1/7, 5/7, 1/7), replace = TRUE),
1.d = sample(c("1.a", "1.b", "1.c"), size = 100, prob = c(1/7, 2/7, 4/7), replace = TRUE)
)
int_1_pathchoice_long <- pivot_longer(
int_1_pathchoice,
cols = 1.a:1.d,
names_to = "origin"
) %>%
rename(
chosen = value
) %>%
mutate_if(
is.character, as.factor
)
int_1_pathchoice_long

As a contingency table:

chisq <- chisq.test(cont_table_int_1[1, 2:ncol(cont_table_int_1)])

Because pedestrians are not allowed to turn around, the counts in the diagonal are 0.

The following code yields a significant p-value at the 5% alpha level:

chisq <- chisq.test(cont_table_int_1[1, 2:ncol(cont_table_int_1)])
chisq

However, the following command yields an error:

chisq2 <- chisq.test(cont_table_int_1[1,], p = c(0, 1/3, 1/3, 1/3))
chisq2

Should I be using a different test because of the low expected frequency here?

Now for the second part. Let's say each path has a numeric characteristic that might determine how attractive it is to pedestrians. In this example I am using the variable con, whose values are made up.

My idea is that I can use con to predict the probability that a path is chosen.

Below is the transformed data frame with the added numeric variable con and a binary outcome value (path chosen or not chosen).

int_1_pathchoice_long  <- int_1_pathchoice_long  %>%
mutate(
value = 1,
chosen = as.character(chosen),
origin = as.character(origin)
)
complete_data <- tibble(
ID = rep(1:100, each = 12),
origin = rep(
rep(
c("1.a", "1.b", "1.c", "1.d"), each = 3),
100),
chosen = rep(
c("1.b", "1.c", "1.d", "1.a", "1.c", "1.d", "1.a", "1.b", "1.d", "1.a", "1.b", "1.c"),
100)
)
complete_data
full_data <- full_join(complete_data, int_1_pathchoice_long, by = c("ID", "origin", "chosen"))
full_data <- full_data %>%
mutate(
value = ifelse(is.na(value), 0, value)
)
full_data <- full_data %>%
mutate(
con = case_when(chosen == "1.a" ~ 2,
chosen == "1.b" ~ 5,
chosen == "1.c" ~ 7,
chosen == "1.d" ~ 2)
)
full_data

Keep in mind that these are only the data for one intersection. The full data set contains a wider range for the predictor values.

Is it plausible to run a binary logistic regression with value ~ con? What are other approaches?

• Can you give us an example of your data? This is interesting but unclear. Some plots also, maybe a shop plan with paths ... Nov 4 '20 at 3:02
• @kjetilbhalvorsen I've added a figure and some example data. I'd be very grateful for any feedback!
– GFG
Nov 11 '20 at 13:40
• For the contingency table with zeros on the diagonal you need special models, the usual chisquare is invalid. Nov 13 '20 at 16:30