Anda di halaman 1dari 11

BERAT BADAN

Objek Perlakuan Minggu 1 Minggu 2 Minggu 3 Minggu 4


1 1 120 300 395 390
2 1 120 290 350 360
3 1 120 320 465 480
4 1 140 340 440 410
5 1 120 330 445 460
6 1 110 320 440 410
7 2 135 290 420 470
8 2 105 290 390 470
9 2 130 340 430 430
10 2 115 305 430 450
11 2 100 220 310 470
12 2 110 300 395 420
13 3 95 290 405 540
14 3 130 340 435 540
15 3 110 290 370 440
16 3 115 340 430 410
17 3 115 280 375 480
18 3 140 330 395 540

Input data :

Menggunakan syntax sbb

Diperoleh bentuk umum data longitudinal


Menggunakan syntax sbb

Diperoleh Profile plot BB Ayam Buras selama waktu penelitian dan lowess plot setiap kelompok
perlakuan obat

ESTIMASI MODEL
NAIVE MODEL
Menggunakan syntax pemodelan sbb:

Diperoleh Estimasi Naive Model Tanpa Interaksi


Diperoleh Estimasi Naive Model dengan Interaksi






MODEL DENGAN KORELASI EXPONENTIAL

Diperoleh Estimasi Dengan Korelasi Exponential tanpa interaksi


Estimasi Dengan Korelasi Exponential dengan interaksi


MODEL DENGAN KORELASI UNIFORM

Diperoleh Estimasi Dengan Korelasi Uniform tanpa interaksi


Diperoleh Estimasi Dengan Korelasi Uniform dg interaksi




KESIMPULAN:
Dari model naive tanpa dan dengan interaksi, model korelasi exponential tanpa dan dengan interaksi,
model korelasi uniform tanpa dan dengan interaksi, diperoleh model dnegan AIC terkecil pada Estimasi
Dengan Korelasi Uniform dg interaksi. Artinya, model dengan interaksi antara perlakuan obat
dengan lama mingguan pengamatan dan dengan korelasi antar pengamatan uniform adalah yang
terbaik
Scatter Plot Matrix BB Ayam Buras untuk pasangan 4 Minggu pengamatan dan nilai korelasinya (GAK
USAH PO KA??, ANEH SOALNYA KECIL BANGET KORELASINYA)
Dg syntax

Diperoleh:


Syntax R:
ayam<-matrix(scan(),byrow=T,ncol=6)
1 1 120 300 395 390
2 1 120 290 350 360
3 1 120 320 465 480
4 1 140 340 440 410
5 1 120 330 445 460
6 1 110 320 440 410
7 2 135 290 420 470
8 2 105 290 390 470
9 2 130 340 430 430
10 2 115 305 430 450
11 2 100 220 310 470
12 2 110 300 395 420
13 3 95 290 405 540
14 3 130 340 435 540
15 3 110 290 370 440
16 3 115 340 430 410
17 3 115 280 375 480
18 3 140 330 395 540

ayam<-data.frame(ayam)
names(ayam)<-c("id","grup","m1","m2","m3","m4")
ayam$grup<-factor(ayam$grup,levels=1:3,labels=c("A","B","C"))

ayam.ldat<-
reshape(ayam,direction="long",idvar="id",varying=list(paste("m",1:4,sep="")),v.names="bb")
ayam.ldat<-ayam.ldat[order(ayam.ldat$id),]

#Gambar di tayangan
matplot(1:4,t(as.matrix(ayam[,3:6])),type="l",col="grey",lty=1,ylab="bb",xlab="minggu")
lines(lowess(ayam.ldat$time[ayam.ldat$grup%in%"A"],ayam.ldat$bb[ayam.ldat$grup%in%"A"]),lwd=2,
col=2)
text(x=8.2,y=87.05348,"A")
lines(lowess(ayam.ldat$time[ayam.ldat$grup%in%"B"],ayam.ldat$bb[ayam.ldat$grup%in%"B"]),lwd=2,
col=3)
text(x=8.2,y=67.16448,"B")
lines(lowess(ayam.ldat$time[ayam.ldat$grup%in%"C"],ayam.ldat$bb[ayam.ldat$grup%in%"C"]),lwd=2,
col=4)
text(x=8.2,y=47.00303,"C")

## Pemodelan
library(nlme)
library(gee)
naive1<-lm(bb~grup+time,data=ayam.ldat)
naive2<-lm(bb~grup*time,data=ayam.ldat)
summary(naive1)
summary(naive2)
AIC(naive1)
AIC(naive2)

#Gak perlu
m.lme<-lme(bb~grup*time,data=ayam.ldat,random=~1|id)
m.gee<-gee(formula = bb ~ grup + time, id = id, data = ayam.ldat)
m1.gee<-gee(formula = bb ~ grup + time, id = id, data = ayam.ldat,corstr="exchangeable")

#Hasil Estimasi korelasi Exponential
exp.gls<-gls(bb~grup+time,data=ayam.ldat,correlation=corAR1(form = ~ 1 |id))
exp.gls1<-gls(bb~grup*time,data=ayam.ldat,correlation=corAR1(form = ~ 1 |id))
summary(exp.gls)
AIC(exp.gls)
summary(exp.gls1)
AIC(exp.gls1)

#Hasil Estimasi korelasi Uniform
u.gls<-gls(bb~grup+time,data=ayam.ldat,correlation=corCompSymm(form = ~ 1 |id))
u.gls1<-gls(bb~grup*time,data=ayam.ldat,correlation=corCompSymm(form = ~ 1 |id))
summary(u.gls)
AIC(u.gls)
summary(u.gls1)
AIC(u.gls1)

#Tambahan: deskripsi korelasi
pairs(as.formula(paste("~",paste("m",1:4,sep="",collapse="+"),sep="")),data=ayam,pch=19,col="blue")

panel.cor <- function(x, y, digits=2, prefix="", cex.cor)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits=digits,decimal.mark=",")[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex * r)
}

panel.smooth<-function (x, y, col = "blue", bg = NA, pch = 19,
cex = 1, col.smooth = "red", span = 2/3, iter = 3, ...)
{
points(x, y, pch = pch, col = col, bg = bg, cex = cex)
ok <- is.finite(x) & is.finite(y)
if (any(ok))
lines(stats::lowess(x[ok], y[ok], f = span, iter = iter),
col = col.smooth, lwd=2,...)
}


pairs(as.formula(paste("~",paste("m",1:4,sep="",collapse="+"),sep="")),
lower.panel=panel.smooth,upper.panel=panel.cor,
data=ayam)

Anda mungkin juga menyukai