Learn R Programming

hmmm (version 1.0-4)

GMI: function to compute the generalized marginal interactions associated to a hierarchical family of marginal sets

Description

Given a vector of joint probabilities, the generalized marginal interactions (gmi) associated to a hierarchical family of marginal sets are computed. If the input is a matrix, gmi are computed for every column.

Usage

GMI(freq, marg, lev, names, mflag = "M")

Arguments

freq

Matrix of joint probabilities. Every column describes a joint pdf.

marg

A character vector decribing the marginal sets and the logits used to build the interactions. See marg.list

lev

Number of categories of the categorical variables. See the help of hmmm.model

names

Names of the categorical variables

mflag

The symbol used to denote variables that are marginalized, default "M". See marg.list

Value

A list with two components: marginals and gmi; marginals is a legend that explains the interactions, gmi is a vector or a matrix that contains the interactions.

References

Colombi R, Giordano S, Cazzaro M (2014) hmmm: An R Package for hierarchical multinomial marginal models. Journal of Statistical Software, 59(11), 1-25, URL http://www.jstatsoft.org/v59/i11/.

See Also

inv_GMI, hmmm.model, marg.list

Examples

Run this code
# NOT RUN {
# joint frequencies for two ordinal variables 
# H: level of happiness on a scale from 1 to 5
# S: level of satisfaction on a scale from 1 to 5

y<-c(50,36,15,15,13,15,84,60,42,
     35,6,26,105,113,57,5,26,62,
     465,334,4,10,34,186,1404)
  
lev<-c(5,5)
marg<-c("g-m","m-g","g-g")
names<-c("H","S")

o<-GMI(cbind(c(y),c(y/sum(y))),marg,lev,names,mflag="m")
o
# }

Run the code above in your browser using DataLab