On Mon, 30 Apr 2001, Tobias Meyer wrote:
> The outset:
> I am fitting logistic regression models with 1 metric variable and >2
> factor variables containing > 2 levels each. Using glm on s-plus 4.5, NT 4.0 .
>
> On behave of a nice presentation of my models (together with confidence
> limits) I constructed a new dataframe containing all the variables used for
> modelling but specializing on a specific level for each factor variable.
>
> The problem:
> In general, predict.glm does not use the coefficients of the desired levels
> and returns a wrong prediction.
>
> According to the test case below, predict.glm does find the appropriate
> coefficient when the new data includes all of the factor levels in a lead.
>
> In real life predict.glm failed yet again with new data containing > 2
> factor variables.
>
> Do I omit a point or is there a bug?
You have an obselete version of S-PLUS, and this is fixed in 2000 and 6.0.
You need to set up the new dataframe with factors having the same levels
as the original data frame. See section 6.4 of Venables & Ripley (1999),
for example.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|