Re: [R] Fitting problem

2010-09-27 Thread pj-uk
Updated! "MH"<-function(field,diameter,mu=10e-7,sig=0.1,Ms=100,chi=0){ #variables mu, sig, chi, Ms #input: field and diameter #all in CGS rho <- 5 kb <- 1.38e-16 t <- 300 length.d<-length(diameter) length.H<-length(field) M<-double(length.H) for (i in 1:length.H){ S

Re: [R] Fitting problem

2010-09-27 Thread pj-uk
Oops I forgot to add another line to the code (see below)!! You could add some noise if you want to. Generating the data from the function was merely a way to test if the fitting procedure works - I have experimental data that should allow me to calculate the parameters mu, sig, chi and Ms based

[R] Fitting problem

2010-09-27 Thread pj-uk
Hi, I have a function that generates a set of data but I am having problems determining the parameters using the nls fitting procedure. "MH"<-function(field,diameter,mu=10e-7,sig=0.1,Ms=100,chi=0){ #variables mu, sig, chi, Ms #input: field and diameter #all in CGS rho <- 5 kb <- 1.38e-16

[R] Fitting to a sum

2010-09-23 Thread pj-uk
I've run into a problem with a fitting procedure I would like R to solve for me. Basically I have to fit some data to an equation which includes a sum within the formula e.g. Y(x;a,b,c) = f_i(x;a,b,c_i) + m*x where a,b are unknown and f_i(x) is the sum of another function over a known interval i