I have a data table with experimental data which i want to non-linear fit. The Data consist in a table with the first column containing the x values, all the next columns contain y data from different measurements. there are 2 parameters which i guess by the fit method, called a and b. e.g.:
x y1 y2 y3 y4
2 60 100 129 189
5 90 118 156 200
10 114 145 178 225 (all data random, not real)
i managed to fit the x and y1 columns using nls (works like a charm, thanks to several articles found here:-)), extracting a subset of y values column by column. Now i want to recursively fit all y columns against x and save the respective values of a and b in another table.
Up to now i did this:
x<-trx_data[,c(1)]
y_383.2<-trx_data[,c(2)] #corresponds to y1
df<-data.frame(x,y_383.2) #define a new data table with x and y1
colnames(df)<-c("x","y") #rename the columns
start_values<-c(a=20,b=2) #set starting values
#perform fitting
m_HB<-nls(y~x+a*sqrt(b*x/a+1),
data = df,
start = start_values,
algorithm="plinear")
summary(m_HB)
now i want to create a data table looking like this:
383.2 383.3 383.4 #column names, extracted from input table
40 46 49 #parameter a
7 13 9 #parameter b
is there an elegant solution for this? Thanks a lot in advance! Chris