作者jangwei (呆呆)
看板Statistics
標題Re: [問題] 請問一個簡單的ttest程式撰寫的問題
時間Wed Oct 29 13:36:44 2008
※ 引述《qtzbbztq (阿杰)》之銘言:
: 之前我分析ttest
: 例如
: A B
: 1 2
: 1 2
: 2 3
: 2 1
: 2 4
: 2 5
: 1 2
: 1 3
: 我想知道B變相在A組1 和 2的情況下是否平均值不一樣
: 只要撰寫
: proc ttest;
: var b;
: class a;
: run;
: 這樣就好了
: 但是
: 假如a 和 b都是連續變項
: 我想要分析a 和 b是否平均數不同
: 我要怎麼打
: 我打proc ttest;
: var a b;
: run;
: 發現他會單獨去跑a 和 b 的單樣本檢定囧
: 如何才能跑a和b的雙樣本ttest呢??
: 指令要怎麼下 謝謝!!
http://www.ats.ucla.edu/stat/sas/notes2/analyze.htm
==============================================================================
t-tests
This is the one-sample t-test, testing whether the sample of writing scores
was drawn from a population with a mean of 50.
proc ttest data='c:\sas\hs1' H0=50;
var write;
run;
==============================================================================
This is the paired t-test, testing whether or not the mean of write equals
the mean of read.
proc ttest data='c:\sas\hs1';
paired write*read;
run;
==============================================================================
This is the two-sample independent t-test. The output includes the t-test for
both equal and unequal variances. The class statement is necessary in order
to indicate which groups are to be compared.
proc ttest data='c:\sas\hs1';
class female;
var write;
run;
--
歡迎到Ptt統計學板一起討論研究統計方面的問題! telnet://ptt.cc \(^▽^)/
(
C)lass 【 分組討論區 】
國家研究院
Academy 研究 Σ科學學術研究院
Science 理學 Σ 理學研究院
Statistics
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.129.34.115
推 qtzbbztq:謝謝 但是這跟我說的例子是一樣的 我現在的問題是 我要跑 10/29 13:46
→ qtzbbztq:如果我用最後那個例子跑 他就會跟我前面說的一樣 10/29 13:47
→ qtzbbztq:用某變相分成兩組來看這兩組的平均值是否不一樣 但是 10/29 13:48
→ qtzbbztq:我是看兩個變相的平均值是否一樣 不能這樣跑@@~~~ 10/29 13:48
→ qtzbbztq:現在的問題就是 我要看兩個單獨的變項的平均值是否有差異 10/29 13:50
→ qtzbbztq:我要打什麼程式碼才能完成@@ 10/29 13:50
→ jangwei:後面兩個例子就是你要的呀!你有看仔細嗎?看你的兩組樣本 10/29 14:57
→ jangwei:是獨立的或是配對的,寫法有所不同! 10/29 14:57
推 qtzbbztq:不是囧 我可能解釋的不夠清楚 可是真的不是囧 10/29 15:04
→ qtzbbztq:我只是要看A B兩個變項平均值是否有差異 10/29 15:05
→ qtzbbztq:如果用最後一個 他不是看A B兩個平均值是否有差異 10/29 15:05
→ qtzbbztq:他看的是例如A裡面分為兩組 對照B是否有差異~~ 10/29 15:05
→ qtzbbztq:所以A要有2個LEVEL才能夠跑最後的指令 否則 SAS會說 10/29 15:06
→ qtzbbztq:A沒有兩個LEVEL 不能跑 10/29 15:06
→ qtzbbztq:我回在下面 希望能講清楚一點ORZ 10/29 15:06
推 lin15:所以是要比較 mean(A)是否等於mean(B) ? 10/29 15:07
推 qtzbbztq:對的T_T 10/29 15:13