Dear R-help community,

I am working with multidimensional contingency tables and I am having 
trouble getting loglm to run on all dimensions without typing out each 
dimension.

I have generated random data and provided output for the results I want 
below:

d1.c1 <- rnorm(20, .10, .02)
d1.c2 <- rnorm(20, .10, .02)
d2.c1 <- rnorm(20, .09, .02)
d2.c2 <- rnorm(20, .09, .02)
d3.c1 <- rnorm(20, .11, .02)
d3.c2 <- rnorm(20, .11, .02)

group1 <- cbind(1, d1.c1, d2.c1, d3.c1)
group2 <- cbind(2, d1.c2, d2.c2, d3.c2)

colnames(group1) <- colnames(group2) <- c("group", "dim1", "dim2", "dim3")
combined <- rbind(group1, group2)
combined[,2:4] <- combined[,2:4] > .1

ctables <- xtabs(~., data = combined)
loglm(~group+dim1+dim2+dim3, data=ctables)

Call:
loglm(formula = ~group + dim1 + dim2 + dim3, data = ctables)

Statistics:
                       X^2 df  P(> X^2)
Likelihood Ratio 12.29856 11 0.3416253
Pearson          10.28058 11 0.5053391

However, the number and the names of the dimensions change for each 
dataset. What I want is to be able to run the following line at the end 
of the code: "loglm(~., data=ctables)", but it always prints the 
following error:

Error in terms.formula(formula <- denumerate(formula)) :
   '.' in formula and no 'data' argument

Can anyone help me out?

Thank you,
Jason

-- 
Jason Hwa
Carnegie Mellon University
M.S. in Statistical Practice '11
B.S. in Operations Research '10
j...@stat.cmu.edu <mailto:j...@stat.cmu.edu>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to