Page 1 of 1

warning message: ! 'length = 3' in coercion to 'logical(1)'

Posted: 01 May 2024, 19:04
by gmartinez
I've been trying to fit a multinomial model to a survey data. This model has 3 choices alternatives defined by the below equations

V = list()
V[["box1"]] = b_place_1 * (place_1==1) + b_place_2 * (place_1==2) + b_place_3 * (place_1==3) + b_place_4 * (place_1==4) + b_mode * (mode_1==2) + b_access_1 * (access_1==1) + b_access_2 * (access_1==2) + b_access_3 * (access_1==3) + b_access_4 * (access_1==4) + b_fresh_1 * (fresh_1==1) + b_fresh_2 * (fresh_1==2) + b_fresh_3 * (fresh_1==3) + b_comm * (comm_1==2) + b_price * price_1

V[["box2"]] = b_place_1 * (place_2==1) + b_place_2 * (place_2==2) + b_place_3 * (place_2==3) + b_place_4 * (place_2==4) + b_mode * (mode_2==2) + b_access_1 * (access_2==1) + b_access_2 * (access_2==2) + b_access_3 * (access_2==3) + b_access_4 * (access_2==4) + b_fresh_1 * (fresh_2==1) + b_fresh_2 * (fresh_2==2) + b_fresh_3 * (fresh_2==3) + b_comm * (comm_2==2) + b_price * price_2

V[["neither"]] = 0 #To be added if no choice is necessary

mnl_settings = list(
#alternatives = c(box1=1, box2=2),
alternatives = c(box1=1, box2=2, neither=0), #To be replaced to the one above if no choice is necessary
avail = 1,
choiceVar = choice,
utilities = V
)

# Compute probabilities using MNL model
P[["model"]] = apollo_mnl(mnl_settings, functionality)
# Take product across observation for same individual
P = apollo::apollo_panelProd(P, apollo_inputs, functionality)

# Function end: prepare and return outputs of function
P = apollo::apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}

There is a error message.

Error in `test && (as.character(e[[3]][[1]]) %in% c("apollo_mnl", "apollo_el",
"apollo_nl", "apollo_cnl", "apollo_ol", "apollo_op", "apollo_dft",
"apollo_normalDensity", "apollo_mdcev", "apollo_mdcnev", "apollo_ownModel",
"apollo_lc", "apollo_fmnl"))`:
! 'length = 3' in coercion to 'logical(1)'
Backtrace:
1. apollo::apollo_estimate(...)
2. apollo::apollo_modifyUserDefFunc(...)
3. apollo::apollo_insertComponentName(apollo_probabilities)
4. apollo::apollo_insertComponentName(e[])
Warning message:
In sink() : no sink to remove

Please could you help me with this error message?

Re: warning message: ! 'length = 3' in coercion to 'logical(1)'

Posted: 05 May 2024, 10:56
by stephanehess
hi

I wonder if what is happening here is a version mix-up because some of your apollo function calls are using apollo:: and others are not.

Did you ensure you are running the latest version too?

Stephane