### R code from vignette source 'samejima_R.rnw' ### Encoding: UTF-8 ################################################### ### code chunk number 1: Rsettings ################################################### options(digits=2) rm(list=ls(all=T)) options(SweaveHooks=list(fig=function(){par(cex.main=1.1, mar=c(5.1,4.1,2.6,5.1), pty="s", mgp=c(2.25,0.5,0), tck=-0.02)})) #graphics.off() #x11(width=8, height=8) #options(SweaveHooks=list(fig=function() par(mar=c(3,3,1,0.5), mgp=c(2,1,0),bg='red'))) #options(SweaveHooks=list(fig=function() par(mar=c(3.5,3,1,0.5), mgp=c(2,0.8,0)))) options(width=65) ps.options(horizontal=T) badfonts = FALSE .detach.stuff = function() { s1 = grep("package|Autoloads",search()) nattach = length(search()) xattach = search()[c(-1,-s1)] for (i in xattach) eval(substitute(detach(i),list(i=i))) } .detach.stuff() ################################################### ### code chunk number 2: dados ################################################### dados<-read.fwf( 'http://people.ufpr.br/~aanjos/CE095/dados/ordinal.dat', w=c(3,1,rep(1,15)))[,-2] colnames(dados)<-c('id',paste('i',1:15,sep="")) head(dados) ################################################### ### code chunk number 3: semid ################################################### dados<-dados[,-1] # retira 'id' head(dados) ################################################### ### code chunk number 4: desc ################################################### dados.desc<-descript(dados) dados.desc$per ################################################### ### code chunk number 5: descfreq ################################################### dados.desc$per*dim(dados)[1] # frequência ################################################### ### code chunk number 6: fit1 ################################################### fit1<-grm(dados,H=TRUE) # com EP ################################################### ### code chunk number 7: fit1result ################################################### summary(fit1) ################################################### ### code chunk number 8: plotfit1 (eval = FALSE) ################################################### ## plot(fit1) ################################################### ### code chunk number 9: fit2 ################################################### fit2<-grm(dados) # samejima ################################################### ### code chunk number 10: summaryfit2 ################################################### summary(fit2) ################################################### ### code chunk number 11: plotfit2 (eval = FALSE) ################################################### ## plot(fit2) ################################################### ### code chunk number 12: theta (eval = FALSE) ################################################### ## factor.scores(fit2) ################################################### ### code chunk number 13: fig1 ################################################### getOption("SweaveHooks")[["fig"]]() plot(fit2, items=1,lwd=2,cex=1.2,legend=FALSE,cx='left',xlab="Traço latente",cex.main=1.0, cex.lab=1.3,cex.axis=1.1) ################################################### ### code chunk number 14: fig2 ################################################### getOption("SweaveHooks")[["fig"]]() plot(fit2, type="IIC",lwd=2,cex=1.2,legend=FALSE,cx='left',xlab="Traço latente",cex.main=1.0, cex.lab=1.3,cex.axis=1.1) ################################################### ### code chunk number 15: fig3 ################################################### getOption("SweaveHooks")[["fig"]]() plot(fit2, type="IIC",items=0,lwd=2,cex=1.2,legend=FALSE,cx='left',xlab="Traço latente",cex.main=1.0, cex.lab=1.3,cex.axis=1.1) ################################################### ### code chunk number 16: fig4 ################################################### getOption("SweaveHooks")[["fig"]]() plot(fit2, category=1,lwd=2,cex=1.2,legend=TRUE,cx=2,cy=0.85,xlab="Traço latente",cex.main=1.0, cex.lab=1.3,cex.axis=1.1,ylab="Probabilidade") ################################################### ### code chunk number 17: fig5 ################################################### getOption("SweaveHooks")[["fig"]]() par(mfrow=c(2,2)) for(ctg in 1:4){ plot(fit2, category=ctg,lwd=2,cex=.8,legend=TRUE,cx=1.5,cy=0.95,xlab="Traço latente",cex.main=1.0, cex.lab=1.3,cex.axis=1.1,ylab="Probabilidade") } par(mfrow=c(1,1)) ################################################### ### code chunk number 18: dados2 ################################################### dados2<-dados dados2$i9 table(dados2$i9) ################################################### ### code chunk number 19: ifelse ################################################### dados2$i9<-ifelse(dados2$i9==1|dados2$i9==2,1,dados2$i9) dados2$i9<-ifelse(dados2$i9==3,2,dados2$i9) dados2$i9<-ifelse(dados2$i9==4,3,dados2$i9) ################################################### ### code chunk number 20: dados2desc ################################################### dados.desc<-descript(dados2) dados.desc$per$i1*580 # frequência (mudou forma) ################################################### ### code chunk number 21: fit3 ################################################### fit3<-grm(dados2)