0

I want to estimate the parameters of a nonlinear model. Apparently I have a problem with the initial values.

My dataset has this structure, where the columns are:

color Lum ruido Dist RT Resp RT.ms Condicion

With 7920 rows.

There are four different colors = [0,90,180,270]; three luminance = [13,19,25];and two types of noise = [1, 2] -> 4x3x2 = 24 conditions.

These are the values ​​Dist:

        if( ColorCase == 0 || ColorCase == 180)  
            DistTemp = [0.003; 0.004; 0.005; 0.006; 0.007; 0.008; 0.01; 0.015; 0.02; 0.03; 0.05];
        elseif(ColorCase == 90 || ColorCase == 270)
            DistTemp = [0.007; 0.008; 0.009; 0.01; 0.015; 0.02; 0.03; 0.04; 0.05; 0.06; 0.07];
        end

I take thirty measures for every possible combination.

When i combine only two variables, it works:

RT0_K.nls <- nls(RT.ms ~ RT0[Condicion] + K[Condicion]/(Dist^n), 
                 data = ICM,
                 start = list(RT0 = rep(300,24),K = rep(1,24),n=1))

But when I combine the 3 variables, throws the error:

> RT0_K.nls <- nls(RT.ms ~ RT0[Condicion] + K[Condicion]/(Dist^n[Condicion]), 
 data = ICM, start = list(RT0 = rep(300,24),K = rep(1,24),n=rep(1,24)))

Error in nls(RT.ms ~ RT0[Condicion] + K[Condicion]/(Dist^n[Condicion]),  : 
 singular gradient

Could you help me to find a solution?

Thank you very much.

  • I just refactor your code to make it more readable. Yes It looks that you have a problem with starting condition. Did you try to play with them to avoid singular values? – agstudy Jun 02 '14 at 20:23
  • Do you have any `Dist` values that are equal to 1? – Ben Bolker Jun 02 '14 at 20:30
  • Hi thanks for answering, Ben, i have no distance equal to 1, now i put the values ​​of the distances in the post to clarify a little. agstudy, can you give me an initial help to start to play with starting conditions? – user3096207 Jun 04 '14 at 20:49

0 Answers0