Now we move on to the second part of the Exercise 5.2, which requires to implement regularized logistic regression using Newton’s Method. Plot the data:
A little piece of code dealing with the subsampling of matrices, in R. Useful if you want to use something akin to bootstrap, or just check the size of your sample with regard to various statistics.
Inspired from a mail that came along the previous random generation post the following question rised : How to draw random variates from the Von Mises distribution? First of all let’s check the pdf of the probability rule, it is , for . Ok, I admit that Bessels functions can be a bit frightening,...
WelshPerm <- function(response,variable,nperm=999,...){ base <- oneway.test(response~variable,...) base.p <- base$p.value base.W <- base$statistic count <- 1 # Permutation loop for(i in 1:nperm){ SAMPLE <- sample(response) welsh.perm<-oneway.test(SAMPLE~variable,...) welsh.perm.p<-welsh.perm$p.value welsh.perm.W<-welsh.perm$statistic if(abs(welsh.perm.W) >= abs(base.W)) {count <- count+1} } result=count/(nperm+1) return(result) }
The GenEstim function presented here uses a very simple genetic algorithm to estimate parameters. The function returns the best estimated set of parameters ($estim), the AIC ($information) at each generation, and the cost of the best model ($bestcost) at each generation. Results of running the program with a logistic function : Logis = function(x,p)...