# # ############### Categorical Regression Data Generation ############### # # ## This script shows how I generated the (2nd) Categorial Regression ## example data file (catreg2.sav). # # # The script results in a data file made up of 6 ordinal # variables: y , x1 - x5 (N = 1000). ###### b1 <- 17 b2 <- 13 b3 <- 9 b4 <- 5 b5 <- 1 e <- rnorm(1000) a <- 25 x1 <- rnorm(1000,5) x2 <- rnorm(1000,5) x3 <- rnorm(1000,5) x4 <- rnorm(1000,5) x5 <- rnorm(1000,5) y <- a + b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + e reg1 <- lm(y~x1+x2+x3+x4+x5) reg2 <- lm(scale(y)~scale(x1)+scale(x2)+scale(x3)+scale(x4)+scale(x5)) summary(reg1) summary(reg2) x1 <- trunc(x1) x2 <- trunc(x2) x3 <- trunc(x3) x4 <- trunc(x4) x5 <- trunc(x5) y <- trunc(y) catreg <- data.frame(y,x1,x2,x3,x4,x5) rm(b1,b2,b3,b4,b5,e,a,x1,x2,x3,x4,x5,y) attach(catreg) reg3 <- lm(y~x1+x2+x3+x4+x5) reg4 <- lm(scale(y)~scale(x1)+scale(x2)+scale(x3)+scale(x4)+scale(x5)) summary(reg3) summary(reg4)