Interaction plot of medians
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I would like to generate an interaction plot for studying the effects of a number of categorical variables, but using sample medians as opposed to the means. I started by modifying the interactionplot.m code by replacing calls to mean or nanmean with the median equivalents, and 'mean' with @median at line 298:
[interact,num] = grpstats(y,{factor1,factor2}, {@median,'numel'});
but I get the error: ??? Error using ==> interactionplotmed>plotaninteraction at 305 Some combinations of factor levels are missing.
Error in ==> interactionplotmed at 164
plotaninteraction(ybar,group{j},group{i},varnames{j},varnames{i},...
Error in ==> intrcPlot at 144
interactionplotmed(Y,GROUP,'varnames',VARNAMES);
since my design matrix is atypical - one category (wavelet family) is only combined with certain levels of subcategories (wavelet number, wNum, and decomposition level, J). For the Db family (wType = 1) I am testing 10 sublevels (wNum = 1:10), while for the Coif family (wType = 2) there are 5 sublevels (wNum = 1:5), and for the Sym family there are 7 (wNum = 1:7). The number of levels of J is in turn dependent on wNum. For example, the design matrix for Db wavelets is: dFFdb2_6 = fullfact([2 2 4 1 3 8]);
dFFdb8_14 = fullfact([2 2 4 1 4 7]);
[dm,~] = size(dFFdb8_14);
dFFdb8_14 = dFFdb8_14 + [zeros(dm,4) 3*ones(dm,1) zeros(dm,1)];
dFFdb16_20 = fullfact([2 2 4 1 3 6]);
[dm,~] = size(dFFdb16_20);
dFFdb16_20 = dFFdb16_20 + [zeros(dm,4) 7*ones(dm,1) zeros(dm,1)];
dFFdb = [dFFdb2_6; dFFdb8_14; dFFdb16_20];
with similar ones for Coiflets and Symlets. The Db, Coif, and Sym design matrices are then stacked into one large matrix to evaluate all combinations of variables in my algorithm.
I am able to generate interaction plots in JMP easily enough, but these use the sample means and I don't believe there is a way of modifying it to use the medians.
Any help is much appreciated. Thanks!
Phil
0 commentaires
Réponse acceptée
Tom Lane
le 5 Fév 2012
It is true that interactionplot wants all factor combinations present. Here's a little script that will plot medians as functions of two predictors without that restriction. Maybe you can adapt it to your problem.
load carsmall
[med,grps] = grpstats(MPG,{Model_Year Origin},{@median 'gname'});
uyr = unique(grps(:,1));
uorg = unique(grps(:,2));
n1 = length(uyr);
n2 = length(uorg);
y = nan(n1,n2);
for j=1:length(med)
[~,i1] = ismember(grps{j,1},uyr);
[~,i2] = ismember(grps{j,2},uorg);
y(i1,i2) = med(j);
end
plot((1:n1)',y,'o-')
xlim([.5,n1+.5])
set(gca,'xtick',1:n1,'xticklabel',uyr)
legend(uorg)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!