visualization - Visualising logistic regression using the effects package in R -
i using effects package in r plot effects of categorical , numerical predictors in binomial logistic regression estimated using lme4 package. dependent variable presence or absence of virus in individual animal , predictive factors various individual traits (eg. sex, age, month/year captured, presence of parasites, scaled mass index (smi), site random variable).
when use alleffects
function on regression, plots below. when compared model summary output below, can see slope of each line appears zero, regardless of estimated coefficients, , there strange going on scale of y-axes ticks , tick labels appear overwritten on same point.
here code model , summary output:
library(lme4) library(effects) virus1.mod<-glmer(virus1~ age + sex + month.yr + parasites + smi + (1|site) , data=virus1data, family=binomial) virus1.effects<-alleffects(virus1.mod) plot(virus1.effects, ylab="probability(infected)", rug=false) > summary(virus1.mod) generalized linear mixed model fit maximum likelihood ['glmermod'] family: binomial ( logit ) formula: virus1 ~ age + sex + month.yr + parasite + smi + (1 | site) data: virus1data aic bic loglik deviance 189.5721 248.1130 -76.7860 153.5721 random effects: groups name variance std.dev. site (intercept) 4.729e-10 2.175e-05 number of obs: 191, groups: site, 6 fixed effects: estimate std. error z value pr(>|z|) (intercept) 5.340e+00 2.572e+00 2.076 0.03789 * agej 1.126e+00 8.316e-01 1.354 0.17583 sexm -3.943e-02 4.562e-01 -0.086 0.93113 month.yrfeb-08 -2.259e+01 6.405e+04 0.000 0.99972 month.yrfeb-09 -2.201e+01 2.741e+04 -0.001 0.99936 month.yrjan-08.516e+00 8.175e-01 -3.078 0.00208 ** month.yrjan-09 -2.607e+00 8.066e-01 -3.232 0.00123 ** month.yrjul-08 -1.428e+00 8.571e-01 -1.666 0.09563 . month.yrjul-09 -2.795e+00 1.170e+00 -2.389 0.01691 * month.yrjun-08 -2.259e+01 3.300e+04 -0.001 0.99945 month.yrmar-09 -5.451e-01 6.705e-01 -0.813 0.41622 month.yrmar-08 -1.863e+00 7.921e-01 -2.352 0.01869 * month.yrmay-09 -6.319e-01 8.956e-01 -0.706 0.48047 month.yrmay-08 3.818e-01 1.015e+00 0.376 0.70691 month.yrsep-08 2.563e+01 5.806e+05 0.000 0.99996 parasitetrue -6.329e-03 4.834e-01 -0.013 0.98955 smi -3.438e-01 1.616e-01 -2.127 0.03342 *
and str of data frame:
> str(virus1data) 'data.frame': 191 obs. of 8 variables: $ virus1 : factor w/ 2 levels "0","1": 1 1 1 1 1 2 1 2 1 1 ... $ age : factor w/ 2 levels "a","j": 1 1 1 1 1 1 1 1 1 1 ... $ sex : factor w/ 2 levels "f","m": 2 2 2 2 1 1 2 1 2 2 ... $ site : factor w/ 6 levels “site1”,"site2”,"site3",..: 1 1 1 1 2 2 2 3 2 3 ... $ rep : factor w/ 7 levels "nrf","l","nr",..: 3 7 3 7 1 1 3 1 7 7 ... $ month.yr : factor w/ 17 levels "feb-08","feb-09",..: 4 5 5 5 13 7 14 9 9 9 ... $ parasite : factor w/ 2 levels "false","true": 1 1 2 1 1 2 2 1 2 1 ... $ smi : num 14.1 14.8 14.5 13.1 15.3 ... - attr(*, "na.action")=class 'omit' named int [1:73] 6 12 13 21 22 23 24 25 26 27 ... .. ..- attr(*, "names")= chr [1:73] "1048" "1657" "1866" "2961" ...
without making actual data available, have idea of might causing this? have used function different dataset (same independent variables different virus response variable, , different records) without problems.
this first time have posted on cv, hope question appropriate , have provided enough (and right) information.
Comments
Post a Comment