R list: I am using a 'for' loop to run a number of different models (stratified by different variables) with coxph. The data becomes sparse when some strata are used causing the model to become unstable. The following error occurs and the analysis is terminated.>Error in fitter(X, Y, strats, offset, init, control, weights = weights,: (converted from warning) Loglik converged before variable 1 ; beta may be infinite. Is there any way to have R skip the models without convergence and apply 'NA' to the results, then go on to the other models? The same situation occurs with windows and unix versions. Thanks, Fred ____________________________________ [[alternative HTML version deleted]]
Take a look at ?try and see the thread on this list of yesterday about how to use try to skip errors within a loop. On Tue, Feb 10, 2004 at 08:59:10AM -0500, Fredrick Schumacher wrote:> R list: > > > > I am using a 'for' loop to run a number of different models (stratified > by different variables) with coxph. The data becomes sparse when some > strata are used causing the model to become unstable. The following > error occurs and the analysis is terminated. > > > > >Error in fitter(X, Y, strats, offset, init, control, weights = weights, > : > > (converted from warning) Loglik converged before variable 1 ; > beta may be infinite. > > > > Is there any way to have R skip the models without convergence and apply > 'NA' to the results, then go on to the other models? > > > > The same situation occurs with windows and unix versions. > > > > Thanks, > > Fred > > ____________________________________ > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On Tue, 10 Feb 2004, Fredrick Schumacher wrote:> R list: > > > > I am using a 'for' loop to run a number of different models (stratified > by different variables) with coxph. The data becomes sparse when some > strata are used causing the model to become unstable. The following > error occurs and the analysis is terminated. > > > > >Error in fitter(X, Y, strats, offset, init, control, weights = weights, > : > > (converted from warning) Loglik converged before variable 1 ; > beta may be infinite. > > > > Is there any way to have R skip the models without convergence and apply > 'NA' to the results, then go on to the other models?This is usually a warning, not an error, and for good reason since it does not reliably indicate lack of convergence (poor sensitivity and poor specificity). You have deliberately turned it into an error with the setting of options(warn). If you really want it to be an error but not fatal then use try() to capture it. -thomas
Have you considered "try"? hope this helps. spencer graves Fredrick Schumacher wrote:>R list: > > > >I am using a 'for' loop to run a number of different models (stratified >by different variables) with coxph. The data becomes sparse when some >strata are used causing the model to become unstable. The following >error occurs and the analysis is terminated. > > > > > >>Error in fitter(X, Y, strats, offset, init, control, weights = weights, >> >> >: > > (converted from warning) Loglik converged before variable 1 ; >beta may be infinite. > > > >Is there any way to have R skip the models without convergence and apply >'NA' to the results, then go on to the other models? > > > >The same situation occurs with windows and unix versions. > > > >Thanks, > >Fred > >____________________________________ > > > > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >