Error in apollo_probabilities(apollo_beta_shifted, apollo_inputs) : object 'v' not found
Posted: 16 Mar 2023, 12:12
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
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