In model 'Similarity Model' NPSOL returned a non-zero status code 6

4 replies [Last post]
alena.d's picture
Offline
Joined: 11/27/2010

Hello all,
when I want to fit my model, I receive this warning message:
In model 'Similarity Model' NPSOL returned a non-zero status code 6. The model does not satisfy the first-order optimality conditions to the required accuracy, and no improved point for the merit function could be found during the final linesearch (Mx status RED)
and when I then summary my fit, some values are missing.
Below, you can see, my model and also results from summary.
I am a begginer, so I would be really happy, if someone helped me.
Alena

simModel<-mxModel("Similarity Model",
type="RAM",
mxData(
observed=sim,
type="raw"
),
manifestVars=c("plot","depth","veg_div","sim","man","aver_L",
"aver_H",
"VVS","cover","GWT","pH","Ca","K","Mg","P","N","C"),
latentVars=c("vegetation","productivity","soil_depth","soil","SB",
"topography","disturbance"),
# residual variances
mxPath(
from=c("plot","depth","veg_div","sim","man","aver_L","aver_H",
"VVS","cover","GWT","pH","Ca","K","Mg","P","N","C"),
arrows=2,
free=TRUE,
values=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
labels=c("e1","e2","e3","e4","e5","e6","e7","e8","e9","e10","e11",
"e12", "e13","e14","e15","e16","e17")
),
# latent variances and covariance
mxPath(
from=c("vegetation","productivity","soil_depth","soil","SB",
"topography","disturbance"),
arrows=2,
all=TRUE,
free=TRUE,
values=c(1,.5,.5,.5,.5,.5,.5,.5,1,.5,.5,.5,.5,.5,.5,.5,1,.5,.5,.5,.5,.5,
.5,.5,1,.5,.5,.5,.5,.5,.5,.5,1,.5,.5,.5,.5,.5,.5,.5,1,.5,.5,.5,.5,.5,.5,
.5,1),
labels=c("var1","cov12","cov13","cov14","cov15","cov16","cov17",
"cov12","var2","cov23","cov24","cov25","cov26","cov27","cov13",
"cov23","var3","cov34","cov35","cov36","cov37","cov14","cov24",
"cov34","var4","cov45","cov46","cov47","cov15","cov25","cov35",
"cov45","var5","cov56","cov57","cov16","cov26","cov36","cov46",
"cov56","var6","cov67","cov17","cov27","cov37","cov47","cov57",
"cov67","var7")
),
# factor loadings for vegetation
mxPath(
from="vegetation",
to=c("veg_div"),
arrows=1,
free=c(FALSE),
values=c(1),
labels=c("a")
),
#factor loadings for productivity
mxPath(
from="productivity",
to=c("cover","VVS","aver_L","aver_H"),
arrows=1,
free=c(FALSE,TRUE,TRUE,TRUE),
values=c(1,1,1,1),
labels=c("b","c","d","e")
),
#factor loadings for soil_depth
mxPath(
from="soil_depth",
to=c("depth"),
arrows=1,
free=c(FALSE),
values=c(1),
labels=c("f")
),
#factor loadings for soil
mxPath(
from="soil",
to=c("N","C","pH","K","Mg","Ca","P"),
arrows=1,
free=c(FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),
values=c(1,1,1,1,1,1,1),
labels=c("g","h","i","j","k","l","m")
),
#factor loadings for SB
mxPath(
from="SB",
to=c("sim"),
arrows=1,
free=c(FALSE),
values=c(1),
labels=c("n")
),
#factor loadings for topography
mxPath(
from="topography",
to=c("plot","GWT"),
arrows=1,
free=c(FALSE,TRUE),
values=c(1,1),
labels=c("o","p")
),
#factor loadings for disturbance
mxPath(
from="disturbance",
to=c("man"),
arrows=1,
free=c(FALSE),
values=c(1),
labels=c("q")
),
#means
mxPath(
from="one",
to=c("plot","depth","veg_div","sim","man","aver_L","aver_H",
"VVS","cover","GWT","pH","Ca","K","Mg","P","N","C","vegetation",
"productivity","soil_depth","soil","SB","topography","disturbance"),
arrows=1,
free=c(TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,
TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,
FALSE),
values=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0),
labels=c("mean1","mean2","mean3","mean4","mean5","mean6",
"mean7","mean8","mean9","mean10","mean11","mean12","mean13",
"mean14","mean15","mean16","mean17",NA,NA,NA,NA,NA,NA,NA)
)
)
simFit <- mxRun(simModel)
Running Similarity Model
Warning message:
In model 'Similarity Model' NPSOL returned a non-zero status code 6. The model does not satisfy the first-order optimality conditions to the required accuracy, and no improved point for the merit function could be found during the final linesearch (Mx status RED)

summary(simFit)
data:
$`Similarity Model.data`
plot depth veg_div sim
Min. :0.0000 Min. :0.0 Min. : 6.00 Min. :0.0000
1st Qu.:0.0000 1st Qu.:0.0 1st Qu.:25.00 1st Qu.:0.1050
Median :0.0000 Median :0.5 Median :32.00 Median :0.1490
Mean :0.4928 Mean :0.5 Mean :30.43 Mean :0.1649
3rd Qu.:1.0000 3rd Qu.:1.0 3rd Qu.:37.00 3rd Qu.:0.2220
Max. :1.0000 Max. :1.0 Max. :51.00 Max. :0.4650
man aver_L VVS GWT
Min. :0.0000 Min. : 0.700 Min. :0.0120 Min. :-10.0
1st Qu.:0.0000 1st Qu.: 3.500 1st Qu.:0.1432 1st Qu.: 70.0
Median :0.0000 Median : 5.100 Median :0.2040 Median :125.0
Mean :0.3671 Mean : 6.316 Mean :0.2117 Mean :154.9
3rd Qu.:0.0000 3rd Qu.: 7.675 3rd Qu.:0.2580 3rd Qu.:216.5
Max. :3.0000 Max. :24.600 Max. :0.4990 Max. :707.0
pH Ca K Mg
Min. :4.220 Min. : 3.63 Min. : 2.450 Min. : 2.150
1st Qu.:5.010 1st Qu.: 53.58 1st Qu.: 7.335 1st Qu.: 6.537
Median :5.260 Median : 83.06 Median :10.240 Median : 9.680
Mean :5.279 Mean :109.17 Mean :13.271 Mean :13.667
3rd Qu.:5.548 3rd Qu.:147.91 3rd Qu.:14.668 3rd Qu.:15.930
Max. :6.800 Max. :478.16 Max. :78.520 Max. :73.530
P N C
Min. : 0.290 Min. :0.0850 Min. : 5.85
1st Qu.: 1.823 1st Qu.:0.2100 1st Qu.:10.42
Median : 2.130 Median :0.2520 Median :11.99
Mean : 2.923 Mean :0.2849 Mean :13.37
3rd Qu.: 3.172 3rd Qu.:0.3262 3rd Qu.:13.70
Max. :16.610 Max. :1.4220 Max. :70.15

The model does not satisfy the first-order optimality conditions to the required accuracy, and no improved point for the merit function could be found during the final linesearch (Mx status RED)

free parameters:
name matrix row col Estimate Std.Error
1 c A aver_L productivity 2.625390e+02 NaN
2 i A pH soil 2.935776e-01 1.129321e-02
3 l A Ca soil 9.552065e+01 4.482451e+00
4 j A K soil 4.946630e+00 NaN
5 k A Mg soil 1.106808e+01 NaN
6 m A P soil 3.832614e-01 1.153177e-01
7 h A C soil 3.885944e+00 1.411022e-01
8 p A GWT topography 1.600260e+02 6.841943e+00
9 e1 S plot plot 4.312332e-01 4.224270e-02
10 e2 S depth depth 4.983519e-01 NaN
11 e3 S veg_div veg_div 2.940395e+01 6.641467e+01
12 e4 S sim sim 2.970145e+00 NaN
13 e5 S man man 7.689308e-01 1.311142e+00
14 e6 S aver_L aver_L -1.402127e+01 NaN
15 e7 S VVS VVS 8.703063e-03 5.895986e-04
16 e8 S GWT GWT -7.595319e+01 NaN
17 e9 S pH pH 1.004841e-01 7.089877e-03
18 e10 S Ca Ca -8.869452e+01 NaN
19 e11 S K K 6.770639e+01 3.469788e+00
20 e12 S Mg Mg 8.308394e+01 5.045812e+00
21 e13 S P P 4.089212e+00 3.127822e-01
22 e14 S N N 6.785176e-01 NaN
23 e15 S C C 3.380603e+01 1.944256e+00
24 var1 S vegetation vegetation 2.940395e+01 6.641467e+01
25 cov12 S vegetation productivity 1.477552e-03 7.685325e-03
26 var2 S productivity productivity 6.573134e-04 4.748615e-05
27 cov13 S vegetation soil_depth -1.965396e+00 4.667837e-01
28 cov23 S productivity soil_depth -1.425096e-02 1.132874e-03
29 var3 S soil_depth soil_depth 4.967564e-01 NaN
30 cov14 S vegetation soil -4.143258e+00 1.015247e+00
31 cov24 S productivity soil -2.879921e-02 8.988565e-04
32 cov34 S soil_depth soil 1.507398e+00 NaN
33 var4 S soil soil 3.748584e+00 2.324992e-01
34 cov15 S vegetation SB -3.906109e-01 9.030622e-02
35 cov25 S productivity SB -1.681545e-03 1.369041e-04
36 cov35 S soil_depth SB 9.102603e-02 9.106335e-03
37 cov45 S soil SB 1.985258e-01 2.762651e-02
38 var5 S SB SB -2.950044e+00 NaN
39 cov16 S vegetation topography 7.189850e+00 1.404624e+00
40 cov26 S productivity topography 4.651940e-02 3.142341e-03
41 cov36 S soil_depth topography -2.327834e+00 NaN
42 cov46 S soil topography -4.859159e+00 NaN
43 cov56 S SB topography -3.294746e-01 3.669061e-02
44 var6 S topography topography 8.538890e+00 NaN
45 cov17 S vegetation disturbance -4.054148e+00 5.953045e-01
46 cov27 S productivity disturbance -4.890707e-03 1.194785e-03
47 cov37 S soil_depth disturbance 3.857770e-01 1.264814e-01
48 cov47 S soil disturbance 1.040433e+00 2.137051e-01
49 cov57 S SB disturbance 5.993311e-02 1.731205e-02
50 cov67 S topography disturbance -1.810321e+00 1.286270e-01
51 var7 S disturbance disturbance 7.668210e-01 1.264187e+00
52 mean1 M 1 plot 7.544507e-02 1.522074e-01
53 mean2 M 1 depth 5.917900e-01 5.138060e-02
54 mean3 M 1 veg_div 3.009372e+01 3.858053e-01
55 mean4 M 1 sim 1.779674e-01 7.327289e-03
56 mean5 M 1 man 4.748542e+02 NaN
57 mean6 M 1 aver_L 5.669472e+00 2.876393e-01
58 mean7 M 1 VVS 2.066480e-01 4.769057e-03
59 mean8 M 1 GWT 8.357171e+01 2.459515e+01
60 mean9 M 1 pH 5.334432e+00 3.214698e-02
61 mean10 M 1 Ca 1.272341e+02 9.365325e+00
62 mean11 M 1 K 1.408931e+01 6.083485e-01
63 mean12 M 1 Mg 1.599236e+01 1.140197e+00
64 mean13 M 1 P 3.001567e+00 1.082431e-01
65 mean14 M 1 N 4.462727e-01 1.053452e-01
66 mean15 M 1 C 1.406673e+01 4.644328e-01
67 M 1 disturbance -4.743693e+02 NaN

observed statistics: 6210
estimated parameters: 67
degrees of freedom: 6143
-2 log likelihood: 28740.37
saturated -2 log likelihood: NA
number of observations: 414
chi-square: NA
p: NA
AIC (Mx): 16454.37
BIC (Mx): -4138.261
adjusted BIC:
RMSEA: NA
timestamp: 2010-11-27 13:47:57
frontend time: 3.421 secs
backend time: 1.12475 mins
independent submodels time: 0 secs
wall clock time: 70.906 secs
cpu time: 70.906 secs
openmx version number: 1.0.3-1505

neale's picture
Offline
Joined: 07/31/2009
I agree with Ryne that

I agree with Ryne that identification problems are the likely cause of Code Red, IFAIL 6 on this occasion. However, note also that Code Red isn't always as disastrous as it sounds - sometimes the error can be reported even if optimization has identified the global minimum. So code reds can be false alarms. Here's some text from another thread about what to do when it is encountered.

********************************************
Optimization may not have been successful, NPSOL IFAIL= 6. For a full technical description of what this means, please see http://www.sbsi-sol-optimize.com/asp/sol_product_npsol.htm and read the notes below.

There are several things to note about IFAIL = 6
1. Often, but not always, IFAIL = 6 is returned when optimization has completed successfully.
2. It is still the responsibility of the user to check that the solution is a global minimum. Unfortunately, optimization is not an exact science.
3. Checking that the solution is a global minimum can be done several ways:

i) Fit the model again from the present solution several times. If the fit improves, and keeps improving over the successive optimizations then a global solution probably has not been found, and the number of refits should be increased until the solution stabilizes. Here is some example R code that can be used to refit the model:

refits <- 3
for(i in 1:refits) {
model <- mxOption(model, "Cold Start")
model <- mxRun(model)
summary(model)
}

ii) Try starting optimization from a different place by changing the starting values of the parameters. These could be manually changed, but note that changing all the starting values from say .6 to .7 may not be sufficient. Random starting values could be assigned using, e.g., rnorm(), but be careful to keep the range of possible starting values reasonable.

iii) Consider whether the model is identified. IFAIL = 6 does occur more often with underidentified, or nearly-identified models. If two different sets of parameter estimates yield the same -2lnL (or whichever fit function is being used) then the model can be said to be underidentified. Sometimes this condition arises because of characteristics of the data, particularly if the dataset does not provide much information to estimate every parameter of the model.

Steve's picture
Offline
Joined: 07/30/2009
Pretty complicated model for

Pretty complicated model for a beginner. Way to go!

The "Code Red" error can happen for a variety of reasons. The first thing I do is look at the variance estimates to make sure they are positive. In your case, you have a number of negative variance estimates:

14 e6 S aver_L aver_L -1.402127e+01 NaN
16 e8 S GWT GWT -7.595319e+01 NaN
18 e10 S Ca Ca -8.869452e+01 NaN
38 var5 S SB SB -2.950044e+00 NaN

For the residual variances (parameters 14,16, & 18), I might constrain the lower bound of the parameters with an lbounds=.00001 argument in your mxPath statement that creates the residual variances. Doesn't hurt to make that constraint for all the residual terms at once, so just add "bounds=.00001" to that one mxPath statement.

This might be enough. You also have a fairly large negative variance estimated for one of your latent variables. But it is only indicated by one manifest variable and you have a fixed loading of 1 for it. So, I'd just add an lbound to that mxPath as well.

Hope that gets you going!

alena.d's picture
Offline
Joined: 11/27/2010
Thank you for your reply.

Thank you for your reply. Now, I have not so complicated models and I tried your advice and added lbounds to residual variances and then as well to latent variances. But I had still the same warning message as before.
Maybe, the problem can be in specifying fixed loading values and using free as TRUE or FALSE, because I am not sure with my decisions.

Ryne's picture
Offline
Joined: 07/31/2009
I think I see your problem,

I think I see your problem, and its that your model isn't identified. You have a number of factors indicated by a single manifest variable. This is fine, but you cannot simultaneously estimate a residual variance and a factor variance without extra information from other variables. If you fix the residual variances at zero for any manifest variables that have exactly one relationship (i.e., they are the only manifest variable for a factor, and have no relationships but with that factor), then your model will be identified.

While you specify them as latent variables, there is no distinction between a manifest variable and latent variable that fully explains that manifest variable. You can only estimate one free parameter for that manifest-latent combination. Your model was unidentified (leading to the NPSOL 6 warning) because for every possible value for the variance of the latent variable, you can find a value for the residual variance that doesn't affect fit. Fix one of the parameters, and the other parameter becomes identified. Does that make sense?