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.

Singular Hessian, cannot calculate s.e.

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
halilka
Posts: 4
Joined: 20 Nov 2022, 05:01

Singular Hessian, cannot calculate s.e.

Post by halilka »

Dear sir,

I try to analyze my data but I have a problem but I can't find the solution. I took singular hessian, cannot calculate s.e. and WARNING: Some eigenvalues of the Hessian are complex, indicating that the Hessian is not symmetrical. I don't know how to fix it. This is my pilot study data to find beta values. Can you help me how can I solve this problem.

Code: Select all

install.packages("apollo")
### Clear memory
rm(list = ls())


### Load Apollo library
library(apollo)
library(tidyverse)

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
  modelName       = "MNL_Deneme",
  modelDescr      = "Simple MNL model on mode choice SP data",
  indivID         = "id"
)
library(readxl)
database = read_excel("001.xlsx")
View(database)
attach(database)
apollo_beta=c (asc_ev = 0,
               asc_nokta= 0,
               b_ucret_ev= 0,
               b_m1ev= 0,
               b_m2ev= 0,
               b_m3ev= 0,
               b_h1ev= 0,
               b_h2ev= 0,
               b_h3ev= 0,
               b_h4ev= 0,
               b_s1ev= 0,
               b_s2ev= 0,
               b_s3ev= 0,
               b_s4ev= 0,
               b_b1ev= 0,
               b_b2ev= 0,
               b_ucret_n= 0,
               b_m1n= 0,
               b_m2n= 0,
               b_h1n= 0,
               b_h2n= 0,
               b_h3n= 0,
               b_h4n= 0,
               b_a1n= 0,
               b_a2n= 0,
               b_a3n= 0,
               b_a4n= 0,
               b_b1n= 0,
               b_b2n= 0,
               b_u1n= 0,
               b_u2n= 0,
               b_u3n= 0,
               b_u4n= 0
)
apollo_fixed = c("asc_ev","b_m1ev","b_h1ev", "b_s1ev","b_b1ev","b_m1n", "b_h1n","b_a1n","b_b1n","b_u1n")
df<-data.frame(id,dogum,cinsiyet,egitim,is,gelir,plan,olumlu,urun,secim_seti
               ,metot_ev,hiz_ev,saat_ev,bilgi_ev,
               ucret_nokta,metot_nokta,hiz_nokta,acik_nokta,bilgi_nokta,uzaklik_nokta,secim,blok)
apollo_inputs = apollo_validateInputs()

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[['ev']] = asc_ev + b_ucret_ev*ucret_ev + b_m1ev*(metot_ev==0) + b_m2ev*(metot_ev==1) +b_m3ev*(metot_ev==2) +
    b_h1ev*(hiz_ev==0) + b_h2ev*(hiz_ev==1) + b_h3ev*(hiz_ev==2) + b_h4ev*(hiz_ev==3) +
    b_s1ev*(saat_ev==0) + b_s2ev*(saat_ev==1) + b_s3ev*(saat_ev==2) + b_s4ev*(saat_ev==3) +
    b_b1ev*(bilgi_ev==0) + b_b2ev*(bilgi_ev==1)
  
  V[['nokta']] = asc_nokta + b_ucret_n*(ucret_nokta) + b_m1n*(metot_nokta==0) + b_m2n*(metot_nokta==1) +
    b_h1n*(hiz_nokta==0) + b_h2n*(hiz_nokta==1) + b_h3n*(hiz_nokta==2) + b_h4n*(hiz_nokta==3) +
    b_a1n*(acik_nokta==0) + b_a2n*(acik_nokta==1) + b_a3n*(acik_nokta==2) + b_a4n*(acik_nokta==3) +
    b_b1n*(bilgi_nokta==0) +b_b2n*(bilgi_nokta==1) +
    b_u1n*(uzaklik_nokta==0) + b_u2n*(uzaklik_nokta==1) + b_u3n*(uzaklik_nokta==2) + b_u4n*(uzaklik_nokta==3)
  ### Define settings for MNL model component
  mnl_settings = list(
    alternatives = c(ev=1, nokta=2),
    avail = 1,
    choiceVar = secim,
    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)
}

# ################################################################# #
#### MODEL ESTIMATION                                            ####
# ################################################################# #

model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)

# ################################################################# #
#### MODEL OUTPUTS                                               ####
# ################################################################# #
apollo_modelOutput(model,modelOutput_settings=list(printPVal=TRUE))
# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO SCREEN)                               ----
# ----------------------------------------------------------------- #

apollo_modelOutput(model)

# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO FILE, using model name)               ----
# ----------------------------------------------------------------- #

apollo_saveOutput(model)

RESULTS

Code: Select all

Preparing user-defined functions.

Testing likelihood function...

Overview of choices for MNL model component :
                                     ev  nokta
Times available                  900.00 900.00
Times chosen                     480.00 420.00
Percentage chosen overall         53.33  46.67
Percentage chosen when available  53.33  46.67

Pre-processing likelihood function...

Testing influence of parameters
Starting main estimation
Initial function value: -623.8325 
Initial gradient value:
 asc_nokta b_ucret_ev     b_m2ev     b_m3ev     b_h2ev     b_h3ev     b_h4ev     b_s2ev     b_s3ev     b_s4ev     b_b2ev 
     -30.0     -270.0       23.0       -3.0       18.5        2.5      -35.5        4.5       19.5       14.5       20.0 
 b_ucret_n      b_m2n      b_h2n      b_h3n      b_h4n      b_a2n      b_a3n      b_a4n      b_b2n      b_u2n      b_u3n 
   -2060.0      -17.0       -2.5      -18.5      -44.5        0.5       -1.5       -4.5      -10.0        2.5       -0.5 
     b_u4n 
     -26.5 
initial  value 623.832463 
iter   2 value 610.890899
iter   3 value 588.349575
iter   4 value 579.057272
iter   5 value 572.574571
iter   6 value 568.180675
iter   7 value 564.360219
iter   8 value 561.150469
iter   9 value 549.029496
iter  10 value 541.320361
iter  11 value 539.138734
iter  12 value 538.116894
iter  13 value 536.697178
iter  14 value 535.180667
iter  15 value 533.470347
iter  16 value 532.303595
iter  17 value 531.961703
iter  18 value 531.714620
iter  19 value 531.605944
iter  20 value 530.978735
iter  21 value 530.968901
iter  22 value 530.926961
iter  23 value 530.918919
iter  24 value 530.882081
iter  25 value 530.876991
iter  26 value 530.853602
iter  27 value 530.852557
iter  28 value 530.852500
iter  28 value 530.852499
iter  28 value 530.852499
final  value 530.852499 
converged
Additional convergence test using scaled estimation. Parameters will be scaled by their current estimates
  and additional iterations will be performed.
initial  value 530.852499 
iter   1 value 530.852499
final  value 530.852499 
converged
Estimated parameters:
              Estimate
asc_ev         0.00000
asc_nokta     -1.00355
b_ucret_ev    -0.05401
b_m1ev         0.00000
b_m2ev        -0.18670
b_m3ev        -0.47414
b_h1ev         0.00000
b_h2ev         0.37460
b_h3ev         0.02086
b_h4ev        -0.55408
b_s1ev         0.00000
b_s2ev         0.40350
b_s3ev         0.07974
b_s4ev         0.22376
b_b1ev         0.00000
b_b2ev         0.52489
b_ucret_n     -0.02765
b_m1n          0.00000
b_m2n          0.07634
b_h1n          0.00000
b_h2n         -0.02086
b_h3n         -0.37460
b_h4n         -1.16214
b_a1n          0.00000
b_a2n          0.09933
b_a3n          0.53015
b_a4n          0.58522
b_b1n          0.00000
b_b2n         -0.47866
b_u1n          0.00000
b_u2n          0.29916
b_u3n          0.25463
b_u4n         -0.08154

Final LL: -530.8525

Calculating log-likelihood at equal shares (LL(0)) for applicable models...
Calculating log-likelihood at observed shares from estimation data (LL(c)) for applicable models...
Calculating LL of each model component...
Calculating other model fit measures
Computing covariance matrix using analytical gradient.
 0%....25%....50%....75%...100%
ERROR: Singular Hessian, cannot calculate s.e.
Hessian written to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_hessian.csv
WARNING: Some eigenvalues of the Hessian are complex, indicating that the Hessian is not symmetrical.
Computing score matrix...
> # ################################################################# #
> #### MODEL OUTPUTS                                               ####
> # ################################################################# #
> apollo_modelOutput(model,modelOutput_settings=list(printPVal=TRUE))
Model run by acer using Apollo 0.2.8 on R 4.2.2 for Windows.
www.ApolloChoiceModelling.com

Model name                                  : MNL_Deneme
Model description                           : Simple MNL model on mode choice SP data
Model run at                                : 2022-11-26 18:52:35
Estimation method                           : bfgs
Model diagnosis                             : successful convergence 
Number of individuals                       : 90
Number of rows in database                  : 900
Number of modelled outcomes                 : 900

Number of cores used                        :  1 
Model without mixing

LL(start)                                   : -623.83
LL at equal shares, LL(0)                   : -623.83
LL at observed shares, LL(C)                : -621.83
LL(final)                                   : -530.85
Rho-squared vs equal shares                  :  0.149 
Adj.Rho-squared vs equal shares              :  0.1122 
Rho-squared vs observed shares               :  0.1463 
Adj.Rho-squared vs observed shares           :  0.1093 
AIC                                         :  1107.7 
BIC                                         :  1218.16 

Estimated parameters                        :  23
Time taken (hh:mm:ss)                       :  00:00:1.79 
     pre-estimation                         :  00:00:0.74 
     estimation                             :  00:00:0.35 
     post-estimation                        :  00:00:0.7 
Iterations                                  :  31  

Unconstrained optimisation.

These outputs have had the scaling used in estimation applied to them.
Estimates:
              Estimate        s.e.   t.rat.(0)  p(1-sided)    Rob.s.e. Rob.t.rat.(0)  p(1-sided)
asc_ev         0.00000          NA          NA          NA          NA            NA          NA
asc_nokta     -1.00355          NA          NA          NA          NA            NA          NA
b_ucret_ev    -0.05401          NA          NA          NA          NA            NA          NA
b_m1ev         0.00000          NA          NA          NA          NA            NA          NA
b_m2ev        -0.18670          NA          NA          NA          NA            NA          NA
b_m3ev        -0.47414          NA          NA          NA          NA            NA          NA
b_h1ev         0.00000          NA          NA          NA          NA            NA          NA
b_h2ev         0.37460          NA          NA          NA          NA            NA          NA
b_h3ev         0.02086          NA          NA          NA          NA            NA          NA
b_h4ev        -0.55408          NA          NA          NA          NA            NA          NA
b_s1ev         0.00000          NA          NA          NA          NA            NA          NA
b_s2ev         0.40350          NA          NA          NA          NA            NA          NA
b_s3ev         0.07974          NA          NA          NA          NA            NA          NA
b_s4ev         0.22376          NA          NA          NA          NA            NA          NA
b_b1ev         0.00000          NA          NA          NA          NA            NA          NA
b_b2ev         0.52489          NA          NA          NA          NA            NA          NA
b_ucret_n     -0.02765          NA          NA          NA          NA            NA          NA
b_m1n          0.00000          NA          NA          NA          NA            NA          NA
b_m2n          0.07634          NA          NA          NA          NA            NA          NA
b_h1n          0.00000          NA          NA          NA          NA            NA          NA
b_h2n         -0.02086          NA          NA          NA          NA            NA          NA
b_h3n         -0.37460          NA          NA          NA          NA            NA          NA
b_h4n         -1.16214          NA          NA          NA          NA            NA          NA
b_a1n          0.00000          NA          NA          NA          NA            NA          NA
b_a2n          0.09933          NA          NA          NA          NA            NA          NA
b_a3n          0.53015          NA          NA          NA          NA            NA          NA
b_a4n          0.58522          NA          NA          NA          NA            NA          NA
b_b1n          0.00000          NA          NA          NA          NA            NA          NA
b_b2n         -0.47866          NA          NA          NA          NA            NA          NA
b_u1n          0.00000          NA          NA          NA          NA            NA          NA
b_u2n          0.29916          NA          NA          NA          NA            NA          NA
b_u3n          0.25463          NA          NA          NA          NA            NA          NA
b_u4n         -0.08154          NA          NA          NA          NA            NA          NA

> apollo_modelOutput(model)
Model run by acer using Apollo 0.2.8 on R 4.2.2 for Windows.
www.ApolloChoiceModelling.com

Model name                                  : MNL_Deneme
Model description                           : Simple MNL model on mode choice SP data
Model run at                                : 2022-11-26 18:52:35
Estimation method                           : bfgs
Model diagnosis                             : successful convergence 
Number of individuals                       : 90
Number of rows in database                  : 900
Number of modelled outcomes                 : 900

Number of cores used                        :  1 
Model without mixing

LL(start)                                   : -623.83
LL at equal shares, LL(0)                   : -623.83
LL at observed shares, LL(C)                : -621.83
LL(final)                                   : -530.85
Rho-squared vs equal shares                  :  0.149 
Adj.Rho-squared vs equal shares              :  0.1122 
Rho-squared vs observed shares               :  0.1463 
Adj.Rho-squared vs observed shares           :  0.1093 
AIC                                         :  1107.7 
BIC                                         :  1218.16 

Estimated parameters                        :  23
Time taken (hh:mm:ss)                       :  00:00:1.79 
     pre-estimation                         :  00:00:0.74 
     estimation                             :  00:00:0.35 
     post-estimation                        :  00:00:0.7 
Iterations                                  :  31  

Unconstrained optimisation.

These outputs have had the scaling used in estimation applied to them.
Estimates:
              Estimate        s.e.   t.rat.(0)    Rob.s.e. Rob.t.rat.(0)
asc_ev         0.00000          NA          NA          NA            NA
asc_nokta     -1.00355          NA          NA          NA            NA
b_ucret_ev    -0.05401          NA          NA          NA            NA
b_m1ev         0.00000          NA          NA          NA            NA
b_m2ev        -0.18670          NA          NA          NA            NA
b_m3ev        -0.47414          NA          NA          NA            NA
b_h1ev         0.00000          NA          NA          NA            NA
b_h2ev         0.37460          NA          NA          NA            NA
b_h3ev         0.02086          NA          NA          NA            NA
b_h4ev        -0.55408          NA          NA          NA            NA
b_s1ev         0.00000          NA          NA          NA            NA
b_s2ev         0.40350          NA          NA          NA            NA
b_s3ev         0.07974          NA          NA          NA            NA
b_s4ev         0.22376          NA          NA          NA            NA
b_b1ev         0.00000          NA          NA          NA            NA
b_b2ev         0.52489          NA          NA          NA            NA
b_ucret_n     -0.02765          NA          NA          NA            NA
b_m1n          0.00000          NA          NA          NA            NA
b_m2n          0.07634          NA          NA          NA            NA
b_h1n          0.00000          NA          NA          NA            NA
b_h2n         -0.02086          NA          NA          NA            NA
b_h3n         -0.37460          NA          NA          NA            NA
b_h4n         -1.16214          NA          NA          NA            NA
b_a1n          0.00000          NA          NA          NA            NA
b_a2n          0.09933          NA          NA          NA            NA
b_a3n          0.53015          NA          NA          NA            NA
b_a4n          0.58522          NA          NA          NA            NA
b_b1n          0.00000          NA          NA          NA            NA
b_b2n         -0.47866          NA          NA          NA            NA
b_u1n          0.00000          NA          NA          NA            NA
b_u2n          0.29916          NA          NA          NA            NA
b_u3n          0.25463          NA          NA          NA            NA
b_u4n         -0.08154          NA          NA          NA            NA

> apollo_saveOutput(model)

Old result file "C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_output.txt" 
 renamed to: "C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_OLD3_output.txt"
Old result file "C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_estimates.csv" 
 renamed to: "C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_OLD3_estimates.csv"
Old result file "C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_model.rds" 
 renamed to: "C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_OLD3_model.rds"
Model output saved to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_output.txt 
Estimates saved to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_estimates.csv 
Model object saved to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme.rds 
Thank you so much. Best regards.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Singular Hessian, cannot calculate s.e.

Post by stephanehess »

Hi

this could be an empirical identification issue but it's difficult to diagnose just from the outputs. Can you gradually build up the model one variable at a time to see where it starts failing and get back to us

Thanks

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
halilka
Posts: 4
Joined: 20 Nov 2022, 05:01

Re: Singular Hessian, cannot calculate s.e.

Post by halilka »

Dear Sir, thank you so much for your reply. When I added the hiz_ev(h1ev, h2ev, h3ev, h4ev) and hiz_ nokta(h1n, h2n, h3n, h4n) attributes level , the model started to fail.

Code: Select all

install.packages("apollo")
### Clear memory
rm(list = ls())


### Load Apollo library
library(apollo)
library(tidyverse)

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
  modelName       = "MNL_Deneme",
  modelDescr      = "Simple MNL model on mode choice SP data",
  indivID         = "id"
)
library(readxl)
database <- read_excel("ayakkabi.xlsx")
attach(database)
apollo_beta=c (asc_ev = 0,
               b_ucret_ev= 0,
               b_m1ev= 0,
               b_m2ev= 0,
               b_m3ev= 0,
               b_h1ev= 0,
               b_h2ev= 0,
               b_h3ev= 0,
               b_h4ev= 0,
               asc_nokta= 0,
               b_ucret_n= 0,
               b_m1n= 0,
               b_m2n= 0,
               b_h1n= 0,
               b_h2n= 0,
               b_h3n= 0,
               b_h4n= 0
              
               
               
              
               
)
apollo_fixed = c( "asc_ev", "b_m1ev", "b_m1n", "b_h1ev", "b_h1n")
apollo_inputs = apollo_validateInputs()

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[['ev']] = asc_ev + b_ucret_ev*ucret_ev + b_m1ev*(metot_ev==0) + b_m2ev*(metot_ev==1) +b_m3ev*(metot_ev==2) +
    b_h1ev*(hiz_ev==0) + b_h2ev*(hiz_ev==1) + b_h3ev*(hiz_ev==2) + b_h4ev*(hiz_ev==3)
  
  V[['nokta']] = asc_nokta + b_ucret_n*(ucret_nokta) + b_m1n*(metot_nokta==0) + b_m2n*(metot_nokta==1) +
    b_h1n*(hiz_nokta==0) + b_h2n*(hiz_nokta==1) + b_h3n*(hiz_nokta==2) + b_h4n*(hiz_nokta==3) 
  ### Define settings for MNL model component
  mnl_settings = list(
    alternatives = c(ev=1, nokta=2),
    avail = 1,
    choiceVar = secim,
    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)
}

# ################################################################# #
#### MODEL ESTIMATION                                            ####
# ################################################################# #

model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)

# ################################################################# #
#### MODEL OUTPUTS                                               ####
# ################################################################# #
apollo_modelOutput(model,modelOutput_settings=list(printPVal=TRUE))
# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO SCREEN)                               ----
# ----------------------------------------------------------------- #

apollo_modelOutput(model)

# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO FILE, using model name)               ----
# ----------------------------------------------------------------- #

apollo_saveOutput(model)

OUTPUT

Code: Select all

Testing likelihood function...

Overview of choices for MNL model component :
                                  ev nokta
Times available                  600   600
Times chosen                     282   318
Percentage chosen overall         47    53
Percentage chosen when available  47    53

Pre-processing likelihood function...

Testing influence of parameters
Starting main estimation
Initial function value: -415.8883 
Initial gradient value:
b_ucret_ev     b_m2ev     b_m3ev     b_h2ev     b_h3ev     b_h4ev  asc_nokta  b_ucret_n      b_m2n      b_h2n      b_h3n 
     -1580          9        -23         -2        -17        -43         18       -370         14         17          2 
     b_h4n 
       -44 
initial  value 415.888308 
iter   2 value 412.134697
iter   3 value 391.639178
iter   4 value 335.080347
iter   5 value 330.533939
iter   6 value 327.869859
iter   7 value 317.630003
iter   8 value 314.349248
iter   9 value 312.857048
iter  10 value 310.487871
iter  11 value 309.037416
iter  12 value 308.412088
iter  13 value 308.397603
iter  14 value 308.395389
iter  15 value 308.395264
iter  16 value 308.395245
iter  16 value 308.395244
iter  16 value 308.395244
final  value 308.395244 
converged
Additional convergence test using scaled estimation. Parameters will be scaled by their current estimates
  and additional iterations will be performed.
initial  value 308.395244 
iter   1 value 308.395244
final  value 308.395244 
converged
Estimated parameters:
              Estimate
asc_ev         0.00000
b_ucret_ev    -0.07333
b_m1ev         0.00000
b_m2ev        -0.22802
b_m3ev        -0.88333
b_h1ev         0.00000
b_h2ev         0.40267
b_h3ev        -0.06615
b_h4ev        -0.99482
asc_nokta     -1.61848
b_ucret_n     -0.03315
b_m1n          0.00000
b_m2n          0.39579
b_h1n          0.00000
b_h2n          0.06615
b_h3n         -0.40267
b_h4n         -2.27677

Final LL: -308.3952

Calculating log-likelihood at equal shares (LL(0)) for applicable models...
Calculating log-likelihood at observed shares from estimation data (LL(c)) for applicable models...
Calculating LL of each model component...
Calculating other model fit measures
Computing covariance matrix using analytical gradient.
 0%....25%....50%....75%....100%
ERROR: Singular Hessian, cannot calculate s.e.
Hessian written to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_hessian.csv
WARNING: Some eigenvalues of the Hessian are positive, indicating convergence to a saddle point!
Computing score matrix...
> # ################################################################# #
> #### MODEL OUTPUTS                                               ####
> # ################################################################# #
> apollo_modelOutput(model,modelOutput_settings=list(printPVal=TRUE))
Model run by acer using Apollo 0.2.8 on R 4.2.2 for Windows.
www.ApolloChoiceModelling.com

Model name                                  : MNL_Deneme
Model description                           : Simple MNL model on mode choice SP data
Model run at                                : 2022-11-30 21:10:57
Estimation method                           : bfgs
Model diagnosis                             : successful convergence 
Number of individuals                       : 60
Number of rows in database                  : 600
Number of modelled outcomes                 : 600

Number of cores used                        :  1 
Model without mixing

LL(start)                                   : -415.89
LL at equal shares, LL(0)                   : -415.89
LL at observed shares, LL(C)                : -414.81
LL(final)                                   : -308.4
Rho-squared vs equal shares                  :  0.2585 
Adj.Rho-squared vs equal shares              :  0.2296 
Rho-squared vs observed shares               :  0.2565 
Adj.Rho-squared vs observed shares           :  0.2276 
AIC                                         :  640.79 
BIC                                         :  693.55 

Estimated parameters                        :  12
Time taken (hh:mm:ss)                       :  00:00:0.78 
     pre-estimation                         :  00:00:0.35 
     estimation                             :  00:00:0.16 
     post-estimation                        :  00:00:0.26 
Iterations                                  :  20  
Min abs eigenvalue of Hessian               :  0 

Unconstrained optimisation.

These outputs have had the scaling used in estimation applied to them.
Estimates:
              Estimate        s.e.   t.rat.(0)  p(1-sided)    Rob.s.e. Rob.t.rat.(0)  p(1-sided)
asc_ev         0.00000          NA          NA          NA          NA            NA          NA
b_ucret_ev    -0.07333          NA          NA          NA          NA            NA          NA
b_m1ev         0.00000          NA          NA          NA          NA            NA          NA
b_m2ev        -0.22802          NA          NA          NA          NA            NA          NA
b_m3ev        -0.88333          NA          NA          NA          NA            NA          NA
b_h1ev         0.00000          NA          NA          NA          NA            NA          NA
b_h2ev         0.40267          NA          NA          NA          NA            NA          NA
b_h3ev        -0.06615          NA          NA          NA          NA            NA          NA
b_h4ev        -0.99482          NA          NA          NA          NA            NA          NA
asc_nokta     -1.61848          NA          NA          NA          NA            NA          NA
b_ucret_n     -0.03315          NA          NA          NA          NA            NA          NA
b_m1n          0.00000          NA          NA          NA          NA            NA          NA
b_m2n          0.39579          NA          NA          NA          NA            NA          NA
b_h1n          0.00000          NA          NA          NA          NA            NA          NA
b_h2n          0.06615          NA          NA          NA          NA            NA          NA
b_h3n         -0.40267          NA          NA          NA          NA            NA          NA
b_h4n         -2.27677          NA          NA          NA          NA            NA          NA

> apollo_modelOutput(model)
Model run by acer using Apollo 0.2.8 on R 4.2.2 for Windows.
www.ApolloChoiceModelling.com

Model name                                  : MNL_Deneme
Model description                           : Simple MNL model on mode choice SP data
Model run at                                : 2022-11-30 21:10:57
Estimation method                           : bfgs
Model diagnosis                             : successful convergence 
Number of individuals                       : 60
Number of rows in database                  : 600
Number of modelled outcomes                 : 600

Number of cores used                        :  1 
Model without mixing

LL(start)                                   : -415.89
LL at equal shares, LL(0)                   : -415.89
LL at observed shares, LL(C)                : -414.81
LL(final)                                   : -308.4
Rho-squared vs equal shares                  :  0.2585 
Adj.Rho-squared vs equal shares              :  0.2296 
Rho-squared vs observed shares               :  0.2565 
Adj.Rho-squared vs observed shares           :  0.2276 
AIC                                         :  640.79 
BIC                                         :  693.55 

Estimated parameters                        :  12
Time taken (hh:mm:ss)                       :  00:00:0.78 
     pre-estimation                         :  00:00:0.35 
     estimation                             :  00:00:0.16 
     post-estimation                        :  00:00:0.26 
Iterations                                  :  20  
Min abs eigenvalue of Hessian               :  0 

Unconstrained optimisation.

These outputs have had the scaling used in estimation applied to them.
Estimates:
              Estimate        s.e.   t.rat.(0)    Rob.s.e. Rob.t.rat.(0)
asc_ev         0.00000          NA          NA          NA            NA
b_ucret_ev    -0.07333          NA          NA          NA            NA
b_m1ev         0.00000          NA          NA          NA            NA
b_m2ev        -0.22802          NA          NA          NA            NA
b_m3ev        -0.88333          NA          NA          NA            NA
b_h1ev         0.00000          NA          NA          NA            NA
b_h2ev         0.40267          NA          NA          NA            NA
b_h3ev        -0.06615          NA          NA          NA            NA
b_h4ev        -0.99482          NA          NA          NA            NA
asc_nokta     -1.61848          NA          NA          NA            NA
b_ucret_n     -0.03315          NA          NA          NA            NA
b_m1n          0.00000          NA          NA          NA            NA
b_m2n          0.39579          NA          NA          NA            NA
b_h1n          0.00000          NA          NA          NA            NA
b_h2n          0.06615          NA          NA          NA            NA
b_h3n         -0.40267          NA          NA          NA            NA
b_h4n         -2.27677          NA          NA          NA            NA

> apollo_saveOutput(model)
Model output saved to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_output.txt 
Estimates saved to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme_estimates.csv 
Model object saved to C:/Users/acer/Documents/halil ne olur olsun/MNL_Deneme.rds 
> 
Thanks in advance.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Singular Hessian, cannot calculate s.e.

Post by stephanehess »

Hi

can you share your data and code with me via e-mail and I'll look into it

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
waqararif097
Posts: 3
Joined: 13 Jun 2023, 13:32

Re: Singular Hessian, cannot calculate s.e.

Post by waqararif097 »

Was there a solution to this problem ? I'm currently facing similar problem with singular hessian and cannot calculate s.e and consequently p vales. Can you help me?
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Singular Hessian, cannot calculate s.e.

Post by stephanehess »

Hi

there is not some universal solution to this problem. There are many reasons why you can get a singular hessian, generally related to an overspecification of your model. Have you checked that your model is theoretically identified?

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
waqararif097
Posts: 3
Joined: 13 Jun 2023, 13:32

Re: Singular Hessian, cannot calculate s.e.

Post by waqararif097 »

Thank you for your message! I do realize your suggestion. But can you also look at mz code to see if I made a mistake? Theoretically I aim to put "car" as a reference. but I am getting this error. Would highly appreciate your reponse

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

### Load Apollo library
library(apollo)

### Initialise code
apollo_initialise()

### Set core controls
apollo_control = list(
modelName = "MNL_MODEL WITH SEC",
modelDescr = "MNL model with socio-demographics",
indivID = "ID",
outputDirectory = "output"
)

# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #

### Loading data from package
### if data is to be loaded from a file (e.g. called data.csv),
### the code would be: database = read.csv("data.csv",header=TRUE)
database = read.csv("C:\\Users\\waqar\\OneDrive - TUM\\Car as reference.csv")


# ################################################################# #
#### ANALYSIS OF CHOICES ####
# ################################################################# #

### Define settings for analysis of choice data to be conducted prior to model estimation
choiceAnalysis_settings <- list(
alternatives = c(Car=1, PuT=2, Uam=5),
choiceVar = database$chosen_NUMERIC,
explanators = database[,c("MALE","Business","FEMALE","AGE1","AGE2","AGE3","BSC","MSC","LOWERTHANBSC","EMPLOYED","UNEMPLOYED","INCOME1","INCOME2","INCOME3","NOCHILD","HAVECHILD")],
rows = (database$ID)
)

### Run function to analyse choice data
apollo_choiceAnalysis(choiceAnalysis_settings, apollo_control, database)

# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #

### Vector of parameters, including any that are kept fixed in estimation
apollo_beta=c(asc_Car= 0,
asc_PuT= 0,
asc_Uam =0,
b_InVT_Car = 0,
b_InVT_PuT = 0,
b_InVT_Uam = 0,
b_TC_Car = 0,
b_TC_PuT = 0,
b_TC_Uam = 0,
b_WT_PuT = 0,
b_WT_Uam =0,
b_INCOME1_Car = 0,
b_INCOME1_PuT = 0,
b_INCOME1_Uam = 0,
b_INCOME3_Car = 0,
b_INCOME3_PuT = 0,
b_INCOME3_Uam = 0,
b_AGE1_Car = 0,
b_AGE1_PuT = 0,
b_AGE1_Uam = 0,
b_AGE3_Car = 0,
b_AGE3_PuT = 0,
b_AGE3_Uam = 0,
b_FEMALE_Car = 0,
b_FEMALE_PuT = 0,
b_FEMALE_Uam = 0,
b_MSC_Car = 0,
b_MSC_PuT = 0,
b_MSC_Uam = 0,
b_LOWERTHANBSC_Car = 0,
b_LOWERTHANBSC_PuT = 0,
b_LOWERTHANBSC_Uam = 0,
b_EMPLOYED_Car = 0,
b_EMPLOYED_PuT = 0,
b_EMPLOYED_Uam = 0,
b_HAVECHILD_Car = 0,
b_HAVECHILD_PuT = 0,
b_HAVECHILD_Uam = 0,
b_Business_Car = 0,
b_Business_PuT = 0,
b_Business_Uam = 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_Car","b_INCOME1_Car", "b_INCOME3_Car","b_EMPLOYED_Car","b_AGE1_Car", "b_AGE3_Car", "b_FEMALE_Car", "b_MSC_Car", "b_LOWERTHANBSC_Car", "b_HAVECHILD_Car", "b_Business_Car")

# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #

apollo_inputs = apollo_validateInputs()

# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #

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()

### Create alternative specific constants and coefficients using interactions with socio-demographics


### List of utilities: these must use the same names as in mnl_settings, order is irrelevant

V = list()
V[["Car"]] = asc_Car + b_InVT_Car * InVT_Car + b_TC_Car * TC_Car
V[["PuT"]] = asc_PuT + b_InVT_PuT * InVT_PuT + b_WT_PuT * WT_PuT + b_TC_PuT * TC_PuT + b_INCOME1_PuT * (INCOME1==1) + b_INCOME3_PuT* (INCOME3==1) + b_AGE1_PuT * (AGE1==1)+ b_AGE3_PuT *(AGE3==1)+b_FEMALE_PuT* (FEMALE==1)+b_MSC_PuT* (MSC==1) +b_LOWERTHANBSC_PuT* (LOWERTHANBSC==1) +b_EMPLOYED_PuT* (EMPLOYED==1)+b_HAVECHILD_PuT*(HAVECHILD==1) +b_Business_PuT* (Business==1)
V[["Uam"]] = asc_Uam + b_InVT_Uam * InVT_Uam + b_WT_Uam * WT_Uam +b_TC_Uam *TC_Uam+ b_INCOME1_Uam * (INCOME1==1) + b_INCOME3_Uam* (INCOME3==1) + b_AGE1_Uam* (AGE1==1) + b_AGE3_Uam *(AGE3==1)+ b_FEMALE_Uam* (FEMALE==1) + b_MSC_Uam* (MSC==1)+ b_LOWERTHANBSC_Uam* (LOWERTHANBSC==1) + b_EMPLOYED_Uam* (EMPLOYED==1)+b_HAVECHILD_Uam* (HAVECHILD==1) +b_Business_Uam* (Business==1 )


### Define settings for MNL model component
mnl_settings = list(
alternatives = c(Car=1, PuT=2, Uam=5),
choiceVar = chosen_NUMERIC,
utilities = 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)
}

# ################################################################# #
#### MODEL ESTIMATION ####
# ################################################################# #

model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)

# ################################################################# #
#### MODEL OUTPUTS ####
# ################################################################# #

# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO SCREEN) ----
# ----------------------------------------------------------------- #

apollo_modelOutput(model)
apollo_modelOutput(model, modelOutput_settings=list(printPVal = 2, printOutliers= TRUE))



OUTPUT:
Preparing user-defined functions.

Testing likelihood function...
Setting "avail" is missing, so full availability is assumed.

Overview of choices for MNL model component :
Car PuT Uam
Times available 418.00 418.0 418
Times chosen 168.00 204.0 46
Percentage chosen overall 40.19 48.8 11
Percentage chosen when available 40.19 48.8 11


Pre-processing likelihood function...

Testing influence of parameters
Starting main estimation
Initial function value: -459.2199
Initial gradient value:
asc_PuT asc_Uam b_InVT_Car b_InVT_PuT b_InVT_Uam b_TC_Car b_TC_PuT b_TC_Uam b_WT_PuT b_WT_Uam b_INCOME1_PuT
6.466667e+01 -9.333333e+01 2.226667e+03 5.600000e+03 -4.050000e+03 2.333333e+03 1.387333e+03 -2.733000e+04 8.233333e+02 -2.261667e+03 3.600000e+01
b_INCOME1_Uam b_INCOME3_PuT b_INCOME3_Uam b_AGE1_PuT b_AGE1_Uam b_AGE3_PuT b_AGE3_Uam b_FEMALE_PuT b_FEMALE_Uam b_MSC_PuT b_MSC_Uam
-1.400000e+01 3.666667e+00 -3.333333e-01 3.433333e+01 -7.666667e+00 1.200000e+01 -5.000000e+00 6.400000e+01 -2.000000e+01 1.833333e+01 -2.666667e+00
b_LOWERTHANBSC_PuT b_LOWERTHANBSC_Uam b_EMPLOYED_PuT b_EMPLOYED_Uam b_HAVECHILD_PuT b_HAVECHILD_Uam b_Business_PuT b_Business_Uam
4.033333e+01 -1.466667e+01 5.633333e+01 -1.766667e+01 2.900000e+01 -6.000000e+00 6.666667e+00 1.666667e+00
initial value 459.219937
iter 2 value 415.396492
iter 3 value 414.335050
iter 4 value 409.706849
iter 5 value 406.218359
iter 6 value 404.552100
iter 7 value 397.097138
iter 8 value 360.154451
iter 9 value 329.347332
iter 10 value 327.761855
iter 11 value 289.278171
iter 12 value 274.379398
iter 13 value 245.555556
iter 14 value 233.132576
iter 15 value 226.776430
iter 16 value 224.181164
iter 17 value 220.275087
iter 18 value 215.225546
iter 19 value 213.067821
iter 20 value 209.952879
iter 21 value 208.010934
iter 22 value 205.676252
iter 23 value 201.446980
iter 24 value 199.326015
iter 25 value 197.640340
iter 26 value 196.256763
iter 27 value 195.198287
iter 28 value 194.791798
iter 29 value 194.627719
iter 30 value 194.474321
iter 31 value 194.334985
iter 32 value 194.227436
iter 33 value 194.172862
iter 34 value 194.138193
iter 35 value 194.115720
iter 36 value 194.097988
iter 37 value 194.084544
iter 38 value 194.077460
iter 39 value 194.074582
iter 40 value 194.072895
iter 41 value 194.071556
iter 42 value 194.070677
iter 43 value 194.070193
iter 44 value 194.069914
iter 45 value 194.069737
iter 46 value 194.069639
iter 47 value 194.069592
iter 48 value 194.069565
iter 49 value 194.069547
iter 50 value 194.069535
iter 51 value 194.069529
iter 51 value 194.069527
iter 51 value 194.069527
final value 194.069527
converged
Additional convergence test using scaled estimation. Parameters will be scaled by their current estimates and additional iterations will be performed.
initial value 194.069527
iter 1 value 194.069527
final value 194.069527
converged

Estimated parameters:
Estimate
asc_Car 0.000000
asc_PuT -0.199829
asc_Uam -3.089841
b_InVT_Car -0.049942
b_InVT_PuT -0.008880
b_InVT_Uam 0.021338
b_TC_Car 0.054868
b_TC_PuT -0.007672
b_TC_Uam -0.004831
b_WT_PuT -0.031818
b_WT_Uam 0.003526
b_INCOME1_Car 0.000000
b_INCOME1_PuT 3.537453
b_INCOME1_Uam 2.611847
b_INCOME3_Car 0.000000
b_INCOME3_PuT -24.778454
b_INCOME3_Uam -25.760029
b_AGE1_Car 0.000000
b_AGE1_PuT 1.802059
b_AGE1_Uam 2.589308
b_AGE3_Car 0.000000
b_AGE3_PuT -2.296784
b_AGE3_Uam -2.387755
b_FEMALE_Car 0.000000
b_FEMALE_PuT 19.316469
b_FEMALE_Uam 19.376168
b_MSC_Car 0.000000
b_MSC_PuT 27.613395
b_MSC_Uam 28.448532
b_LOWERTHANBSC_Car 0.000000
b_LOWERTHANBSC_PuT 16.429613
b_LOWERTHANBSC_Uam 16.564978
b_EMPLOYED_Car 0.000000
b_EMPLOYED_PuT 16.775757
b_EMPLOYED_Uam 16.308468
b_HAVECHILD_Car 0.000000
b_HAVECHILD_PuT 23.052888
b_HAVECHILD_Uam 23.447171
b_Business_Car 0.000000
b_Business_PuT 19.255931
b_Business_Uam 20.510771

Final LL: -194.0695

Calculating log-likelihood at equal shares (LL(0)) for applicable models...
Calculating log-likelihood at observed shares from estimation data (LL(c)) for applicable models...
Calculating LL of each model component...
Calculating other model fit measures
Computing covariance matrix using analytical gradient.
0%....25%....50%....75%...100%
WARNING: Singular Hessian, cannot calculate s.e.
Hessian written to output/MNL_MODEL WITH SEC_hessian.csv
Negative definite Hessian with maximum eigenvalue: 0
>
> # ################################################################# #
> #### MODEL OUTPUTS ####
> # ################################################################# #
>
> # ----------------------------------------------------------------- #
> #---- FORMATTED OUTPUT (TO SCREEN) ----
> # ----------------------------------------------------------------- #
>
> apollo_modelOutput(model)
Model run by waqar using Apollo 0.2.9 on R 4.2.2 for Windows.
www.ApolloChoiceModelling.com

Model name : MNL_MODEL WITH SEC
Model description : MNL model with socio-demographics
Model run at : 2023-06-15 14:42:03
Estimation method : bfgs
Model diagnosis : successful convergence
Optimisation diagnosis : Maximum found
hessian properties : Negative definitive
maximum eigenvalue : 0
Number of individuals : 215
Number of rows in database : 418
Number of modelled outcomes : 418

Number of cores used : 1
Model without mixing

LL(start) : -459.22
LL at equal shares, LL(0) : -459.22
LL at observed shares, LL(C) : -400.99
LL(final) : -194.07
Rho-squared vs equal shares : 0.5774
Adj.Rho-squared vs equal shares : 0.5121
Rho-squared vs observed shares : 0.516
Adj.Rho-squared vs observed shares : 0.4462
AIC : 448.14
BIC : 569.2

Estimated parameters : 30
Time taken (hh:mm:ss) : 00:00:3.78
pre-estimation : 00:00:1.22
estimation : 00:00:0.7
initial estimation : 00:00:0.65
estimation after rescaling : 00:00:0.05
post-estimation : 00:00:1.87
Iterations : 55
initial estimation : 54
estimation after rescaling : 1

Unconstrained optimisation.

Estimates:
Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0)
asc_Car 0.000000 NA NA NA NA
asc_PuT -0.199829 NA NA NA NA
asc_Uam -3.089841 NA NA NA NA
b_InVT_Car -0.049942 NA NA NA NA
b_InVT_PuT -0.008880 NA NA NA NA
b_InVT_Uam 0.021338 NA NA NA NA
b_TC_Car 0.054868 NA NA NA NA
b_TC_PuT -0.007672 NA NA NA NA
b_TC_Uam -0.004831 NA NA NA NA
b_WT_PuT -0.031818 NA NA NA NA
b_WT_Uam 0.003526 NA NA NA NA
b_INCOME1_Car 0.000000 NA NA NA NA
b_INCOME1_PuT 3.537453 NA NA NA NA
b_INCOME1_Uam 2.611847 NA NA NA NA
b_INCOME3_Car 0.000000 NA NA NA NA
b_INCOME3_PuT -24.778454 NA NA NA NA
b_INCOME3_Uam -25.760029 NA NA NA NA
b_AGE1_Car 0.000000 NA NA NA NA
b_AGE1_PuT 1.802059 NA NA NA NA
b_AGE1_Uam 2.589308 NA NA NA NA
b_AGE3_Car 0.000000 NA NA NA NA
b_AGE3_PuT -2.296784 NA NA NA NA
b_AGE3_Uam -2.387755 NA NA NA NA
b_FEMALE_Car 0.000000 NA NA NA NA
b_FEMALE_PuT 19.316469 NA NA NA NA
b_FEMALE_Uam 19.376168 NA NA NA NA
b_MSC_Car 0.000000 NA NA NA NA
b_MSC_PuT 27.613395 NA NA NA NA
b_MSC_Uam 28.448532 NA NA NA NA
b_LOWERTHANBSC_Car 0.000000 NA NA NA NA
b_LOWERTHANBSC_PuT 16.429613 NA NA NA NA
b_LOWERTHANBSC_Uam 16.564978 NA NA NA NA
b_EMPLOYED_Car 0.000000 NA NA NA NA
b_EMPLOYED_PuT 16.775757 NA NA NA NA
b_EMPLOYED_Uam 16.308468 NA NA NA NA
b_HAVECHILD_Car 0.000000 NA NA NA NA
b_HAVECHILD_PuT 23.052888 NA NA NA NA
b_HAVECHILD_Uam 23.447171 NA NA NA NA
b_Business_Car 0.000000 NA NA NA NA
b_Business_PuT 19.255931 NA NA NA NA
b_Business_Uam 20.510771 NA NA NA NA
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Singular Hessian, cannot calculate s.e.

Post by stephanehess »

Hi

without knowing your data, it's very hard to identify the issue. Did you start with a simpler model first and gradually add the terms? Then you'll find where the issue happens

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
waqararif097
Posts: 3
Joined: 13 Jun 2023, 13:32

Re: Singular Hessian, cannot calculate s.e.

Post by waqararif097 »

Hi ! The same model went smoothly before but the issue started when I tried normalizing the values of dummy variables (i.e. income, age etc) for my reference alternative "car" by assigning them "0" . I believe that might be the wrong approach. Can you guide how can I go about this for example:
Income 1. Age 1. Income 2
Car 0. 0. 0
PuT. 1. 1. 1
UAM 1. 1. 1
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Singular Hessian, cannot calculate s.e.

Post by stephanehess »

sorry, it's not clear what you're trying to do here, or why you would do that in the data. But again, without kwowing the data or model, we can't really help. How many categories do you have for these covariates?
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply