[R] Effects - plot the marginal effect

From: Tomii <diogenas_at_gmail.com>
Date: Thu, 31 Mar 2011 22:09:32 +0200


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

______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

graph.png
Received on Thu 31 Mar 2011 - 20:12:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Apr 2011 - 05:40:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive