Skip to content
Prev 294061 / 398502 Next

Automating R for Hypothesis Testing

Hello,

Yes, it does help. Now we can see your data and what you're doing.
What follows is a suggestion on what you could do, not full solution.
(You forgot to say what X1 is, but I don't think it's important to
understand the suggestion.)
(If I'm wrong, say something.)


milwaukeephos <- read.csv("milwaukeephos.csv", header=TRUE,
stringsAsFactors=FALSE)
# list of data.frames, one per month
ls1 <- split(milwaukeephos, milwaukeephos$month)

#--------- if you want to keep the models, not needed if you don't.
#          (yoy probably don't)
modelH <- vector("list", 12)
modelHa <- vector("list", 12)
modelH2 <- vector("list", 12)
modelH2a <- vector("list", 12)
#--------- values to record, these are needed, create them beforehand.
chi_fm <- numeric(12)
chi_fms <- numeric(12)
#
seq_months <- c(1:12, 1) # wrap months around.
for(i in 1:12){
	month_this <- seq_months[i]
	month_next <- seq_months[i + 1]

	lload <- c(ls1[[month_this]]$load_kg, ls1[[month_next]]$load_kg)
	lflow <- c(ls1[[month_this]]$flow, ls1[[month_next]]$flow)
	modelH[[i]] <- lm(lload ~ lflow)
	# If you don't want to keep the models, use modelH only
	# ( without [[i]] )
	# and do the same with X1

	# rest of your code for first test goes here
	chi_fm[i] <- bfm %*% var_fm %*% (bunres_fm - bres_fm)

	# and the same for the second test
	chi_fms[i] <- ...etc...
}


Hope this helps,

Rui Barradas


meredith wrote
--
View this message in context: http://r.789695.n4.nabble.com/Automating-R-for-Hypothesis-Testing-tp4618653p4620696.html
Sent from the R help mailing list archive at Nabble.com.