If your "non-linear function (A, B)" is parametric nls should do it for you. If you have R version 2 (perhaps even 1.9) do ?nls to see the help page. Older versions of R require library(nls) first.
Hope this helps,
Andy
__________________________________ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory ----- E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122
Diana Abdueva <[EMAIL PROTECTED] ail.com> To Sent by: [EMAIL PROTECTED] [EMAIL PROTECTED] cc at.math.ethz.ch Subject [R] Non-Linear Regression on a 11/16/2004 08:33 Matrix PM Please respond to Diana Abdueva <[EMAIL PROTECTED] ail.com>
Hi, I'm terribly sorry for submitting my primitive question, I'm a beginner in R and was hoping to get some help re: non-linear fit.
I have a 2D data with the following structure:
A B C 1 1 111 1 2 121 1 3 131 2 1 141 2 2 151 2 3 161 3 1 171 3 2 181 3 3 191
I'm trying to fit C = non-linear function (A,B). I was wondering if there's a package that would save my time of doing direct least square estimation.
Thank you, Diana
By "non-linear" do you mean something like a response surface model that has quadratic terms in A and B and an interaction term?
If so, you can fit the model using the lm function, as in
> rs <- read.table("/tmp/rs.dat", header = TRUE)
> rs
A B C
1 1 1 111
2 1 2 121
3 1 3 131
4 2 1 141
5 2 2 151
6 2 3 161
7 3 1 171
8 3 2 181
9 3 3 191
> fm <- lm(C ~ A * B + I(A^2) + I(B^2), rs)
> fmCall: lm(formula = C ~ A * B + I(A^2) + I(B^2), data = rs)
Coefficients:
(Intercept) A B I(A^2) I(B^2) A:B
7.100e+01 3.000e+01 1.000e+01 -1.174e-15 7.217e-16 -4.008e-15
______________________________________________ [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
