#delimit;
recode V146B
(1=0)
(2=0.5)
(3=1.5)
(4=2.5)
(5=3.5)
(6=4.5)
(7=5.5)
(8=6.5)
(9=7.5)
(10=8.5)
(11=9.5)
(12=10.5)
(13=11.5)
(14=12.5)
(15=13.5)
(16=14.5)
(17=15.5)
(18=16.5)
(19=17.5)
(20=18.5)
(21=19.5)
(22=20.5)
(23=21.5)
(24=22.5)
(25=23.5)
(26=24.5)
(27=25.5)
(28=26.5)
(29=27.5)
(30=28.5)
(31=29.5)
(32=30.5)
(33=31.5)
(95=.)
(96=.)
(97=.)
(98=.)
, gen (hincome);
#delimit cr
sdtest hincomeb ,by (minnan)
ttest hincomeb ,by (minnan) unequal
recode V5 (1=1)(2=2)(3=3)(else=.), gen(ethnic)
recode V13A (1/5=1)(6/9=2)(10/18=3)(else=.), gen(education)
兩個類別之間的交叉表:
tab ethnic education
*依變項(反映變項)的敘述性統計按照因子水準(自變項的數值)來計算
tabstat
*ex-->tabstat miles, statistics( mean count max sum min ) by(car) columns(statistics)
oneway Anova:
*oneway miles cars, tabulate nomeans nostandard nofreq noobs
gen tvtime = v50b_1*60 + v50b_2
利用tabulate可以將一個k類別的類別變數的各組變成k個虛擬變數。
tabulate v2, gen(cohort)
Recode v2 (1=1)(else=0), gen(cohort1)
Recode v2 (2=1)(else=0), gen(cohort2)
Recode v2 (3=1)(else=0), gen(cohort3)
sum if midterm~=. & stata~=.
pwcorr來取得 pair-wise correlation
pwcorr midterm stata,obs star(0.05)
predict residual, resid
y-ybar
gen toty = midterm – 82.49091(mean)
(yhat – ybar)
gen explain = yhat - 82.49091
root MSE=Se
Abj R^=R^=1-Se/Sy
Ms residual=Se^2 =SSE/(n-k-1)
Total SS= Sy^2
T=(1,1)/(2,1)
(1,1)=b1
*excel ci Yhat
=H2-TINV(0.05,8)*$E$19*SQRT(1/10+(A2-$A$12)*(A2-$A$12)/($E$12))
=yhat-TINV(0.05,8)*Se*Sqrt(1/10+(Xi-$Xbar)*(Xi-Xbar)/(Xbar^2's mean)
Y's +1
=yhat-TINV(0.05,8)*Se*Sqrt(1+1/10+(Xi-$Xbar)*(Xi-Xbar)/(Xbar^2's mean)
*regress之後可以執行predict來儲存預測值及殘差值
predict newvarname , options
xb : fitted values; the default
residuals : residuals
stdp : standard error of the prediction--->Sqrt(1+1/10+(Xi-$Xbar)*(Xi-Xbar)/(Xbar^2's mean)
stdf : standard error of the forecast
tabstat income sen educ age, sta(mean sd max min) by(gender)
t=11.32, p-value this is no difference~
recode jstatus (1=1)(else=0), gen(prof)
recode jstatus (2=1)(else=0), gen(skilled)
gen educfem = educ*female interact within vars
regress income age agesqr ,beta
predict yhat, xb
list age yhat
gen lnincome=ln(income) get i in log~ be positive,
- Jun 25 Sun 2006 11:21
stata
全站熱搜
留言列表
發表留言