楼主: DaTao
486 0

[学习心得] 残差分析与一些命令 [推广有奖]

  • 0关注
  • 0粉丝

学前班

80%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
21.6737
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
30 点
帖子
2
精华
0
在线时间
0 小时
注册时间
2024-1-12
最后登录
2024-1-12

楼主
DaTao 发表于 2024-1-12 22:45:46 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

残差分析

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.


二维码

扫码加我 拉你入群

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

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

关键词:残差分析 distribution independence Probability coefficient

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-5 04:55