I have a dataset on fecal egg counts (FEC) in sheep and would like to test the effect of different treatments. I have 120 farms treated with combination of different drugs. I am using the "eggcount" package that is based on the Bayesian approach to simulate and produce the outputs for each farm and treatment (Drug).
I want to make a loop for two variables; i) Farm and ii) Drug. This means the for loop can generate the output for each farm and drug, similar to the subset function.
setwd("C:/Data")
dat <- read.csv("McMaster_UTC.csv", header=T, sep="'", na.string=NA)
dat$EPG1 <- as.numeric(dat$EPG1)
dat$EPG2 <- as.numeric(dat$EPG2)
# subset for Fram & Drug: if I want to run the data for each Farm and Drug. I assume with a loop I don't #need the subset function.
dat1 <-subset(dat, Farm==1 & Drug=="CLO", select=1:9)
# A model to compare the two groups (unpaired)
model <- fecr_stan(egg.1$EPG1/50, egg.1$EPG2/50, rawCounts=FALSE, paired=FALSE, indEfficacy=FALSE)
#This is the for loop that I have in my mind, but not sure how to fit these in the loop:
out <- vectro()
for(i in 1:ncol(dat)) {
for(j in 1:ncol(dat)) {
....
....
set.seed(1234)
model <- fecr_stan(egg.1$EPG1/50, egg.1$EPG2/50, rawCounts=FALSE, paired=FALSE, indEfficacy=FALSE)
model[i] <- out[i]