jmanitz / kangar00

development of kangar00
https://cran.r-project.org/package=kangar00
2 stars 0 forks source link

Kernel doesn't always have to be PSD #15

Closed hofnerb closed 8 years ago

hofnerb commented 8 years ago

The validity check of the kernel breaks our code when we try to predict the outcome for new data:

>     pr <- predict(mod, newdata = newdata)
Error in eigen(object@kernel, only.values = TRUE, symmetric = TRUE) : 
  non-square matrix in 'eigen'
> traceback()
24: stop("non-square matrix in 'eigen'")
23: eigen(object@kernel, only.values = TRUE, symmetric = TRUE)
22: validityMethod(object)
21: anyStrings(validityMethod(object))
20: validObject(.Object)
19: initialize(value, ...)
18: initialize(value, ...)
17: new("kernel", ...)
16: kernel(type = "network", kernel = K, pathway = pathway)
15: .local(GWASdata, ...)
14: net_kernel(GWASdata = GWASdata, pathway = pathway, parallel = parallel, 
        ...)
13: net_kernel(GWASdata = GWASdata, pathway = pathway, parallel = parallel, 
        ...)
12: .local(GWASdata, ...)
11: calc_kernel(type = args$kernel, GWASdata = mf, pathway = args$pathway, 
        knots = args$knots)
10: calc_kernel(type = args$kernel, GWASdata = mf, pathway = args$pathway, 
        knots = args$knots)
9: Xfun(mf, vary, args)
8: newX(newdata, prediction = TRUE)
7: bl[[w]]$predict(ens[ix], newdata = newdata, aggregate = agg)
6: FUN(X[[i]], ...)
5: lapply(which, pfun, agg = "sum")
4: do.call("cbind", lapply(which, pfun, agg = "sum"))
3: object$predict(newdata = newdata, which = which, aggregate = aggregate)
2: predict.mboost(mod, newdata = newdata)
1: predict(mod, newdata = newdata)

Is it possible to

a) remove this check

or

b) make it somehow optional (though I do not know how to trigger it)?

hofnerb commented 8 years ago

Perhaps we can use a different constructor if knots where specified (and differ from the data)? I think that is the way to go as all other validity checks fail as well...

jmanitz commented 8 years ago

exception to kernel constructor added, which skips validity checks if knot is specified in further arguments. However, I couldn't test it yet...

jmanitz commented 8 years ago

new object lowrank_kernel fixed the problem? @hofnerb: please test this...

hofnerb commented 8 years ago

@jmanitz: The lowrank_kernel is currently only implemented for linear and network kernels, not for SIA. Is this by purpose?

jmanitz commented 8 years ago

Yes and no, since I do have an overview on the implementation of sia I left a command in the r code for steffi to add this also for sia. The implementation was meant to be reviewed and improved since a while...