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.