[R] Design matrix not identity
Hello again, I was too quick before. What I was looking for was a function that constructs the design (or incidence) matrix (X in a linear model) from a factor. Uwe Ligges suggested using model.matrix and this does almost what I want, but it is first necessary to construct a data variable. It also asigns ones to all rows of the first column (because this is set to be the contrast, not really what I want - see below). Maybe time for a function that just converts a factor into a design matrix? I have a factor factor<-as.factor(c(1,1,2,2,3,3,3)) and I want a matrix 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 Patrik Waldmann### This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange. ### __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Identity matrix
Hello, I cannot find a function that forms the identity matrix from a factor, is there any? Patrik Waldmann### This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange. ### __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Mode of MCMC chain
Hello, are there any functions in R for estimation of the mode of a MCMC-chain? Best, Patrik Waldmann [[alternate HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Tabulating
Hello, I wonder if someone could send me suggestions on how to solve the following problem: I have a vector of an arbitrary size (ex. data<-c(10,10,11,10,12,11,10,12,11,11,10,11)) and use the table function, which gives the following result 10 11 12 55 2 that's fine, but what I would like to do now is: construct new classes based on the number of classes from table, 10 10, 11 11, 12 12, 10 11, 10 12, 11 12. After that I would like to do tabulation on the pairs in data, and positions in pairs should be unimportant: 10 11 should be treated as the same class as 11 10. So the following result should be obtained: 10 10, 11 11, 12 12, 10 11, 10 12, 11 12 1 , 1 , 0 , 2 , 1 , 2 Remeber that it should be possible to do for an arbitrary number of classes. Best regards, [EMAIL PROTECTED] [[alternate HTML version deleted]] __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help