In R, how do I find the optimal variable to maximize or minimize correlation between several datasets
问题 I am able to do this easily in Excel, but my dataset has gotten too large. In excel, I would use solver. Column A,B,C,D = random numbers Column E = random number (which I want to maximize the correlation to) Column F = A*x+B*y+C*z+D*j where x,y,z,j are coefficients resulted from solver In a separate cell, I would have correl(E,F) In solver, I would set the objective of correl(C,D) to max, by changing variables x,y and setting certain constraints: 1. A,B,C,D have to be between 0 and 1 2. A+B+C