我有多個(22?)樣本的數據,這些樣本的樣本量差異很大。我知道使用較大的樣本可以更好地估計參數,但這不是我想在這裡解決的問題。我想要圖形分佈和估計參數,就好像樣本大小在組/樣本之間沒有差異一樣。這意味著大樣本需要降低權重,小樣本需要增加權重。
我嘗試在“Fit Y by X”中執行此操作,如下所示:我計算了一個新變數“WEIGHT”,即該組的樣本大小除以總樣本大小。假設我有四個組:
第 1 組:N1=100
第2組:N1=500
第3組:N1=200
第 4 組:N1=400
此外,組 1 和組 2 屬於類型 1,組 3 和組 4 屬於類型 2
重量為:
第 1 組:100/1200
第 2 組:500/1200
第 3 組:200/1200
第 4 組:400/1200
如果我執行“通過 X 擬合 Y”,其中 Y 是 DV,X 是“類型”,重量按重量計算,然後使用“比較密度”來獲取重疊密度圖,它看起來是正確的。然而,如果我繼續並獲得 DV 的標準差,這些值比任何組的標準差都大得多。這讓我覺得我不明白我在做什麼。
幫助?
我認為這篇文章可以幫助你:
已解決:加權標準差 - JMP 用戶社區
可能以下腳本有助於理解會發生什麼。
因此,無論您採用何種方法(角色權重或頻率),在平均工作量的計算方法中。
與你的相比,我對重量的定義不同,我希望重量的總和為 1200(你有 4*1200)。
這應該無關緊要,對於頻率作用中的權重而言,它並不重要,但對於角色權重中的權重而言,它確實如此。 見腳本。
不幸的是,我無法準確解釋為什麼與總平均值相比,小數據集的標準偏差非常大。 這可能是由於平方和根...
我個人不會使用您的方法,因為不清楚發生了什麼。 我會做組總結,然後是每個組的平均值,每個權重為 1。 然後將該結果組合到您的圖表中。
Names Default To Here( 1 );
// about the role of weight and frequency for calculation of mean and stddev
//
// web("https://www.jmp.com/support/help/en/16.1/?os=win&source=application&utm_source=helpmenu&utm_medium=application#page/jmp/summary-statistics.shtml");
//
nelem_lst = {100, 500, 200, 400};
table_lst = {};
For Each( {value, index}, nelem_lst,
Eval(
Eval Expr(
table_lst[index] = New Table( "Table " || Char( index ),
add rows( nelem_lst[index] ),
New Column( "Group", "Character", set each value( "Group " || Char( index ) ) ),
New Column( "Type", "Character", set each value( If( index <= 2, "Type 1", "Type 2" ) ) ),
New Column( "DV", "Continuous", formula( Random Normal( Expr( Mod( index, 2 ) ), Expr( Mod( index, 2 ) + 1 ) ) ) )
)
)
);
Wait( 0.1 );
table_lst[index]:DV << delete formula;
);
Wait( 0 );
dt = table_lst[1] << concatenate( Table Name( "All" ), table_lst[2 :: 4] );
For Each( {value}, table_lst, Close( value, "NoSave" ) );
Summarize( dt, group_lst = by( :group ) );
ngroups = N Items( group_lst );
dt << New Column( "ColMean[Group]", formula( Col Mean( :DV, :group ) ) );
dt << New Column( "ColStd[Group]", formula( Col Std Dev( :DV, :group ) ) );
Eval( Eval Expr( dt << New Column( "weight[Group]", formula( Col Number( :DV ) / Expr( ngroups ) / Col Number( :DV, :group ) ) ) ) );
nw = New Window( "oneway comparison",
H List Box(
Panel Box( "w/o weight",
dt << Oneway( Y( :DV ), X( :Group ), Means and Std Dev( 1 ), Mean Error Bars( 1 ), Std Dev Lines( 1 ) );
),
Panel Box( "weight in role frequency",
dt << dt << Oneway(
Y( :DV ),
X( :Group ),
Freq( :"weight[Group]"n ),
Means and Std Dev( 1 ),
Mean Error Bars( 1 ),
Std Dev Lines( 1 )
);
),
Panel Box( "weight in role weight",
dt << dt << Oneway(
Y( :DV ),
X( :Group ),
Weight( :"weight[Group]"n ),
Means and Std Dev( 1 ),
Mean Error Bars( 1 ),
Std Dev Lines( 1 )
);
)
)
);
nw = New Window( "Tabulate comparison",
H List Box(
Panel Box( "w/o weight",
dt << Tabulate(
Change Item Label( Grouping Columns( :Type( "All" ), "All" ) ),
Show Control Panel( 0 ),
Add Table(
Column Table( Statistics( N ) ),
Column Table( Analysis Columns( :"weight[Group]"n ), Statistics( Sum ) ),
Column Table( Analysis Columns( :DV ), Statistics( Mean ) ),
Column Table( Statistics( Std Dev ), Analysis Columns( :DV ) ),
Row Table( Grouping Columns( :Type, :Group ), Add Aggregate Statistics( :Type, :Group ) )
)
)
),
Panel Box( "weight in role frequency",
dt << Tabulate(
Change Item Label( Grouping Columns( :Type( "All" ), "All" ) ),
Freq( :"weight[Group]"n ),
Show Control Panel( 0 ),
Add Table(
Column Table( Statistics( N ) ),
Column Table( Analysis Columns( :"weight[Group]"n ), Statistics( Sum ) ),
Column Table( Analysis Columns( :DV ), Statistics( Mean ) ),
Column Table( Statistics( Std Dev ), Analysis Columns( :DV ) ),
Row Table( Grouping Columns( :Type, :Group ), Add Aggregate Statistics( :Type, :Group ) )
)
)
),
Panel Box( "weight in role weight",
dt << Tabulate(
Change Item Label( Grouping Columns( :Type( "All" ), "All" ) ),
weight( :"weight[Group]"n ),
Show Control Panel( 0 ),
Add Table(
Column Table( Statistics( N ) ),
Column Table( Analysis Columns( :"weight[Group]"n ), Statistics( Sum ) ),
Column Table( Analysis Columns( :DV ), Statistics( Mean ) ),
Column Table( Statistics( Std Dev ), Analysis Columns( :DV ) ),
Row Table( Grouping Columns( :Type, :Group ), Add Aggregate Statistics( :Type, :Group ) )
)
)
)
)
);
dt << Summary( Group( :Group, :Type, :"ColMean[Group]"n, :"ColStd[Group]"n, :"weight[Group]"n ), Freq( "None" ), Weight( "None" ) );我在我的原始帖子中犯了一個錯誤,如果我知道如何刪除,我會刪除它。 正確版本如下:
我有幾個(22 個?)樣本的數據,樣本大小差異很大。 我知道使用更大的樣本可以更好地估計參數,但這不是我想在這裡解決的問題。 這是我想要圖形分佈和估計參數,就好像樣本大小在組/樣本之間沒有差異一樣。 這意味著需要對大樣本進行去加權,對小樣本進行加權。
我嘗試在“用 X 擬合 Y”中執行此操作,如下所示:我計算了一個新變量 WEIGHT,作為該組的樣本大小除以總樣本大小。 所以假設我有四個組:
第一組:N1=100
第 2 組:N1=500
第 3 組:N1=200
第 4 組:N1=400
此外,第 1 組和第 2 組是第 1 類,第 3 組和第 4 組是第 2 類
重量將是:
第 1 組:1200/100
第 2 組:1200/500
第 3 組:1200/200
第 4 組:1200/400
如果我執行“用 X 擬合 Y”,其中 Y 是 DV,X 是“類型”,重量按重量計算,然後使用“比較密度”得到重疊密度圖,它看起來是正確的。 但是,如果我繼續並獲得 DV 的標準差,這些將比任何組的標準差大得多。 這讓我覺得我不明白我在做什麼。
幫助?