[R] gnls(0 error: invalid variable type

Yang, Richard dyang at NRCan.gc.ca
Wed Dec 1 21:32:29 CET 2004


Dear R-helpers;

While using gnls() to fit a function 	

         > Gbht0t.gnls <- gnls(h2 ~ Rht(b0, b1, b2, h1,t1, t2), data=gbht10,
+     params=list(b0 + b1 + b2 ~ Sisp -1), start=c(strssb0,strssb1,strssb2))

I encountered an error: 
    "Error in model.frame(formula, rownames, variables, varnames, extras,
extranames,  :  invalid variable type " 

Rht is a defined function to be fitted  and initial values are stored in
three vectors strssb0-b2. The error occurred at the gnls() source line:

	dataMod <- do.call("model.frame", mfArgs)

All variables in the data frame are listed below. By examining those 5
variables used in the function, I failed to spot any offending one: t1, t2,
h1, and h2 are all numeric and Sisp is a factor of 15 levels. 
> str(gbht10)
`data.frame':   2400 obs. of  15 variables:
 $ sidx44: num  17.8 17.8 17.8 17.8 17.8 ...
 $ tree  : int  1 1 1 1 1 1 1 1 2 2 ...
 $ blk   : int  1 1 1 1 1 1 1 1 1 1 ...
 $ sp    : int  200 200 200 200 200 200 200 200 200 200 ...
 $ tn    : int  8 8 8 8 8 8 8 8 19 19 ...
 $ re    : int  1 1 1 1 1 1 1 1 1 1 ...
 $ si    : int  1 1 1 1 1 1 1 1 1 1 ...
 $ tdbh  : num  11.4 11.4 11.4 11.4 11.4 ...
 $ t1    : int  7 9 14 19 24 29 34 39 7 9 ...
 $ h1    : num  0.5 0.8 2.1 4 6.3 8.4 10.1 11.8 0.5 0.9 ...
 $ t2    : int  9 14 19 24 29 34 39 44 9 14 ...
 $ h2    : num  0.8 2.1 4 6.3 8.4 10.1 11.8 12.6 0.9 2.1 ...
 $ Site  : chr  "L" "L" "L" "L" ...
 $ Sp    : chr  "1" "1" "1" "1" ...
 $ Sisp  : chr  "L1" "L1" "L1" "L1" ...

What puzzles me most is the same function was successfully run a few days
back. The original data frame was modified  by adding an additional column.
Here are bits of info from the previous run (Gbht02.gnls):

 > Gbht02.gnls$call
gnls(model = h2 ~ Rht(b0, b1, b2, h1, t1, t2), data = gbht10, 
    params = list(b0 + b1 + b2 ~ Sisp - 1), start = c(strssb0, 
        strssb1, strssb2))
> Gbht02.gnls$coef[1:5]
b0.SispH1 b0.SispH2 b0.SispH3 b0.SispH4 b0.SispH5 
0.9354108 0.8420247 0.8681101 0.8998161 0.7892491 

Any insight and ideas of the error message? I use R2.0.0 on XP. 

TIA,

Richard Yang




More information about the R-help mailing list