/ Published in: R
Expand |
Embed | Plain Text
# read and expand the data data(g1_part) data <- expData(g1_part, 2, 3) #plotCounts(data$count[data$index == 1]) # get the CV R squared for Poisson linear model ##R_sq <- iterGlmCV(data) # train and predict by Poisson linear model train.data <- data[data$index < 6, ] test.data <- data[data$index >= 6, ] train.glm <- iterGlm(train.data) ##plotCoef(train.glm, 2, 3) pred.pref <- exp(glmPred(train.glm, test.data)) # get predicted counts pred.count <- getPredCount(test.data, pred.pref) ##plotCounts(pred.count[data$index == 1]) # get the R squared glm.dev <- getDev(pred.count, test.data$count) null.count <- getNullCount(test.data) null.dev <- getDev(null.count, test.data$count) R_sq <- 1 - glm.dev / null.dev
You need to login to post a comment.
