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 testLL[["model"]] : subscript out of bounds

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
NullPunkt
Posts: 1
Joined: 12 Oct 2021, 15:55

Error in testLL[["model"]] : subscript out of bounds

Post by NullPunkt »

R version 4.1.1 (2021-08-10) -- "Kick Things"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Workspace loaded from C:/Users/neuhoff.SSP/Desktop/Lokales Arbeiten/Schätzung mit R (Arbeitstitel)/RStudio/Schätzung Sendungsgroessen/.RData]

> ### Clear memory
> rm(list = ls())
> ### Load Apollo library
> library(apollo)
Apollo 0.2.5
www.ApolloChoiceModelling.com
See url for a detailed manual, examples and a help forum.
Sign up to our mailing list for updates on new releases.
> ### Initialise code
> apollo_initialise()
Apollo ignition sequence completed
> ### Set core controls
> apollo_control = list(
+ modelName ="Schaetzung_Test",
+ modelDescr ="MNL Model Schaetzung Sendungsgroessen",
+ indivID ="RECNR"
+ )
> database = read.csv("R_Input_20211012.csv",header=TRUE, sep = ';')
> ### Vector of parameters, including any that are kept fixed in estimation
> apollo_beta=c(asc_SG1 = 0,
+ asc_SG2 = 0,
+ asc_SG3 = 0,
+ asc_SG4 = 0,
+ asc_SG5 = 0,
+ asc_SG6 = 0,
+ asc_SG7 = 0,
+ b1_SG1 = 0,
+ b1_SG2 = 0,
+ b1_SG3 = 0,
+ b1_SG4 = 0,
+ b1_SG5 = 0,
+ b1_SG6 = 0,
+ b1_SG7 = 0,
+ b2_SG1 = 0,
+ b2_SG2 = 0,
+ b2_SG3 = 0,
+ b2_SG4 = 0,
+ b2_SG5 = 0,
+ b2_SG6 = 0,
+ b2_SG7 = 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() if none
> apollo_fixed = c("asc_SG1")
> apollo_inputs = apollo_validateInputs()
All checks on apollo_control completed.
All checks on database completed.
> 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[['SG1']] = asc_SG1 + b1_SG1 * 1/database$rp_anzjahr + b2_SG1 * database$rp_wert/database$rp_anzjahr + b_cost * database$min_kost_s1
+ V[['SG2']] = asc_SG2 + b1_SG2 * 1/database$rp_anzjahr + b2_SG2 * database$rp_wert/database$rp_anzjahr + b_cost * database$min_kost_s2
+ V[['SG3']] = asc_SG3 + b1_SG3 * 1/database$rp_anzjahr + b2_SG3 * database$rp_wert/database$rp_anzjahr + b_cost * database$min_kost_s3
+ V[['SG4']] = asc_SG4 + b1_SG4 * 1/database$rp_anzjahr + b2_SG4 * database$rp_wert/database$rp_anzjahr + b_cost * database$min_kost_s4
+ V[['SG5']] = asc_SG5 + b1_SG5 * 1/database$rp_anzjahr + b2_SG5 * database$rp_wert/database$rp_anzjahr + b_cost * database$min_kost_s5
+ V[['SG6']] = asc_SG6 + b1_SG6 * 1/database$rp_anzjahr + b2_SG6 * database$rp_wert/database$rp_anzjahr + b_cost * database$min_kost_s6
+ V[['SG7']] = asc_SG7 + b1_SG7 * 1/database$rp_anzjahr + b2_SG7 * database$rp_wert/database$rp_anzjahr + b_cost * database$min_kost_s7
+
+
+ ### Define settings for MNL model component
+ mnl_settings = list(
+ alternatives = c(SG1=1, SG2=2, SG3=3, SG4=4, SG5 = 5, SG6 = 6, SG7 = 7 ),
+ avail = list(SG1=database$av_SG1, SG2=database$av_SG2, SG3=database$av_SG3, SG4=database$av_SG4,SG5=database$av_SG5, SG6=database$av_SG6, SG7=database$av_SG7 ),
+ choiceVar = Sendungsgroesse,
+ V = V
+ )
+
+ ### Compute probabilities using MNL model
+ P[['model']] = apollo_mnl(mnl_settings, functionality)
+
+
+ }
> model = apollo_estimate(apollo_beta, apollo_fixed,apollo_probabilities, apollo_inputs)

Testing likelihood function...

Overview of choices for MNL model component :
SG1 SG2 SG3 SG4 SG5 SG6 SG7
Times available 1594.00 1594.00 1594.00 1594.00 1594.00 1594.00 1594.00
Times chosen 33.00 104.00 242.00 591.00 131.00 186.00 307.00
Percentage chosen overall 2.07 6.52 15.18 37.08 8.22 11.67 19.26
Percentage chosen when available 2.07 6.52 15.18 37.08 8.22 11.67 19.26



Error in testLL[["model"]] : subscript out of bounds



Hello together,

can somebody help me with this Error in the End?
stephanehess
Site Admin
Posts: 977
Joined: 24 Apr 2020, 16:29

Re: Error in testLL[["model"]] : subscript out of bounds

Post by stephanehess »

Hi

it looks like you removed the two compulsory lines at the end of apollo_probabilities

Code: Select all

  P = apollo_prepareProb(P, apollo_inputs, functionality)
  return(P)
Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
stephanehess
Site Admin
Posts: 977
Joined: 24 Apr 2020, 16:29

Re: Error in testLL[["model"]] : subscript out of bounds

Post by stephanehess »

Also, you should drop database$ from anywhere inside apollo_probabilities as you are using apollo_attach
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply