# GLM # priklad motak zere tetreva rm(list=ls()) load("motak.RData") # budeme modelovat pomoci Gamma distribuce, ocistime od nulovych hodnot cisty <- motak[motak$pomer.zkonzumovanych!=0,] attach(cisty) #Vykresleni dat plot(tetrev.pocty,pomer.zkonzumovanych,pch=20,xlab="pocty tetreva",ylab="pomer zkonzumovanych tetrevu",main="Konzumace tetreva motakem") # definice GLM modelu glmmod <- glm(pomer.zkonzumovanych~tetrev.pocty,data=cisty,family=Gamma(link="inverse")) summary(glmmod) # vykresleni regresni krivky t <- seq(from=min(tetrev.pocty),to=max(tetrev.pocty),length.out=100) lines(t,predict.glm(glmmod,data.frame(tetrev.pocty=t),type="response"),col="red") # overeni normality residui plot(glmmod,which=2) shapiro.test(residuals(glmmod)) detach(cisty) # -----------------------------------------------------