您的位置:首页 > 其它

R 语言学习笔记(三)

2016-10-12 18:43 183 查看
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)#均匀分布


median(x1)
[1] 99
quantile(x1)
0%  25%  50%  75% 100%
86   95   99  105  115
fivenum:中位数,上四分位数,下四分位数,最大值,最小值
cor:相关系数
cos:协方差


一元线性回归分析

lm: linear model
a=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 ' ' 1

Residual standard error: 0.9584 on 18 degrees of freedom
Multiple R-squared(拟合的越好越接近于1):  0.9759,    Adjusted R-squared:  0.9745
F-statistic: 728.5 on 1 and 18 DF,  p-value: 5.164e-16

predict(model,data)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  r语言