tag 标签: Library经管大学堂:名校名师名课

相关帖子

版块 作者 回复/查看 最后发表
library(xlsx)失败(已解决) R语言论坛 felicitykris 2013-3-19 8 14030 yuzhaoyu 2021-3-31 19:39:54
原文 python for data analysis pdf attachment python论坛 dgg32 2013-8-3 28 19508 AuHunter 2021-2-9 22:54:15
3.0版本R,加载rmmseg4j(library(rmmseg4j))时崩溃 R语言论坛 danglihui0529 2013-4-24 3 2157 gts499 2019-4-21 23:03:39
新手問題請各位大大幫我看一下 Gauss专版 xu.6m4rmp 2013-4-10 2 2787 longwen516317 2018-9-4 10:28:36
关于广义混合检验(GARCH) R语言论坛 chenliya_110 2013-4-19 4 3842 尒lóng☆笣 2014-10-30 11:18:22
Textbook Seeking - "Multivariate Analysis" (Chatfield & Collins) 计量经济学与统计软件 karinadu 2013-1-17 3 3161 kkwei 2013-6-6 08:20:42
reshape data with melt function R语言论坛 bobguy 2013-5-26 1 2797 jgchen1966 2013-6-1 09:47:40
求助:怎样获取一个library中所有dataset的名称 attach_img SAS专版 francisnoten 2013-5-9 4 3323 缘味奶茶 2013-5-10 16:58:57
悬赏 如何merge - [!reward_solved!] attach_img R语言论坛 dxystata 2013-4-27 5 1585 lutian08 2013-4-30 22:29:08
悬赏 求 wiley online library 上一篇文章 - [悬赏 10 个论坛币] 悬赏大厅 gogotulio 2013-4-30 0 636 gogotulio 2013-4-30 20:20:50
SAS求问这种error怎么解决? SAS专版 005 2013-4-9 3 3595 005 2013-4-10 15:42:09
sas显示没有library数据类型的默认操作 SAS专版 shelven 2013-4-8 1 2978 zhengbo8 2013-4-8 12:32:26
悬赏 R程序求助 - [悬赏 2 个论坛币] 悬赏大厅 wkn1986 2013-4-2 5 1589 admonzhang 2013-4-3 17:19:16
标准回归系数 SAS专版 恋风尘 2013-3-9 1 1823 恋风尘 2013-3-9 23:36:37
【国外文献】[5-22]The University of Sydney Library 国内外文献账号区 paxwkj 2009-5-22 10 2613 connorhk 2012-9-25 03:34:57
【国外文献】[6-3]Charles C. Myers Library 国内外文献账号区 zhengxq629 2009-6-3 0 1723 zhengxq629 2009-6-3 01:03:00
【国外文献】[5-23]st marys university library 国内外文献账号区 jh81522 2009-5-23 4 1716 iasccer 2009-5-26 08:43:00
【国外文献】[5-14]old dominion university library 国内外文献账号区 jh81522 2009-5-14 0 2075 jh81522 2009-5-14 08:10:00
【国内文献】[12-25]3个library.macu.edu密码 国内外文献账号区 wangyyong01 2008-12-25 0 1781 wangyyong01 2008-12-25 11:22:00

相关日志

分享 R_quantmod
accumulation 2016-12-5 00:17
library(quantmod) setSymbolLookup(WK=list(name='000002.sz',src='yahoo',from="2007-01-04",to="2015-12-16")) getSymbols('WK') setSymbolLookup(HS300=list(name='000300.ss',src='yahoo',from="2007-01-04",to="2015-12-16")) getSymbols('HS300') sum(is.na(WK)) sum(is.na(HS300)) Merged_data-coredata(merge(WK,HS300)) Stock_Index_data-na.omit(Merged_data) l_r-length(r_WK) WK_close-stock_Index_data HS300_close-Stock_Index_data R_WK-(WK_Close -WK_Close )/WK_Close R_HS300-(HS300_Close -HS300_Close )/HS300_Close r_WK-log(1+R_WK) r_HS300-log(1+R_HS300) par(nfrow-c(2,1)) plot(1:length(r_WK),r_WK,xlab='days',ylab='Log return',ylin-c(-0.1,0.1),type='1',main='Returns of Vanke') plot(1:length(r_HS300),r_HS300,xlab='days',ylab='Log return',type='1',main='Returns of HS300') library(fGarch) xp-r_WK+r_HS300 xm-r_WK-r_HS300 n1-garchFit(-1+garch(1,1),data=xp,trace=F) summary(n1) n2-garchFit(-1+garch(1,1),data=xm,trace=F) summary(n2) n3-garchFit(-1+garch(1,1),data=r_HS300,trace=F) summary(n3) vol_xp-volatility(n1) vol_xm-volatility(n2) vol_HS300-volatility(n3) beta_GARCH-(vol_xp^2-vol_xm^2)/(4*vol_HS300^2) plot(beta_GARCH,xlab='day',ylin=c(-1,3),type='l') alpha_GARCH-r_WK-beta_GARCH*r_HS300 CAPM-ln(r_WK-r_HS300) plot(1:length(alpha_GARCH),alpha_GARCH,xlab='days',ylab='Alpha',main='Alpha by GARCH',type='l',ylin=c(-0.2,0.2)) plot(1:length(alpha_GARCH),beta_GARCH,xlab='days',ylab='Beta',main='Beta by GARCH',type='l',ylin=c(-3,2.5)) L_window-30 alpha_ln-rep(0,(l_r-L_window+1)) beta_ln-rep(0,(l_r-L_window+1)) for(i in 1:(l_r-L_window+1)) { sample_rWK-r_WK sample_rHS300-r_HS300 n4-ln(sample_rWK-sample_rHS300) alpha_ln -coefficients(n4) beta_ln -coefficients(n4) } plot(1:length(alpha_ln),alpha_ln,xlab='days',ylab='Alpha',main='Alpha by linear regression',type='l') plot(1:length(alpha_ln),beta_ln,xlab='days',ylab='Beta',main='Beta by linear regression',type='l') plot(beta_GARCH,ylin=c(-1,3),type='l') lines(beta_ln,type='p') plot(alpha_GARCH,ylin=c(-0.12,0.12),type='l') lines(alpha_ln,type='p')
个人分类: 金融工程|0 个评论
分享 收集一下,不知道有没有用,R的一些包
zelision 2015-10-13 17:03
Rweibo 简介: Rweibo 是一个新浪微博的 R 语言 SDK,作为 library 在 R 环境中调用, 实现了新浪微博提供的接口,可以进行微博信息获取、用户信息获取、 搜索、发表微博等操作。 资源站点: https://r-forge.r-project.org/R/?group_id=1054 安装方式: install.packages("Rweibo", repos = "http://R-Forge.R-project.org") Rwordseg 简介: Rwordseg 是一个 R 环境下的中文分词工具,使用 rJava 调用 Java 分词工具 Ansj。 资源站点: https://r-forge.r-project.org/R/?group_id=1054 安装方式: install.packages("Rwordseg", repos = "http://R-Forge.R-project.org") tmcn 简介: tmcn包是一个进行中文文本挖掘的R包。包含了中文编码处理、文字操作、 文本挖掘模型和算法的一些函数。主要针对目前可用的R资源的不足而开发的。该工程下还提供了tmcn.crfpp(实现了条件随机场)和tmcn.word2vec (实现了Google的word2vec)这两个子包。 资源站点: https://r-forge.r-project.org/R/?group_id=1571 安装方式: install.packages("tmcn", repos = "http://R-Forge.R-project.org") Rofficetool 简介: 一个R环境下 Office 自动化报告的工具包,通过在 PPT 模板的基础上进行修改的方式生成复杂报告。 资源站点: https://github.com/lijian13/Rofficetool 安装方式: library(devtools) install_github("lijian13/Rofficetool") RbaiduLBS 简介: 百度地图 API 服务接口的 R 语言接口。注册百度开发者账号后可以使用该 R 包进行服务接口中提到的相关操作。 资源站点: https://github.com/lijian13/RbaiduLBS 安装方式: library(devtools) install_github("lijian13/RbaiduLBS")
个人分类: R_D_PG|0 个评论
分享 Fortran——Black Scholes Model
accumulation 2015-5-1 14:59
Languages: BLACK_SCHOLES is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version . Related Data and Programs: COLORED_NOISE , a FORTRAN90 library which generates samples of noise obeying a 1/f^alpha power law. GNUPLOT , FORTRAN90 programs which illustrate how a program can write data and command files so that gnuplot can create plots of the program results. ORNSTEIN_UHLENBECK , a FORTRAN90 library which approximates solutions of the Ornstein-Uhlenbeck stochastic differential equation (SDE) using the Euler method and the Euler-Maruyama method. PCE_LEGENDRE , a MATLAB program which assembles the system matrix associated with a polynomal chaos expansion of a 2D stochastic PDE, using Legendre polynomials; PCE_ODE_HERMITE , a FORTRAN90 program which sets up a simple scalar ODE for exponential decay with an uncertain decay rate, using a polynomial chaos expansion in terms of Hermite polynomials. PINK_NOISE , a FORTRAN90 library which computes a "pink noise" signal obeying a 1/f power law. SDE , a FORTRAN90 library which illustrates the properties of stochastic differential equations, and common algorithms for their analysis, by Desmond Higham; STOCHASTIC_DIFFUSION , a FORTRAN90 library which implements several versions of a stochastic diffusivity coefficient. STOCHASTIC_GRADIENT_ND_NOISE , a MATLAB program which solves an optimization problem involving a functional over a system with stochastic noise. STOCHASTIC_RK , a FORTRAN90 library which applies a Runge-Kutta scheme to a stochastic differential equation. Author: Original MATLAB version by Desmond Higham; FORTRAN90 version by John Burkardt. Reference: Desmond Higham, Black-Scholes for Scientific Computing Students, Computing in Science and Engineering, Volume 6, Number 6, November/December 2004, pages 72-79. Source Code: black_scholes.f90 , the source code. black_scholes.sh , BASH commands to compile the source code. Examples and Tests: black_scholes_prb.f90 , a sample calling program. black_scholes_prb.sh , BASH commands to compile and run the sample program. black_scholes_prb_output.txt , the output file. asset_path_data.txt , the graphics data file. asset_path_commands.txt , the graphics data file. asset_path.png , a PNG image of the asset path, created by GNUPLOT. List of Routines: ASSET_PATH simulates the behavior of an asset price over time. BINOMIAL uses the binomial method for a European call. BSF evaluates the Black-Scholes formula for a European call. FORWARD uses the forward difference method to value a European call option. GET_UNIT returns a free FORTRAN unit number. MC uses Monte Carlo valuation on a European call. R8_NORMAL_01 returns a unit pseudonormal R8. R8_UNIFORM_01 returns a unit pseudorandom R8. R8VEC_NORMAL_01 returns a unit pseudonormal R8VEC. R8VEC_PRINT_PART prints "part" of an R8VEC. R8VEC_UNIFORM_01 returns a unit pseudorandom R8VEC. TIMESTAMP prints the current YMDHMS date as a time stamp.
个人分类: 金融工程|0 个评论
分享 Source Codes in Fortran90
accumulation 2015-5-1 13:26
calpak , a library which makes various calendar calculations; cauchy_principal_value , a library which uses Gauss-Legendre quadrature to estimate the Cauchy Principal Value (CPV) of certain singular integrals. cc_io a library which reads and writes sparse linear systems stored in the Compressed Column (CC) format. cc_to_st a library which converts a sparse matrix from compressed column (CC) to sparse triplet (ST) format. ccn_rule , a program which defines a one of a sequence of nested Clenshaw Curtis quadrature rules of any order. ccvt_box , a program which calculates a Centroidal Voronoi Tessellation (CVT) constrained to a box region, with points projected to the boundary; ccvt_reflect , a program which carries out a Centroidal Voronoi Tessellation (CVT) calculation that tries to include points on the boundary as well as the interior, using a natural (nonparametric) technique; cdflib , a library which evaluates the cumulative density function (CDF), inverse CDF, and certain other inverse functions, for distributions including beta, binomial, chi-square, noncentral chi-square, F, noncentral F, gamma, negative binomial, normal, Poisson, and students T, by Barry Brown, James Lovato, Kathy Russell. cell , a library which defines a cell array, a generalization of an array which can compactly store and retrieve vector or matrix data of varying size, such as the rows of a triangular matrix. cellular_automaton , a program which demonstrates the 1D Cellular Automaton known as rule #30. cg , a library which implements a simple version of the conjugate gradient (CG) method for solving a system of linear equations of the form A*x=b, suitable for situations in which the matrix A is positive definite (only real, positive eigenvalues) and symmetric. cg_rc , a library which implements the conjugate gradient method for solving a positive definite sparse linear system A*x=b, using reverse communication. cg_serial , a program which is a serial version of the NAS Parallel Benchmark CG (conjugate gradient solver). change_making , a library which considers the change making problem, in which a given sum is to be formed using coins of various denominations. chebyshev , a library which computes the Chebyshev interpolant/approximant to a given function over an interval. chebyshev_interp_1d , a library which determines the combination of Chebyshev polynomials which interpolates a set of data, so that p(x(i)) = y(i). chebyshev_polynomial , a library which considers the Chebyshev polynomials T(i,x), U(i,x), V(i,x) and W(i,x). Functions are provided to evaluate the polynomials, determine their zeros, produce their polynomial coefficients, produce related quadrature rules, project other functions onto these polynomial bases, and integrate double and triple products of the polynomials. chebyshev_series , a library which can evaluate a Chebyshev series approximating a function f(x), while efficiently computing one, two or three derivatives of the series, which approximate f'(x), f''(x), and f'''(x), by Manfred Zimmer. chebyshev1_rule , a program which computes and writes out a Gauss-Chebyshev type 1 quadrature rule of given order. chebyshev2_rule , a program which computes and writes out a Gauss-Chebyshev type 2 quadrature rule of given order.
个人分类: 裂变模型|0 个评论
分享 Source Codes in Fortran90
accumulation 2015-5-1 13:23
blas2_c , a library which constitutes the Level 2 Basic Linear Algebra Subprograms (BLAS), for matrix-vector operations using single precision complex arithmetic. blas2_d , a library which constitutes the Level 2 Basic Linear Algebra Subprograms (BLAS), for matrix-vector operations using double precision real arithmetic. blas2_s , a library which constitutes the Level 2 Basic Linear Algebra Subprograms (BLAS), for matrix-vector operations using single precision real arithmetic. blas2_z , a library which constitutes the Level 2 Basic Linear Algebra Subprograms (BLAS), for matrix-vector operations using double precision complex arithmetic. blas3_c , a library which constitutes the Level 3 Basic Linear Algebra Subprograms (BLAS), for matrix-matrix operations using single precision complex arithmetic. blas3_d , a library which constitutes the Level 3 Basic Linear Algebra Subprograms (BLAS), for matrix-matrix operations using double precision real arithmetic. blas3_s , a library which constitutes the Level 3 Basic Linear Algebra Subprograms (BLAS), for matrix-matrix operations using single precision real arithmetic. blas3_z , a library which constitutes the Level 3 Basic Linear Algebra Subprograms (BLAS), for matrix-matrix operations using double precision complex arithmetic. blend , a library which carries out 1D/2D/3D blending interpolation; box_behnken , a library which computes a Box-Behnken design, that is, a set of arguments to sample the behavior of a function of multiple parameters; brent , a library which contains routines for finding zeroes or minima of a scalar function of a scalar variable, without the use of derivative information, including a reverse communication option, by Richard Brent. brownian_motion_simulation , a library which simulates Brownian motion in an M-dimensional region, creating graphics files for processing by gnuplot. bt_serial , a program which is a serial version of the NAS Parallel Benchmark BT (block tridiagonal solver for a 3D PDE). burgers_solution , a library which evaluates an exact solution of the time-dependent 1D viscous Burgers equation. bvec , a library which demonstrates how signed integers can be stored as binary vectors, and arithmetic can be performed on them. bvls , a library which applies least squares methods to solve a linear system for which lower and upper constraints may have been placed on every variable, by Charles Lawson and Richard Hanson. c_comment , a program which makes a copy of a file in which C++ style comments have been replaced by C-style comments. c4lib , a library which implements certain elementary functions for single precision complex (C4) variables; c8lib , a library which implements certain elementary functions for double precision complex (C8) variables; calendar_nyt , a library which shows the correspondence between dates and the New York Times volume and issue number;
个人分类: 裂变模型|0 个评论
分享 Source Codes in Fortran90
accumulation 2015-5-1 13:19
asa121 , a library which evaluates the trigamma function, by BE Schneider; this is a version of Applied Statistics Algorithm 121; asa136 , a library which implements a clustering algorithm, by Hartigan and Wong; this is a version of Applied Statistics Algorithm 136; asa144 , a library which randomly generates tables with given row and column sums, by James Boyett; this is a version of Applied Statistics Algorithm 144; asa147 , a library which evaluates the incomplete Gamma function, by Chi Leung Lau; this is a version of Applied Statistics Algorithm 147; asa152 , a library which evaluates the probability density function (PDF) and cumulative density function (CDF) associated with the hypergeometric distribution, by Richard Lund; this is a version of Applied Statistics Algorithm 152; asa159 , a library which computes a random table with given row and column sums, by Michael Patefield; this is a version of Applied Statistics Algorithm 159; asa172 , a library which generates all multidimensional indices in a given range, simulating the behavior of an arbitrary number of nested loops, by OFlaherty and MacKenzie; this is a version of Applied Statistics Algorithm 172; asa183 , a library which implements a random number generator (RNG), by Wichman and Hill; this is a version of Applied Statistics Algorithm 183; asa189 , a library which estimates the parameters of a beta binomial distribution based on a sample of values generated by the distribution, by D Smith; this is a version of Applied Statistics Algorithm 189; asa205 , a library which generates tables with given row and column sums; this is a version of Applied Statistics Algorithm 205; asa226 , a library which evaluates the noncentral incomplete Beta function, by Russell Lenth; this is a version of Applied Statistics Algorithm 226; asa239 , a library which evaluates the incomplete Gamma function, by Shea; this is a version of Applied Statistics Algorithm 239; asa241 , a library which computes the inverse of the normal cumulative density function (CDF), by Michael Wichura; this is a version of Applied Statistics Algorithm 241; asa243 , a library which evaluates the lower tail of the noncentral Student's T distribution, by Russell Lenth; this is a version of Applied Statistics Algorithm 243; asa245 , a library which evaluates the logarithm of the Gamma function, by Allan Mcleod; this is a version of Applied Statistics Algorithm 245; asa266 , a library which evaluates various properties of the Dirichlet probability density function (PDF); this is a version of Applied Statistics Algorithm 266; asa299 , a library which computes the lattice points (integer coordinates) in an M-dimensional simplex, by Chasalow and Brand; this is a version of Applied Statistics Algorithm 299; asa310 , a library which evaluates the noncentral incomplete Beta function, by Chattamvelli and Shanmugam; this is a version of Applied Statistics Algorithm 310; asa314 , a library which computes the inverse of a matrix whose elements are subject to modulo arithmetic, by Roger Payne. This is a version of Applied Statistics Algorithm 314. backtrack_binary_rc , a library which carries out a backtrack search for a set of binary decisions, using reverse communication.
个人分类: 裂变模型|0 个评论
分享 转一个code,有时间测试一下
唐伯小猫 2014-4-26 05:19
library(rpart) #Popular decision tree algorithm library(rattle) #Fancy tree plot, nice graphical interface library(rpart.plot) #Enhanced tree plots library(RColorBrewer) #Color selection for fancy tree plot library(party) #Alternative decision tree algorithm library(partykit) #Convert rpart object to BinaryTree library(RWeka) #Weka decision tree J48 library(evtree) #Evolutionary Algorithm, builds the tree from the bottom up library(randomForest) library(doParallel) library(CHAID) #Chi-squared automatic interaction detection tree library(tree) library(caret) ls(package:party) #list functions in package party #Data Prep data(weather) dsname - “weather” target - “RainTomorrow” risk - “RISK_MM” ds - get(dsname) vars - colnames(ds) (ignore - vars ) vars - setdiff(vars, ignore) (inputs - setdiff(vars, target)) (nobs - nrow(ds)) dim(ds ) (form - formula(paste(target, “~ .”))) set.seed(1426) length(train - sample(nobs, 0.7*nobs)) length(test - setdiff(seq_len(nobs), train)) dim(ds) head(ds) tail(ds) summary(ds) str(ds) #——————————————————————- # Basic Scatterplot Matrix pairs(paste(“~”, paste(vars, collapse=’+'), sep=”),data=ds, main=”Simple Scatterplot Matrix”) pairs(~MinTemp+MaxTemp+Rainfall+Evaporation, data =ds, main=”Simple Scatterplot Matrix”) histogram(ds$MinTemp, breaks=20, col=”blue”) #——————————————————————- #Rpart Tree library(rpart) model - rpart(formula=form, data=ds ) model summary(model) printcp(model) #printcp for rpart objects plotcp(model) plot(model) text(model) fancyRpartPlot(model) prp(model) prp(model, type=2, extra=104, nn=TRUE, fallen.leaves=TRUE, faclen=0, varlen=0, shadow.col=”grey”, branch.lty=3) pred - predict(model, newdata=ds , type=”class”) #na.action = na.pass pred.prob - predict(model, newdata=ds , type=”prob”) #Check for na in the data, remove rows, if there are NA’s, rpart will use surrogate splits. table(is.na(ds)) ds.complete - ds (nobs - nrow(ds.complete)) set.seed(1426) length(train.complete - sample(nobs, 0.7*nobs)) length(test.complete - setdiff(seq_len(nobs), train.complete)) #Prune tree model$cptable ),”CP”] #want the first minimum model - rpart(formula=form, data=ds , cp=0) printcp(model) prune - prune(model, cp=.01) printcp(prune) #——————————————————————- #Party Tree install.packages(“partykit”, repos=”http://R-Forge.R-project.org”) library(partykit) class(model) plot(as.party(model)) #——————————————————————- #tree model - tree(formula=form, data=ds ) summary(model) #——————————————————————- #Conditional Inference Tree model - ctree(formula=form, data=ds ) model plot(model) pred - predict(model, newdata=ds ) pred.prob - predict(model, newdata=ds , type=”prob”) #Try this for class predictions: library(caret) confusionMatrix(pred, ds ) mc - table(pred, ds ) err - 1.0 – (mc + mc ) / sum(mc) #resubstitution error rate #For class probabilities: probs - treeresponse(model, newdata=test) pred - do.call(rbind, as.list(pred)) summary(pred) #For a roc curve: library(ROCR) roc - prediction(pred , ds ) #noquote(paste(“test$”, target, sep=”)) plot(performance(roc, measure=”tpr”, x.measure=”fpr”), colorize=TRUE) #For a lift curve: plot(performance(roc, measure=”lift”, x.measure=”rpp”), colorize=TRUE) #Sensitivity/specificity curve and precision/recall curve: #sensitivity(i.e True Positives/Actual Positives) and specifcity(i.e True Negatives/Actual Negatives) plot(performance(roc, measure=”sens”, x.measure=”spec”), colorize=TRUE) plot(performance(roc, measure=”prec”, x.measure=”rec”), colorize=TRUE) #Here’s an example of using 10-fold cross-validation to evaluation your model library(doParallel) registerDoParallel(cores=2) model - train(ds , ds , method=’rpart’, tuneLength=10) #cross validation #example n - nrow(ds) #nobs K - 10 #for 10 validation cross sections taille - n%/%K set.seed(5) alea - runif(n) rang - rank(alea) bloc - (rang-1)%/%taille +1 bloc - as.factor(bloc) print(summary(bloc)) all.err - numeric(0) for(k in 1:K){ model - rpart(formula=form, data = ds , method=”class”) pred - predict(model, newdata=ds , type=”class”) mc - table(ds ,pred) err - 1.0 – (mc +mc ) / sum(mc) all.err - rbind(all.err,err) } print(all.err) (err.cv - mean(all.err)) #——————————————————————- #Weka Decision Tree model - J48(formula=form, data=ds ) model predict - predict(model, newdata=ds ) predict.prob - predict(model, newdata=ds , type=”prob”) #——————————————————————- #Evolutionary Trees target - “RainTomorrow” model - evtree(formula=form, data=ds ) model plot(model) predict - predict(model, newdata=ds ) predict.prob - predict(model, newdata=ds , type=”prob”) #——————————————————————- #Random Forest from library(randomForest) table(is.na(ds)) table(is.na(ds.complete)) setnum - colnames(ds.complete) #subset(ds, select=-c(Humidity3pm, Humidity9am, Cloud9am, Cloud3pm)) ds.complete - lapply(ds.complete , function(x) as.numeric(x)) ds.complete$Humidity3pm - as.numeric(ds.complete$Humidity3pm) ds.complete$Humidity9am - as.numeric(ds.complete$Humidity9am) begTime - Sys.time() set.seed(1426) model - randomForest(formula=form, data=ds.complete ) runTime - Sys.time()-begTime runTime #Time difference of 0.3833725 secs begTime - Sys.time() set.seed(1426) model - randomForest(formula=form, data=ds.complete , ntree=500, replace = FALSE, sampsize = .632*.7*nrow(ds), na.action=na.omit) runTime - Sys.time()-begTime runTime #Time difference of 0.2392061 secs model str(model) pred - predict(model, newdata=ds.complete ) #Random Forest in parallel library(doParallel) ntree = 500 numCore = 4 rep - 125 # tree / numCore registerDoParallel(cores=numCore) begTime - Sys.time() set.seed(1426) rf - foreach(ntree=rep(rep, numCore), .combine=combine, .packages=’randomForest’) %dopar% randomForest(formula=form, data=ds.complete , ntree=ntree, mtry=6, importance=TRUE, na.action=na.roughfix, #can also use na.action = na.omit replace=FALSE) runTime - Sys.time()-begTime runTime #Time difference of 0.1990662 secs importance(model) importance(rf) pred - predict(rf, newdata=ds.complete ) confusionMatrix(pred, ds.complete ) #Random Forest from library(party) model - cforest(formula=form, data=ds.complete ) #Factor Levels id - which(!(ds$var.name %in% levels(ds$var.name))) ds$var.name - NA #——————————————————————- #Regression Trees – changing target and vars target - “RISK_MM” vars - c(inputs, target) form - formula(paste(target, “~ .”)) (model - rpart(formula=form, data=ds )) plot(model) text(model) prp(model, type=2, extra=101, nn=TRUE, fallen.leaves=TRUE, faclen=0, varlen=0, shadow.col=”grey”, branch.lty=3) rsq.rpart(model) library(Metrics) pred - predict(model, newdata=ds ) err - rmsle(ds , pred) #compare probabilities not class #——————————————————————- #Chaid Tree – new data set data(“BreastCancer”, package = “mlbench”) sapply(BreastCancer, function(x) is.factor(x)) b_chaid - chaid(Class ~ Cl.thickness + Cell.size + Cell.shape + + Marg.adhesion + Epith.c.size + Bare.nuclei + + Bl.cromatin + Normal.nucleoli + Mitoses, data = BreastCancer) plot(b_chaid) #——————————————————————- #List functions from a package ls(package:rpart) #save plots as pdf pdf(“plot.pdf”) fancyRpartPlot(model) dev.off()
0 个评论
分享 Customized Format 三种格式 Value的要求
yukai08008 2013-3-16 23:08
libname library 'F:\Library'; /*引用库(库必须存在,否则需要建立),创建库语句:*/proc format lib=library; value one /* 数字范围型 */ low-0='not so good' 0-1.2='normal' 1.2-1.5='good' 1.5-high='excellence' ;run; proc format lib=library; /* 一一对应型 ,如果名字取数字尾,则数字会变成格式的一部分,限制字符串长度*/ value two 257='not so good' 259='normal' 237='good' 232='excellence' ;run;proc import dmbs=excel datafile='F:\raw material\_3 of 70.xls' out=third;run;proc print data=third;run; proc format lib=library; /* 字母排序型 */ value $three 'a'-'c'='low' 'd'-'f'='medium' 'g'-'i'='high' 'j'='excellence' ;run;data new; set resdat.yrret;format yrret one.; /*format+变量+格式 ,可以在数据部或过程部声明*/format yrtrds two.;run;proc print data=third;format product $three.;run;/*proc print data=new(obs=15); run; VALUE format-name range1 =' label1 ' range2 =' label2 ' ... ; where format-name must begin with a dollar sign ($) if the format applies to character data cannot be longer than eight characters cannot be the name of an existing SAS format cannot end with a number does not end in a period when specified in a VALUE statement.
个人分类: 学习笔记|0 个评论

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-25 05:33