R 语言学习笔记(三)

来源:互联网 发布:安卓编程软件开发 编辑:程序博客网 时间:2024/04/29 19:22
  1. R语言中各种分布

    rnorm(n,mean=0,sd=1)rexp(n,rate=1)rgamma(n,shape,scale=1)rpois(n,lambda)rweibull(n,shape,scale=1)#weibull分布rcauchy(n,location=0,scale=1)#Cauchy分布rbeta(n,shape1,shape2)#beta分布rt(n,df)#t分布rf(n,df1,df2)#F分布rchisq(n,df)#卡方分布rbinom(n,size,prob)#二项分布rgeom(n,prob)#几何分布rhyper(nn,m,n,k)#超几何分布rlogis(n,location=0,scale=1)#logistic分布rlnorm(n,meanlog=0,sdlog=1)#对数正态rnbinom(n,size,prob)#负二项分布runif(n,min,max)#均匀分布
  2. median(x1)[1] 99quantile(x1)0%  25%  50%  75% 100% 86   95   99  105  115 fivenum:中位数,上四分位数,下四分位数,最大值,最小值cor:相关系数cos:协方差
  3. 一元线性回归分析

    lm: linear modela=lm(w~1+h)summary(a)Call:lm(formula = y ~ x)Residuals:(对残差的描述)     Min       1Q   Median       3Q      Max -1.81085 -0.66032  0.01576  0.67239  1.60354 Coefficients:            Estimate Std. Error t value Pr(>|t|)    (Intercept)(截距) -0.25072    0.44522  -0.563     0.58    x            1.00317    0.03717  26.991 5.16e-16 ***(P值,越小代表预测越准确,***代表预测结果好)---Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1Residual standard error: 0.9584 on 18 degrees of freedomMultiple R-squared(拟合的越好越接近于1):  0.9759,    Adjusted R-squared:  0.9745 F-statistic: 728.5 on 1 and 18 DF,  p-value: 5.164e-16predict(model,data)
0 0
原创粉丝点击