[R] linear models with factors
David Winsemius
dwinsemius at comcast.net
Sat Feb 12 17:36:42 CET 2011
On Feb 12, 2011, at 11:16 AM, Ista Zahn wrote:
> Well, I may have been too hasty there. Actually the question was
> slightly improved. I think you are looking for ?contr.sum
>
Another issue will arise besides what the switch of the contrasts
-- The intercept is not a "general effect" but rather a combined
intercept for all of the continuous terms estimated when they are
simultaneous zero. (Only in the situation where the continuous
variables had all been centered would this be anywhere near the
"general effect" or "grand mean". ) I infer that OP has been brought
up in an anova tradition and has not made a proper transition to
regression.
Perhaps what could be explored is whether the predict() function is a
path to enlightenment or at least partial satisfaction.
?predict
OP: Try something along these lines with the names for the factor
variables matching that of the original data and choosing a
representative value or values for the continuous variables:
predict(mdl, data.frame(lev1=factor(val1,val2,val3, levels=levels(dat
$lev1)),
lev2= ... etc
etc=etc ), contin=median(dat$contin) )
)
Perhaps with expand.grid() if combinations are needed.
--
david. .... er, David.
> Best,
> Ista
>
> On Sat, Feb 12, 2011 at 3:55 PM, Ista Zahn
> <izahn at psych.rochester.edu> wrote:
>> I already responded to your identical post yesterday, asking you to
>> actually ask a question. "can you please help me?" is not enough.
>>
>> Best,
>> Ista
>>
>>
>> On Sat, Feb 12, 2011 at 5:57 AM, ATANU <ata.sonu at gmail.com> wrote:
>>>
>>> i am trying to fit a linear model with both continuous covariates
>>> and
>>> factors. When fitted with the intercept
>>> term the first level of the factor is treated by R as intercept
>>> and the
>>> estimate of the effects of remaining levels(say i th level) are
>>> given as
>>> true estimate of i th level - estimate of 1st level. i want the
>>> estimates of
>>> coefficients of each level along with the intercept term(general
>>> effect).can anyone please help me?
>>> thanks in advance.....
>>> --
>>> View this message in context: http://r.789695.n4.nabble.com/linear-models-with-factors-tp3302404p3302404.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>>
>> --
>> Ista Zahn
>> Graduate student
>> University of Rochester
>> Department of Clinical and Social Psychology
>> http://yourpsyche.org
>>
>
>
>
> --
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list