2005/12/18, Bart Joosen <email@example.com>:
> I have a problem with fitting a model:
> I made a dataframe with this data:
> a <- 1:3
> b <- 1:3
> c <- c(3, 2, 3, 2, 1, 2, 3, 2, 3)
> df <- expand.grid(a,b)
> df$result <- c
> names(df) <- c("A","B", "result")
> Although I can make a graph of the data:
> wireframe(result~A*B, data=df)
> I can't get a model to fit this 3D data.
> I have tried the lm function, but its easy to see that this a non lineair
> data set. The use of poly also isn't a solution.
> I tried to use nls, but there seems to be an error?
> mod <- nls(result~A:B, df, start = list (A=0, B=0))
> Error in qr.qty(QR, resid) : 'qr' and 'y' must have the same number of
That's not the proper way to use 'nls'. You have to already know which model to fit to data. 'nls' doesn't magically find it for you.
Watch at: "An Introduction to R"->"Statistical Models in R"-> "Nonlinear least squares and maximum likelihood models" for an overview.
There are various functions in R packages to do nonparametric even nonlinear fitting. Anyway, you should keep in mind that you really have'nt a lot of observations, so parametric models should be more appropriate.
Antonio, Fabio Di Narzo.
> Is there a way to fit this data?
> Thanks for your time by reading this, hopefully I will get an answer.
> Bart Joosen
> [[alternative HTML version deleted]]
> Rfirstname.lastname@example.org mailing list
> PLEASE do read the posting guide!
This archive was generated by hypermail 2.1.8 : Mon 19 Dec 2005 - 23:44:55 EST