if (FALSE) {
data(PErisk)
post <- MCMCmixfactanal(~courts+barb2+prsexp2+prscorr2+gdpw2,
factors=1, data=PErisk,
lambda.constraints = list(courts=list(2,"-")),
burnin=5000, mcmc=1000000, thin=50,
verbose=500, L0=.25, store.lambda=TRUE,
store.scores=TRUE, tune=1.2)
plot(post)
summary(post)
library(MASS)
data(Cars93)
attach(Cars93)
new.cars <- data.frame(Price, MPG.city, MPG.highway,
Cylinders, EngineSize, Horsepower,
RPM, Length, Wheelbase, Width, Weight, Origin)
rownames(new.cars) <- paste(Manufacturer, Model)
detach(Cars93)
# drop obs 57 (Mazda RX 7) b/c it has a rotary engine
new.cars <- new.cars[-57,]
# drop 3 cylinder cars
new.cars <- new.cars[new.cars$Cylinders!=3,]
# drop 5 cylinder cars
new.cars <- new.cars[new.cars$Cylinders!=5,]
new.cars$log.Price <- log(new.cars$Price)
new.cars$log.MPG.city <- log(new.cars$MPG.city)
new.cars$log.MPG.highway <- log(new.cars$MPG.highway)
new.cars$log.EngineSize <- log(new.cars$EngineSize)
new.cars$log.Horsepower <- log(new.cars$Horsepower)
new.cars$Cylinders <- ordered(new.cars$Cylinders)
new.cars$Origin <- ordered(new.cars$Origin)
post <- MCMCmixfactanal(~log.Price+log.MPG.city+
log.MPG.highway+Cylinders+log.EngineSize+
log.Horsepower+RPM+Length+
Wheelbase+Width+Weight+Origin, data=new.cars,
lambda.constraints=list(log.Horsepower=list(2,"+"),
log.Horsepower=c(3,0), weight=list(3,"+")),
factors=2,
burnin=5000, mcmc=500000, thin=100, verbose=500,
L0=.25, tune=3.0)
plot(post)
summary(post)
}
Run the code above in your browser using DataLab