Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

Error in apollo_probabilities(apollo_beta_shifted, apollo_inputs) : object 'v' not found

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
Padma
Posts: 3
Joined: 01 Mar 2023, 06:46

Error in apollo_probabilities(apollo_beta_shifted, apollo_inputs) : object 'v' not found

Post by Padma »

Hi

Kindly help me with the following error

Error in apollo_probabilities(apollo_beta_shifted, apollo_inputs) :
object 'v' not found


i have specified v in my model. the code is as follows:
# ####################################################### #
#### 1. Definition of core settings
# ####################################################### #

### Clear memory
rm(list = ls())

### Load libraries
library(apollo)
#> Apollo 0.2.8
#> http://www.ApolloChoiceModelling.com
#> See url for a detailed manual, examples and a user forum.
#> Sign up to the user forum to receive updates on new releases.

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
modelName ="MNL2",
modelDescr ="Simple MNL model on mode choice SP data",
indivID ="ID",
panelData=FALSE,
outputDirectory = "output"
)

# ####################################################### #
#### 2. Data loading ####
# ####################################################### #


database = read.csv("apollotrial1.csv",header=TRUE)



# ####################################################### #
#### 3. Parameter definition ####
# ####################################################### #

### Vector of parameters, including any that are kept fixed
### during estimation
apollo_beta=c(asc_car = 0,
asc_tw=0,
asc_h=0,
asc_bus = 0,
asc_ipt = 0,
asc_nmt = 0,
#b_tt_car = 0,
#b_tt_tw=0,
# b_tt_h=0,
# b_tt_bus = 0,
# b_tt_ipt = 0,
# b_tt_nmt= 0,
b_t=0,
b_cost_car= 0,
b_cost_tw=0,
b_cost_h=0,
b_cost_bus=0,
b_cost_ipt=0
## b_cost=0

)

### Vector with names (in quotes) of parameters to be
### kept fixed at their starting value in apollo_beta.
### Use apollo_beta_fixed = c() for no fixed parameters.
apollo_fixed = c("asc_tw")

# ####################################################### #
#### 4. Input validation ####
# ####################################################### #

apollo_inputs = apollo_validateInputs()
#> Several observations per individual detected based on the value of ID.
#> Setting panelData in apollo_control set to TRUE.
#> All checks on apollo_control completed.
#> All checks on database completed.

# ####################################################### #
#### 5. Likelihood definition ####
# ####################################################### #

apollo_probabilities=function(apollo_beta, apollo_inputs,
functionality="estimate"){

### Attach inputs and detach after function exit
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))

### Create list of probabilities P
P = list()

### List of utilities: these must use the same names as
### in mnl_settings, order is irrelevant.
V = list()
V[["car"]] = asc_car + b_t *LNTTC + b_cost_car*TCC
V[["tw"]] = asc_tw + b_t *LNTTTW + b_cost_tw*TCTW
V[["h"]] = asc_h + b_t *LNTTH + b_cost_h*TCH
v[["bus"]] = asc_bus + b_t *LNTTB + b_cost_bus*TCB
V[["ipt"]] = asc_ipt + b_t *LNTTIPT + b_cost_ipt*TCIPT
V[["nmt"]]= asc_nmt+ b_t*LNTTNMT

## V[['car']] = asc_car + b_t *TTC + b_cost*TCC
##V[['tw']] = asc_tw + b_t *TTTW + b_cost*TCTW
##V[['h']] = asc_h + b_t *TTH + b_cost*TCH
## V[['bus']] = asc_bus + b_t *TTB + b_cost*TCB
## V[['ipt']] = asc_ipt + b_t *TTIPT + b_cost*TCIPT
## V[['nmt']]= asc_nmt+ b_t*TTNMT+b_cost*TCNMT



##V[['car']] = asc_car + b_t *TTC
## V[['tw']] = asc_tw + b_t *TTTW
## V[['h']] = asc_h + b_t *TTH
## V[['bus']] = asc_bus + b_t *TTB
## V[['ipt']] = asc_ipt + b_t *TTIPT
## V[['nmt']]= asc_nmt+ b_t*TTNMT

#V[['car']] = asc_car + b_tt_car *LNTTC
#V[['tw']] = asc_tw + b_tt_tw *LNTTTW
#V[['h']] = asc_h + b_tt_h *LNTTH
#V[['bus']] = asc_bus + b_tt_bus *LNTTB
#V[['ipt']] = asc_ipt + b_tt_ipt *LNTTIPT
#V[['nmt']]= asc_nmt+ b_tt_nmt*LNTTNMT

### Define settings for MNL model component
mnl_settings = list(
alternatives = c(car=1, tw=2, h=3, bus=4, ipt=5, nmt=6),
avail = list(car=CAR_AV, tw=TW_AV, h=H_AV, bus=BUS_AV, ipt=IPT_AV, nmt=NMT_AV),
choiceVar = choice,
V = V
)

### Compute probabilities using MNL model
P[['model']] = apollo_mnl(mnl_settings, functionality)

### Take product across observation for same individual
## P = apollo_panelProd(P, apollo_inputs, functionality)

### Prepare and return outputs of function
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}

# ####################################################### #
#### 6. Model estimation and reporting ####
# ####################################################### #

model = apollo_estimate(apollo_beta, apollo_fixed,
apollo_probabilities,
apollo_inputs,
list(writeIter=FALSE))


modelOutput_Liste = list(printChange=TRUE, printClassical=TRUE, printCorr=TRUE,
printCovar=TRUE, printDataReport=TRUE, printFixed=TRUE,
printFunctions=TRUE, printModelStructure=TRUE,
printOutliers=TRUE, printPVal=2, printT1=TRUE)

apollo_modelOutput(model,modelOutput_settings=modelOutput_Liste)
apollo_saveOutput(model)

I am not able to understand why this error is coming. Also I am not able to see my earlier post in my profile. Will the post show in my profile only if it is approved by the moderator or is there some other reason.
regards
Padma
stephanehess
Site Admin
Posts: 1042
Joined: 24 Apr 2020, 16:29

Re: Error in apollo_probabilities(apollo_beta_shifted, apollo_inputs) : object 'v' not found

Post by stephanehess »

You're mixing lower case v and upper case V. R is case sensitive
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply