1. If we use all k categories, the A matrix would be of less than full rank, and A'A would be singular. 2. # 7 dummies; 2 squared terms; 7x2 interaction terms 2 + 7*2 3. The glm() function will be run 3 times in either case, but AvA will work on smaller datasets. 4. getTrainAcc <- function(qeObj,xdata,ydata) { xdata <- xdata[-(qeObj$holdIdxs),] ydata <- ydata[-(qeObj$holdIdxs)] preds <- predict(qeObj,xdata) if (!qeObj$classif) { return(mean(abs(ydata - preds))) } return(mean(preds$predClasses != ydata)) } set.seed(9999) data(mlb) data <- mlb[,c(3:6)] z <- qePolyLog(data,'Position',deg=4) print(z$testAcc) # 0.68 print(getTrainAcc(z, data[,-1], data[,1])) # 0.61 5. lass <- function(xdata,ydata,b,lam) { xdata <- as.matrix(xdata) b <- matrix(b,ncol=1) A <- cbind(1,xdata) D <- ydata tmp <- D - A %*% b t(tmp) %*% tmp + lam * sum(abs(b)) } data(mlb) mlb <- mlb[,4:6] # Height, Weight and Age only, e.g. no Position lass(mlb[,-2],mlb[,2],c(-100,5.0,1.1),1.5) # 10184259