下载此文档

R软件基础介绍.doc


文档分类:IT计算机 | 页数:约34页 举报非法文档有奖
1/34
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/34 下载此文档
文档列表 文档介绍
R 软件与线性回归分析分析步骤. 数据集建立. 图形制作. 回归分析. 模型检验与预测. 模型诊断一、数据集建立与梗概 >library(AER) > data(Journals) >journal=( ‘d:/,head=T) (1)names(journal) (2)str(journal) (3)head(journal) (4)tail(journal) (5)summary(journals) 二、图形制作 函数 plot(x, y,...) 说明:x表示横轴变量,y表示纵轴变量;data 指定分析变量所在的数据框,如果没有该选项,则分析变量已经存在于内存中,或者通过使用 attach 和detac h 来实现数据框的调入。Type 的取值主要有"p" 、"l" 、"b" 、"c" 、"b" 、"o" 、"h" 、"s" 、"S" 。 main :作标题; sub:作副标题; xlab :x轴标签. ylab :y轴标签; col :指定颜色。 >journals= Journals [,c("subs", "price")] >journals$citeprice= journal s$price/ journal s$ci tations >plot(log(subs)~log(citeprice),data=journals) >plot(log(subs)~log(citeprice),data=journals,c ol='green',main='price vssubs') 三、回归分析 lm lm(formula, data, subset, weights, , method ="qr", model =TRUE, x=FALSE, y= FALSE, qr=TRUE, =TRUE, contrasts =NULL, offset, ...) formula :指定用于回归分析的模型,因变量在左,自变量在右,中间用‘~’分开,解释变量之间用‘+’连接。默认回归模型包括截距项,如果取消,则使用‘+0’或者‘-1’表示。 subset: 用于对部分观测的数据框进行分析 weights: 表示指定权重变量,执行 WLS data: 指定分析数据所在的数据框 >jour_lm=lm(log(subs)~log(citeprice),data=jour nals) >cps_lm=lm(log(wage)~experience+I(experience^2) +education+ethnicity,data=CPS1988 说明: I函数表示变量为新产生变量作为解释变量 Function Description print() simple printed display summary() standard regression output coef() extracting the regression coefficients resid() extracting residuals fitted() extracting fitted values anova() comparison of nested models predict() predictions for new data plot() diagnostic plots confint() confidence intervals for coefficients deviance() residual sum of squares vcov() variance-covariance matrix logLik() log-likelihood AIC() information criteria including AIC, BIC/SBC coeftest() extracting the regression output > coeftest(jour_lm) Estimate Std. Error t value Pr(>|t|) (Intercept) < -16 *** log(citeprice) - - < -16 *** : 0‘*** ’ ‘**’ *’ .’ ‘’1 四、模型检验与预测 coeftest()

R软件基础介绍 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数34
  • 收藏数0 收藏
  • 顶次数0
  • 上传人63229029
  • 文件大小313 KB
  • 时间2017-05-29