【Stata基础】第三章 区间估计和假设检验

您所在的位置:网站首页 单侧检验假设的建立方法 【Stata基础】第三章 区间估计和假设检验

【Stata基础】第三章 区间估计和假设检验

2024-07-04 07:24| 来源: 网络整理| 查看: 265

首先看一下 auto 中每个变量的描述性统计信息:

sum make price mpg rep78 headroom trunk weight length turn displacement gear_ratio foreign

画出汽车价格和重量的散点图,加上拟合线、xlabel、ylabel、title并保存

tabstat price weight, stat(max min median) twoway (scatter price weight) (lfit price weight), xlabel(1600(400)5000) ylabel(3000(2000)16000) graph save pwscatter, replace

做汽车价格和重量的一元OLS回归并计算价格和残差的拟合值

reg price weight predict priceHat, xb predict e, residuals br price priceHat e

创建一个虚拟变量,使得价格大于6000的时候取值1,价格不大于6000时取0

gen x = price > 6000

做出 p r i c e = β 1 + β 2 ∗ w e i g h t 2 + e price=\beta_1+\beta_2*weight^2+e price=β1​+β2​∗weight2+e 的回归,算出价格拟合值并做拟合曲线

gen weight2 = weight^2 reg price weight2 //二次模型 predict priceq, xb //价格拟合值 graph twoway (scatter price weight) (line priceq weight, sort lwidth(medthick))

做出 l n ( p r i c e ) = β 1 + β 2 ∗ w e i g h t + e ln(price)=\beta_1+\beta_2*weight+e ln(price)=β1​+β2​∗weight+e 的回归,算出价格拟合值并做拟合曲线

gen lnprice = ln(price) reg lnprice weight predict lnpriceHat, xb gen priceHat = exp(lnpriceHat) graph twoway (scatter price weight) (line priceHat weight, sort lwidth(medthick))


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3