我有来自几个(22 个?)样本的数据,它们的样本量差异很大。 我知道使用更大的样本可以更好地估计参数,但这不是我想在这里解决的问题。 这是我想要绘制分布图和估计参数,就好像样本量在组/样本之间没有差异。 这意味着需要对大样本进行去加权,对小样本进行加权。
我尝试在“用 X 拟合 Y”中执行此操作,如下所示:我计算了一个新变量 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
如果我执行“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" ) );