[R] How to put factor variables in an nls formula ?

Douglas Bates dmbates at gmail.com
Fri Aug 19 16:12:40 CEST 2005


On 8/18/05, François Morneau <francois.morneau at cirad.fr> wrote:
> Hello,
> 
> I want to fit a Gompertz model for tree diameter growth that depends on a 4
> levels edaphic factor ('Drain') and I don't manage to introduce the factor
> variable in the formula.
> Dinc is the annual diameter increment and D is the Diameter.
> 
>  >treestab
>  >     Dinc     D      Drain
>   [1,]  0.03  26.10     2
>   [2,]  0.04  13.05     1
>   [3,]  0.00  24.83     1
>   [4,]  0.00  15.92     4
>   [5,]  0.00  12.25     4
>   [6,]  0.00  11.78     4
>   [7,]  0.00  16.87     4
>   [8,]  0.00  15.12     4
>   [9,] -0.01  13.53     4
> [10,] 0.04  16.55     3
> [11,] 0.025 16.07     3
> [12,] 0.00  30.24     3
> [13,] 0.06  15.28     2
> etc…
>  >contrasts(Drain)<-contr.sum(4)
>  >mymodel<-nls(Dinc~r*(1+Drain)*D*log(Asym/D), data=treestab, start(r=0.05,
> Asym=40))
> 
> Error in numericDeriv(form[[3]], names(ind), env) :
>          Missing value or an infinity produced when evaluating the model
> In addition: Warning messages:
> 1: + not meaningful for factors in: Ops.factor(1, Drain)
> 2: + not meaningful for factors in: Ops.factor(1, Drain)

It is not clear to me what you are trying to do.  Can you give us a
bit more information such as how many parameter estimates you expect
to obtain and what they would represent?

> 
> Do I need to use another function instead of nls to correctly include the
> factor 'Drain' ?
> 
> Thanks,
> 
> François
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list