glm for nominal X ordinal

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

glm for nominal X ordinal

Gang Chen-3
Suppose I have a two-way table of nominal category (party  
affiliation) X ordinal category (political ideology):

party affiliation X (3 levels) - democratic, independent, and republic
political ideology Y (3 levels) - liberal, moderate, and conservative

The dependent variable is the frequency (or count) for all the two-
way cells sampled from the voters. I want to test whether there is  
any party affiliation effect, and, if there is, the pair-wise  
contrasts. I have never used glm (I assume this the program I should  
use) before, so I am not so sure how I can code the two independent  
variables reflecting the fact that one is nominal while the other is  
ordinal and how to formulate the model.

Any help is highly appreciated,
Gang

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: glm for nominal X ordinal

David Winsemius
Gang Chen <[hidden email]> wrote in
news:[hidden email]:

> Suppose I have a two-way table of nominal category (party  
> affiliation) X ordinal category (political ideology):
>
> party affiliation X (3 levels) - democratic, independent, and
> republic
> political ideology Y (3 levels) - liberal, moderate, and
> conservative
>
> The dependent variable is the frequency (or count) for all the two-
> way cells sampled from the voters. I want to test whether there is  
> any party affiliation effect, and, if there is, the pair-wise  
> contrasts. I have never used glm (I assume this the program I should
>  use) before, so I am not so sure how I can code the two independent
>  variables reflecting the fact that one is nominal while the other
> is  ordinal and how to formulate the model.

?factor

Set up affiliation as a factor and ideology as an ordered factor. The
levels argument in factor sets the sort order.

> theo<-c("cons", "mod", "cons", "cons", "lib", "mod")
> table(theo)
theo
cons  lib  mod
   3    1    2

> theo<-ordered(theo, levels=c("lib", "mod", "cons"))
> table(theo)
theo
 lib  mod cons
   1    2    3

 The formula  in glm would be something similar to counts ~ theo + affil

Much more detail and worked examples regarding modeling count data would
be found in:
Thompson, LA;  (2004) R (and S-PLUS)Manual to Accompany Agresti’s (2002)
Catagorical Data Analysis;
https://home.comcast.net/~lthompson221/Splusdiscrete2.pdf

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: glm for nominal X ordinal

Gang Chen-3
Thanks a lot! This is exactly what I wanted.

Gang


On Jan 5, 2008, at 2:20 PM, David Winsemius wrote:

> Gang Chen <[hidden email]> wrote in
> news:[hidden email]:
>
>> Suppose I have a two-way table of nominal category (party
>> affiliation) X ordinal category (political ideology):
>>
>> party affiliation X (3 levels) - democratic, independent, and
>> republic
>> political ideology Y (3 levels) - liberal, moderate, and
>> conservative
>>
>> The dependent variable is the frequency (or count) for all the two-
>> way cells sampled from the voters. I want to test whether there is
>> any party affiliation effect, and, if there is, the pair-wise
>> contrasts. I have never used glm (I assume this the program I should
>>  use) before, so I am not so sure how I can code the two independent
>>  variables reflecting the fact that one is nominal while the other
>> is  ordinal and how to formulate the model.
>
> ?factor
>
> Set up affiliation as a factor and ideology as an ordered factor. The
> levels argument in factor sets the sort order.
>
>> theo<-c("cons", "mod", "cons", "cons", "lib", "mod")
>> table(theo)
> theo
> cons  lib  mod
>    3    1    2
>
>> theo<-ordered(theo, levels=c("lib", "mod", "cons"))
>> table(theo)
> theo
>  lib  mod cons
>    1    2    3
>
>  The formula  in glm would be something similar to counts ~ theo +  
> affil
>
> Much more detail and worked examples regarding modeling count data  
> would
> be found in:
> Thompson, LA;  (2004) R (and S-PLUS)Manual to Accompany Agresti’s  
> (2002)
> Catagorical Data Analysis;
> https://home.comcast.net/~lthompson221/Splusdiscrete2.pdf
>
> ______________________________________________
> [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
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.