[R] effect function in the effects package

Xu Jun junxu.r at gmail.com
Thu Oct 20 16:34:30 CEST 2011


Dear r-help listers,

I am using effects to produce an effect plot after the proportional
odds logistic regression model. There is no problem for me to estimate
the model, but when it comes to the graphing, I was stuck. see the
codes below:

##############################################################################
 myologit <- polr(factor(warm) ~ yr89 + male + white + age + ed + prst,
+               data=ordwarm2, method=c("logistic"))

require(effects)
plot(effect("age", myologit, xlevles=list(age=seq(20, 80, 5),
given.values(male=1, yr89=1))))

##############################################################################

I got the following error message:

Warning message:
package 'effects' was built under R version 2.13.2
Error in plot(effect("age", myologit, xlevles = list(age = seq(20, 80,  :
  error in evaluating the argument 'x' in selecting a method for
function 'plot': Error in model.frame.default(formula = factor(warm) ~
yr89 + male + white +  :
  variable lengths differ (found for 'yr89')


the full set of codes:

> myologit <- polr(factor(warm) ~ yr89 + male + white + age + ed + prst,
+               data=ordwarm2, method=c("logistic"))

> summary(myologit)

Re-fitting to get Hessian

Call:
polr(formula = factor(warm) ~ yr89 + male + white + age + ed +
    prst, data = ordwarm2, method = c("logistic"))

Coefficients:
          Value Std. Error t value
yr89   0.523912   0.079899   6.557
male  -0.733309   0.078483  -9.344
white -0.391140   0.118381  -3.304
age   -0.021666   0.002469  -8.777
ed     0.067176   0.015975   4.205
prst   0.006072   0.003293   1.844

Intercepts:
    Value    Std. Error t value
1|2  -2.4654   0.2389   -10.3188
2|3  -0.6309   0.2333    -2.7042
3|4   1.2618   0.2340     5.3919

Residual Deviance: 5689.825
AIC: 5707.825

> plot(effect("age", myologit, xlevles=list(age=seq(20, 80, 5), given.values(male=1, yr89=1))))
Warning message:
package 'effects' was built under R version 2.13.2
Error in plot(effect("age", myologit, xlevles = list(age = seq(20, 80,  :
  error in evaluating the argument 'x' in selecting a method for
function 'plot': Error in model.frame.default(formula = factor(warm) ~
yr89 + male + white +  :
  variable lengths differ (found for 'yr89')



More information about the R-help mailing list