0

I am using the nls2 package to do a fit. The fit is correct but how do I get back just the calculated values of the predicted variables?

The formula:

fit <- nls2(Trans ~ t - (h * W ^ 2 / ((WLn - x0) ^ 2 + W ^ 2)),
     data = siteData,
     start = list(t=0.6, h=0.5, x0=830, W=100),
     algorithm = "port",
     #trace = TRUE,
     lower = c(t=-Inf, h=0, x0=700, W=35),
     upper = c(t=0.6, h=Inf, x0=950, W=Inf)
     )
fit

i.e. how can I get back the values for t, h, x0, & W only? Thanks!

LyzandeR
  • 37,047
  • 12
  • 77
  • 87
user3646105
  • 2,459
  • 4
  • 14
  • 18
  • As for this question: Provide sample data that we can use in order to have something to work with. Also always mention the name of the package you are using (even if the name of the package coincides with the name of the function). Saying this so that you can get more answers to your questions :) – LyzandeR Jan 07 '15 at 09:34

1 Answers1

0

You can get the parameter estimates using coef(fit). nls2 returns an object of class "nls", so you can use any of the generic functions mentioned in ?nls.

Heather Turner
  • 3,264
  • 23
  • 30