[R] Predicted values from a logistic model
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Mon May 14 03:54:43 CEST 2007
MANASI VYDYANATH wrote:
> Hello -
> I apologize if this question is simple/obvious, but I couldn't find a
> satisfactory answer online, and I am not very accustomed to working
> with R (Matlab is my poison. :-)). Any help would be greatly
> I have a model with a three-level factor and a continuous covariate.
> The call I use is:
> mymodel <- glm(Response ~ Factor_covariate + continuous_covariate -
> 1, family = binomial(link = "logit"))
> I would like to generate predicted values for a given level of the
> covariate, and a given level of the factor. For instance, I want it
> to give me a fitted value for the response at factor level 1 and
> continuous covariate value 10. How would I go about expressing this?
> I tried to look at the package Design, and specifically, at the
> command "predict.lrt". But I was unable to quite understand how I
> ought to enter my x-values. Again, any help would be much appreciated.
> Thank you for taking the time to read this!
With Design you do predict(mymodel, data.frame(age=30, sex='male'),
For ordinal responses there are several options for prediction different
things. If you want to leave some covariates unspecified (default to
reference values - medians or modes) you can use predict(mymodel,
gendata(mymodel, list of covariates you care to specify))
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help