how to get correct coefficients from lm model

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to get correct coefficients from lm model

Kum-Hoe Hwang
Howdy

I apologize for duplicated posting. But I decided to correct my previous
posting.

I had the regression results using

r <-  lm(Y ~ nemp + as.factor(devt), data=d).

First, there is the result of anova(r). Here I could not find regression
coefficients.

Response: Y
                       Df Sum Sq Mean Sq F value  Pr(>F)
nemp                    1   58.2    58.2 1233.23 < 2e-16 ***
as.factor(devt)        3    3.6     1.2   25.69 2.6e-16 ***

Second, there is the result of summary(r) that I am confused
with too many coefficients for a factor variable "devt".
Because there are three coefficients for factor variables
such as"as.factor(devt)A ", "as.factor(devt)B", "as.factor(devt)C".

Coefficients:
                                  Estimate Std. Error t value Pr(>|t|)
(Intercept)                       as.factor(devt1)        3    3.6     1.2
25.69 2.6e-16 ***   5.95e-02   10.19  < 2e-16 ***
nemp                              2.87e-06   1.04e-07   27.63  < 2e-16 ***
as.factor(devt)A            2.44e-02   1.47e-02    1.66  0.09630 .
as.factor(devt)B           -1.10e-01   1.40e-02   -7.90  4.6e-15 ***
as.factor(devt)C          -9.19e-03   1.53e-02   -0.60  0.54953

Is this model right  as a tentative model at least?
   Y = 6.07e-01  + 2.87e-06* nemp + 2.44e-02 * as.factor(devt)A
         - 1.10e-01 * as.factor(devt1)B - 9.19e-03 * as.factor(devt)C


 And so, my question is "which coefficients should I use for a final
model?".

Thanks in advance,
--
Kum-Hoe Hwang, Ph.D.Phone : 82-31-250-3516Email : [hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: how to get correct coefficients from lm model

Hank Stevens

On May 18, 2006, at 10:37 AM, Kum-Hoe Hwang wrote:

> Howdy
>
> I apologize for duplicated posting. But I decided to correct my  
> previous
> posting.
>
> I had the regression results using
>
> r <-  lm(Y ~ nemp + as.factor(devt), data=d).
>
Can you tell us how many levels of devt there are?
Do
levels(d$devt)

> First, there is the result of anova(r). Here I could not find  
> regression
> coefficients.
>
> Response: Y
>                        Df Sum Sq Mean Sq F value  Pr(>F)
> nemp                    1   58.2    58.2 1233.23 < 2e-16 ***
> as.factor(devt)        3    3.6     1.2   25.69 2.6e-16 ***
>
> Second, there is the result of summary(r) that I am confused
> with too many coefficients for a factor variable "devt".
> Because there are three coefficients for factor variables
> such as"as.factor(devt)A ", "as.factor(devt)B", "as.factor(devt)C".
>
> Coefficients:
>                                   Estimate Std. Error t value Pr(>|t|)
> (Intercept)                       as.factor(devt1)        3    
> 3.6     1.2
> 25.69 2.6e-16 ***   5.95e-02   10.19  < 2e-16 ***
Why is the as.factor(devt1) here? what is devt1?

> nemp                              2.87e-06   1.04e-07   27.63  <  
> 2e-16 ***
> as.factor(devt)A            2.44e-02   1.47e-02    1.66  0.09630 .
> as.factor(devt)B           -1.10e-01   1.40e-02   -7.90  4.6e-15 ***
> as.factor(devt)C          -9.19e-03   1.53e-02   -0.60  0.54953
>
> Is this model right  as a tentative model at least?
>    Y = 6.07e-01  + 2.87e-06* nemp + 2.44e-02 * as.factor(devt)A
>          - 1.10e-01 * as.factor(devt1)B - 9.19e-03 * as.factor(devt)C
>
>
>  And so, my question is "which coefficients should I use for a final
> model?".
>
> Thanks in advance,
> --
> Kum-Hoe Hwang, Ph.D.Phone : 82-31-250-3516Email : [hidden email]
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting- 
> guide.html

Dr. M. Hank H. Stevens, Assistant Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/~stevenmh/
http://www.muohio.edu/ecology/
http://www.muohio.edu/botany/
"E Pluribus Unum"

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html