Hi all, Is it possible to model a function where the unknown parameter appears both in the fitted equation AND in the determination of other parameters? E.g. y = a^2 + b/2 + k where a = 2/k and b = k^2 and the model needs to determine k? I know this is a very simple equation (its just an example), the one I am modelling is much more complicated! k appears in the equation which the n.l.r model fits, but it also affects other parameters in the equation. Please let me know if you know a way of achieving this. I realise it is possible to set up a loop where the modelled value for k is fed back in to a and b, and the model is run again - but it seems like there should be a more elegant way within one run of the model. Thanks, Jeff -- View this message in context: http://r.789695.n4.nabble.com/Non-linear-regression-with-complex-equation-tp4425942p4425942.html Sent from the R help mailing list archive at Nabble.com.
Non linear regression with complex equation
3 messages · jeff_hawkes, Rolf Turner
Your question is (completely) ill-posed. What is your actual
model? What you have said makes no sense at all as it stands.
(Minimal self-contained example .....)
cheers,
Rolf Turner
On 28/02/12 09:25, jeff_hawkes wrote:
Hi all, Is it possible to model a function where the unknown parameter appears both in the fitted equation AND in the determination of other parameters? E.g. y = a^2 + b/2 + k where a = 2/k and b = k^2 and the model needs to determine k? I know this is a very simple equation (its just an example), the one I am modelling is much more complicated! k appears in the equation which the n.l.r model fits, but it also affects other parameters in the equation. Please let me know if you know a way of achieving this. I realise it is possible to set up a loop where the modelled value for k is fed back in to a and b, and the model is run again - but it seems like there should be a more elegant way within one run of the model.
Apologies for the phrasing of the question.
I've sorted the problem (thanks Bert Gunter) by using the curly brackets {}
as below (using a simplified version of my real model). I hope this helps
someone else!
Jeff
-----------------------
data
Alpha ip X 1 0.7106967 0.3616727 0.006027879 2 2.1678517 5.0615917 0.084359861 3 4.4066250 11.2282945 0.187138242 4 9.8495694 18.0534974 0.300891624 5 27.7247098 29.2064434 0.486774057 6 70.6931430 35.3946092 0.589910153 7 133.1240255 46.0347288 0.767245480 8 214.7851844 49.3811149 0.823018582 9 359.5511036 58.5069583 0.975115972 10 748.1840127 57.3744477 0.956240795 11 2129.9844080 60.0000000 1.000000000
c<-1.83e-9
cFe=c
model<-nls({Fe1<-cFe/(Alpha+1+k*c)
+ X~Alpha/(Alpha+1+k*c/(1+k*Fe1))},start=list(k=1e10))
summary(model)
Formula: X ~ Alpha/(Alpha + 1 + k * c/(1 + k * Fe1)) Parameters: Estimate Std. Error t value Pr(>|t|) k 3.491e+10 7.190e+09 4.856 0.000665 *** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Residual standard error: 0.05589 on 10 degrees of freedom Number of iterations to convergence: 8 Achieved convergence tolerance: 2.393e-06 -- View this message in context: http://r.789695.n4.nabble.com/Non-linear-regression-with-complex-equation-tp4425942p4427617.html Sent from the R help mailing list archive at Nabble.com.