Joglekar, Prasad V.
2012-Jan-04 12:36 UTC
[R] Non Negative Least Squares Regression with nnls
Hello R experts, I have two questions related to the nnls library (http://www.inside-r.org/packages/cran/nnls), and more broadly to linear regression with positive coefficients. Sample code is below the Qs. Q1: Regular regression (with lm) gives me the significance of each variable. How do I get variable significance with nnls? If there's no ready function, any easy way to manually derive them? Q2: With regular regression, I can model interactions by doing (a*b). How do I model interactions with nnls? Any workarounds to manually perform interactions if no built-in way? I'm not a statistician; any links to references are highly appreciated as are any relevant workarounds or alternative approaches. Code: library(nnls) #data avgprice <- c(116.0666667,145.1034483,145.75,131.6666667,113.8163265,122.7142857,120.5882353) stars <- c(2.5,2.5,2.5,2.5,3,3,3) lookahead <- c(2,30,60,15,2,30,60) #regular regression reg1 <- lm(avgprice ~ stars + lookahead + stars*lookahead) summary(reg1) #Non-negative s<-cbind(stars,lookahead) reg2<-nnls(s, avgprice) print(reg2) Thanks and Regards, Prasad Joglekar MBA Candidate, Class of 2012 | Tuck School of Business at Dartmouth 1210 Byrne Hall, Hanover NH 03755 http://www.linkedin.com/in/prasadjoglekar [[alternative HTML version deleted]]