protected SparseDesignMatrix createDesignMatrix(SparseDataset sd, List<int[]> groupList) {
		int[] attrs = sd.attrs;
		Map<Integer, Integer> attrSet = new HashMap<>();
		for (int j = 0; j < attrs.length; j++) {
			attrSet.put(attrs[j], j);
		}
		List<int[]> gList = new ArrayList<>();
		for (int[] group : groupList) {
			List<Integer> list = new ArrayList<>();
			for (int idx : group) {
				if (attrSet.containsKey(idx)) {
					list.add(attrSet.get(idx));
				}
			}
			if (list.size() > 0) {
				int[] a = new int[list.size()];
				for (int i = 0; i < a.length; i++) {
					a[i] = list.get(i);
				}
				gList.add(a);
			}
		}
		
		int[][] groups = new int[gList.size()][];
		int[][][] indices = new int[gList.size()][][];
		double[][][] values = new double[gList.size()][][];
		for (int g = 0; g < groups.length; g++) {
			int[] group = gList.get(g);
			groups[g] = group;
			int[][] idx = new int[group.length][];
			double[][] val = new double[group.length][];
			for (int j = 0; j < group.length; j++) {
				int index = group[j];
				idx[j] = sd.indices[index];
				val[j] = sd.values[index];
			}
			indices[g] = idx;
			values[g] = val;
		}
		return new SparseDesignMatrix(groups, indices, values);
	}