The data= argument cannot be a matrix. See ?nls On 5/22/06, H. Paul Benton <[EMAIL PROTECTED]> wrote: > So thanks for the help, > > I have a matrix (AB) which in the first column has my bin numbers so -4 - +4 > in 0.1 bin units. Then I have in the second column the frequency from some > data. I have plotted them and they look roughly Gaussian. So I want to fit > them/ find/optimize "mu", "sigma", and "A". > > So I call the nls function : > > nls_AB <- nls(x ~ (A/sig*sqrt(2*pi))* exp(-1*((x-mu)^2/(2* > sig^2))),data=temp, start= list(A=0.1, mu=0.01, sig=0.5), trace=TRUE) > Error in eval(expr, envir, enclos) : numeric 'envir' arg not of length one > > Temp looks like this: > bin x > [1,] -4.0 0 > [2,] -3.9 0 > [3,] -3.8 0 > .........etc > [41,] 0.0 241 > [42,] 0.1 229 > [43,] 0.2 258 > [44,] 0.3 305 > [45,] 0.4 370 > [46,] 0.5 388 > > So I don't get my error message. I looked at doing > class(fo <- (x ~ (A/sig*sqrt(2*pi))* exp(-1*((x-mu)^2/(2* sig^2))))) > terms(fo) > > and that seems to work. So if anyone has any ideas I would welcome them. > > Cheers, > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
