anujkhare / iregnet

7 stars 12 forks source link

S3 functions: plot, logLik, coef #43

Closed anujkhare closed 7 years ago

anujkhare commented 7 years ago

@tdhock Is this method like what you had in mind for the tidy matrix output? It returns a single matrix with lambda, n_iters, scale, loglik, arclength, beta columns.

Could you please review?

tdhock commented 7 years ago

Hey @anujkhare the tidymatrix you have proposed sounds reasonable for your plotting purposes, but strictly speaking it is not "tidy" since tidy functions always return data.frame (not matrix). right now you have a column for each variable, right? to make that tidy you would have to convert it to a tall format data.frame, for example

tidy.df <- with(fit, data.frame(
  weight=as.numeric(t(beta)),
  lambda,
  arclength=colSums(abs(beta[-1,])),
  variable=rownames(beta)[as.integer(col(t(beta)))]))
library(ggplot2)
ggplot()+
  geom_point(aes(arclength, weight, color=variable),
             data=tidy.df)
tdhock commented 7 years ago

looks great @anujkhare !