[R] predict.gl1ce question

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Dec 4 01:29:40 CET 2003


Richard Bonneau <rbonneau at systemsbiology.org> writes:

> Hi,
> 
> I'm using gl1ce with family=binomial like so:
>  >yy
>        succ fail
>   [1,]   76   23
>   [2,]   32   67
>   [3,]   56   43
>   ...
> [24,]   81   18
> 
>  >xx
>           c1219       c643
> X1  0.04545455 0.64274145
> X2  0.17723669 0.90392792
> ...
> X24 0.80629054 0.12239320
> 
>  >test.gl1ce <- gl1ce(yy ~ xx, family = binomial(link=logit), bound =
> 0.5 )
> or
>  >omit <- c(2,3)
>  >test.gl1ce <- gl1ce(yy[-omit,] ~ xx[-omit,], family =
> binomial(link=logit), bound = 1 )
> 
> this seems to work fine and as i change the shrinkage parameter
> everything behaves as expected.
> 
> if i try to get the fitted values (y-hat) using predict i have no
> problems:
>  > predict.gl1ce(test.gl1ce)
>   [1] 0.38129977 0.16513661 0.47666779 0.45348757 0.09916513 0.18167674
>   [7] 0.11047684 0.15786664 0.14765670 0.40657031 0.19072570 0.80259477
> [13] 0.36317090 0.35930557 0.23700520 0.17579282 0.18835043 0.52306049
> [19] 0.28388953 0.41262864 0.29933710 0.43556139 0.15276727 0.73017401
> 
> ***
> I have problems, however, when i try to use predict.gl1ce() with
> newdata.
> 
> so, the following tries all give errors:
>  > predict.gl1ce(test.gl1ce, xx, family=binomial(link-logit))
>  > predict.gl1ce(test.gl1ce, xx)
>  > predict.gl1ce(test.gl1ce, xx[omit,], family=binomial(link-logit))
> Error in predict.l1ce(test.gl1ce, xx, family = binomial(link - logit)) :
>          Argument `newdata' is not a data frame, and cannot be coerced
> to an appropriate model matrix
> 
> the following weak try also bombs:
>  > predict.gl1ce(test.gl1ce, data.frame(xx), family=binomial(link-logit))
> Error in eval(expr, envir, enclos) : attempt to apply non-function
> 
> 
> I've tried quite a few variations. It seems I'm missing something, but
> if glm or gl1ce take a certain
> data format then the corresponding predict me,thods should (what am i
> missing).

1. try link=logit, as opposed to what you typed
2. xx is probably not a data frame (or yy~xx would unlikely work), so
   as.data.frame might do the trick.
3. what is gl1ce? I you're having trouble with an add-on package, you
   might have the courtesy to tell us which one. Not everyone uses
   lasso2 on a daily basis, you know.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list