hi all - quick question: i have a matrix 'y' of response values, with two explanatory variables 'x1' and 'x2'. tested values of 'x1' and 'x2' are sitting in two vectors 'x1' and 'x2'. i want to learn model parameters without "unrolling" the matrix of response values. example below:
# some fake data for the example x1 <- 1:5 x2 <- 1:10 y <- matrix(runif(50), nrow = 5) # current method: z <- vector() for(i in x1) for(j in x2) z <- c(z, i, j, y[i, j]) z <- data.frame(matrix(z, ncol = 3, byrow = TRUE)) colnames(z) <- c("x1", "x2", "y") m <- glm(y ~ x1 + x2 + x1:x2, family = binomial, data = z) # what i'd like to do, kind of: m <- glm(y ~ x1 + x2 + x1:x2) basically, i have to "unfold" the matrix 'y' to a data frame 'z' then solve. this is somewhat tedious. anyone know of a way i can do this more generally, especially if working in even higher dimensions than 2 (i.e. with an arbitrary- dimension array of response values)? ______________________________________________ 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.