Code Monkey home page Code Monkey logo

r-program's People

Contributors

freshjx avatar

r-program's Issues

relweights

#计算模型中各个预测变量的权重,但只支持一元一维的线性回归模型
relweights <- function(fit,...){
R <- cor(fit$model)
nvar <- ncol(R)
rxx <- R[2:nvar,2:nvar]
rxy <- R[2:nvar,1]
svd <- eigen(rxx)#Computes eigenvalues and eigenvectors of numeric (double, integer, logical) or complex matrices.
evec <- svd$vectors
ev <- svd$values
delta <- diag(sqrt(ev))#Extract or replace the diagonal of a matrix, or construct a diagonal matrix.
lambda <- evec %% delta %% t(evec)
lambdasq <- lambda^2
beta <- solve(lambda) %% rxy
rsquare <- colSums(beta^2)
rawwgt <- lambdasq %
% beta^2
import <- (rawwgt / rsquare) * 100
import <- as.data.frame(import)
row.names(import) <- names(fit$model[2:nvar])
names(import) <- 'Weights'
import <- import[order(import),1,drop=FALSE]
dotchart(import$Weights, labels = row.names(import),
xlab = '% of R-Square', pch = 19,
main = 'Relative Importance of Predictor Variabels',
sub = paste('Total R-Square=',round(rsquare,digits = 3)),
...)
return(import)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.