[R-sig-eco] Logistic regression plot
solymos at ualberta.ca
Wed Aug 18 16:24:24 CEST 2010
it depends on whether you are interested (1) only in mean predictions
only or (2) prediction intervals as well. In the first case, this will
give you mean predictions:
x1 <- seq(min1, max1, len=25)
x2 <- seq(min2, max2, len=25)
x3 <- seq(min3, max3, len=25)
x10 <- x20 <- x30 <- rep(0, 25)
beta.hat <- c(beta0, beta1, beta2, beta3)
X <- model.matrix(~x1+x20+x30)
Y.hat <- plogis(X %*% beta.hat) # inverse logit link
and then repeat with ~ x10 + x2 + x30 etc. to control for other covariates.
In the second case, either you write a program that calculates the
distribution of Y.hat based on varying beta.hat, that is generating
parameters from a normal distribution with beta.i mean and SE.i
standard deviation. Or do the same in WinBUGS/OpenBUGS/JAGS to
generate from the posterior distribution (note that you should use the
precision = 1/variance in the prior specification). This won't be the
*joint* posterior because you don't have the variance-covariance
matrix, but should work as an approximation.
Alberta Biodiversity Monitoring Institute
and Boreal Avian Modelling project
Department of Biological Sciences
CW 405, Biological Sciences Bldg
University of Alberta
Edmonton, Alberta, T6G 2E9, Canada
email <- paste("solymos", "ualberta.ca", sep = "@")
On Tue, Aug 17, 2010 at 8:15 AM, Manuel Spínola <mspinola10 at gmail.com> wrote:
> Dear List members,
> How can I plot in R the result from a logistic regression model with 3
> continuous explanatory variable when I only have the model output
> (coefficients and SE) and the explanatory variable range values. I don't
> have the var-cov matrix.
> I will like to make 3 plots, one for each variable in the model.
> Thank you very much in advance.
> Manuel Spínola, Ph.D.
> Instituto Internacional en Conservación y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> COSTA RICA
> mspinola at una.ac.cr
> mspinola10 at gmail.com
> Teléfono: (506) 2277-3598
> Fax: (506) 2237-7036
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
More information about the R-sig-ecology