From: Luis Orlindo Tedeschi <luis.tedeschi_at_hotmail.com>

Date: Mon, 09 Jun 2008 14:43:03 -0500

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 09 Jun 2008 - 19:48:27 GMT

Date: Mon, 09 Jun 2008 14:43:03 -0500

Questions are:

(3) is the cv.glm sampling using replacement = TRUE or not?

glm0.dmi<-glm(DMI_kg~Sex+DOF+Avg_Nem+In_Wt)

# Simulation for 50 re-samplings...

perr1.vect<-vector()

for (j in 1:50)

{

print(j)

cv.dmi<-cv.glm(data.dmi, glm0.dmi, K = 10)
perr1<-cv.dmi$delta[2]

perr1.vect<-c(perr1.vect,perr1)

}

x11()

hist(perr1.vect)

mean(perr1.vect)

sd(perr1.vect)

- homemade method

# Brute-force cross-validation. This should be similar to the cv.glm
perr2.vect <- vector()

for(j in 1:50)

{

print(j)

select.dmi <- sample(1:nrow(data.dmi), 0.9*nrow(data.dmi))
train.dmi <- data.dmi[select.dmi,] #Selecting 90% of the data for
training purpose

test.dmi <- data.dmi[-select.dmi,] #Selecting 10% (remaining) of the data for testing purpose

glm1.dmi <- glm(DMI_kg~Sex+DOF+Avg_Nem+In_Wt, na.action=na.omit, data = train.dmi)

#Create fitted values using test.dmi data
dmi_pred <- predict.glm(glm1.dmi, test.dmi)
dmi_obs<-test.dmi[,"DMI_kg"]

# Get the prediction error = MSE

perr2 <- t(dmi_obs - dmi_pred)%*%(dmi_obs - dmi_pred)/nrow(test.dmi)
perr2.vect <- c(perr2.vect, perr2)

}

x11()

hist(perr2.vect)

mean(perr2.vect)

sd(perr2.vect)

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 09 Jun 2008 - 19:48:27 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 10 Jun 2008 - 12:30:38 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*