全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
489 0
2024-01-12

残差分析

1. Examine for linearityassumption

Scatter residual X

2. Residual Analysis forIndependence

3. Checking for Normality

Examinethe Boxplot of the Residuals

*绘制箱式图* graph box var

Examinethe Histogram of the Residuals

*直方图*  histogram var

Constructa Normal Probability Plot of the Residuals

*绘制分位正态图* qnorm var

4. Residual Analysis for EqualVariance

计算Z

gen Z=(var-r(mean))/r(sd)

twoway (line var Z)

oneway a(被作用的变量) b(因素水平变量)

clear all

cap log use

set more off


/*导入数据*/


/*添加标签*/

labone, n(1) /*把第一行设置为标签*/

//ssc install labone


/*清洗数据*/

drop in 1

destring code R001-Inde, replace

egen A = rowmiss(_all)

drop if A == 79


/*茎叶图*/

stem R001


/*简单散点图*/


scatter E001 R001

egen group_E001 = total(E001), by(prefecture)


/*数据分析*/

//回归分析

reg E001 R001


//散点图画拟合线

//twoway (scatter E001 R001)(lfit E001 R001)



//回归分析只分析E001>1000

reg E001 R001 if E001>1000

//E001=6514.452+0.7376998R001+(e)

//回归分析后的函数

//E001=(constant+ Coefficient*R001)




//回归分析强制过原点(x=0,y=0)

reg E001 R001, noconstant


//预测(xb就是yhat)

predict yhat, xb

//下一步(计算residual)=y-yhat

generate residual = E001 - yhat

//直接预测residual

//predict residual, r


//开始画图对比散点图

scatter residual R001

//散点图基础上画回归直线 (拟合命令)

scatter residual R001 || lfit R001 E001


//slide (文本切片)



//99%置信度回归分析

//regress E001 R001, level(99)


//normal probability plot for residual

pnorm residual


Wecan apply the Central Limit Theorem, as the sample size gets large enough thesampling distribution becomes almost normal regardless of shape of population.For most distributions, n > 30 will give a sampling distribution that isnearly normal.


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群