[R] Effects - plot the marginal effect

Tomii diogenas at gmail.com
Thu Mar 31 22:09:32 CEST 2011


Hello,

I try to plot the marginal effect by using package "effects" (example of the
graph i want to get is in the attached picture).
All variables are continuous.

Here is regression function, results and error effect function gives:

> mreg01 = lm(a90$enep1 ~ a90$enpres + a90$proximity1 + (a90$enpres * a90$proximity1), data=a90)> summary(mreg01)
Call:
lm(formula = a90$enep1 ~ a90$enpres + a90$proximity1 + (a90$enpres *
    a90$proximity1), data = a90)

Residuals:
    Min      1Q  Median      3Q     Max
-2.3173 -1.3349 -0.5713  0.8938  8.1084

Coefficients:
                          Estimate Std. Error t value Pr(>|t|)
(Intercept)                 4.2273     0.3090  13.683  < 2e-16 ***
a90$enpres                  0.4225     0.2319   1.822 0.072250 .
a90$proximity1             -3.8797     1.0984  -3.532 0.000696 ***
a90$enpres:a90$proximity1   0.8953     0.4101   2.183 0.032025 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.029 on 78 degrees of freedom
Multiple R-squared: 0.2128,	Adjusted R-squared: 0.1826
F-statistic: 7.031 on 3 and 78 DF,  p-value: 0.0003029
> plot(effect(a90$enpres:a90$proximity1, mreg01))Warning messages:1: In a90$enpres:a90$proximity1 :
  numerical expression has 82 elements: only the first used2: In
a90$enpres:a90$proximity1 :
  numerical expression has 82 elements: only the first used3: In
analyze.model(term, mod, xlevels, default.levels) :
  0 does not appear in the modelError in
plot(effect(a90$enpres:a90$proximity1, mreg01)) :
  error in evaluating the argument 'x' in selecting a method for function 'plot'

>

Thanks in advance.
Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graph.png
Type: image/png
Size: 30266 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110331/c332c7c4/attachment.png>


More information about the R-help mailing list