资源描述:
《《抽样调查实验》word版》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、实验(实训)报告项目名称R语言初步所属课程名称抽样调查项目类型综合性实验实验(实训)日期2013年4月1日班级学号姓名指导教师浙江财经学院教务处制实验名称:R语言初步实验目的:熟悉R语言实验要求:会以下操作:61.安装R并导入程序包2.查询函数帮助3.数据读取和t检验4.方差分析和箱线图绘制5.下标和条件筛选6.了解工作路径7.R脚本运行8.绘图练习9.编写函数作业:画出三大抽样分布分布、t分布、F分布的概率密度函数,并比较参数不同时,概率密度函数的不同形态。作业说明:作业用word编辑,以唯一附件的方式
2、上传。作业中要包含程序及图形。6实验过程:1.分布概率密度函数(p.d.f.):程序>x<-c(0,10)>y<-c(0,0.8)>par(lwd=2)>plot(function(x)dchisq(x,1),xlim=x,ylim=y,col=hsv(0),xlab="n",ylab="densityoft(n)",lty=2,main="theChisqDensityDistribution")>plot(function(x)dchisq(x,1),xlim=x,ylim=y,col=”red”,a
3、dd=TRUE)>plot(function(x)dchisq(x,2),xlim=x,ylim=y,yaxs="i",col=”green”,add=TRUE)>plot(function(x)dchisq(x,3),xlim=x,ylim=y,col=”blue”,add=TRUE)>plot(function(x)dchisq(x,5),xlim=x,ylim=y,col=”orange”,add=TRUE)legend("topright",legend=paste("df=",c(1,2,3,5
4、)),lwd=3,+col=c("red",”green”,"blue",”orange”),bty="n")>p.d.f.图像62.t分布概率密度函数(p.d.f.):程序>x<-c(-4,4)>y<-c(0,0.4)>par(lwd=2)>plot(function(x)dnorm(x,0,1),xlim=x,ylim=y,col=hsv(0),xlab="n",ylab="densityoft(n)",lty=2,main="Centralt-Density")>plot(function(x)dt
5、(x,df=20),xlim=x,ylim=y,col=hsv(0.2),add=TRUE)>plot(function(x)dt(x,df=10),xlim=x,ylim=y,yaxs="i",col=hsv(0.4),add=TRUE)>plot(function(x)dt(x,df=5),xlim=x,ylim=y,col=hsv(0.6),add=TRUE)>plot(function(x)dt(x,df=2),xlim=x,ylim=y,col=hsv(0.8),add=TRUE)>legend
6、("topright",c("N(0,1)","t(20)","t(10)","t(5)","t(2)"),col=hsv(seq(0,1,0.2)),bty="n",cex=1.2,pch=15)>abline(v=0)p.d.f.图像63.F分布概率密度函数(p.d.f.):程序>x<-c(0,2)>y<-c(0,0.8)>par(lwd=2)>plot(function(x)df(x,1,1),xlim=x,ylim=y,col=hsv(0),xlab="n",ylab="densityoft(n)
7、",lty=2,main="TheFDensityDistribution")>plot(function(x)df(x,3,1),xlim=x,ylim=y,col=”green”,add=TRUE)>plot(function(x)df(x,6,1),xlim=x,ylim=y,yaxs="i",col=”blue”,add=TRUE)>plot(function(x)df(x,3,3),xlim=x,ylim=y,col=”orange”,add=TRUE)>plot(function(x)df(x
8、,3,6),xlim=x,ylim=y,col=”pink”,add=TRUE)>legend("topright",c((1,1),(3,1),(6,1),(3,3),(3,6)),lwd=3,legend("topright",legend=paste("df1=",c(1,1),"df2=",c(3,1),"df3=",c(6,1),"df4=",c(3,3),"df5=",c(3,6),),lwd=3,col=c("r