Re: [R] Effects - plot the marginal effect

From: Tomii <diogenas_at_gmail.com>
Date: Fri, 08 Apr 2011 10:24:45 +0200

Thank you for your response, but these changes doesn't seem to change anything, outcomes of effect command is still the same - error.

Tomas

> Dear Tomas,
>
> Write the model as
>
> mreg01 = lm(enep1 ~ enpres * proximity1), data=a90)
>
> That is, it's not necessary to index a90 as a list since it's given as the
> data argument to lm, and doing so confuses the effect() function. Also,
> enpres*proximity1 will include both the enpres:proximity1 interaction and
> enpres + proximity1, which are marginal to the interaction.
>
> Next, you must quote the name of the term for which you want to compute
> effects, thus "enpres:proximity1" in the call to effect().
>
> Finally, effect() doesn't compute what are usually termed marginal effects.
> ?effect.
>
> I hope this helps,
> John
>
> ------------------------------------------------
> John Fox
> Sen. William McMaster Prof. of Social Statistics
> Department of Sociology
> McMaster University
> http://socserv.mcmaster.ca/jfox/
>
> On Thu, 31 Mar 2011 22:09:32 +0200
> Tomii <diogenas_at_gmail.com> wrote:
> > 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'
> >
> > >
> >
> > Tomas
>
>
>
>

[[alternative HTML version deleted]]

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. Received on Fri 08 Apr 2011 - 08:28:26 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 08 Apr 2011 - 14:10:28 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.