cat proc statprincomp data=s1050 n=4 out = w1 outstat= w2;为什么运行的时候说找不到w1

统计分析 SAS练习_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
统计分析 SAS练习
上传于||暂无简介
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩13页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢SAS 分析常用的过程 过程步大全 - Arndata - 博客园
数据质量依赖数据清洗的工作,数据结果依赖数据算法的效能。
为区分过程名称的拼写,故意部分小写,以便识别和记忆。
基本SAS程序代码结构:
PROC MODE data=Arndata. & & & & &/* 命令的解释 */
& & & & & & & & var y x1-x6; & & & & & & & & & & & & & /* 命令的解释 */
& & & & & & & & model y = x1-x6;
------------------------------------------
正态性检验
PROC UNIvariate
PROC UNIvariate&data=Arndata.
& & & & & & & & var x1;
&------------------------------------------
相关分析和回归分析
PROC REG 回归
PROC REG data=Arndata.
& & & & & & & & var y x1-x6;
& & & & & & & & model y = x1-x6 / selection= /* 加入逐步回归选项 */
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & &/* 加入输出预测结果部分,还可以输出acov,all,cli,clm,collin,collinoint,cookd,corrb,
& & & & & & & &&& & & & & & & &&& & & & & & & & & & & & & & & & & & & & & &&covb,dw(时序检验统计量),i,influence,p,partial,pcorr1,pcorr2,r,
& & & & & & & & & & & & & & & &&& & & & & & & & & & & & & & & & & & & & & & scorr1,scorr2,seqb,spec,ss1,ss2,stb,tol,vif(异方差检验统计量),xpx*/
& & & & & & & & plot y*x2 / conf95;&& & & & & & & & & & & & & &/* 做散点图 */
&------------------------------------------
DATA&Arndata.
x2x2 = x2*x2;
x1x2 = x1*x2;
PROC REG data=Arndata.
& & & & & & & & var y x1 x2 x2x2 x1x2 ; & & & & & & & & & & & & & & & &/* 多项式回归,非线性回归 */
& & & & & & & & model y =&x1 x2 x2x2 x1x2&/ selection= & &/* 加入逐步回归选项 */
& & & & & & & &&
& & & & & & & & plot y*x2 / conf95; & & & & & & & & & & & & & & &/* 做散点图 */
&------------------------------------------
PROC RSreg 二次响应面回归
PROC ORTHOreg 病态数据回归
PROC NLIN 非线性回归
PROC TRANSreg 变换回归
PROC CALIS 线性结构方程和路径分析
PROC GLM 一般线性模型
PROC GENmod 广义线性模型
PROC ANOVA 单因素均衡数据和非均衡数据
PROC ANOVA data=Arndata. & & & & &/* 命令的解释 */
& & & & & & & & & & & & & & & & & & & & & & & & & /* 命令的解释 */
& & & & & & & & model y =& & & & & & & & & & & & & & /* 可以看出此处是 单因素方差分析(分类型自变量对数值型自变量的影响)&*/
------------------------------------------
PROC GLM 多因素非均衡数据:
PROC GLM data=Arndata. & & & & &/* 命令的解释 */
& & & & & & & & & & & & & & & &/* 命令的解释 */
& & & & & & & & model y =& & & & /* 可以看出此处是 不考虑交互作用的多因素方差分析(分类型自变量对数值型自变量的影响)&*/
------------------------------------------
PROC GLM data=Arndata. & & & & &/* 命令的解释 */
& & & & & & & & & & & & & & & &/* 命令的解释 */
& & & & & & & & model y = typea typeb typea*& & & & /* 可以看出此处是 考虑交互作用的多因素方差分析(分类型自变量对数值型自变量的影响)&*/
------------------------------------------
主成分分析
PROC PRINcomp
PROC PRINcomp&data=Arndata.pmdat & n=4 &out=w1 outstat=w2 ; & & & & &
& & & & & & & & var x1-x6; & & & & & & & & & & & &
PROC print data=w1;
PROC plot data=w1 vpct=80;& & & & & & & & & & & & & & & & & & & & & /* 一句话,其实print就是plot输出图形的文字形式而已 */
& & & & &plot prin1*prin2 $ districts='*'/
& & & & & & & & haxis=-3.5 to 3 by 0.5 HREF=-2,0,2
& & & & & & & & vaxis=-3 to 4.5 by 1.5 HREF=-2,0,2; & & & & & & &/* 主成分的散点图,也就是载荷图 */
------------------------------------------
PROC FACTOR
PROC FACTOR data=Arndata.fa & & & &&
& & & & & & & & var y x1-x6; & & & & & & & & & & & &&
& & & & & & & & title'18个财务指标的分析';
& & & & & & & & title2'主成分解';
PROC FACTOR data=Arndata.factordat n=4 ; & & & & & & & & & & & &/* 选择4个公共因子 */
& & & & & & & & var y x1-x6; &&
PROC FACTOR data=Arndata.factordat n=4
& & & & & & & & rotate=VARImax RE & & & &&& & & & & & & & & & & & & /* 因子旋转:方差最大因子法 */
& & & & & & & & var y x1-x6; &&
------------------------------------------
PROC SCORE
&---------
PROC FACTOR data=Arndata.factordat n=4
& & & & & & & & rotate=VARImax REorder score out=score_O & & /* 输出因子得分矩阵 */
PROC print data=score_O
& & & & &var districts factor1 factor2 factor3 factor4;
PROC plot&data=score_O
& & & & &plot factor1*factor2 $ districts='*' / href=0&Vref=0;&& & /* 因子的散点图,也就是载荷图 */
------------------------------------------
典型相关分析
PROC CANcorr
基本SAS程序代码结构:
DATA jt(TYPE=CORR);& & & & & & & & & & & & & & & &/* TYPE=CORR 表明数据类型为相关矩阵,而不是原始数据, type还可以是cov,ucov,factor,sscp,ucorr等*/
& & & & &input names$ 1-2(x1 x2 y1-y3)(6.);& &/* name $ 表示读取左侧的变量名,1-2表示变量名的字符落在第1,2列上 */
x1 1 0.8 &&
PROC CANcorr data=Arndata.cancorrdat
& & & & & & & & edf=70 &&& & & & & & & &/* 误差自由度的参考值,默认值是n=1000; redundancy表示输出冗余度分析的结果&*/
& & & & & & & & var x1 x2;
& & & & & & & & with y1 y2 y3;
------------------------------------------
对应分析&&& & & & & & & &/* 交叉表分析的拓展,寻找行和列的关系,一般行指代各种cases,而列代表各种visions */&
PROC CORResp
PROC CORResp data=Arndata.correspdat out= & & & &&
& & & & & & & & var x1-x6; & & & & & & & & & & & &
& & & & & & & & id T
options ps=40;
proc plot data=
& & & &plot dim2*dim1="*" $ Type / box
& & & & & & &haxis=-0.2 to 0.3 by 0.1
& & & & & & &Vaxis=-0.1 to 0.3 by 0.1
& & & & & & &Href=0 Vref=0;
------------------------------------------
PROC CLUSTER
PROC CLUSTER data=Arndata.clusdat
& & & & & & & & & & &&method=ave outtree=clusdat_O &
& & & & & & & & & & & var x1-x6; &
& & & & & & & & & & &&
& & & & & & & & &/* 做聚类树 */
------------------------------------------
PROC FASTclus
PROC FASTclus data=Arndata.clusdat & & & & & & & & & & & &maxclusters=3 list out=clusdat_O
& & & & & & & & & & & &var x1-x6;
& & & & & & & & & & & &
------------------------------------------
PROC ACEclus
PROC VARCLUS
PROC VARclus data=Arndata. /* 系统默认使用主成分法聚类 */
& & & & & & & & & & & &var x1-x6;&
&---------
PROC VARclus hierarchy data=Arndata. /* 保证分析过程中不同水平的谱系结构 */
& & & & & & & & & & & &var x1-x6;&
&---------
PROC VARclus centroid data=Arndata.clusdat outtree=clusdat_ /* 使用重心法聚类 */
var x1-x6;&
------------------------------------------
PROC TREE---------
PROC TREE data=Arndata. /* 使用TREE过程绘制聚类谱系图 */
var x1-x6;&
------------------------------------------
PROC DISCRIM
PROC DISCRIM data=Arndata.discrimdat
& & & & & & & & & & & &list out=discrimdat_Out distance pool=
& & & & & & & & & & & &class T
/* 指定分类变量 */
& & & & & & & & & & & &var x1-x6;
/* 用于建立判别识别函数的变量 */
& & & & & & & & & & & &
/* 标注样本的变量 */---------
第二种方法,将需要判别的新样本放在testdata里:
PROC DISCRIM data=Arndata.discrimdat1 testdata=Arndata.discrimdat2& & & & & & & & & & & &testlist testout=discrimdat_O
/* 将原来的几个选项加注test标示 */
& & & & & & & & & & & &class T
/* 指定分类变量 */
& & & & & & & & & & & &var x1-x6;
/* 用于建立判别识别函数的变量 */
& & & & & & & & & & & &
/* 标注样本的变量 */
&------------------------------------------
PROC STEPdisc: 逐步判别分析过程
PROC STEPdisc method=stepwise data=Arndata.discrimdat
& & & & & & & & & & & &SLentry=0.10 SLstay=0.10;
/* 设定引入和剔除的显著性水平 */
& & & & & & & & & & & &class T
/* 指定分类变量 */
& & & & & & & & & & & &var x1-x6;
/* 用于建立判别识别函数的变量 */
------------------------------------------
PROC CANdisc: Fisher判别分析过程
PROC CANdisc data=Arndata.discrimdat out=discrimdat_Out
& & & & & & & & & & & &
& & & & & & & & & & & &class T
/* 指定分类变量 */
& & & & & & & & & & & &var x1-x6;
/* 用于建立判别识别函数的变量 */proc print data=discrimdat_O&
------------------------------------------
-----------------------------------------------------------------------------------------------------------------
友情协助:
豆瓣统计学小组&
阅读(...) 评论()SAS分析法代码_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
SAS分析法代码
上传于||暂无简介
阅读已结束,如果下载本文需要使用2下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩12页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢6381人阅读
最简单的主成分分析函数,prcomp 和 princomp 都是自带的函数,不需要额外的包
很好的一个介绍
很好的一个介绍
主成分分析的结果包含特征根集,PC scores表,(变量和PC)相关系数表(table of loadings)
特征根包含了数据变化度的信息,scores提供了观测结构的信息,相关系数表提供了变量之间,以及和PC之间的关系的大致感官概念
prcomp : Performs a principalcomponents analysis on the givendata matrix and returns the results as anobject of class&prcomp.
princomp : Performs a principal components analysison the givennumeric
data matrix and returns the results as an object of class&princomp.
以下使用内置数据集USArrests
& str(USArrests)
'data.frame': 50 obs. of &4 variables:
&$ Murder &: num &13.2 10 8.1 8.8 9 7.9 3.3 5.9 15.4 17.4 ...
&$ Assault : int &NA 263 294 190 276 204 110 238 335 211 ...
&$ UrbanPop: int &58 48 80 50 91 78 77 72 80 60 ...
&$ Rape & &: num &21.2 44.5 31 19.5 40.6 38.7 11.1 15.8 31.9 25.8 ...
prcomp(x, ...)
prcomp(formula, data = NULL, subset, na.action, ...)
prcomp(x, retx = TRUE, center = TRUE, scale. = FALSE,& tol = NULL, ...)
prcomp(USArrests)& #inappropriate,没有scale不太合适
prcomp(USArrests,
scale = TRUE) #直接数据矩阵
prcomp(~ Murder + Assault + Rape, data = USArrests, scale = TRUE) #直接方程
plot(prcomp(USArrests))
summary(prcomp(USArrests, scale = TRUE))
biplot(prcomp(USArrests, scale = TRUE))
princomp :
princomp(x, ...) #完全一样
princomp(formula, data = NULL, subset, na.action, ...) #继续完全一样
princomp(x,
cor = FALSE, scores = TRUE, covmat = NULL, subset = rep(TRUE,nrow(as.matrix(x))), ...) #参数变化
princomp(USArrests, cor = TRUE) # =^= prcomp(USArrests, scale=TRUE) 近似但不完全一样,标准差differ by a factor of sqrt(49/50)
summary(pc.cr &- princomp(USArrests, cor = TRUE))
loadings(pc.cr)& #一个列包含了特征向量的矩阵,对应rotation in prcomp
plot(pc.cr) # shows a screeplot.
biplot(pc.cr)
返回值:
the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix).
特征向量矩阵
the matrix of variable loadings (i.e., a matrix whose columns contain the eigenvectors). The function&princomp&returns this in the element&loadings.
在retx值为true的情况下,返回旋转后的数据,也就是(centred (and scaled if requested) data multiplied by the&rotation&matrix). 所以,&cov(x)&就是矩阵对角元素(sdev^2). For the formula method,&()&is
applied to handle the treatment of values omitted by the&na.action.
center, scale
the centering and scaling used, or&FALSE.
因为PCA必须建立在标准正态数据上(mean=0, variance=1)所以通常需要标准化。
princomp :
the standard deviations of the principal components.
特征向量矩阵
the matrix of variable loadings (i.e., a matrix whose columns contain the eigenvectors). This is of class&&loadings&: see&&for
its&print&method.
the means that were subtracted.
the scalings applied to each variable.
the number of observations.
if&scores = TRUE, the scores of the supplied data on the principal components. These are non-null only if&x&was supplied, and if&covmat&was also supplied if it was a covariance list. For the formula method,&()&is
applied to handle the treatment of values omitted by the&na.action.
the matched call.
If relevant.
The calculation is doneby a singular value decomposition奇异值分解
of the (centered and possibly scaled) datamatrix, not by using&eigen&on the covariance matrix而不使用协方差矩阵的特征根. This is generally the preferred method for numerical accuracy提高数值型准确性.&
The&print&method for these objects prints the results in a nice format and theplot&method produces a screeplot.
Unlike&, variances are computed with the usual divisor&N - 1.
Note that&scale= TRUE&cannot be used if there are zero or constant(for&center = TRUE) variables.
princomp :
princomp&is a generic function with&&formula&&and&&default&&methods.
The calculation is done using&&on the correlation or covariance matrix,
as determined by&. This is done for compatibility with the S-PLUS result. Apreferred method of calculation is to use&&on&x,
as is done in&prcomp.
Note that the default calculation uses divisor&N&for the covariance matrix.
The&&method for these objects prints the results in a nice formatand the&&method
produces a scree plot ().There is also a&&method.
If&x&is a formula then the standard NA-handling is applied to the scores (if requested): see.
princomp&only handles so-calledR-mode PCA, that is feature extraction of variables. If a data matrix is supplied (possibly via a formula) it is required that there are at least as many
units as variables. ForQ-mode PCA use&.
R和Q-Mode区别:
R-mode PCA examines the correlations or covariances&among&variables变量的相关性和协方差&
Q-mode focusses on the correlations or covariances among samples.样本的相关性和协方差&
通常多变量分析,例如计算相关系数,是在数据列(features或者Question)上完成的;然而每一行是一个样本单位sample unit,也就是Respondents(R&way
analysis)
有时候数据列Question被当做样本单位那么就是Q analysis. 区别也许就在于标准化和结果解释的时候。
使用PCA结果进行回归分析
回归的一大问题是多重共线性对结果的干扰。对此提出了解决方法PCA回归
原始数据有很高的VI(最后一列大于4的都算比较大)
Parameter Estimates
特征值Eigenvalue ,也代表了样本variance覆盖率
Eigenvalues of the Correlation Matrix
Eigenvalue Difference
Proportion
Cumulative
<span style="color:#ff02239
主成分之间的VI完美为1
Parameter Estimates
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:11928次
排名:千里之外课程设计任务书_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
课程设计任务书
上传于||文档简介
&&应&#8203;用&#8203;多&#8203;元&#8203;分&#8203;析&#8203;课&#8203;程&#8203;设&#8203;计&#8203;任&#8203;务&#8203;书
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩9页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢

我要回帖

更多关于 华为w1和w2有什么区别 的文章

 

随机推荐