# NOT RUN {
library(MASS)
## lm
## unrestricted linear model for ages (in months) at which an
## infant starts to walk alone.
# prepare data
DATA <- subset(ZelazoKolb1972, Group != "Control")
# fit unrestrikted linear model
fit1.lm <- lm(Age ~ Group, data = DATA)
# some artificial restrictions
fit1.con <- restriktor(fit1.lm, constraints = "GroupPassive > 0; GroupPassive < GroupNo")
fit2.con <- restriktor(fit1.lm, constraints = "GroupPassive > 0; GroupPassive > GroupNo")
fit3.con <- restriktor(fit1.lm, constraints = "GroupPassive == 0; GroupPassive < GroupNo")
fit4.con <- restriktor(fit1.lm) # unrestricted model
goric(fit1.con, fit2.con, fit3.con, fit4.con)
# fit1.con verus the complement
goric(fit1.con, complement = TRUE)
## mlm
# generate data
n <- 30
mu <- c(1,2,3,4)
Sigma <- matrix(5,4,4)
diag(Sigma) <- c(10,10,10,10)
# 4 Y's.
Y <- mvrnorm(n, mu, Sigma)
# fit unrestricted multivariate linear model
fit2.mlm <- lm(Y ~ 1)
# constraints
myConstraints2 <- rbind(c(-1,1,0,0), c(0,-1,1,0), c(0,0,-1,1))
# fit restricted multivariate linear model
fit5.con <- restriktor(fit2.mlm, constraints = myConstraints2)
# fit5.con verus the complement
goric(fit5.con, complement = TRUE)
# }
Run the code above in your browser using DataLab