Hey!

```
#
Function1<-function(d,a,b){
d^2/(a+b*d)^2
}
#Data
Data<-thesample
Model1<-nls(Heigth~Function1(dbh,a,b), data=Data,start=list(a=2,b=0.1))
pa<-coef(Model1)[1]
pb<-coef(Model1)[2]
#Using pa and pb to predict heigth with Model 1
Data_noheigth$pred.h<-Function1(Data_noheigth$dbh, pa, pb)
```

This line: Model1<-nls(Heigth~Function1(dbh,a,b), data=Data,start=list(a=2,b=0.1))

tends to give an error (not always).

The error im getting: "Error in nls (...) step factor reduced below minfactor"

This is done within a big script running several loops.

What I would like to do is: If I get an error I want to use pa_2 and pb_2 (from the global model) to predict the heigth. I created a global model to use when we encounter errors.

```
#If this line gives an error
Model1<-nls(Heigth~Function1(dbh,a,b),
data=Data,start=list(a=2,b=0.1))
#Do heigth with the pa_2 and pb_2 instead
Data_noheigth$pred.h<-Function1(Data_noheigth$dbh, pa_2, pb_2)
```

Im not sure how to apply the "try" function since Im extracting the coef [1] and [2] from Model1 before im predicting the heigths on the dataset without heigths.

Thanks!