我有來自幾個(22 個?)樣本的數據,它們的樣本量差異很大。 我知道使用更大的樣本可以更好地估計參數,但這不是我想在這裡解決的問題。 這是我想要繪製分佈圖和估計參數,就好像樣本量在組/樣本之間沒有差異。 這意味著需要對大樣本進行去加權,對小樣本進行加權。
我嘗試在“用 X 擬合 Y”中執行此操作,如下所示:我計算了一個新變量 WEIGHT,作為組的樣本量除以總樣本量。 所以假設我有四個組:
第一組: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
如果我執行“Fit Y by X”,其中 Y 是 DV,X 是“Type”,權重是 WEIGHT,然後使用“Compare Densities”來獲得重疊密度圖,它看起來是正確的。 但是,如果我繼續獲得 DV 的標準偏差,這些標準偏差將遠大於任何組的標準偏差。 這讓我覺得我不明白我在做什麼。
幫助?
我在我的原始帖子中犯了一個錯誤,如果我知道如何刪除它。 正確的版本如下:
我有來自幾個(22 個?)樣本的數據,這些樣本的樣本量差異很大。 我知道使用更大的樣本可以更好地估計參數,但這不是我想在這裡解決的問題。 這是我想要繪製分佈圖和估計參數,就好像樣本量在組/樣本之間沒有差異。 這意味著需要對大樣本進行去加權,對小樣本進行加權。
我嘗試在“用 X 擬合 Y”中執行此操作,如下所示:我計算了一個新變量 WEIGHT,作為組的樣本量除以總樣本量。 所以假設我有四個組:
第一組:N1=100
第 2 組:N1=500
第 3 組:N1=200
第 4 組:N1=400
第 1 組和第 2 組也屬於第 1 類,第 3 組和第 4 組屬於第 2 類
重量將是:
第一組:1200/100
第 2 組:1200/500
第 3 組:1200/200
第 4 組:1200/400
如果我執行“Fit Y by X”,其中 Y 是 DV,X 是“Type”,權重是 WEIGHT,然後使用“Compare Densities”來獲得重疊密度圖,它看起來是正確的。 但是,如果我繼續並獲得 DV 的標準偏差,這些標準偏差將遠大於任何組的標準偏差。 這讓我覺得我不明白我在做什麼。
幫助?
我認為這篇文章可以幫助你:
已解決:加權標準偏差 - JMP 用戶社區
並且可能以下腳本有助於理解可能發生的情況。
因此,在您計算平均工作的方法中,無論您採用何種方法(角色權重或頻率)。
與你的相比,我對重量的定義不同,我希望重量的總和為 1200(你有 4*1200)。
這應該無關緊要,並且對於頻率角色中的權重它無關緊要,但對於角色權重中的權重它確實如此。 見腳本。
不幸的是,我無法準確解釋為什麼,與總平均值相比,小數據集的 stddev 非常大。 它可能是由於平方和根...
我個人不會使用您的方法,因為目前尚不清楚發生了什麼。 我會做小組總結,然後每個小組的平均權重為 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" ) );