# NOT RUN {
fit <- mixreg(plntsInf ~ aphRel, ncomp=2, data=aphids)
sim1 <- rmixreg(fit)
with(sim1,plot(aphRel,plntsInf,,main="Parametric simulation"))
sim2 <- rmixreg(fit,semiPar=TRUE)
with(sim2,plot(aphRel,plntsInf,,main="Semiparametric simulation"))
x <- cbind(1:50,rnorm(50))
pmat <- matrix(c(3,5,0.01,1600,0.7,1,2,-0.01,100,0.3),nrow=2,byrow=TRUE)
sim3 <- rmixreg(x,theta=pmat,seed=42)
with(sim3,plot(X1,y,main="Using rmixreg.default; predictor 1"))
with(sim3,plot(X2,y,main="Using rmixreg.default; predictor 2"))
pmat <- matrix(c(10,2,0.7,3,1,0.3),nrow=2,byrow=TRUE)
sim4 <- rmixreg(x=rep(1,50),theta=pmat,seed=17)
sim5 <- rmixreg(x=NULL,nobs=50,theta=pmat,seed=17) # Same as sim4 but
# with no columns of 1s.
chk4 <- mixreg(y~1,data=sim4,ncomp=2,seed=116)
chk5 <- mixreg(y~1,data=sim5,ncomp=2,seed=116) # Same-same.
# }
Run the code above in your browser using DataLab